Fix edit name content types

This commit is contained in:
soupette 2019-08-22 14:34:01 +02:00
parent 3569f8fdee
commit 70117b4aa7
12 changed files with 170 additions and 66 deletions

View File

@ -0,0 +1,52 @@
{
"routes": [
{
"method": "GET",
"path": "/hozhrehRieozhobzes",
"handler": "HozhrehRieozhobze.find",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/hozhrehRieozhobzes/count",
"handler": "HozhrehRieozhobze.count",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/hozhrehRieozhobzes/:id",
"handler": "HozhrehRieozhobze.findOne",
"config": {
"policies": []
}
},
{
"method": "POST",
"path": "/hozhrehRieozhobzes",
"handler": "HozhrehRieozhobze.create",
"config": {
"policies": []
}
},
{
"method": "PUT",
"path": "/hozhrehRieozhobzes/:id",
"handler": "HozhrehRieozhobze.update",
"config": {
"policies": []
}
},
{
"method": "DELETE",
"path": "/hozhrehRieozhobzes/:id",
"handler": "HozhrehRieozhobze.delete",
"config": {
"policies": []
}
}
]
}

View File

@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/guides/controllers.html#core-controllers)
* to customize this controller
*/
module.exports = {};

View File

@ -0,0 +1,44 @@
'use strict';
/**
* Lifecycle callbacks for the `HozhrehRieozhobze` model.
*/
module.exports = {
// Before saving a value.
// Fired before an `insert` or `update` query.
// beforeSave: async (model, attrs, options) => {},
// After saving a value.
// Fired after an `insert` or `update` query.
// afterSave: async (model, response, options) => {},
// Before fetching a value.
// Fired before a `fetch` operation.
// beforeFetch: async (model, columns, options) => {},
// After fetching a value.
// Fired after a `fetch` operation.
// afterFetch: async (model, response, options) => {},
// Before fetching all values.
// Fired before a `fetchAll` operation.
// beforeFetchAll: async (model, columns, options) => {},
// After fetching all values.
// Fired after a `fetchAll` operation.
// afterFetchAll: async (model, response, options) => {},
// Before creating a value.
// Fired before an `insert` query.
// beforeCreate: async (model, attrs, options) => {},
// After creating a value.
// Fired after an `insert` query.
// afterCreate: async (model, attrs, options) => {},
// Before updating a value.
// Fired before an `update` query.
// beforeUpdate: async (model, attrs, options) => {},
// After updating a value.
// Fired after an `update` query.
// afterUpdate: async (model, attrs, options) => {},
// Before destroying a value.
// Fired before a `delete` query.
// beforeDestroy: async (model, attrs, options) => {},
// After destroying a value.
// Fired after a `delete` query.
// afterDestroy: async (model, attrs, options) => {}
};

View File

@ -0,0 +1,16 @@
{
"connection": "default",
"collectionName": "hozhrehRieozhobzes",
"info": {
"name": "hozhrehRieozhobze",
"description": ""
},
"options": {
"increments": true,
"timestamps": true,
"comment": ""
},
"attributes": {
}
}

View File

@ -0,0 +1,8 @@
'use strict';
/**
* Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/guides/services.html#core-services)
* to customize this service
*/
module.exports = {};

View File

@ -292,7 +292,7 @@ export function getDataSucceeded({ allModels, models }, connections, { data }) {
export function onChangeExistingContentTypeMainInfos({ target }) {
const value =
target.name === 'name'
target.name.split('.')[1] === 'name'
? camelCase(target.value.trim()).toLowerCase()
: target.value;
@ -304,15 +304,10 @@ export function onChangeExistingContentTypeMainInfos({ target }) {
}
export function onChangeExistingGroupMainInfos({ target }) {
const value =
target.name === 'name'
? camelCase(target.value.trim()).toLowerCase()
: target.value;
return {
type: ON_CHANGE_EXISTING_GROUP_MAIN_INFOS,
keys: target.name.split('.'),
value,
value: target.value,
};
}
@ -330,39 +325,26 @@ export function onChangeNewContentTypeMainInfos({ target }) {
}
export function onChangeNewGroupMainInfos({ target }) {
const value =
target.name === 'name'
? camelCase(target.value.trim()).toLowerCase()
: target.value;
return {
type: ON_CHANGE_NEW_GROUP_MAIN_INFOS,
keys: target.name.split('.'),
value,
value: target.value,
};
}
export function onChangeAttribute({ target }) {
const value = target.name.includes('name')
? target.value.split(' ').join('')
: target.value;
return {
type: ON_CHANGE_ATTRIBUTE,
keys: target.name.split('.'),
value: value,
value: target.value,
};
}
export function onChangeAttributeGroup({ target }) {
const value = target.name.includes('name')
? target.value.split(' ').join('')
: target.value;
return {
type: ON_CHANGE_ATTRIBUTE_GROUP,
keys: target.name.split('.'),
value: value,
value: target.value,
};
}

View File

@ -608,13 +608,13 @@ describe('App actions', () => {
it('has a type of ON_CHANGE_NEW_CONTENT_TYPE_MAIN_INFOS and returns the correct data tolowercase if the name is equal to name', () => {
const e = {
target: {
name: 'name',
name: 'article.name',
value: 'testWith spaces and stuff ',
},
};
const expected = {
type: ON_CHANGE_EXISTING_CONTENT_TYPE_MAIN_INFOS,
keys: ['name'],
keys: ['article', 'name'],
value: 'testwithspacesandstuff',
};
@ -624,13 +624,13 @@ describe('App actions', () => {
it('should not return the data tolowercase if the name is not equal to name', () => {
const e = {
target: {
name: 'test',
name: 'article.test',
value: 'testWith spaces and stuff',
},
};
const expected = {
type: ON_CHANGE_EXISTING_CONTENT_TYPE_MAIN_INFOS,
keys: ['test'],
keys: ['article', 'test'],
value: 'testWith spaces and stuff',
};
@ -688,22 +688,6 @@ describe('App actions', () => {
expect(onChangeAttribute(e)).toEqual(expected);
});
it('should remove the spaces if the user is modifying the name input', () => {
const e = {
target: {
name: 'name',
value: 'attribute with space',
},
};
const expected = {
type: ON_CHANGE_ATTRIBUTE,
keys: ['name'],
value: 'attributewithspace',
};
expect(onChangeAttribute(e)).toEqual(expected);
});
});
describe('OnChangeRelation', () => {

View File

@ -38,9 +38,25 @@ class AttributeForm extends React.Component {
state = { didCheckErrors: false, formErrors: {}, showForm: false };
getCurrentForm = () => {
const { activeTab, attributeType } = this.props;
const { activeTab, attributeType, modifiedData } = this.props;
const isRepeatable = get(modifiedData, 'repeatable', false);
const form = get(
supportedAttributes,
[attributeType, activeTab, 'items'],
[]
);
return get(supportedAttributes, [attributeType, activeTab, 'items'], []);
if (
activeTab === 'advanced' &&
attributeType === 'group' &&
!isRepeatable
) {
const slicedForm = form.slice(0, 1);
return slicedForm;
}
return form;
};
getIcon = () => {

View File

@ -326,6 +326,19 @@
"validations": {
"required": true
}
},
{
"customBootstrapClass": "col-md-12",
"label": {
"id": "content-type-builder.form.attribute.item.repeatable"
},
"name": "repeatable",
"type": "checkbox",
"value": false,
"validations": {},
"inputDescription": {
"id": "content-type-builder.form.attribute.item.repeatable.description"
}
}
]
},
@ -344,20 +357,6 @@
"id": "content-type-builder.form.attribute.item.requiredField.description"
}
},
{
"customBootstrapClass": "col-md-12",
"label": {
"id": "content-type-builder.form.attribute.item.repeatable"
},
"name": "repeatable",
"type": "checkbox",
"value": false,
"validations": {},
"inputDescription": {
"id": "content-type-builder.form.attribute.item.repeatable.description"
}
},
{
"custom": true,
"customBootstrapClass": "col-md-12",

View File

@ -13,9 +13,4 @@
}
}
}
> div:last-of-type {
> div {
padding-bottom: 1rem;
}
}
}

View File

@ -35,7 +35,7 @@
"error.validation.minLength": "The value is too short.",
"error.validation.minSupMax": "Can't be superior",
"error.validation.regex": "The value does not match the regex.",
"error.validation.regex.name": "The name should not start with a number or a special character.",
"error.validation.regex.name": "Name should start with alphabetical characters. Underscores and numbers only are allowed after.",
"error.validation.regex.values": "Values should not start with a number or a special character.",
"error.validation.required": "This value input is required.",
"form.attribute.info.no-space-allowed": "No space is allowed for the name of the attribute",

View File

@ -34,7 +34,7 @@
"error.validation.minLength": "La valeur est trop courte.",
"error.validation.minSupMax": "Ne peut pas être plus grand",
"error.validation.regex": "La valeur ne correspond pas au format attendu.",
"error.validation.regex.name": "Le nom ne peut pas commencer par un nombre ou un caractère spécial",
"error.validation.regex.name": "Le nom doit commencer par une lettre. Seulement les chiffres et les underscores sont autorisés après.",
"error.validation.regex.values": "Les valeurs ne peuvent pas commencer par un nombre ou un caractère spécial",
"error.validation.required": "Ce champ est obligatoire.",
"form.attribute.info.no-space-allowed": "Les espaces ne sont pas autorisés pour les noms du champ",