diff --git a/examples/getstarted/api/hozhrehrieozhobze/config/routes.json b/examples/getstarted/api/hozhrehrieozhobze/config/routes.json new file mode 100644 index 0000000000..e7c2b981d2 --- /dev/null +++ b/examples/getstarted/api/hozhrehrieozhobze/config/routes.json @@ -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": [] + } + } + ] +} diff --git a/examples/getstarted/api/hozhrehrieozhobze/controllers/HozhrehRieozhobze.js b/examples/getstarted/api/hozhrehrieozhobze/controllers/HozhrehRieozhobze.js new file mode 100644 index 0000000000..73c6f64c3f --- /dev/null +++ b/examples/getstarted/api/hozhrehrieozhobze/controllers/HozhrehRieozhobze.js @@ -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 = {}; diff --git a/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.js b/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.js new file mode 100644 index 0000000000..f983513cb8 --- /dev/null +++ b/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.js @@ -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) => {} +}; diff --git a/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.settings.json b/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.settings.json new file mode 100644 index 0000000000..338bbb14af --- /dev/null +++ b/examples/getstarted/api/hozhrehrieozhobze/models/HozhrehRieozhobze.settings.json @@ -0,0 +1,16 @@ +{ + "connection": "default", + "collectionName": "hozhrehRieozhobzes", + "info": { + "name": "hozhrehRieozhobze", + "description": "" + }, + "options": { + "increments": true, + "timestamps": true, + "comment": "" + }, + "attributes": { + + } +} diff --git a/examples/getstarted/api/hozhrehrieozhobze/services/HozhrehRieozhobze.js b/examples/getstarted/api/hozhrehrieozhobze/services/HozhrehRieozhobze.js new file mode 100644 index 0000000000..8564ba30ea --- /dev/null +++ b/examples/getstarted/api/hozhrehrieozhobze/services/HozhrehRieozhobze.js @@ -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 = {}; 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 56c8e76d56..8d709ec92a 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 @@ -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, }; } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/actions.test.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/actions.test.js index 025633d3b3..de7d221744 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/actions.test.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/App/tests/actions.test.js @@ -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', () => { 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 8bb4eaf533..84f8578e38 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 @@ -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 = () => { 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 f066326f98..97899b571d 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 @@ -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", diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss index bca2cde918..d60d1fba90 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/HomePage/styles.scss @@ -13,9 +13,4 @@ } } } - > div:last-of-type { - > div { - padding-bottom: 1rem; - } - } } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json b/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json index 312e2aac18..87a2e99dd2 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/translations/en.json @@ -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", diff --git a/packages/strapi-plugin-content-type-builder/admin/src/translations/fr.json b/packages/strapi-plugin-content-type-builder/admin/src/translations/fr.json index 6af59f8f92..0ff4b803fb 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/translations/fr.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/translations/fr.json @@ -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",