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

161 lines
6.0 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/customer.customerForm*/ -}}
{{ if .Slug }}
{{( pgettext "Edit Customer" "title" )}}
{{ else }}
{{( pgettext "New Customer" "title" )}}
{{ end }}
{{- end }}
{{ define "breadcrumb" -}}
<li><a href="./">{{( pgettext "Customer" "title" )}}</a></li>
{{- end }}
{{ define "content" -}}
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/customer.customerForm*/ -}}
<h2>{{ template "title" .}}</h2>
<form id="contact-form"
{{- if .URL }} data-hx-put="{{ .URL }}"
{{- else }} action="/admin/customers" method="post"
{{- end -}}
>
{{ CSRFInput }}
<fieldset class="customer-details">
<legend>{{( pgettext "Customer Details" "title" )}}</legend>
{{ with .FullName -}}
<label>
{{( pgettext "Full name" "input" )}}<br>
<input type="text"
required
minlength="2"
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .IDDocumentNumber -}}
<label>
{{( pgettext "ID document number" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .IDDocumentType -}}
<label>
{{( pgettext "ID document type" "input" )}}<br>
<select name="{{ .Name }}"
required
{{ template "error-attrs" . }}
>
<option value="">{{( gettext "Choose an ID document type" )}}</option>
{{ template "list-options" . }}
</select><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Address -}}
<label class="colspan">
{{( pgettext "Address" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .City -}}
<label>
{{( pgettext "Town or village" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Province -}}
<label>
{{( pgettext "Province" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .PostalCode -}}
<label>
{{( pgettext "Postcode" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Country -}}
<label>
{{( pgettext "Country" "input" )}}<br>
<select name="{{ .Name }}"
{{ template "error-attrs" . }}
>
<option value="">{{( gettext "Choose a country" )}}</option>
{{ template "list-options" . }}
</select><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Email -}}
<label>
{{( pgettext "Email (optional)" "input" )}}<br>
<input type="email"
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Phone -}}
<label>
{{( pgettext "Phone (optional)" "input" )}}<br>
<input type="tel"
name="{{ .Name }}"
value="{{ .Val }}"
{{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
</fieldset>
<footer>
<button type="submit">
{{- if .Slug -}}
{{( pgettext "Update" "action" )}}
{{- else -}}
{{( pgettext "Add" "action" )}}
{{- end -}}
</button>
</footer>
</form>
{{- end }}