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

98 lines
4.0 KiB
Plaintext

<!--
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 "breadcrumb" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite/types.optionForm*/ -}}
<li><a href="/admin/campsites">{{( pgettext "Campsites" "title" )}}</a></li>
<li><a href="/admin/campsites/types">{{( pgettext "Campsite Types" "title" )}}</a></li>
<li><a href="/admin/campsites/types/{{ .TypeSlug }}/options">{{( pgettext "Campsite Type Options" "title" )}}</a></li>
{{- 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 {{ template "init-lang" . }}>
{{ 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 }}