2022-06-10 14:05:34 +00:00
<form
class="new-secure-variables"
{{ on "submit" this .save }}
autocomplete="off"
>
{{!-- TODO: {{if this.parseError 'is-danger'}} on inputs --}}
<div>
<label>
<span>Path</span>
<Input
@type="text"
@value= {{ @ model .path }}
placeholder="/path/to/variable"
class="input path-input {{ if this .duplicatePathWarning "error" }} "
disabled= {{ not @ model .isNew }}
{{ on "input" this .validatePath }}
{{ autofocus }}
/>
</label>
{{ # if this .duplicatePathWarning }}
<p class="duplicate-path-error help is-danger">
There is already a Secure Variable located at {{ @ model .path }} .
<br />
Please choose a different path, or <LinkTo @route="variables.variable.edit" @model= {{ this .duplicatePathWarning .path }} >edit the existing Secure Variable</LinkTo>.
</p>
{{ / if }}
</div>
2022-06-10 18:59:47 +00:00
{{ # each this .keyValues as | entry iter | }}
2022-06-10 14:05:34 +00:00
<div class="key-value">
2022-05-30 17:10:44 +00:00
2022-06-10 14:05:34 +00:00
<label>
<span>Key</span>
<Input
@type="text"
@value= {{ entry .key }}
class="input"
{{ autofocus ignore = ( eq iter 0 ) }}
2022-06-10 18:59:47 +00:00
{{ on "input" ( fn this .validateKey entry ) }}
2022-06-10 14:05:34 +00:00
/>
</label>
2022-05-30 17:10:44 +00:00
2022-06-10 14:05:34 +00:00
<label class="value-label">
<span>Value
</span>
<Input
@type= {{ this .valueFieldType }}
@value= {{ entry .value }}
class="input value-input"
autocomplete="new-password" {{!-- prevent auto-fill --}}
/>
<button
class="show-hide-values button is-light"
type="button"
tabindex="-1"
{{ on "click" this .toggleShowHide }}
>
<FlightIcon
@name= {{ if this .shouldHideValues "eye-off" "eye" }}
@title= {{ if this .shouldHideValues "Show Values" "Hide Values" }}
/>
</button>
</label>
2022-05-30 17:10:44 +00:00
2022-06-10 18:59:47 +00:00
{{ # if ( eq entry this .keyValues .lastObject ) }}
2022-06-10 14:05:34 +00:00
<button
{{ on "click" this .appendRow }}
class="add-more button is-info is-inverted"
type="button"
disabled= {{ not ( and entry .key entry .value ) }}
>Add More</button>
{{ else }}
2022-05-30 17:10:44 +00:00
<button
2022-06-10 14:05:34 +00:00
{{ on "click" ( action this .deleteRow entry ) }}
class="delete-row button is-danger is-inverted" type="button">Delete</button>
{{ / if }}
2022-06-10 18:59:47 +00:00
{{ # each - in entry .warnings as | k v | }}
<span class="key-value-error help is-danger"> {{ v }} </span>
{{ / each - in }}
2022-06-10 14:05:34 +00:00
</div>
{{ / each }}
2022-06-10 18:59:47 +00:00
2022-06-10 14:05:34 +00:00
<footer>
<button
disabled= {{ this .shouldDisableSave }}
2022-06-10 18:59:47 +00:00
class="button is-primary" type="submit">Save {{ pluralize 'Variable' @ this .keyValues .length }} </button>
2022-06-10 14:05:34 +00:00
</footer>
</form>