2023-02-04 10:32:39 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{( pgettext "Products" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "breadcrumbs" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
|
2023-04-25 13:28:55 +00:00
|
|
|
<nav data-hx-boost="true" data-hx-target="main">
|
|
|
|
<p>
|
2023-02-04 10:32:39 +00:00
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a>{{( pgettext "Products" "title" )}}</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
2023-05-24 10:13:09 +00:00
|
|
|
{{ template "filters-toggle" }}
|
2023-02-04 10:32:39 +00:00
|
|
|
<a class="primary button"
|
|
|
|
href="{{ companyURI "/products/new" }}">{{( pgettext "New product" "action" )}}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
2023-03-20 12:09:52 +00:00
|
|
|
{{- end }}
|
2023-02-04 10:32:39 +00:00
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "content" }}
|
2023-02-04 10:32:39 +00:00
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
|
2023-05-24 10:13:09 +00:00
|
|
|
<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"
|
|
|
|
>
|
2023-07-16 18:56:11 +00:00
|
|
|
<fieldset>
|
|
|
|
{{ with .Filters }}
|
|
|
|
{{ template "input-field" .Name }}
|
|
|
|
{{ template "tags-field" .Tags | addTagsAttr (print `data-conditions="` .TagsCondition.Name `-field"`) }}
|
|
|
|
{{ template "toggle-field" .TagsCondition }}
|
|
|
|
{{ end }}
|
|
|
|
</fieldset>
|
2023-05-24 10:13:09 +00:00
|
|
|
<noscript>
|
|
|
|
<button type="submit">{{( pgettext "Filter" "action" )}}</button>
|
|
|
|
</noscript>
|
2023-07-16 18:56:11 +00:00
|
|
|
{{ if .Filters.HasValue }}
|
|
|
|
<a href="{{ companyURI "/products" }}" class="button">{{( pgettext "Reset" "action" )}}</a>
|
|
|
|
{{ end }}
|
2023-05-24 10:13:09 +00:00
|
|
|
</form>
|
2023-02-04 10:32:39 +00:00
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{( pgettext "Name" "title" )}}</th>
|
2023-03-26 11:51:57 +00:00
|
|
|
<th>{{( pgettext "Tags" "title" )}}</th>
|
2023-02-04 10:32:39 +00:00
|
|
|
<th>{{( pgettext "Price" "title" )}}</th>
|
2023-05-11 21:32:21 +00:00
|
|
|
<th>{{( pgettext "Actions" "title" )}}</th>
|
2023-02-04 10:32:39 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ with .Products }}
|
|
|
|
{{- range $product := . }}
|
|
|
|
<tr>
|
2023-05-23 12:34:46 +00:00
|
|
|
<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"
|
|
|
|
>
|
2023-03-26 11:51:57 +00:00
|
|
|
{{- range $index, $tag := .Tags }}
|
|
|
|
{{- if gt $index 0 }}, {{ end -}}
|
2023-05-09 10:18:31 +00:00
|
|
|
{{ . }}
|
2023-03-26 11:51:57 +00:00
|
|
|
{{- end }}
|
|
|
|
</td>
|
Add currency_pattern to language relation
The design calls for rendering all amounts with their currency symbol,
but golang.org/x/text’s currency package always render the symbol in
front, which is wrong in Catalan and Spanish, and a lot of other
languages.
Consulting the Internet, the most popular package for that is
accounting[0], which is almost as useless because they confuse locale
with the currency’s country of origin’s “usual locale” (e.g., en-US for
USD), which is also wrong: in Catalan i need to write USD prices as
"1.234,56 $" regardless of what Americans do.
With accounting i have the recourse of initializing the struct that
holds all the “locale” information, which is also wrong because i have
to define the decimal and thousands separators, something that depends
only on the locale, next to the currency’s precision, that is
locale-independent. But, since all CLDR data from golang.org/x/text
is inside an internal package, i can not access it and would need to
define all that information myself, which defeats the purpose of using
an external package.
Since for now i only need the format pattern for currency, i just saved
it into the database of available languages, that i do not expect to
grow too much.
[0]: https://github.com/leekchan/accounting
2023-02-23 11:12:33 +00:00
|
|
|
<td class="numeric">{{ .Price | formatPrice }}</td>
|
2023-05-11 21:32:21 +00:00
|
|
|
<td class="actions">
|
|
|
|
<details class="menu">
|
2023-07-06 09:49:36 +00:00
|
|
|
{{- $label := .Name | printf (gettext "Actions for product %s") -}}
|
|
|
|
<summary aria-label="{{ $label }}"><i class="ri-more-line"></i></summary>
|
2023-05-11 21:32:21 +00:00
|
|
|
<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>
|
2023-02-04 10:32:39 +00:00
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
{{ else }}
|
|
|
|
<tr>
|
2023-05-23 12:21:04 +00:00
|
|
|
<td colspan="4">{{( gettext "No products added yet." )}}</td>
|
2023-02-04 10:32:39 +00:00
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{{- end }}
|