forked from UKSOURCE/cms.lams
Refactor the CMS page content system to use a more modular configuration-driven approach. This replaces the monolithic `pageContentConfig.js` with individual configuration files for each page and introduces a shared field utility to standardize editor components. Key changes: - Implement a generic `_renderSingletonPageView` helper to reduce duplication across controllers. - Enhance `_createPageContentController` with `normalizeForEditor`, `normalizeForApi`, and `preparePayload` hooks for custom data transformation. - Create dedicated configuration and view structures for Partnerships, History, Accreditation, Admissions, and Policies pages. - Add a specialized section editor for Policies to manage complex nested content. - Improve the frontend `page-content-editor.js` with support for visibility logic, auto-sequencing for arrays, and URL synchronization for active tabs. - Update data JSON files to align with the new schema.
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
const AccreditationPage = require("../models/accreditationPage");
|
|
const AUDIT_ACTIONS = require("../constants/auditAction");
|
|
const accreditationConfig = require("../utils/contentEditors/accreditationConfig");
|
|
const createPageContentController = require("./_createPageContentController");
|
|
const createRenderSingletonPageView = require("./_renderSingletonPageView");
|
|
|
|
const controller = createPageContentController({
|
|
model: AccreditationPage,
|
|
modelName: "AccreditationPage",
|
|
auditAction: AUDIT_ACTIONS.UPDATE_ACCREDITATION,
|
|
editorConfig: accreditationConfig,
|
|
});
|
|
|
|
controller.index = async function index(req, res) {
|
|
try {
|
|
return await createRenderSingletonPageView({
|
|
model: AccreditationPage,
|
|
editorConfig: accreditationConfig,
|
|
view: "admin/accreditation/index",
|
|
})(req, res);
|
|
} catch (error) {
|
|
console.error("accreditation index error:", error);
|
|
req.flash("error_msg", "Error loading Accreditation Management");
|
|
return req.session.save(() => res.redirect("/admin/dashboard"));
|
|
}
|
|
};
|
|
|
|
module.exports = controller;
|