Create Teks collection

This commit is contained in:
2020-12-18 19:23:21 +01:00
parent 1ba20a2003
commit 3ba187e602
6 changed files with 152 additions and 2 deletions
+2 -2
View File
@@ -32,8 +32,8 @@
"component": "url.liens" "component": "url.liens"
}, },
"awtis": { "awtis": {
"collection": "awtis", "via": "miziks",
"via": "miziks" "collection": "awtis"
}, },
"kouteyAchtey": { "kouteyAchtey": {
"type": "component", "type": "component",
+52
View File
@@ -0,0 +1,52 @@
{
"routes": [
{
"method": "GET",
"path": "/teks",
"handler": "teks.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/teks/count",
"handler": "teks.count",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/teks/:id",
"handler": "teks.findOne",
"config": {
"policies": []
}
},
{
"method": "POST",
"path": "/teks",
"handler": "teks.create",
"config": {
"policies": []
}
},
{
"method": "PUT",
"path": "/teks/:id",
"handler": "teks.update",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/teks/:id",
"handler": "teks.delete",
"config": {
"policies": []
}
}
]
}
+8
View File
@@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/controllers.html#core-controllers)
* to customize this controller
*/
module.exports = {};
+25
View File
@@ -0,0 +1,25 @@
'use strict';
const slugify = require('slugify')
const jwennAwtisEpiId = async data => {
const awtis = await strapi.query('awtis').find({_id: data})
return awtis.map(a => a.alias).join('-')
}
module.exports = {
lifecycles: {
beforeCreate: async data => {
if (data.tit) {
const awtis = await jwennAwtisEpiId(data.awtis)
data.slug = slugify(`${awtis}-${data.tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
}
},
beforeUpdate: async (params, data) => {
if (data.tit) {
const awtis = await jwennAwtisEpiId(data.awtis)
data.slug = slugify(`${awtis}-${data.tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"kind": "collectionType",
"collectionName": "teks",
"info": {
"name": "Teks",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"draftAndPublish": true
},
"attributes": {
"tit": {
"type": "string",
"required": true
},
"transkripsyon": {
"type": "richtext"
},
"tradiksyon": {
"type": "component",
"repeatable": false,
"component": "trad.traductions"
},
"lanne": {
"type": "integer"
},
"lyen": {
"type": "component",
"repeatable": false,
"component": "url.liens"
},
"awtis": {
"via": "teks",
"collection": "awtis",
"dominant": true
},
"kouteyAchtey": {
"type": "component",
"repeatable": false,
"component": "store.store"
},
"slug": {
"type": "string"
},
"kouveti": {
"model": "file",
"via": "related",
"allowedTypes": [
"images"
],
"plugin": "upload",
"required": false
}
}
}
+8
View File
@@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/services.html#core-services)
* to customize this service
*/
module.exports = {};