numerus/web/template/quotes/index.gohtml

166 lines
8.1 KiB
Plaintext
Raw Normal View History

{{ define "title" -}}
{{( pgettext "Quotations" "title" )}}
{{- end }}
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.QuotesIndexPage*/ -}}
<nav data-hx-target="main">
<p data-hx-boost="true">
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Quotations" "title" )}}</a>
</p>
<form id="batch-form" action="{{ companyURI "/quotes/batch" }}" method="post">
{{ csrfToken }}
<p>
{{ template "filters-toggle" }}
<button type="submit"
name="action" value="download"
>{{( pgettext "Download quotations" "action" )}}</button>
<a class="primary button" data-hx-boost="true"
href="{{ companyURI "/quotes/new" }}">{{( pgettext "New quotation" "action" )}}</a>
</p>
</form>
</nav>
{{- end }}
{{ define "content" }}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.QuotesIndexPage*/ -}}
<form class="filters" method="GET" action="{{ companyURI "/quotes"}}"
data-hx-target="main" data-hx-boost="true" data-hx-trigger="change,search,submit"
aria-labelledby="filters-toggle"
>
<fieldset>
{{ with .Filters }}
{{ template "select-field" .Customer }}
{{ template "select-field" .QuoteStatus }}
{{ template "input-field" .FromDate }}
{{ template "input-field" .ToDate }}
{{ template "input-field" .QuoteNumber }}
{{ template "tags-field" .Tags | addTagsAttr (print `data-conditions="` .TagsCondition.Name `-field"`) }}
{{ template "toggle-field" .TagsCondition }}
{{ end }}
</fieldset>
<noscript>
<button type="submit">{{( pgettext "Filter" "action" )}}</button>
</noscript>
{{ if .Filters.HasValue }}
<a href="{{ companyURI "/quotes" }}" class="button">{{( pgettext "Reset" "action" )}}</a>
{{ end }}
</form>
<table id="quote-list">
<thead>
<tr>
<th>{{( pgettext "All" "quote" )}}</th>
<th>{{( pgettext "Date" "title" )}}</th>
<th>{{( pgettext "Quotation Num." "title" )}}</th>
<th>{{( pgettext "Customer" "title" )}}</th>
<th>{{( pgettext "Status" "title" )}}</th>
<th>{{( pgettext "Tags" "title" )}}</th>
<th>{{( pgettext "Amount" "title" )}}</th>
<th>{{( pgettext "Download" "title" )}}</th>
<th>{{( pgettext "Actions" "title" )}}</th>
</tr>
</thead>
<tbody>
{{ with .Quotes }}
{{- range $quote := . }}
<tr>
{{ $title := .Number | printf (pgettext "Select quotation %v" "action") }}
<td><input type="checkbox" form="batch-form"
name="quote" value="{{ .Slug }}"
aria-label="{{ $title }}"
title="{{ $title }}"/></td>
<td>{{ .Date|formatDate }}</td>
<td><a href="{{ companyURI "/quotes/"}}{{ .Slug }}" data-hx-target="main"
data-hx-boost="true">{{ .Number }}</a></td>
<td>{{ .CustomerName }}</td>
<td>
<details class="quote-status menu">
<summary class="quote-status-{{ .Status }}">{{ .StatusLabel }}</summary>
<form action="{{companyURI "/quotes/"}}{{ .Slug }}" method="POST" data-hx-boost="true">
{{ csrfToken }}
{{ putMethod }}
<input type="hidden" name="quick" value="status">
<ul role="menu">
{{- range $status, $name := $.QuoteStatuses }}
{{- if ne $status $quote.Status }}
<li role="presentation">
<button role="menuitem" type="submit"
name="quote_status" value="{{ $status }}"
class="quote-status-{{ $status }}"
>{{ $name }}</button>
</li>
{{- end }}
{{- end }}
</ul>
</form>
</details>
</td>
<td data-hx-get="{{companyURI "/quotes/"}}{{ .Slug }}/tags/edit"
data-hx-target="this"
data-hx-swap="outerHTML"
>
{{- range $index, $tag := .Tags }}
{{- if gt $index 0 }}, {{ end -}}
{{ . }}
{{- end }}
</td>
<td class="numeric">{{ .Total|formatPrice }}</td>
<td class="quote-download"><a href="{{ companyURI "/quotes/"}}{{ .Slug }}.pdf"
download="{{ .Number}}.pdf"
title="{{( pgettext "Download quotation" "action" )}}"
aria-label="{{( pgettext "Download quotation" "action" )}}"><i
class="ri-download-line"></i></a></td>
<td class="actions">
<details class="menu">
{{- $label := .Number | printf (gettext "Actions for quote %s") -}}
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
<ul role="menu" class="action-menu">
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/quotes"}}/{{ .Slug }}/edit"
data-hx-target="main" data-hx-boost="true"
>
<i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}}
</a>
</li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/quotes/new"}}?duplicate={{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<i class="ri-file-copy-line"></i>
{{( pgettext "Duplicate" "action" )}}
</a>
</li>
<li role="presentation">
<a role="menuitem" href="{{ companyURI "/invoices/new"}}?quote={{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<i class="ri-bill-line"></i>
{{( pgettext "Create invoice" "action" )}}
</a>
</li>
</ul>
</details>
</td>
</tr>
{{- end }}
{{ else }}
<tr>
<td colspan="9">{{( gettext "No quotations added yet." )}}</td>
</tr>
{{ end }}
</tbody>
{{ if .Quotes }}
<tfoot>
<tr>
<th scope="row" colspan="6">{{( gettext "Total" )}}</th>
<td class="numeric">{{ .TotalAmount|formatPrice }}</td>
<td colspan="2"></td>
</tr>
</tfoot>
{{ end }}
</table>
{{- end }}