Create Teks collection
This commit is contained in:
@@ -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})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user