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.
120 lines
3.6 KiB
JavaScript
120 lines
3.6 KiB
JavaScript
const {
|
|
text,
|
|
textarea,
|
|
image,
|
|
icon,
|
|
url,
|
|
select,
|
|
combobox,
|
|
object,
|
|
stringList,
|
|
objectList,
|
|
} = require("./sharedFields");
|
|
|
|
const statusOptions = [
|
|
{ value: "Active", label: "Active" },
|
|
{ value: "Inactive", label: "Inactive" },
|
|
];
|
|
|
|
module.exports = {
|
|
key: "accreditation",
|
|
title: "Accreditation Management",
|
|
subtitle: "Edit content displayed on the accreditation page",
|
|
routeBase: "/admin/accreditation",
|
|
apiPath: "/api/accreditation",
|
|
previewPath: "/about/accreditation",
|
|
dataFile: "accreditation",
|
|
imageType: "accreditation",
|
|
tabs: [
|
|
{
|
|
key: "trustBanner",
|
|
label: "Trust Banner",
|
|
icon: "fas fa-shield-check",
|
|
schema: object("trustBanner", "Trust banner", [
|
|
icon("icon", "Banner icon"),
|
|
text("text", "Banner message", {
|
|
maxLength: 120,
|
|
helpText:
|
|
"This is the slim credibility strip shown above the accreditation content.",
|
|
}),
|
|
objectList(
|
|
"links",
|
|
"Banner links",
|
|
[
|
|
text("label", "Link label", { maxLength: 40 }),
|
|
url("href", "Link URL", { maxLength: 255 }),
|
|
icon("icon", "Link icon"),
|
|
],
|
|
{
|
|
itemLabel: "Link",
|
|
sortable: true,
|
|
emptyText: "No trust banner links yet.",
|
|
},
|
|
),
|
|
]),
|
|
},
|
|
{
|
|
key: "hero",
|
|
label: "Hero",
|
|
icon: "fas fa-image",
|
|
schema: object("hero", "Hero", [
|
|
text("badge", "Eyebrow label", { maxLength: 40 }),
|
|
text("title", "Headline", { maxLength: 60 }),
|
|
textarea("description", "Supporting text", { maxLength: 420, rows: 5 }),
|
|
]),
|
|
},
|
|
{
|
|
key: "grid",
|
|
label: "Accreditation Grid",
|
|
icon: "fas fa-table-cells-large",
|
|
schema: object("grid", "Accreditation grid", [
|
|
stringList("tabs", "Category tabs", {
|
|
itemLabel: "Tab",
|
|
maxLength: 30,
|
|
sortable: true,
|
|
helpText:
|
|
"The frontend shows up to 3 direct tabs. Additional tabs move into a More dropdown.",
|
|
}),
|
|
objectList(
|
|
"items",
|
|
"Accreditation cards",
|
|
[
|
|
icon("icon", "Fallback icon"),
|
|
image("image", "Card image", {
|
|
imageHint: "Recommended 118x58 px minimum visible ratio",
|
|
helpText: "Logo or badge used at the top of the card.",
|
|
}),
|
|
select("status", "Status", statusOptions),
|
|
combobox("category", "Category", {
|
|
maxLength: 30,
|
|
optionsPath: "grid.tabs",
|
|
}),
|
|
text("title", "Card title", {
|
|
maxLength: 17,
|
|
helpText: "Frontend title space is capped at 17 characters.",
|
|
}),
|
|
textarea("description", "Card description", {
|
|
maxLength: 300,
|
|
rows: 5,
|
|
helpText: "Frontend description preview is capped at 300 characters.",
|
|
}),
|
|
text("scopeLabel", "Scope label", { maxLength: 20 }),
|
|
text("scope", "Scope text", { maxLength: 60 }),
|
|
text("validUntilLabel", "Validity label", { maxLength: 24 }),
|
|
text("validUntil", "Validity text", { maxLength: 40 }),
|
|
text("buttonLabel", "Certificate button label", { maxLength: 30 }),
|
|
url("certificateHref", "Certificate URL", { maxLength: 255 }),
|
|
],
|
|
{
|
|
itemLabel: "Accreditation",
|
|
sortable: true,
|
|
itemTitleKey: "title",
|
|
itemSubtitleKey: "category",
|
|
emptyText: "No accreditation cards yet.",
|
|
},
|
|
),
|
|
]),
|
|
},
|
|
],
|
|
};
|