diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/actions.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/App/actions.js index e1831fa142..544cec9bc9 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/actions.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/App/actions.js @@ -3,7 +3,15 @@ * App actions * */ -import { cloneDeep, pick, set, camelCase } from 'lodash'; +import { + cloneDeep, + isEmpty, + pick, + toInteger, + toNumber, + set, + camelCase, +} from 'lodash'; import { fromJS, OrderedMap } from 'immutable'; import { ADD_ATTRIBUTE_RELATION, @@ -734,16 +742,32 @@ export const buildGroupAttributes = attributes => }); return acc.concat(attribute); } else { - const attribute = { name: current, ...attributes[current] }; - return acc.concat(attribute); + if (attributes[current].type === 'enumeration') { + return acc.concat({ + name: current, + ...attributes[current], + enum: attributes[current].enum.join('\n'), + }); + } + return acc.concat({ name: current, ...attributes[current] }); } }, []); export const formatGroupAttributes = attributes => { const formattedAttributes = attributes.reduce((acc, current) => { - const name = current['name']; - const newAttribute = { ...current }; - delete newAttribute['name']; + const { name, ...newAttribute } = current; + const { type } = newAttribute; + + if (type === 'enumeration') { + newAttribute.enum = newAttribute.enum.split('\n'); + } + + if (type === 'integer' && !isEmpty(newAttribute.default)) { + newAttribute.default = toInteger(newAttribute.default); + } + if (['decimal', 'float'].includes(type) && !isEmpty(newAttribute.default)) { + newAttribute.default = toNumber(newAttribute.default); + } acc[name] = newAttribute; return acc; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js index 2911d15e94..ded091acc8 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/index.js @@ -93,7 +93,7 @@ class AttributeForm extends React.Component { const split = value.split('\n'); const hasEnumFormatError = split.filter( - v => !new RegExp('^[A-Za-z][_0-9A-Za-z]*$').test(v) + v => !new RegExp('^[_A-Za-z][_0-9A-Za-z]*$').test(v) ); if (hasEnumFormatError.length > 0) { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/supportedAttributes.json b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/supportedAttributes.json index 5723e1677b..f066326f98 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/supportedAttributes.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/AttributeForm/supportedAttributes.json @@ -634,15 +634,6 @@ }, "advanced": { "items": [ - { - "label": { - "id": "content-type-builder.form.attribute.settings.default" - }, - "name": "default", - "type": "password", - "value": "", - "validations": {} - }, { "title": { "id": "content-type-builder.form.attribute.item.settings.name" @@ -659,19 +650,6 @@ "id": "content-type-builder.form.attribute.item.requiredField.description" } }, - { - "label": { - "id": "content-type-builder.form.attribute.item.uniqueField" - }, - "name": "unique", - "type": "checkbox", - "customBootstrapClass": "col-md-12", - "value": false, - "validations": {}, - "inputDescription": { - "id": "content-type-builder.form.attribute.item.uniqueField.description" - } - }, { "label": { "id": "content-type-builder.form.attribute.item.minimumLength" @@ -879,23 +857,6 @@ "value": "", "validations": {} }, - { - "customBootstrapClass": "col-md-12", - "title": { - "id": "content-type-builder.form.attribute.item.appearance.name" - }, - "label": { - "id": "content-type-builder.form.attribute.item.appearance.label" - }, - "name": "appearance.WYSIWYG", - "type": "checkbox", - "value": false, - "validations": {}, - "inputDescription": { - "id": "content-type-builder.form.attribute.item.appearance.description" - }, - "inputStyle": { "fontWeight": "500" } - }, { "title": { "id": "content-type-builder.form.attribute.item.settings.name"