camper/web/templates/admin/amenity/feature/form.gohtml

79 lines
3.1 KiB
Plaintext

<!--
SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/amenity/types.featureForm*/ -}}
{{- if .ID -}}
{{( pgettext "Edit Amenity Feature" "title" )}}
{{- else -}}
{{( pgettext "New Amenity Feature" "title" )}}
{{- end -}}
{{- end }}
{{ define "breadcrumb" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/amenity.featureForm*/ -}}
<li><a href="/admin/amenities">{{( pgettext "Amenities" "title" )}}</a></li>
<li><a href="/admin/amenities/{{ .Label }}/features">{{( pgettext "Amenity Features" "title" )}}</a></li>
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/amenity.featureForm*/ -}}
<form
{{- if .ID }} data-hx-put="/admin/amenities/{{ .Label }}/features/{{ .ID }}"
{{- else }} action="/admin/amenities/{{ .Label }}/features" method="post"
{{- end -}}
>
<h2>{{ template "title" . }}</h2>
{{ CSRFInput }}
<fieldset {{ template "init-lang" . }}>
{{ with $field := .Icon -}}
<fieldset class="icon-input">
<legend>{{( pgettext "Icon" "input")}}</legend>
<input type="hidden" name="{{ .Name }}"
{{- range .Options }}
{{ if $field.IsSelected .Value }} value="{{ .Value }}"{{ end }}
{{- end }}
>
<ul>
{{- range .Options }}
<li>
<button type="button" data-icon-name="{{ .Value }}" class="icon_{{ .Value }}"></button>
</li>
{{- end }}
</ul>
{{ template "error-message" . }}
</fieldset>
{{- end }}
{{ with .Name -}}
<fieldset>
<legend>{{( pgettext "Name" "input")}}</legend>
{{ template "lang-selector" . }}
{{ range $lang, $input := . -}}
<label x-cloak x-show="lang === '{{ $lang }}'"><span>{{ $lang }}</span><br>
<input type="text" name="{{ $input.Name }}" value="{{ $input.Val }}"
{{ template "error-attrs" . }}><br>
</label>
{{- end }}
{{ template "error-message" . }}
</fieldset>
{{- end }}
</fieldset>
<footer>
<button type="submit">
{{- if .ID -}}
{{( pgettext "Update" "action" )}}
{{- else -}}
{{( pgettext "Add" "action" )}}
{{- end -}}
</button>
</footer>
</form>
<script type="module">
import {setupIconInput} from "/static/camper.js?v={{ camperVersion }}";
setupIconInput(document.querySelector('.icon-input'));
</script>
{{- end }}