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

99 lines
4.0 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/amenity.amenityForm*/ -}}
{{ if .ID }}
{{( pgettext "Edit Amenity" "title" )}}
{{ else }}
{{( pgettext "New Amenity" "title" )}}
{{ end }}
{{- end }}
{{ define "breadcrumb" -}}
<li><a href="./">{{( pgettext "Amenities" "title" )}}</a></li>
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/amenity.amenityForm*/ -}}
<form
{{- if .ID }} data-hx-put="/admin/amenities/{{ .CurrentLabel }}"
{{- else }} action="/admin/amenities" method="post"
{{- end -}}
>
<h2>{{ template "title" .}}</h2>
{{ CSRFInput }}
<fieldset {{ template "init-lang" . }}>
{{ if .ID }}
{{ with .Active -}}
<label>
<input type="checkbox" name="{{ .Name }}" {{ if .Checked}}checked{{ end }}
{{ template "error-attrs" . }}>
{{( pgettext "Active" "amenity" )}}<br>
</label>
{{ template "error-message" . }}
{{- end }}
{{ else }}
<input type="hidden" name="{{ .Active.Name }}" value="true">
{{ end }}
{{ with .Label -}}
<label>
{{( pgettext "Label" "input")}}<br>
<input type="text" name="{{ .Name }}" value="{{ .Val }}"
required {{ template "error-attrs" . }}><br>
</label>
{{ template "error-message" . }}
{{- end }}
{{ with .Name -}}
<fieldset>
<legend>{{( pgettext "Name" "input")}}<br></legend>
{{ template "lang-selector" . }}
{{ range $lang, $input := . -}}
<label x-cloak x-show="lang === '{{ $lang }}'"><span>{{ $lang }}</span><br>
<input name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}><br>
</label>
{{- end }}
{{ template "error-message" . }}
</fieldset>
{{ template "error-message" . }}
{{- end }}
{{ with .Info1 -}}
<fieldset>
<legend>{{( pgettext "Info (First Column)" "input")}}<br></legend>
{{ template "lang-selector" . }}
{{ range $lang, $input := . -}}
<label x-cloak x-show="lang === '{{ $lang }}'"><span>{{ $lang }}</span><br>
<textarea class="html"
name="{{ .Name }}" {{ template "error-attrs" . }}>{{ .Val }}</textarea><br>
</label>
{{- end }}
{{ template "error-message" . }}
</fieldset>
{{- end }}
{{ with .Info2 -}}
<fieldset>
<legend>{{( pgettext "Info (Second Column)" "input")}}<br></legend>
{{ template "lang-selector" . }}
{{ range $lang, $input := . -}}
<label x-cloak x-show="lang === '{{ $lang }}'"><span>{{ $lang }}</span><br>
<textarea class="html"
name="{{ .Name }}" {{ template "error-attrs" . }}>{{ .Val }}</textarea><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>
{{- end }}