Add board feature

This commit is contained in:
julien vdb
2025-03-28 14:52:43 +01:00
parent 9d4ecb2733
commit c6d5936639
23 changed files with 3485 additions and 11 deletions

View File

@@ -0,0 +1,59 @@
{
"kind": "collectionType",
"collectionName": "board_cards",
"info": {
"singularName": "board-card",
"pluralName": "board-cards",
"displayName": "BoardCard",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"description": {
"type": "text"
},
"order": {
"type": "integer"
},
"boardList": {
"type": "relation",
"relation": "manyToOne",
"target": "api::board-list.board-list",
"inversedBy": "cards"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"type": {
"type": "enumeration",
"enum": [
"link",
"youtube",
"image",
"video",
"audio",
"pdf"
]
},
"url": {
"type": "string"
},
"imageUrl": {
"type": "string"
}
}
}

View File

@@ -0,0 +1,53 @@
/**
* board-card controller
*/
import { factories } from "@strapi/strapi";
export default factories.createCoreController(
"api::board-card.board-card",
({ strapi }) => ({
async delete(ctx) {
// some logic here
const response = await super.delete(ctx);
// some more logic
return response;
},
async create(ctx) {
ctx.request.body.data = JSON.parse(ctx.request.body.data);
switch (ctx.request.body.data.type) {
case "link":
case "image":
case "video":
case "audio":
case "pdf":
const files = Array.isArray(ctx.request.files.files)
? ctx.request.files.files[0]
: ctx.request.files.files;
const extension = files.originalFilename.match(/\.[0-9a-z]+$/i);
const payload = {
fileInfo: {
caption: "undefined",
alternativeText: ctx.request.body.data.title || "",
name: `${ctx.request.body.data.title}.${extension}`,
},
};
const asset = await strapi.services["plugin::upload.upload"].upload({
data: payload,
files,
});
ctx.request.body.data.image = asset[0].id;
break;
case "youtube":
const image = ctx.request.body.image;
ctx.request.body.data.imageUrl = image;
break;
}
const { data, meta } = await super.create(ctx);
return { data, meta };
},
})
);

View File

@@ -0,0 +1,7 @@
/**
* board-card router
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreRouter('api::board-card.board-card');

View File

@@ -0,0 +1,7 @@
/**
* board-card service
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::board-card.board-card');

View File

@@ -0,0 +1,34 @@
{
"kind": "collectionType",
"collectionName": "board_lists",
"info": {
"singularName": "board-list",
"pluralName": "board-lists",
"displayName": "BoardList",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"order": {
"type": "integer"
},
"board": {
"type": "relation",
"relation": "manyToOne",
"target": "api::board.board",
"inversedBy": "board_lists"
},
"cards": {
"type": "relation",
"relation": "oneToMany",
"target": "api::board-card.board-card",
"mappedBy": "boardList"
}
}
}

View File

@@ -0,0 +1,15 @@
/**
* board-list controller
*/
import { factories } from "@strapi/strapi";
export default factories.createCoreController(
"api::board-list.board-list",
({ strapi }) => ({
async update(ctx) {
console.log(ctx);
return super.update(ctx);
},
})
);

View File

@@ -0,0 +1,7 @@
/**
* board-list router
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreRouter('api::board-list.board-list');

View File

@@ -0,0 +1,7 @@
/**
* board-list service
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::board-list.board-list');

View File

@@ -0,0 +1,45 @@
{
"kind": "collectionType",
"collectionName": "boards",
"info": {
"singularName": "board",
"pluralName": "boards",
"displayName": "Board",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"image": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"choral": {
"type": "relation",
"relation": "manyToOne",
"target": "api::choral.choral",
"inversedBy": "boards"
},
"unsplashImage": {
"type": "string"
},
"board_lists": {
"type": "relation",
"relation": "oneToMany",
"target": "api::board-list.board-list",
"mappedBy": "board"
}
}
}

View File

@@ -0,0 +1,18 @@
/**
* board controller
*/
import { factories } from "@strapi/strapi";
export default factories.createCoreController(
"api::board.board",
({ strapi }) => ({
async update(ctx) {
return super.update(ctx);
},
async find(ctx) {
console.log(ctx);
return super.find(ctx);
},
})
);

View File

@@ -0,0 +1,7 @@
/**
* board router
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreRouter('api::board.board');

View File

@@ -0,0 +1,7 @@
/**
* board service
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::board.board');

View File

@@ -0,0 +1,66 @@
{
"kind": "collectionType",
"collectionName": "chorals",
"info": {
"singularName": "choral",
"pluralName": "chorals",
"displayName": "Choral",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"cover": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"country": {
"type": "string"
},
"address": {
"type": "string"
},
"city": {
"type": "string"
},
"postal": {
"type": "integer"
},
"owner": {
"type": "relation",
"relation": "oneToOne",
"target": "plugin::users-permissions.user",
"inversedBy": "choralOwner"
},
"admins": {
"type": "relation",
"relation": "manyToMany",
"target": "plugin::users-permissions.user",
"inversedBy": "choralAdmin"
},
"users": {
"type": "relation",
"relation": "manyToMany",
"target": "plugin::users-permissions.user",
"inversedBy": "chorals"
},
"boards": {
"type": "relation",
"relation": "oneToMany",
"target": "api::board.board",
"mappedBy": "choral"
}
}
}

View File

@@ -0,0 +1,7 @@
/**
* choral controller
*/
import { factories } from '@strapi/strapi'
export default factories.createCoreController('api::choral.choral');

View File

@@ -0,0 +1,7 @@
/**
* choral router
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreRouter('api::choral.choral');

View File

@@ -0,0 +1,7 @@
/**
* choral service
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::choral.choral');

View File

@@ -88,6 +88,24 @@
"nbSaved": {
"type": "integer",
"default": 0
},
"choralOwner": {
"type": "relation",
"relation": "oneToOne",
"target": "api::choral.choral",
"mappedBy": "owner"
},
"choralAdmin": {
"type": "relation",
"relation": "manyToMany",
"target": "api::choral.choral",
"mappedBy": "admins"
},
"chorals": {
"type": "relation",
"relation": "manyToMany",
"target": "api::choral.choral",
"mappedBy": "users"
}
}
}