mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
Attributes fixes
This commit is contained in:
parent
f15098ce69
commit
334e63a9f3
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user