forked from UKSOURCE/cms.lams
Improve the policy content management experience by adding a dedicated fullscreen editing mode and a structured date picker for effective dates. - Implement fullscreen toggle in `policies-block-editor.js` with corresponding CSS for an expanded workspace - Add `date` field type to `sharedFields.js` and integrate it into `policiesConfig.js` - Implement date parsing and formatting utilities in `editor-script.ejs` to handle "Effective Date" strings - Update `policiesController.js` to use `updateOne` for more reliable document persistence and state reloading - Add support for `ICON_OPTIONS` in the policy editor configuration - Refine editor UI layout and overflow handling for better stability with long content strings
113 lines
3.1 KiB
JavaScript
113 lines
3.1 KiB
JavaScript
const {
|
|
ICON_OPTIONS,
|
|
text,
|
|
date,
|
|
textarea,
|
|
icon,
|
|
url,
|
|
combobox,
|
|
object,
|
|
objectList,
|
|
stringList,
|
|
variantList,
|
|
} = require("./sharedFields");
|
|
|
|
const baseConfig = {
|
|
key: "policies",
|
|
title: "Policies Management",
|
|
subtitle: "Manage policy metadata and block-based content for the policies page",
|
|
routeBase: "/admin/policies",
|
|
apiPath: "/api/policies",
|
|
previewPath: "/policies",
|
|
dataFile: "policies",
|
|
imageType: "policies",
|
|
tabs: [
|
|
{
|
|
key: "hero",
|
|
label: "Hero",
|
|
icon: "fas fa-scale-balanced",
|
|
schema: object("hero", "Hero", [
|
|
text("badge", "Eyebrow label", { maxLength: 40 }),
|
|
icon("icon", "Hero icon", {
|
|
helpText: "Policies uses icon-only controls and does not require image upload.",
|
|
}),
|
|
text("titlePrefix", "Headline prefix", { maxLength: 50 }),
|
|
text("titleHighlight", "Headline highlight", { maxLength: 40 }),
|
|
textarea("description", "Supporting text", {
|
|
maxLength: 220,
|
|
rows: 4,
|
|
}),
|
|
]),
|
|
},
|
|
{
|
|
key: "sidebar",
|
|
label: "Sidebar",
|
|
icon: "fas fa-bars",
|
|
schema: object("sidebar", "Sidebar", [
|
|
text("heading", "Sidebar heading", { maxLength: 30 }),
|
|
text("helperText", "Helper text", { maxLength: 60 }),
|
|
text("contactLabel", "Contact link label", { maxLength: 40 }),
|
|
url("contactHref", "Contact URL", { maxLength: 255 }),
|
|
]),
|
|
},
|
|
{
|
|
key: "policies",
|
|
label: "Policies",
|
|
icon: "fas fa-file-lines",
|
|
schema: objectList(
|
|
"policies",
|
|
"Policies",
|
|
[
|
|
text("navLabel", "Sidebar label", { maxLength: 40 }),
|
|
text("title", "Policy title", { maxLength: 70 }),
|
|
date("effectiveDate", "Effective date", {
|
|
helpText: "Pick a calendar date. It will be saved in the standard policy display format.",
|
|
}),
|
|
textarea("intro", "Intro text", { maxLength: 260, rows: 4 }),
|
|
],
|
|
{
|
|
itemLabel: "Policy",
|
|
sortable: true,
|
|
itemTitleKey: "title",
|
|
itemSubtitleKey: "effectiveDate",
|
|
emptyText: "No policies yet.",
|
|
itemActions: [
|
|
{
|
|
label: "Edit Content",
|
|
icon: "fas fa-pen-to-square",
|
|
hrefTemplate: "/admin/policies/{id}/section",
|
|
className: "btn btn-outline-primary btn-sm",
|
|
},
|
|
],
|
|
},
|
|
),
|
|
},
|
|
],
|
|
};
|
|
|
|
function createPoliciesSectionEditorConfig(policy, allPolicies = []) {
|
|
const policyOptions = allPolicies
|
|
.filter((item) => item.id && item.id !== policy.id)
|
|
.map((item) => ({
|
|
value: item.id,
|
|
label: item.title || item.navLabel || item.id,
|
|
}));
|
|
|
|
return {
|
|
key: "policyContent",
|
|
title: `Policy Content: ${policy.title || policy.id}`,
|
|
subtitle: "Edit block-based policy content with realtime preview",
|
|
routeBase: `/admin/policies/${policy.id}/section`,
|
|
previewPath: "/policies",
|
|
imageType: "policies",
|
|
policyId: policy.id,
|
|
policyOptions,
|
|
iconOptions: ICON_OPTIONS,
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
baseConfig,
|
|
createPoliciesSectionEditorConfig,
|
|
};
|