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

99 lines
3.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" -}}
{{( pgettext "Campsites" "title" )}}
{{- end }}
{{ define "breadcrumb" -}}
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite.campsiteIndex*/ -}}
{{ if isAdmin -}}
<a href="/admin/campsites/new">{{( pgettext "Add Campsite" "action" )}}</a>
{{- end }}
<h2>{{( pgettext "Campsites" "title" )}}</h2>
{{ if .Campsites -}}
<div id="campsites-booking">
<table>
<colgroup></colgroup>
{{ range .Months }}
<colgroup>
{{ range .Spans }}
<col span="{{ .Count }}" class="{{ if .Weekend }}weekend{{ else }}weekday{{ end }}">
{{- end }}
</colgroup>
{{- end }}
<thead>
<tr>
<th scope="col" rowspan="2">{{( pgettext "Label" "header" )}}</th>
{{ range .Months }}
<th scope="col" colspan="{{ len .Days }}">{{ pgettext .Name "month" }} {{ .Year }}</th>
{{- end }}
</tr>
<tr>
{{ range .Months }}
{{ range .Days }}
<th scope="col">{{ .Day }}</th>
{{- end }}
{{- end }}
</tr>
</thead>
<tbody>
{{ range $campsite := .Campsites -}}
<tr>
<th scope="row">
{{- if isAdmin -}}
<a href="/admin/campsites/{{ .Label }}">{{ .Label }}</a>
{{- else -}}
{{ .Label }}
{{- end -}}
</th>
{{ range $.Months }}
{{ range $day := .Days }}
{{ with index $campsite.Bookings $day -}}
<td class="booking-{{ .Status }}">
<div class="booking-status"
style="--booking-nights: {{ .Nights }}; --booking-begin: {{ if .Begin }}1{{ else }}0{{ end }}; --booking-end: {{ if .End }}1{{ else }}0{{ end }}"
title="{{ .Holder }}"
>{{ .Holder }}</div>
</td>
{{- else -}}
<td></td>
{{- end }}
{{- end }}
{{- end }}
</tr>
{{- end }}
</tbody>
</table>
</div>
<form id="booking-filter">
<fieldset>
{{ with .From -}}
<fieldset>
<legend>{{( gettext "From Date" )}}</legend>
{{ template "month-input" . }}
{{ template "error-message" . }}
</fieldset>
{{- end }}
{{ with .To -}}
<fieldset>
<legend>{{( gettext "To Date" )}}</legend>
{{ template "month-input" . }}
{{ template "error-message" . }}
</fieldset>
{{- end }}
</fieldset>
<footer>
<button type="submit">{{( pgettext "Show" "action" )}}</button>
</footer>
</form>
{{ else -}}
<p>{{( gettext "No campsites added yet." )}}</p>
{{- end }}
{{- end }}