Append an empty item when editing an existing Secure Variable (#13436)
* Did-insert modifier to add an extra row when editing * Defensive logic on model existing * Defensive pattern on copy keyValues
This commit is contained in:
parent
7de6301054
commit
7ddbd36443
|
@ -1,4 +1,6 @@
|
|||
<form class="new-secure-variables" autocomplete="off" {{on "submit" this.save}}>
|
||||
<form class="new-secure-variables" autocomplete="off" {{on "submit" this.save}}
|
||||
{{did-insert this.appendItemIfEditing}}
|
||||
>
|
||||
{{!-- TODO: {{if this.parseError 'is-danger'}} on inputs --}}
|
||||
<div>
|
||||
<label>
|
||||
|
|
|
@ -26,7 +26,7 @@ export default class SecureVariableFormComponent extends Component {
|
|||
return !this.args.model?.path;
|
||||
}
|
||||
|
||||
@tracked keyValues = copy(this.args.model?.keyValues)?.map((kv) => {
|
||||
@tracked keyValues = copy(this.args.model?.keyValues || [])?.map((kv) => {
|
||||
return {
|
||||
key: kv.key,
|
||||
value: kv.value,
|
||||
|
@ -109,4 +109,14 @@ export default class SecureVariableFormComponent extends Component {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a row to the end of the Items list if you're editing an existing variable.
|
||||
* This will allow it to auto-focus and make all other rows deletable
|
||||
*/
|
||||
@action appendItemIfEditing() {
|
||||
if (!this.args.model?.isNew) {
|
||||
this.appendRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue