mirror of
https://github.com/strapi/strapi.git
synced 2025-09-18 13:02:18 +00:00
Fix schema handler set disgarding falsy values
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
f12a696824
commit
38d896f0ea
@ -77,13 +77,15 @@ module.exports = function createComponentBuilder() {
|
|||||||
.setUID(uid)
|
.setUID(uid)
|
||||||
.set('kind', infos.kind || typeKinds.COLLECTION_TYPE)
|
.set('kind', infos.kind || typeKinds.COLLECTION_TYPE)
|
||||||
.set('collectionName', infos.collectionName || defaultCollectionName)
|
.set('collectionName', infos.collectionName || defaultCollectionName)
|
||||||
.set(['info', 'name'], infos.name)
|
.set('info', {
|
||||||
.set(['info', 'description'], infos.description)
|
name: infos.name,
|
||||||
|
description: infos.description,
|
||||||
|
})
|
||||||
.set('options', {
|
.set('options', {
|
||||||
increments: true,
|
increments: true,
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
|
draftAndPublish: infos.draftAndPublish || false,
|
||||||
})
|
})
|
||||||
.setOption('draftAndPublish', infos.draftAndPublish || false)
|
|
||||||
.setAttributes(this.convertAttributes(infos.attributes));
|
.setAttributes(this.convertAttributes(infos.attributes));
|
||||||
|
|
||||||
Object.keys(infos.attributes).forEach(key => {
|
Object.keys(infos.attributes).forEach(key => {
|
||||||
@ -185,7 +187,7 @@ module.exports = function createComponentBuilder() {
|
|||||||
.set('kind', infos.kind || contentType.schema.kind)
|
.set('kind', infos.kind || contentType.schema.kind)
|
||||||
.set(['info', 'name'], infos.name)
|
.set(['info', 'name'], infos.name)
|
||||||
.set(['info', 'description'], infos.description)
|
.set(['info', 'description'], infos.description)
|
||||||
.setOption('draftAndPublish', infos.draftAndPublish || false)
|
.set(['options', 'draftAndPublish'], infos.draftAndPublish || false)
|
||||||
.setAttributes(this.convertAttributes(newAttributes));
|
.setAttributes(this.convertAttributes(newAttributes));
|
||||||
|
|
||||||
return contentType;
|
return contentType;
|
||||||
|
@ -76,15 +76,6 @@ module.exports = function createSchemaHandler(infos) {
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set a particular option inside the schema
|
|
||||||
setOption(path, val) {
|
|
||||||
modified = true;
|
|
||||||
|
|
||||||
_.set(state.schema, ['options'].concat(path), val);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// get a particuar path inside the schema
|
// get a particuar path inside the schema
|
||||||
get(path) {
|
get(path) {
|
||||||
return _.get(state.schema, path);
|
return _.get(state.schema, path);
|
||||||
@ -94,7 +85,8 @@ module.exports = function createSchemaHandler(infos) {
|
|||||||
set(path, val) {
|
set(path, val) {
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
_.set(state.schema, path, val || _.get(state.schema, path));
|
const value = _.defaultTo(val, _.get(state.schema, path));
|
||||||
|
_.set(state.schema, path, value);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -13,6 +13,7 @@ Object {
|
|||||||
"collectionName": "test_collection_types",
|
"collectionName": "test_collection_types",
|
||||||
"connection": "default",
|
"connection": "default",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"draftAndPublish": false,
|
||||||
"kind": "collectionType",
|
"kind": "collectionType",
|
||||||
"name": "Test Collection Type",
|
"name": "Test Collection Type",
|
||||||
},
|
},
|
||||||
@ -34,6 +35,7 @@ Object {
|
|||||||
"collectionName": "test_single_types",
|
"collectionName": "test_single_types",
|
||||||
"connection": "default",
|
"connection": "default",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"draftAndPublish": false,
|
||||||
"kind": "singleType",
|
"kind": "singleType",
|
||||||
"name": "Test Single Type",
|
"name": "Test Single Type",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user