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

79 lines
2.8 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/campsite.campsiteForm*/ -}}
{{ if .Slug}}
{{( pgettext "Edit Campsite" "title" )}}
{{ else }}
{{( pgettext "New Campsite" "title" )}}
{{ end }}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite.campsiteForm*/ -}}
{{ template "settings-tabs" "campsites" }}
<form
{{ if .Slug }}
data-hx-put="/admin/campsites/{{ .Slug }}"
{{ else }}
action="/admin/campsites" method="post"
{{ end }}
>
<h2>
{{ if .Slug }}
{{( pgettext "Edit Campsite" "title" )}}
{{ else }}
{{( pgettext "New Campsite" "title" )}}
{{ end }}
</h2>
{{ CSRFInput }}
<fieldset>
{{ if .Slug }}
{{ with .Active -}}
<label>
<input type="checkbox" name="{{ .Name }}" {{ if .Checked}}checked{{ end }}
{{ template "error-attrs" . }}>
{{( pgettext "Active" "campsite" )}}<br>
</label>
{{ template "error-message" . }}
{{- end }}
{{ else }}
<input type="hidden" name="{{ .Active.Name }}" value="true">
{{ end }}
{{ with .CampsiteType -}}
<label>
{{( pgettext "Campsite Type" "input")}}<br>
<select name="{{ .Name }}"
required
{{ template "error-attrs" . }}>
{{ if not $.Slug }}
<option value="">{{( gettext "Select campsite type" )}}</option>
{{ end }}
{{ template "list-options" . }}
</select><br>
</label>
{{ template "error-message" . }}
{{- 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 }}
</fieldset>
<footer>
<button type="submit">
{{ if .Slug }}
{{( pgettext "Update" "action" )}}
{{ else }}
{{( pgettext "Add" "action" )}}
{{ end }}
</button>
</footer>
</form>
{{- end }}