From 2e3b044ae99f0b5dc23cfc4cedd6c79f3440569e Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 16 Sep 2020 12:01:54 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20cleanu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/account/password/index.hbs | 3 +- .../components/form/account/password/index.js | 6 +- .../account/password/set-password/index.js | 57 +++++++++++-------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/ui/core/app/components/form/account/password/index.hbs b/ui/core/app/components/form/account/password/index.hbs index 8c920be38..facd43c2f 100644 --- a/ui/core/app/components/form/account/password/index.hbs +++ b/ui/core/app/components/form/account/password/index.hbs @@ -87,4 +87,5 @@ @disabled={{if @model.cannotSave @model.cannotSave}} @submitText={{t "actions.save"}} @cancelText={{t "actions.cancel"}} /> - \ No newline at end of file + + diff --git a/ui/core/app/components/form/account/password/index.js b/ui/core/app/components/form/account/password/index.js index 842036137..caf239d17 100644 --- a/ui/core/app/components/form/account/password/index.js +++ b/ui/core/app/components/form/account/password/index.js @@ -11,14 +11,16 @@ export default class FormAccountPasswordIndexComponent extends Component { */ password; + // =actions + /** * Submit with password value when it is allowed. * Callback with no arguments otherwise. - * @param {function} fn + * @param {function} fn */ @action submit(fn) { - this.args.allowPassword ? fn(`${this.password}`) : fn(); + this.args.model.isNew ? fn(this.password) : fn(); delete this.password; } } diff --git a/ui/core/app/components/form/account/password/set-password/index.js b/ui/core/app/components/form/account/password/set-password/index.js index 2ddd5e563..a4039b76d 100644 --- a/ui/core/app/components/form/account/password/set-password/index.js +++ b/ui/core/app/components/form/account/password/set-password/index.js @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; -import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; import { computed } from '@ember/object'; -import { set } from '@ember/object'; +import { action } from '@ember/object'; export default class FormAccountPasswordSetPasswordIndexComponent extends Component { @@ -11,28 +11,7 @@ export default class FormAccountPasswordSetPasswordIndexComponent extends Compon * New password property * @type {string} */ - password; - - /** - * Submit with password value when it is allowed. - * Callback with no arguments otherwise. - * @param {function} fn - */ - @action - submit(fn) { - fn(`${this.password}`); - this.resetPassword(); - } - - /** - * Unset password value before callback. - * @param {function} fn - */ - @action - cancel(fn) { - fn(); - this.resetPassword(); - } + @tracked password; /** * @type {boolean} @@ -42,8 +21,36 @@ export default class FormAccountPasswordSetPasswordIndexComponent extends Compon return !(this.password?.length > 0); } + // =methods + + /** + * Unsets the password field. + */ resetPassword() { - set(this, 'password', ''); + this.password = null; + } + + // =actions + + /** + * Submit with password value when it is allowed. + * Callback with no arguments otherwise. + * @param {function} fn + */ + @action + submit(fn) { + fn(this.password); + this.resetPassword(); + } + + /** + * Unset password value before callback. + * @param {function} fn + */ + @action + cancel(fn) { + fn(); + this.resetPassword(); } }