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

91 lines
3.6 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 x-data="{ lang: '{{ .DefaultLang }}' }">
{{ with .Name -}}
<fieldset>
<legend>{{( pgettext "Name" "input")}}</legend>
{{ template "lang-selector" . }}
{{ range $lang, $input := . -}}
<label x-cloak x-show="lang === '{{ $lang }}'"><span>{{ $lang }}</span><br>
<input type="text" name="{{ $input.Name }}" value="{{ $input.Val }}"
{{ template "error-attrs" . }}><br>
</label>
{{- end}}
{{ template "error-message" . }}
</fieldset>
{{- 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 }}