camper/web/templates/admin/services/form.gohtml

83 lines
2.9 KiB
Plaintext
Raw Normal View History

<!--
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/service.serviceForm*/ -}}
{{ if .ID }}
{{( pgettext "Edit Service" "title" )}}
{{ else }}
{{( pgettext "New Service" "title" )}}
{{ end }}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/services.serviceForm*/ -}}
<form
{{ if .ID }}
data-hx-put="/admin/services/{{ .ID }}"
{{ else }}
action="/admin/services" method="post"
{{ end }}
>
<h2>
{{ if .ID }}
{{( pgettext "Edit Service" "title" )}}
{{ else }}
{{( pgettext "New Service" "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 }}
{{ with .Description -}}
<label>
{{( pgettext "Description" "input")}}<br>
<textarea class="html" name="{{ .Name }}" {{ template "error-attrs" . }}>{{ .Val }}</textarea><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 }}