2022-05-30 17:10:44 +00:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export default class SecureVariableFormComponent extends Component {
|
|
|
|
@service router;
|
|
|
|
|
|
|
|
@tracked
|
|
|
|
shouldHideValues = true;
|
|
|
|
|
|
|
|
get valueFieldType() {
|
|
|
|
return this.shouldHideValues ? 'password' : 'text';
|
|
|
|
}
|
|
|
|
|
|
|
|
get shouldDisableSave() {
|
|
|
|
return !this.args.model?.path;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
toggleShowHide() {
|
|
|
|
this.shouldHideValues = !this.shouldHideValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action appendRow() {
|
|
|
|
this.args.model.keyValues.pushObject({
|
|
|
|
key: '',
|
|
|
|
value: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@action deleteRow(row) {
|
|
|
|
this.args.model.keyValues.removeObject(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async save(e) {
|
|
|
|
e.preventDefault();
|
2022-06-07 01:42:23 +00:00
|
|
|
this.args.model.setAndTrimPath();
|
2022-05-30 17:10:44 +00:00
|
|
|
|
|
|
|
const transitionTarget = this.args.model.isNew
|
|
|
|
? 'variables'
|
|
|
|
: 'variables.variable';
|
|
|
|
|
|
|
|
await this.args.model.save();
|
|
|
|
this.router.transitionTo(transitionTarget);
|
|
|
|
}
|
|
|
|
}
|