numerus/web/template/products/index.gohtml

94 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

{{ define "title" -}}
{{( pgettext "Products" "title" )}}
{{- end }}
{{ define "breadcrumbs" -}}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
<nav data-hx-boost="true" data-hx-target="main">
<p>
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
<a>{{( pgettext "Products" "title" )}}</a>
</p>
<p>
{{ template "filters-toggle" }}
<a class="primary button"
href="{{ companyURI "/products/new" }}">{{( pgettext "New product" "action" )}}</a>
</p>
</nav>
{{- end }}
{{ define "content" }}
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
<form class="filters" method="GET" action="{{ companyURI "/products"}}"
data-hx-target="main"
data-hx-boost="true"
data-hx-trigger="change,search,submit"
aria-labelledby="filters-toggle"
>
<fieldset>
{{ with .Filters }}
{{ template "input-field" .Name }}
{{ 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 "/products" }}" class="button">{{( pgettext "Reset" "action" )}}</a>
{{ end }}
</form>
<table>
<thead>
<tr>
<th>{{( pgettext "Name" "title" )}}</th>
<th>{{( pgettext "Tags" "title" )}}</th>
<th>{{( pgettext "Price" "title" )}}</th>
<th>{{( pgettext "Actions" "title" )}}</th>
</tr>
</thead>
<tbody>
{{ with .Products }}
{{- range $product := . }}
<tr>
<td><a href="{{ companyURI "/products/"}}{{ .Slug }}" data-hx-target="main"
data-hx-boost="true">{{ .Name }}</a></td>
2023-05-09 10:18:31 +00:00
<td
data-hx-get="{{companyURI "/products/"}}{{ .Slug }}/tags/edit"
data-hx-target="this"
data-hx-swap="outerHTML"
>
{{- range $index, $tag := .Tags }}
{{- if gt $index 0 }}, {{ end -}}
2023-05-09 10:18:31 +00:00
{{ . }}
{{- end }}
</td>
<td class="numeric">{{ .Price | formatPrice }}</td>
<td class="actions">
<details class="menu">
{{- $label := .Name | printf (gettext "Actions for product %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 "/products"}}/{{ .Slug }}"
data-hx-target="main" data-hx-boost="true"
>
<i class="ri-edit-line"></i>
{{( pgettext "Edit" "action" )}}
</a>
</li>
</ul>
</details>
</td>
</tr>
{{- end }}
{{ else }}
<tr>
<td colspan="4">{{( gettext "No products added yet." )}}</td>
</tr>
{{ end }}
</tbody>
</table>
{{- end }}