From a5811f0ea7bc4ce0541d8fd9aad2c222465f31a4 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 7 Oct 2020 10:08:07 -0400 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20ensure=20password=20r?= =?UTF-8?q?eset=20is=20always=20called?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on occassion it could break if axe is running, which is probably only an issue when developing the UI, but to be safe... --- .../form/account/password/change-password/index.hbs | 2 +- .../form/account/password/change-password/index.js | 13 +++++++------ .../form/account/password/set-password/index.hbs | 2 +- .../form/account/password/set-password/index.js | 10 +++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ui/core/app/components/form/account/password/change-password/index.hbs b/ui/core/app/components/form/account/password/change-password/index.hbs index 24548e843..954da26c1 100644 --- a/ui/core/app/components/form/account/password/change-password/index.hbs +++ b/ui/core/app/components/form/account/password/change-password/index.hbs @@ -1,6 +1,6 @@ this.resetPasswords()); - fn(currentPassword, newPassword); + submit(fn, currentPassword, newPassword) { + console.log(currentPassword, newPassword); + run(() => this.resetPasswords()); + run(() => fn(currentPassword, newPassword)); } /** diff --git a/ui/core/app/components/form/account/password/set-password/index.hbs b/ui/core/app/components/form/account/password/set-password/index.hbs index b77d6b659..9008a9094 100644 --- a/ui/core/app/components/form/account/password/set-password/index.hbs +++ b/ui/core/app/components/form/account/password/set-password/index.hbs @@ -1,5 +1,5 @@ this.resetPassword()); - fn(password); + submit(fn, password) { + run(() => this.resetPassword()); + run(() => fn(password)); } } From 139bf7a437e08e0a4ef91ac664de32122c2acf69 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 7 Oct 2020 10:16:40 -0400 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20remove=20console.lo?= =?UTF-8?q?g=20statement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/form/account/password/change-password/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/core/app/components/form/account/password/change-password/index.js b/ui/core/app/components/form/account/password/change-password/index.js index ba61219ab..e2dcd0bac 100644 --- a/ui/core/app/components/form/account/password/change-password/index.js +++ b/ui/core/app/components/form/account/password/change-password/index.js @@ -55,7 +55,6 @@ export default class FormAccountPasswordChangePasswordIndexComponent extends Com */ @action submit(fn, currentPassword, newPassword) { - console.log(currentPassword, newPassword); run(() => this.resetPasswords()); run(() => fn(currentPassword, newPassword)); } From ce08ae3001785292e2f09c2fe6244a0ea7888a1d Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 7 Oct 2020 10:53:53 -0400 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20empty=20strings=20s?= =?UTF-8?q?hould=20be=20serialized=20as=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/serializers/application.js | 5 ++++- .../tests/unit/serializers/application-test.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/api/addon/serializers/application.js b/addons/api/addon/serializers/application.js index 2819231fa..e4531c7fe 100644 --- a/addons/api/addon/serializers/application.js +++ b/addons/api/addon/serializers/application.js @@ -37,8 +37,11 @@ export default class ApplicationSerializer extends RESTSerializer { * @param {String} key * @param {Object} attribute */ - serializeAttribute(snapshot, json, key, { options }) { + serializeAttribute(snapshot, json, key, attribute) { + const { type, options } = attribute; let value = super.serializeAttribute(...arguments); + // Convert empty strings to null. + if (type === 'string' && json[key] === '') json[key] = null; // Do not serialize read-only attributes. if (options.readOnly) delete json[key]; // Version is sent only if it has a non-nullish value diff --git a/addons/api/tests/unit/serializers/application-test.js b/addons/api/tests/unit/serializers/application-test.js index 10de9d4fb..014d80377 100644 --- a/addons/api/tests/unit/serializers/application-test.js +++ b/addons/api/tests/unit/serializers/application-test.js @@ -70,6 +70,21 @@ module('Unit | Serializer | application', function (hooks) { }); }); + test('it serializes empty strings to null', function (assert) { + assert.expect(1); + const store = this.owner.lookup('service:store'); + const record = store.createRecord('user', { + name: '', + description: '', + version: null, + }); + let serializedRecord = record.serialize(); + assert.deepEqual(serializedRecord, { + name: null, + description: null, + }); + }); + test('it serializes non-nullish version fields', function (assert) { assert.expect(2); const store = this.owner.lookup('service:store');