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

60 lines
1.9 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/booking.adminBookingForm*/ -}}
{{ if .ID }}
{{( pgettext "Edit Booking" "title" )}}
{{ else }}
{{( pgettext "New Booking" "title" )}}
{{ end }}
{{- end }}
{{ define "head" -}}
<script src="/static/idiomorph-ext@0.3.0.min.js"></script>
{{- end }}
{{ define "breadcrumb" -}}
{{ if eq .Status "created" -}}
<li><a href="/admin/prebookings">{{( pgettext "Prebookings" "title" )}}</a></li>
{{- else -}}
<li><a href="./">{{( pgettext "Bookings" "title" )}}</a></li>
{{- end }}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.adminBookingForm*/ -}}
{{ if .ID -}}
{{ if ne .Status "created" -}}
<a href="{{ .URL }}/check-in">{{( pgettext "Check-in Booking" "action" )}}</a>
<a href="/admin/invoices/new?booking={{ .ID }}">{{( pgettext "Invoice Booking" "action" )}}</a>
{{- end }}
{{- end }}
<h2>{{ template "title" .}}</h2>
<form id="booking-form"
data-hx-ext="morph"
data-hx-swap="morph:innerHTML"
data-hx-include="this"
data-hx-target="#booking-form-fields"
data-hx-replace-url="true"
{{- if .ID }} data-hx-put="{{ .URL }}"
{{- else }} action="/admin/bookings" method="post"
{{- end -}}
>
{{ CSRFInput }}
<fieldset id="booking-form-fields">
{{ template "fields.gohtml" . }}
</fieldset>
<footer>
<button type="submit">
{{- if .ID -}}
{{( pgettext "Update" "action" )}}
{{- else -}}
{{( pgettext "Add" "action" )}}
{{- end -}}
</button>
</footer>
</form>
{{- end }}