chore: 🤖 cleanu

This commit is contained in:
Randall Morey committed 2020-09-16 12:01:54 -04:00
1 parent 88c95d014f
commit 2e3b044ae9
3 files changed
+38 -28

No files matched your search

@@ -87,4 +87,5 @@
@disabled={{if @model.cannotSave @model.cannotSave}}
@submitText={{t "actions.save"}}
@cancelText={{t "actions.cancel"}} />
</Rose::Form>
</Rose::Form>
@@ -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;
}
}
@@ -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();
}
}