diff --git a/examples/getstarted/src/api/aanother-test/content-types/aanother-test/schema.json b/examples/getstarted/src/api/aanother-test/content-types/aanother-test/schema.json new file mode 100644 index 0000000000..9e6b47798f --- /dev/null +++ b/examples/getstarted/src/api/aanother-test/content-types/aanother-test/schema.json @@ -0,0 +1,41 @@ +{ + "kind": "collectionType", + "collectionName": "aanother_tests", + "info": { + "singularName": "aanother-test", + "pluralName": "aanother-tests", + "displayName": "Aanother test" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "text": { + "type": "string", + "unique": true + }, + "email": { + "type": "email", + "unique": true + }, + "number": { + "unique": true, + "type": "integer" + }, + "uid": { + "type": "uid" + }, + "date": { + "unique": true, + "type": "date" + }, + "enum": { + "type": "enumeration", + "enum": [ + "this", + "or that" + ] + } + } +} diff --git a/examples/getstarted/src/api/aanother-test/controllers/aanother-test.js b/examples/getstarted/src/api/aanother-test/controllers/aanother-test.js new file mode 100644 index 0000000000..bb4eb478fe --- /dev/null +++ b/examples/getstarted/src/api/aanother-test/controllers/aanother-test.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * aanother-test controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::aanother-test.aanother-test'); diff --git a/examples/getstarted/src/api/aanother-test/routes/aanother-test.js b/examples/getstarted/src/api/aanother-test/routes/aanother-test.js new file mode 100644 index 0000000000..3262bfc2b4 --- /dev/null +++ b/examples/getstarted/src/api/aanother-test/routes/aanother-test.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * aanother-test router. + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::aanother-test.aanother-test'); diff --git a/examples/getstarted/src/api/aanother-test/services/aanother-test.js b/examples/getstarted/src/api/aanother-test/services/aanother-test.js new file mode 100644 index 0000000000..fe64fe4834 --- /dev/null +++ b/examples/getstarted/src/api/aanother-test/services/aanother-test.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * aanother-test service. + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::aanother-test.aanother-test'); diff --git a/packages/core/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js b/packages/core/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js index 4aef4f8544..e2be985c63 100644 --- a/packages/core/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js +++ b/packages/core/admin/admin/src/content-manager/components/EditViewDataManagerProvider/index.js @@ -235,21 +235,12 @@ const EditViewDataManagerProvider = ({ // Allow to reset text, string, email, uid, select/enum, date if ( - (type === 'text' || - type === 'string' || - type === 'email' || - type === 'uid' || - type === 'select' || - type === 'select-one') && - value === '' + ['text', 'string', 'email', 'uid', 'select', 'select-one', 'number'].includes(type) && + !value ) { inputValue = null; } - if (type === 'number' && !value) { - inputValue = null; - } - if (type === 'password' && !value) { dispatch({ type: 'REMOVE_PASSWORD_FIELD', @@ -259,6 +250,8 @@ const EditViewDataManagerProvider = ({ return; } + console.log({ name, inputValue }); + dispatch({ type: 'ON_CHANGE', keys: name.split('.'), diff --git a/packages/core/helper-plugin/lib/src/components/GenericInput/tests/index.test.js b/packages/core/helper-plugin/lib/src/components/GenericInput/tests/index.test.js index e143e96a52..8498024144 100644 --- a/packages/core/helper-plugin/lib/src/components/GenericInput/tests/index.test.js +++ b/packages/core/helper-plugin/lib/src/components/GenericInput/tests/index.test.js @@ -110,16 +110,5 @@ describe('GenericInput', () => { target: { name: 'number', type: 'number', value: 0 }, }); }); - - test('does call onChange callback with undefined on empty value', () => { - const spy = jest.fn(); - const { input } = setupNumber({ value: 1, onChange: spy }); - - fireEvent.change(input, { target: { value: '' } }); - - expect(spy).toHaveBeenCalledWith({ - target: { name: 'number', type: 'number', value: undefined }, - }); - }); }); });