Files
cms.techvanguard.vn/utils/contentEditors/admissionsConfig.js
T
Tống Thành Đạt a39c336dd4 feat(cms): enhance content editors with dynamic UI configs and validation
Implement a more flexible, configuration-driven approach for CMS editors across accreditation, admissions, and partnerships modules.
- Move UI labels, help texts, and field limits from hardcoded views to `editorUi` configurations in config files.
- Add server-side and client-side validation to prevent duplicate category tabs in accreditation and partnerships editors.
- Refactor partnership and admission views to dynamically render tabs and fields based on the provided configuration.
- Update field length constraints and default values across multiple content editors to better align with frontend requirements.
- Improve the admissions calculator editor with dynamic field configurations and default value fallbacks.
2026-04-22 18:06:03 +07:00

291 lines
8.9 KiB
JavaScript

const {
text,
hidden,
textarea,
image,
icon,
checkbox,
object,
stringList,
objectList,
linkFields,
} = require("./sharedFields");
module.exports = {
key: "admissions",
title: "Admissions Management",
subtitle: "Manage the content for the admissions page",
routeBase: "/admin/admissions",
apiPath: "/api/admissions",
previewPath: "/admissions",
dataFile: "admissions",
imageType: "admissions",
editorUi: {
keyDates: {
tableLabel: "Key dates table",
tableHelpText: "Manage the table directly by adding or removing columns and rows.",
addColumnLabel: "Add Column",
addRowLabel: "Add Row",
columnPlaceholder: "Column name",
emptyRowsText: "No rows yet.",
actionsLabel: "Actions",
columnLabelMaxLength: 40,
cellMaxLength: 60,
},
calculator: {
ctaLabel: "Primary button",
ctaHelpText: "This button appears at the bottom of the calculator card.",
optionsLabel: "Calculator options",
optionsHelpText: "Each option has its own pricing labels, amount, note, and icon. Open the edit page to update the option details.",
optionsEmptyText: "No calculator options yet.",
addOptionLabel: "Add calculator option",
maxOptions: 3,
limitHelpText: "You can add up to 3 calculator options.",
defaultOption: {
paceLabel: "Target Pace",
minPaceLabel: "Relaxed",
maxPaceLabel: "Accelerated",
resultLabel: "Estimated Monthly Payment",
monthlyAmount: "299",
monthlySuffix: "/mo",
noteIcon: "fa-bolt",
note: "",
},
},
},
tabs: [
{
key: "hero",
label: "Hero",
icon: "fas fa-image",
schema: object("hero", "Hero", [
text("badge", "Eyebrow label", { maxLength: 40 }),
text("title", "Headline", { maxLength: 80 }),
textarea("description", "Supporting text", { maxLength: 240, rows: 4 }),
object("primaryCta", "Primary button", linkFields("Primary button")),
object("secondaryCta", "Secondary button", linkFields("Secondary button")),
image("image", "Hero image", {
imageHint: "Recommended 720x646 px",
helpText: "Large image rendered in the right hero panel.",
}),
text("imageAlt", "Hero image alt text", { maxLength: 120 }),
]),
},
{
key: "process",
label: "Admissions Process",
icon: "fas fa-list-ol",
schema: object("process", "Admissions process", [
text("title", "Section title", { maxLength: 60 }),
textarea("description", "Section description", {
maxLength: 180,
rows: 3,
}),
objectList(
"steps",
"Steps",
[
hidden("number", { autoSequence: { padLength: 2 } }),
text("title", "Step title", { maxLength: 50 }),
textarea("description", "Step description", {
maxLength: 180,
rows: 3,
}),
checkbox("active", "Highlight this step"),
],
{
itemLabel: "Step",
sortable: true,
itemTitleKey: "title",
itemSubtitleKey: "number",
emptyText: "No process steps yet.",
},
),
]),
},
{
key: "eligibility",
label: "Eligibility",
icon: "fas fa-check-circle",
schema: object("eligibility", "Eligibility", [
text("title", "Section title", { maxLength: 60 }),
objectList(
"cards",
"Eligibility cards",
[
text("title", "Card title", { maxLength: 50 }),
icon("icon", "Card icon"),
stringList("items", "Checklist items", {
itemLabel: "Checklist item",
maxLength: 120,
sortable: true,
}),
],
{
itemLabel: "Card",
sortable: true,
itemTitleKey: "title",
emptyText: "No eligibility cards yet.",
},
),
]),
},
{
key: "tuition",
label: "Tuition",
icon: "fas fa-chart-column",
schema: object("tuition", "Tuition", [
text("title", "Section title", { maxLength: 45 }),
text("chartTitle", "Chart title", { maxLength: 40 }),
textarea("chartDescription", "Chart description", {
maxLength: 140,
rows: 3,
}),
objectList(
"series",
"Chart series",
[
text("label", "Series label", { maxLength: 20 }),
{ key: "color", label: "Series color", type: "color" },
objectList(
"points",
"Data points",
[
text("time", "Time label", {
maxLength: 14,
placeholder: "Year 1",
}),
{
key: "value",
label: "Value",
type: "number",
min: 0,
},
],
{
itemLabel: "Point",
sortable: true,
itemTitleKey: "time",
itemSubtitleKey: "value",
helpText: "Each chart point requires both a time label and a numeric value.",
emptyText: "No data points yet.",
},
),
],
{
itemLabel: "Series",
sortable: true,
itemTitleKey: "label",
emptyText: "No chart series yet.",
},
),
]),
},
{
key: "keyDates",
label: "Key Dates",
icon: "fas fa-calendar-days",
schema: object("keyDates", "Key dates", [
text("title", "Section title", { maxLength: 60 }),
]),
},
{
key: "calculator",
label: "Calculator",
icon: "fas fa-calculator",
schema: object("calculator", "Calculator", [
text("title", "Card title", { maxLength: 60 }),
textarea("description", "Card description", {
maxLength: 120,
rows: 3,
}),
object("cta", "Button", linkFields("Button")),
objectList(
"options",
"Calculator options",
[
hidden("id"),
text("label", "Option label", {
maxLength: 12,
helpText: "This label appears in the calculator option switcher.",
}),
text("paceLabel", "Pace label", {
maxLength: 20,
helpText: "This appears above the pace slider.",
}),
text("minPaceLabel", "Minimum pace label", {
maxLength: 7,
helpText: "This appears on the left side of the pace slider.",
}),
text("maxPaceLabel", "Maximum pace label", {
maxLength: 7,
helpText: "This appears on the right side of the pace slider.",
}),
text("resultLabel", "Result label", {
maxLength: 40,
helpText: "This label appears above the calculated amount.",
}),
text("monthlyAmount", "Monthly amount", {
maxLength: 20,
helpText: "Enter digits only. The currency symbol is added on the website automatically.",
}),
text("monthlySuffix", "Monthly suffix", {
maxLength: 10,
helpText: "Example: /mo",
}),
icon("noteIcon", "Note icon", {
helpText: "Choose the icon shown beside the note.",
}),
text("note", "Note text", {
maxLength: 60,
helpText: "This short note appears under the amount.",
}),
],
{
itemLabel: "Option",
sortable: true,
itemTitleKey: "label",
emptyText: "No calculator options yet.",
itemActions: [
{
label: "Edit option",
icon: "fas fa-pen",
className: "btn btn-outline-primary btn-sm",
hrefTemplate: "/admin/admissions/calculator/{id}",
},
],
},
),
]),
},
{
key: "scholarships",
label: "Scholarships",
icon: "fas fa-award",
schema: object("scholarships", "Scholarships", [
text("title", "Card title", { maxLength: 50 }),
icon("icon", "Card icon"),
objectList(
"items",
"Scholarship items",
[
text("title", "Title", { maxLength: 40 }),
text("amount", "Amount", { maxLength: 12 }),
textarea("description", "Description", {
maxLength: 160,
rows: 3,
}),
],
{
itemLabel: "Scholarship item",
sortable: true,
itemTitleKey: "title",
itemSubtitleKey: "amount",
emptyText: "No scholarship items yet.",
},
),
]),
},
],
};