1d26f056bc
* Updated code mirror component for consistency - Hide gutters, line number and selection while read only - Show toolbar with copy functionality for all instances * Moved toolbar and actions to json editor component * Updated form-field-from-model template * Added test for toolbar
84 lines
2.8 KiB
Handlebars
84 lines
2.8 KiB
Handlebars
<div class="field">
|
|
{{#unless
|
|
(or
|
|
(contains
|
|
attr.options.editType
|
|
(array
|
|
"boolean"
|
|
"searchSelect"
|
|
"mountAccessor"
|
|
"kv"
|
|
"file"
|
|
"ttl"
|
|
"stringArray"
|
|
"json"
|
|
)
|
|
)
|
|
(eq attr.type "boolean")
|
|
)
|
|
}}
|
|
{{#unless (eq attr.type "object")}}
|
|
<label for="{{attr.name}}" class="is-label">
|
|
{{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
|
|
{{#if attr.options.helpText}}
|
|
<InfoTooltip>{{attr.options.helpText}}</InfoTooltip>
|
|
{{/if}}
|
|
</label>
|
|
{{/unless}}
|
|
{{/unless}}
|
|
{{#if attr.options.possibleValues}}
|
|
<div class="control is-expanded">
|
|
<div class="select is-fullwidth">
|
|
<select
|
|
name="{{attr.name}}"
|
|
id="{{attr.name}}"
|
|
onchange={{action (mut (get model attr.name)) value="target.value"}}
|
|
data-test-input={{attr.name}}
|
|
>
|
|
{{#each attr.options.possibleValues as |val|}}
|
|
<option selected={{eq (get model attr.name) val}} value={{val}}>
|
|
{{val}}
|
|
</option>
|
|
{{/each}}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
{{else if (eq attr.options.editType "ttl")}}
|
|
<TtlPicker2
|
|
@initialValue={{or (get model attr.name) attr.options.defaultValue}}
|
|
@initialEnabled={{or (get model attr.name) false}}
|
|
@label={{or attr.options.label (humanize (dasherize attr.name))}}
|
|
@helperTextDisabled="If this is not set, the engine default will be used."
|
|
@helperTextEnabled="Disable lease after"
|
|
@onChange={{action "updateTtl" attr.name}}
|
|
/>
|
|
{{else if (or (eq attr.type "number") (eq attr.type "string"))}}
|
|
<div class="control">
|
|
<Input @id={{attr.name}} @value={{get model (or attr.options.fieldValue attr.name)}} class="input" data-test-input={{attr.name}} />
|
|
</div>
|
|
{{else if (eq attr.type "boolean")}}
|
|
<div class="b-checkbox">
|
|
<input
|
|
type="checkbox"
|
|
id="{{attr.name}}"
|
|
class="styled"
|
|
checked={{get model attr.name}}
|
|
onchange={{action (mut (get model attr.name)) value="target.checked"}}
|
|
data-test-input={{attr.name}}
|
|
/>
|
|
|
|
<label for="{{attr.name}}" class="is-label">
|
|
{{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
|
|
{{#if attr.options.helpText}}
|
|
<InfoTooltip>{{attr.options.helpText}}</InfoTooltip>
|
|
{{/if}}
|
|
</label>
|
|
</div>
|
|
{{else if (eq attr.type "object")}}
|
|
<JsonEditor
|
|
@title={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}}
|
|
@helpText={{attr.options.helpText}}
|
|
@value={{if (get model attr.name) (stringify (get model attr.name)) emptyData}}
|
|
@valueUpdated={{action "codemirrorUpdated" attr.name}} />
|
|
{{/if}}
|
|
</div> |