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-02-04 10:32:39 +00:00
|
|
|
<nav>
|
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a>{{( pgettext "Products" "title" )}}</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<a class="primary button"
|
2023-03-27 07:44:04 +00:00
|
|
|
data-hx-push-url="false" data-hx-swap="beforeend" data-hx-boost="true"
|
2023-02-04 10:32:39 +00:00
|
|
|
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*/ -}}
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{( pgettext "All" "product" )}}</th>
|
|
|
|
<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>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ with .Products }}
|
|
|
|
{{- range $product := . }}
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
2023-03-27 07:44:04 +00:00
|
|
|
<td><a href="{{ companyURI "/products/"}}{{ .Slug }}" data-hx-push-url="false" data-hx-swap="beforeend" data-hx-boost="true">{{ .Name }}</a></td>
|
2023-03-26 11:51:57 +00:00
|
|
|
<td>
|
|
|
|
{{- range $index, $tag := .Tags }}
|
|
|
|
{{- if gt $index 0 }}, {{ end -}}
|
2023-03-27 07:44:04 +00:00
|
|
|
<a href="?tag={{ . }}" data-hx-target="main" data-hx-boost="true">{{ . }}</a>
|
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-02-04 10:32:39 +00:00
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
{{ else }}
|
|
|
|
<tr>
|
|
|
|
<td colspan="4">{{( gettext "No products added yet." )}}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{{- end }}
|