<!-- 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/campsite/types.featureForm*/ -}} {{ if .ID}} {{( pgettext "Edit Campsite Type Feature" "title" )}} {{ else }} {{( pgettext "New Campsite Type Feature" "title" )}} {{ end }} {{- end }} {{ define "content" -}} {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite/types.featureForm*/ -}} <form {{ if .ID }} data-hx-put="/admin/campsites/types/{{ .TypeSlug }}/features/{{ .ID }}" {{ else }} action="/admin/campsites/types/{{ .TypeSlug }}/features" method="post" {{ end }} > <h2> {{ if .ID }} {{( pgettext "Edit Campsite Type Feature" "title" )}} {{ else }} {{( pgettext "New Campsite Type Feature" "title" )}} {{ end }} </h2> {{ CSRFInput }} <fieldset> {{ 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 -}} <label> {{( pgettext "Name" "input")}}<br> <input type="text" name="{{ .Name }}" value="{{ .Val }}" required {{ template "error-attrs" . }}><br> </label> {{ template "error-message" . }} {{- 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"; setupIconInput(document.querySelector('.icon-input')); </script> {{- end }}