diff --git a/website/app.js b/website/app.js index 7acdbef4..4ab7bc3e 100644 --- a/website/app.js +++ b/website/app.js @@ -86,6 +86,7 @@ function createAposConfig() { 'cases-tags': {}, 'case-studies': {}, 'case-studies-page': {}, + 'categories': {}, 'case-studies-carousel-widget': {}, 'container-widget': {}, }, diff --git a/website/modules/@apostrophecms/admin-bar/index.js b/website/modules/@apostrophecms/admin-bar/index.js index 6b0b25a0..0e002c44 100644 --- a/website/modules/@apostrophecms/admin-bar/index.js +++ b/website/modules/@apostrophecms/admin-bar/index.js @@ -14,6 +14,10 @@ module.exports = { label: 'Cases', items: ['case-studies', 'cases-tags'], }, + { + label: 'Categories', + items: ['categories'], + }, ], }, }; diff --git a/website/modules/cases-tags/index.js b/website/modules/cases-tags/index.js index 1882b173..3905db3f 100644 --- a/website/modules/cases-tags/index.js +++ b/website/modules/cases-tags/index.js @@ -12,11 +12,34 @@ module.exports = { type: 'string', label: 'Description', }, + _category: { + type: 'relationship', + label: 'Category', + withType: 'categories', + required: true, + max: 1, + builders: { + project: { + title: 1, + slug: 1, + }, + }, + help: 'Choose a category for this tag', + }, }, group: { basics: { label: 'Basics', - fields: ['title', 'description'], + fields: ['title', 'description', '_category'], + }, + }, + }, + columns: { + add: { + _category: { + label: 'Category', + type: 'string', + name: '_category.0.title', }, }, }, diff --git a/website/modules/categories/index.js b/website/modules/categories/index.js new file mode 100644 index 00000000..03e3202c --- /dev/null +++ b/website/modules/categories/index.js @@ -0,0 +1,21 @@ +module.exports = { + extend: '@apostrophecms/piece-type', + options: { + label: 'Category', + pluralLabel: 'Categories', + }, + fields: { + add: { + description: { + type: 'string', + label: 'Description', + }, + }, + group: { + basics: { + label: 'Basics', + fields: ['title', 'description'], + }, + }, + }, +};