schuelerzeitung/static/admin/collections.js
Denys Konovalov 126395746e
All checks were successful
schuelerzeitung-prod / prod-build (push) Successful in 6s
schuelerzeitung-prod / test-build (push) Successful in 1s
add categories relation
2024-01-13 18:36:33 +01:00

257 lines
5.1 KiB
JavaScript

const PostCollection = {
name: "post",
label: "Artikel",
description: "Hier könnt ihr die Artikel der Schülerzeitung bearbeiten.",
icon: "news",
folder: "content/post",
create: true,
editor: {
preview: true,
frame: true,
size: "half",
},
filter: {
field: "type",
value: "post",
},
summary_fields: ["title", "date", "draft"],
fields: [
{
name: "title",
label: "Titel",
widget: "string",
required: true,
},
{
name: "draft",
label: "Entwurf",
widget: "boolean",
required: false,
},
{
name: "date",
label: "Datum",
widget: "datetime",
date_format: "dd.MM.yyyy",
time_format: false,
format: "yyyy-MM-dd",
required: true,
},
{
name: "description",
label: "Beschreibung",
widget: "text",
required: false,
},
{
name: "image",
label: "Titelbild",
widget: "image",
required: false,
},
{
name: "tags",
label: "Tags",
widget: "list",
delimiter: ",",
required: false,
},
{
name: "categories",
label: "Kategorie(n)",
hint: "Kategorien müssen vorher im separeten Bereich erstellt werden.",
widget: "relation",
collection: "categories",
value_field: "{{title}}",
search_fields: ["title"],
display_fields: ["{{title}}"],
multiple: true,
required: false,
options_length: 10000,
},
{
name: "type",
widget: "hidden",
default: "post",
},
{
name: "body",
label: "Inhalt",
widget: "markdown",
required: true,
},
],
};
const PagesCollection = {
name: "page",
label: "Seiten",
description: "Hier könnt ihr die Zusatzseiten der Website bearbeiten.",
icon: "page",
folder: "content/page",
create: true,
editor: {
preview: true,
frame: true,
size: "half",
},
media_library: {
folder_support: true,
},
summary_fields: ["title", "date", "draft", "description"],
fields: [
{
name: "title",
label: "Titel",
widget: "string",
required: true,
},
{
name: "draft",
label: "Entwurf",
widget: "boolean",
required: false,
},
{
name: "date",
label: "Datum",
widget: "datetime",
date_format: "dd.MM.yyyy",
time_format: false,
format: "yyyy-MM-dd",
required: true,
},
{
name: "description",
label: "Beschreibung",
widget: "text",
required: false,
},
{
name: "tags",
label: "Tags",
widget: "list",
delimiter: ",",
required: false,
},
{
name: "show-in-menu",
label: "Im Menü anzeigen",
widget: "boolean",
required: false,
},
{
name: "menu",
label: "Menü",
widget: "object",
condition: {
field: "show-in-menu",
value: true,
},
required: false,
fields: [
{
name: "main",
label: "Hauptmenü",
widget: "object",
required: false,
fields: [
{
name: "weight",
label: "Gewichtung",
widget: "string",
required: false,
},
{
name: "params",
label: "Parameter",
widget: "object",
required: false,
fields: [
{
name: "icon",
label: "Symbol",
widget: "string",
required: false,
}
]
}
]
}
]
},
{
name: "body",
label: "Inhalt",
widget: "markdown",
required: true,
},
],
};
const CategoriesCollection = {
name: "categories",
label: "Kategorien",
description: "Hier könnt ihr Kategorien erstellen oder bearbeiten.",
icon: "color",
folder: "content/categories",
path: "{{slug}}/_index",
slug: "{{title}}",
create: true,
editor: {
preview: true,
frame: true,
size: "half",
},
filter: {
field: "title",
pattern: "^(?!Kategorien)"
},
summary_fields: ["title", "description", "style"],
media_folder: "/static/media",
public_folder: "/media",
fields: [
{
name: "title",
label: "Titel",
widget: "string",
required: true,
},
{
name: "description",
label: "Beschreibung",
widget: "text",
required: false,
},
{
name: "image",
label: "Titelbild",
widget: "image",
required: false,
},
{
name: "style",
label: "Aussehen",
widget: "object",
required: true,
collapsed: false,
fields: [
{
name: "background",
label: "Hintergrundfarbe",
widget: "color",
required: true,
},
{
name: "color",
label: "Schriftfarbe",
widget: "color",
required: true,
}
]
}
]
};
export { PostCollection, PagesCollection, CategoriesCollection };