60 lines
2.4 KiB
Cheetah
60 lines
2.4 KiB
Cheetah
{{ define "items:fields" }}
|
|
|
|
{{ range (index .FieldsSection .uisection) }}
|
|
{{ $field := .}}
|
|
{{ $values := (index $.FieldsValues .Type_field_id)}}
|
|
|
|
{{ if eq .Is_multiple 1}}
|
|
<fieldset>
|
|
<label>{{ .Title }}</label>
|
|
|
|
<div id="fields-{{ .Type_field_id }}">
|
|
{{ $g_counter := 0 }}
|
|
{{ range $counter, $value := $values}}
|
|
<input
|
|
type="hidden"
|
|
id="FieldsValuesToRemove-{{$field.Type_field_id}}-{{$counter}}"
|
|
name="FieldsValuesToRemove-{{$field.Type_field_id}}-{{$counter}}"
|
|
value="0"
|
|
/>
|
|
<div class="w3-row w3-section">
|
|
<div id="FieldsValues-{{$field.Type_field_id}}-{{$counter}}" class="w3-col s10 m11 l11" style="padding-right: 4px;">{{ field_widget $field.Widget $field.Type_field_id $counter "" $value $field.Valid_values ""}}</div>
|
|
<div class="w3-col w3-right-align s2 m1 l1">
|
|
<button
|
|
id="Delete-{{$field.Type_field_id}}-{{$counter}}"
|
|
class="w3-button w3-small w3-delete w3-border w3-round-large"
|
|
type="button"
|
|
_="on click set {value: '1'} on #FieldsValuesToRemove-{{$field.Type_field_id}}-{{$counter}} then hide me then show #Undelete-{{$field.Type_field_id}}-{{$counter}} then add .w3-opacity-max to #FieldsValues-{{$field.Type_field_id}}-{{$counter}}"
|
|
>
|
|
<i class="bi bi-dash-square" title="Remove"></i>
|
|
</button>
|
|
|
|
<button
|
|
id="Undelete-{{$field.Type_field_id}}-{{$counter}}"
|
|
style="margin-right: 5px; display: none"
|
|
class="w3-button w3-small w3-delete w3-border w3-round-large"
|
|
type="button"
|
|
_="on click set {value: ''} on #FieldsValuesToRemove-{{$field.Type_field_id}}-{{$counter}} then hide me then show #Delete-{{$field.Type_field_id}}-{{$counter}} then remove .w3-opacity-max from #FieldsValues-{{$field.Type_field_id}}-{{$counter}}">
|
|
<i class="bi bi-arrow-counterclockwise" title="Undo"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{{ $g_counter = $counter}}
|
|
{{ end }}
|
|
</div>
|
|
|
|
<span class="w3-hide" id="fields-{{.Type_field_id}}-counter">{{incr $g_counter }}</span>
|
|
<button type="button" onclick="bm_item_field_add('{{.Type_field_id}}', '{{.Widget}}')" class="w3-button w3-edit w3-border w3-round-large"><i class='bi bi-plus-square-fill'></i> <span class="w3-hide-small"> Add value</span></button>
|
|
</fieldset>
|
|
{{ else }}
|
|
<p>
|
|
{{ $value := ""}}
|
|
{{ if gt (len $values) 0 }}
|
|
{{ $value = index $values 0 }}
|
|
{{ end }}
|
|
{{ field_widget .Widget .Type_field_id 0 .Title $value .Valid_values ""}}
|
|
</p>
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ end }} |