ui/app/components/form-key-value/template.hbs

70 lines
2.1 KiB
Handlebars

<div class="clearfix">
{{#if header}}
<label>{{header}}</label>
{{/if}}
</div>
{{#if ary.length}}
<table class="table fixed no-lines small mt-10">
<tr class="text-muted hidden-xs hidden-sm">
<th>{{t keyLabel}}{{#if editing}}{{field-required}}{{/if}}</th>
<th width="30">&nbsp;</th>
<th>{{t valueLabel}}</th>
<th width="30">&nbsp;</th>
</tr>
{{#each ary as |row|}}
<tr>
<td data-title="{{t keyLabel}}:">
{{#if editing}}
{{input-paste pasted="pastedLabels" class="form-control input-sm key" type="text" value=row.key placeholder=keyPlaceholder disabled=(eq row.editable false)}}
{{else}}
{{row.key}}
{{/if}}
</td>
<td class="valign-top text-center">
{{#if editing}}
{{t 'formKeyValue.separator'}}
{{/if}}
</td>
<td data-title="{{t valueLabel}}:">
{{#if editing}}
{{#if allowMultilineValue}}
{{textarea-autogrow class="form-control input-sm value" value=row.value placeholder=valuePlaceholder disabled=(eq row.editable false)}}
{{else}}
{{input class="form-control input-sm value" type="text" value=row.value placeholder=valuePlaceholder disabled=(eq row.editable false)}}
{{/if}}
{{else}}
{{row.value}}
{{/if}}
</td>
<td class="valign-top text-right">
{{#if editing}}
<button class="btn bg-primary btn-sm" {{action "remove" row}}><i class="icon icon-minus"/><span class="sr-only">{{t 'generic.remove'}}</span></button>
{{/if}}
</td>
</tr>
{{/each}}
</table>
{{else}}
{{#unless editing}}
<div>{{t 'generic.none'}}</div>
{{/unless}}
{{/if}}
{{#if editing}}
<div class="pt-10">
<button class="btn bg-link icon-btn p-0" {{action "add"}}>
<i class="icon icon-plus text-small"/>
<span>{{t addActionLabel}}</span>
</button>
{{#if ary.length}}
<div class="help-block">
{{t 'formKeyValue.protip'}}
</div>
{{/if}}
</div>
{{/if}}