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

86 lines
3.3 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/types.optionForm*/ -}}
{{ if .ID}}
{{( pgettext "Edit Campsite Type Option" "title" )}}
{{ else }}
{{( pgettext "New Campsite Type Option" "title" )}}
{{ end }}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite/types.optionForm*/ -}}
<form
{{ if .ID }}
data-hx-put="/admin/campsites/types/{{ .TypeSlug }}/options/{{ .ID }}"
{{ else }}
action="/admin/campsites/types/{{ .TypeSlug }}/options" method="post"
{{ end }}
>
<h2>
{{ if .ID }}
{{( pgettext "Edit Campsite Type Option" "title" )}}
{{ else }}
{{( pgettext "New Campsite Type Option" "title" )}}
{{ end }}
</h2>
{{ CSRFInput }}
<fieldset>
{{ 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 .Min -}}
<label>
{{( pgettext "Minimum" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="0"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Max -}}
<label>
{{( pgettext "Maximum" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="0"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Prices }}
<fieldset>
<legend>{{( pgettext "Prices" "title" )}}</legend>
{{ range . }}
<fieldset>
<legend>{{ .SeasonName }}</legend>
{{ with .PricePerNight -}}
<label>
{{( pgettext "Price per night" "input")}}<br>
<input type="number" name="{{ .Name }}" value="{{ .Val }}" min="0" step="0.01"
required {{ template "error-attrs" . }}><br>
{{ template "error-message" . }}
</label>
{{- end }}
</fieldset>
{{- end }}
</fieldset>
{{- end }}
</fieldset>
<footer>
<button type="submit">
{{ if .ID }}
{{( pgettext "Update" "action" )}}
{{ else }}
{{( pgettext "Add" "action" )}}
{{ end }}
</button>
</footer>
</form>
{{- end }}