Skip to content

Commit

Permalink
feature/EPMGCIP-165/Add new migration for creating 'Page' model (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Siarhei Balonikau <[email protected]>
  • Loading branch information
gordoney and Siarhei Balonikau authored Jan 8, 2025
1 parent 64b0146 commit 758b444
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions migrations/2_EPMGCIP-165_add-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const languages = require('../languages.js');

module.exports = function (migration) {
const exhibit = migration
.createContentType("page")
.name("Page")
.description("")
.displayField(`name${languages.find((lang) => lang.primary).code}`);

languages.forEach((lang) => {
exhibit
.createField(`name${lang.code}`)
.name(`Name ${lang.code.toUpperCase()}`)
.type("Symbol")
.localized(false)
.required(lang.primary)
.validations([])
.disabled(false)
.omitted(false);
});

languages.forEach((lang) => {
exhibit
.createField(`description${lang.code}`)
.name(`Description ${lang.code.toUpperCase()}`)
.type("RichText")
.localized(false)
.required(false)
.validations([
{
enabledMarks: [
"bold",
"italic",
"underline",
"code",
"superscript",
"subscript",
],
message:
"Only bold, italic, underline, code, superscript, and subscript marks are allowed",
},
{
enabledNodeTypes: [
"heading-1",
"heading-2",
"heading-3",
"heading-4",
"heading-5",
"heading-6",
"ordered-list",
"unordered-list",
"hr",
"blockquote",
"embedded-entry-block",
"embedded-asset-block",
"table",
"hyperlink",
"entry-hyperlink",
"asset-hyperlink",
"embedded-entry-inline",
],

message:
"Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, link to Url, link to entry, link to asset, and inline entry nodes are allowed",
},
{
nodes: {},
},
])
.disabled(false)
.omitted(false);
});

exhibit
.createField("slug")
.name("Slug")
.type("Symbol")
.localized(false)
.required(false)
.validations([])
.disabled(false)
.omitted(false);

languages.forEach((lang) => {
exhibit.changeFieldControl(`name${lang.code}`, "builtin", "singleLine", {});
});

languages.forEach((lang) => {
exhibit.changeFieldControl(`description${lang.code}`, "builtin", "richTextEditor", {});
});

exhibit.changeFieldControl("slug", "builtin", "slugEditor", {
trackingFieldId: `name${languages.find((lang) => lang.primary).code}`,
});
};

0 comments on commit 758b444

Please sign in to comment.