From 4ae35e1185a064c67b2876e268beedea07d6743c Mon Sep 17 00:00:00 2001 From: julien vdb Date: Mon, 31 Mar 2025 18:15:55 +0200 Subject: [PATCH] Add calendar type --- .../choral/content-types/choral/schema.json | 6 ++++ src/api/event/content-types/event/schema.json | 34 +++++++++++++++++++ src/api/event/controllers/event.ts | 7 ++++ src/api/event/routes/event.ts | 7 ++++ src/api/event/services/event.ts | 7 ++++ types/generated/contentTypes.d.ts | 32 +++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 src/api/event/content-types/event/schema.json create mode 100644 src/api/event/controllers/event.ts create mode 100644 src/api/event/routes/event.ts create mode 100644 src/api/event/services/event.ts diff --git a/src/api/choral/content-types/choral/schema.json b/src/api/choral/content-types/choral/schema.json index 0844920..a93166a 100644 --- a/src/api/choral/content-types/choral/schema.json +++ b/src/api/choral/content-types/choral/schema.json @@ -61,6 +61,12 @@ "relation": "oneToMany", "target": "api::board.board", "mappedBy": "choral" + }, + "calendar": { + "type": "relation", + "relation": "oneToMany", + "target": "api::event.event", + "mappedBy": "choral" } } } diff --git a/src/api/event/content-types/event/schema.json b/src/api/event/content-types/event/schema.json new file mode 100644 index 0000000..a66f0ce --- /dev/null +++ b/src/api/event/content-types/event/schema.json @@ -0,0 +1,34 @@ +{ + "kind": "collectionType", + "collectionName": "events", + "info": { + "singularName": "event", + "pluralName": "events", + "displayName": "Event", + "description": "" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "title": { + "type": "string" + }, + "start": { + "type": "datetime" + }, + "end": { + "type": "datetime" + }, + "color": { + "type": "string" + }, + "choral": { + "type": "relation", + "relation": "manyToOne", + "target": "api::choral.choral", + "inversedBy": "calendar" + } + } +} diff --git a/src/api/event/controllers/event.ts b/src/api/event/controllers/event.ts new file mode 100644 index 0000000..9725955 --- /dev/null +++ b/src/api/event/controllers/event.ts @@ -0,0 +1,7 @@ +/** + * event controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::event.event'); diff --git a/src/api/event/routes/event.ts b/src/api/event/routes/event.ts new file mode 100644 index 0000000..bea7eaa --- /dev/null +++ b/src/api/event/routes/event.ts @@ -0,0 +1,7 @@ +/** + * event router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::event.event'); diff --git a/src/api/event/services/event.ts b/src/api/event/services/event.ts new file mode 100644 index 0000000..8fe1b33 --- /dev/null +++ b/src/api/event/services/event.ts @@ -0,0 +1,7 @@ +/** + * event service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::event.event'); diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index bd6f824..d14aef4 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -493,6 +493,7 @@ export interface ApiChoralChoral extends Struct.CollectionTypeSchema { 'plugin::users-permissions.user' >; boards: Schema.Attribute.Relation<'oneToMany', 'api::board.board'>; + calendar: Schema.Attribute.Relation<'oneToMany', 'api::event.event'>; city: Schema.Attribute.String; country: Schema.Attribute.String; cover: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'>; @@ -522,6 +523,36 @@ export interface ApiChoralChoral extends Struct.CollectionTypeSchema { }; } +export interface ApiEventEvent extends Struct.CollectionTypeSchema { + collectionName: 'events'; + info: { + description: ''; + displayName: 'Event'; + pluralName: 'events'; + singularName: 'event'; + }; + options: { + draftAndPublish: false; + }; + attributes: { + choral: Schema.Attribute.Relation<'manyToOne', 'api::choral.choral'>; + color: Schema.Attribute.String; + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + end: Schema.Attribute.DateTime; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation<'oneToMany', 'api::event.event'> & + Schema.Attribute.Private; + publishedAt: Schema.Attribute.DateTime; + start: Schema.Attribute.DateTime; + title: Schema.Attribute.String; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + }; +} + export interface PluginContentReleasesRelease extends Struct.CollectionTypeSchema { collectionName: 'strapi_releases'; @@ -1042,6 +1073,7 @@ declare module '@strapi/strapi' { 'api::board-list.board-list': ApiBoardListBoardList; 'api::board.board': ApiBoardBoard; 'api::choral.choral': ApiChoralChoral; + 'api::event.event': ApiEventEvent; 'plugin::content-releases.release': PluginContentReleasesRelease; 'plugin::content-releases.release-action': PluginContentReleasesReleaseAction; 'plugin::i18n.locale': PluginI18NLocale;