From cf09c6ee6f3518b22c18c999d00a44ff9dc10e1e Mon Sep 17 00:00:00 2001 From: DrMint Date: Fri, 31 Dec 2021 04:21:20 +0100 Subject: [PATCH] Improved the Library items data structure --- .../content-types/audio-subtype/schema.json | 22 ++++++++++++++++++ .../controllers/audio-subtype.js | 9 ++++++++ src/api/audio-subtype/routes/audio-subtype.js | 9 ++++++++ .../audio-subtype/services/audio-subtype.js | 9 ++++++++ .../content-types/content-type/schema.json | 22 ++++++++++++++++++ .../content-type/controllers/content-type.js | 9 ++++++++ src/api/content-type/routes/content-type.js | 9 ++++++++ src/api/content-type/services/content-type.js | 9 ++++++++ .../content-types/library-content/schema.json | 5 ++++ .../content-types/library-item/schema.json | 9 ++++++++ .../content-types/textual-subtype/schema.json | 22 ++++++++++++++++++ .../controllers/textual-subtype.js | 9 ++++++++ .../textual-subtype/routes/textual-subtype.js | 9 ++++++++ .../services/textual-subtype.js | 9 ++++++++ src/components/basics/datepicker.json | 23 +++++++++++++++++++ src/components/metadata/audio.json | 18 ++++++--------- src/components/metadata/books.json | 15 +++--------- 17 files changed, 194 insertions(+), 23 deletions(-) create mode 100644 src/api/audio-subtype/content-types/audio-subtype/schema.json create mode 100644 src/api/audio-subtype/controllers/audio-subtype.js create mode 100644 src/api/audio-subtype/routes/audio-subtype.js create mode 100644 src/api/audio-subtype/services/audio-subtype.js create mode 100644 src/api/content-type/content-types/content-type/schema.json create mode 100644 src/api/content-type/controllers/content-type.js create mode 100644 src/api/content-type/routes/content-type.js create mode 100644 src/api/content-type/services/content-type.js create mode 100644 src/api/textual-subtype/content-types/textual-subtype/schema.json create mode 100644 src/api/textual-subtype/controllers/textual-subtype.js create mode 100644 src/api/textual-subtype/routes/textual-subtype.js create mode 100644 src/api/textual-subtype/services/textual-subtype.js create mode 100644 src/components/basics/datepicker.json diff --git a/src/api/audio-subtype/content-types/audio-subtype/schema.json b/src/api/audio-subtype/content-types/audio-subtype/schema.json new file mode 100644 index 0000000..69fb2a8 --- /dev/null +++ b/src/api/audio-subtype/content-types/audio-subtype/schema.json @@ -0,0 +1,22 @@ +{ + "kind": "collectionType", + "collectionName": "audio_subtypes", + "info": { + "singularName": "audio-subtype", + "pluralName": "audio-subtypes", + "displayName": "Audio Subtypes", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "slug": { + "type": "string", + "regex": "^[a-z0-9]+(?:-[a-z0-9]+)*$", + "unique": true, + "required": true + } + } +} diff --git a/src/api/audio-subtype/controllers/audio-subtype.js b/src/api/audio-subtype/controllers/audio-subtype.js new file mode 100644 index 0000000..ef16c15 --- /dev/null +++ b/src/api/audio-subtype/controllers/audio-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * audio-subtype controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::audio-subtype.audio-subtype'); diff --git a/src/api/audio-subtype/routes/audio-subtype.js b/src/api/audio-subtype/routes/audio-subtype.js new file mode 100644 index 0000000..9a2161a --- /dev/null +++ b/src/api/audio-subtype/routes/audio-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * audio-subtype router. + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::audio-subtype.audio-subtype'); diff --git a/src/api/audio-subtype/services/audio-subtype.js b/src/api/audio-subtype/services/audio-subtype.js new file mode 100644 index 0000000..82c25ac --- /dev/null +++ b/src/api/audio-subtype/services/audio-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * audio-subtype service. + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::audio-subtype.audio-subtype'); diff --git a/src/api/content-type/content-types/content-type/schema.json b/src/api/content-type/content-types/content-type/schema.json new file mode 100644 index 0000000..5369337 --- /dev/null +++ b/src/api/content-type/content-types/content-type/schema.json @@ -0,0 +1,22 @@ +{ + "kind": "collectionType", + "collectionName": "content_types", + "info": { + "singularName": "content-type", + "pluralName": "content-types", + "displayName": "Content Types", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "slug": { + "type": "string", + "regex": "^[a-z0-9]+(?:-[a-z0-9]+)*$", + "unique": true, + "required": true + } + } +} diff --git a/src/api/content-type/controllers/content-type.js b/src/api/content-type/controllers/content-type.js new file mode 100644 index 0000000..790d326 --- /dev/null +++ b/src/api/content-type/controllers/content-type.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * content-type controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::content-type.content-type'); diff --git a/src/api/content-type/routes/content-type.js b/src/api/content-type/routes/content-type.js new file mode 100644 index 0000000..fc5c44e --- /dev/null +++ b/src/api/content-type/routes/content-type.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * content-type router. + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::content-type.content-type'); diff --git a/src/api/content-type/services/content-type.js b/src/api/content-type/services/content-type.js new file mode 100644 index 0000000..ebf65c1 --- /dev/null +++ b/src/api/content-type/services/content-type.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * content-type service. + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::content-type.content-type'); diff --git a/src/api/library-content/content-types/library-content/schema.json b/src/api/library-content/content-types/library-content/schema.json index cc575e5..2d2718d 100644 --- a/src/api/library-content/content-types/library-content/schema.json +++ b/src/api/library-content/content-types/library-content/schema.json @@ -65,6 +65,11 @@ "relation": "manyToOne", "target": "api::video-set.video-set", "inversedBy": "library_contents" + }, + "type": { + "type": "relation", + "relation": "oneToOne", + "target": "api::content-type.content-type" } } } diff --git a/src/api/library-item/content-types/library-item/schema.json b/src/api/library-item/content-types/library-item/schema.json index b15cd39..6b4bc67 100644 --- a/src/api/library-item/content-types/library-item/schema.json +++ b/src/api/library-item/content-types/library-item/schema.json @@ -89,6 +89,15 @@ "relation": "oneToMany", "target": "api::library-content.library-content", "mappedBy": "library_item" + }, + "description": { + "type": "text" + }, + "release_date": { + "type": "component", + "repeatable": false, + "component": "basics.datepicker", + "required": false } } } diff --git a/src/api/textual-subtype/content-types/textual-subtype/schema.json b/src/api/textual-subtype/content-types/textual-subtype/schema.json new file mode 100644 index 0000000..ab994d1 --- /dev/null +++ b/src/api/textual-subtype/content-types/textual-subtype/schema.json @@ -0,0 +1,22 @@ +{ + "kind": "collectionType", + "collectionName": "textual_subtypes", + "info": { + "singularName": "textual-subtype", + "pluralName": "textual-subtypes", + "displayName": "Textual Subtypes", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "slug": { + "type": "string", + "regex": "^[a-z0-9]+(?:-[a-z0-9]+)*$", + "unique": true, + "required": true + } + } +} diff --git a/src/api/textual-subtype/controllers/textual-subtype.js b/src/api/textual-subtype/controllers/textual-subtype.js new file mode 100644 index 0000000..3664f93 --- /dev/null +++ b/src/api/textual-subtype/controllers/textual-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * textual-subtype controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::textual-subtype.textual-subtype'); diff --git a/src/api/textual-subtype/routes/textual-subtype.js b/src/api/textual-subtype/routes/textual-subtype.js new file mode 100644 index 0000000..1169415 --- /dev/null +++ b/src/api/textual-subtype/routes/textual-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * textual-subtype router. + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::textual-subtype.textual-subtype'); diff --git a/src/api/textual-subtype/services/textual-subtype.js b/src/api/textual-subtype/services/textual-subtype.js new file mode 100644 index 0000000..68986f3 --- /dev/null +++ b/src/api/textual-subtype/services/textual-subtype.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * textual-subtype service. + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::textual-subtype.textual-subtype'); diff --git a/src/components/basics/datepicker.json b/src/components/basics/datepicker.json new file mode 100644 index 0000000..651f009 --- /dev/null +++ b/src/components/basics/datepicker.json @@ -0,0 +1,23 @@ +{ + "collectionName": "components_basics_datepickers", + "info": { + "displayName": "datepicker", + "icon": "calendar-alt" + }, + "options": {}, + "attributes": { + "year": { + "type": "integer" + }, + "month": { + "type": "integer", + "max": 12, + "min": 1 + }, + "day": { + "type": "integer", + "max": 31, + "min": 1 + } + } +} diff --git a/src/components/metadata/audio.json b/src/components/metadata/audio.json index 1df6714..7437316 100644 --- a/src/components/metadata/audio.json +++ b/src/components/metadata/audio.json @@ -2,24 +2,20 @@ "collectionName": "components_metadata_audio", "info": { "displayName": "Audio", - "icon": "music" + "icon": "music", + "description": "" }, "options": {}, "attributes": { - "subtype": { - "type": "enumeration", - "enum": [ - "Soundtrack", - "Audiobook", - "Other" - ], - "default": "Soundtrack", - "required": true - }, "languages": { "type": "relation", "relation": "oneToMany", "target": "api::language.language" + }, + "subtype": { + "type": "relation", + "relation": "oneToOne", + "target": "api::audio-subtype.audio-subtype" } } } diff --git a/src/components/metadata/books.json b/src/components/metadata/books.json index f2e23ed..6f9de50 100644 --- a/src/components/metadata/books.json +++ b/src/components/metadata/books.json @@ -35,18 +35,9 @@ "default": "Left_to_Right" }, "subtype": { - "type": "enumeration", - "enum": [ - "Book", - "Manga", - "Comic", - "Magazine", - "Novel", - "Script", - "Scorebook" - ], - "required": true, - "default": "Book" + "type": "relation", + "relation": "oneToOne", + "target": "api::textual-subtype.textual-subtype" } } }