Add board feature
This commit is contained in:
59
src/api/board-card/content-types/board-card/schema.json
Normal file
59
src/api/board-card/content-types/board-card/schema.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
53
src/api/board-card/controllers/board-card.ts
Normal file
53
src/api/board-card/controllers/board-card.ts
Normal 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 };
|
||||
},
|
||||
})
|
||||
);
|
||||
7
src/api/board-card/routes/board-card.ts
Normal file
7
src/api/board-card/routes/board-card.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board-card router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::board-card.board-card');
|
||||
7
src/api/board-card/services/board-card.ts
Normal file
7
src/api/board-card/services/board-card.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board-card service
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::board-card.board-card');
|
||||
34
src/api/board-list/content-types/board-list/schema.json
Normal file
34
src/api/board-list/content-types/board-list/schema.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/api/board-list/controllers/board-list.ts
Normal file
15
src/api/board-list/controllers/board-list.ts
Normal 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);
|
||||
},
|
||||
})
|
||||
);
|
||||
7
src/api/board-list/routes/board-list.ts
Normal file
7
src/api/board-list/routes/board-list.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board-list router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::board-list.board-list');
|
||||
7
src/api/board-list/services/board-list.ts
Normal file
7
src/api/board-list/services/board-list.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board-list service
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::board-list.board-list');
|
||||
45
src/api/board/content-types/board/schema.json
Normal file
45
src/api/board/content-types/board/schema.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/api/board/controllers/board.ts
Normal file
18
src/api/board/controllers/board.ts
Normal 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);
|
||||
},
|
||||
})
|
||||
);
|
||||
7
src/api/board/routes/board.ts
Normal file
7
src/api/board/routes/board.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::board.board');
|
||||
7
src/api/board/services/board.ts
Normal file
7
src/api/board/services/board.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* board service
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::board.board');
|
||||
66
src/api/choral/content-types/choral/schema.json
Normal file
66
src/api/choral/content-types/choral/schema.json
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
7
src/api/choral/controllers/choral.ts
Normal file
7
src/api/choral/controllers/choral.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* choral controller
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi'
|
||||
|
||||
export default factories.createCoreController('api::choral.choral');
|
||||
7
src/api/choral/routes/choral.ts
Normal file
7
src/api/choral/routes/choral.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* choral router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::choral.choral');
|
||||
7
src/api/choral/services/choral.ts
Normal file
7
src/api/choral/services/choral.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* choral service
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::choral.choral');
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user