2023-03-13 14:00:35 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{ printf ( pgettext "Edit Invoice “%s”" "title" ) .Number }}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "breadcrumbs" -}}
|
2023-03-13 14:00:35 +00:00
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editInvoicePage*/ -}}
|
2023-04-02 14:10:13 +00:00
|
|
|
<nav data-hx-target="main" data-hx-boost="true">
|
2023-03-13 14:00:35 +00:00
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a href="{{ companyURI "/invoices"}}">{{( pgettext "Invoices" "title" )}}</a> /
|
|
|
|
<a>{{ .Number }}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
2023-03-20 12:09:52 +00:00
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ define "content" }}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.editInvoicePage*/ -}}
|
2023-05-23 21:13:21 +00:00
|
|
|
<section id="invoice-dialog-content" data-hx-target="main">
|
2023-03-13 14:00:35 +00:00
|
|
|
<h2>{{ printf (pgettext "Edit Invoice “%s”" "title") .Number }}</h2>
|
2023-07-12 18:06:53 +00:00
|
|
|
<form enctype="multipart/form-data" method="POST" action="{{ companyURI "/invoices/" }}{{ .Slug }}/edit"
|
Remove scroll after update quote or invoice form
By default, when using hx-boost, HTMx adds the `show:top` modifier to
`hx-swap`. This is actually the wanted behaviour in these cases,
because it means that you are following a link to a “different” page,
and it makes sense to start from the top.
However, for quote and invoice forms is a hindrance because you are
usually editing the bottom-most product, as new lines are appended,
therefore you are all the time having to scroll down to the line.
Every. Single. Time.
Here i reverted the show:top to just show:false to keep the scroll as
is. I also added the show:bottom to the new product button, because
that way the window show entirely the new line.
I could not use `show:window:bottom`, however, despite appearing in the
documentation, because that, somehow, ended up doing the same as
`show:window:top`. Not sure if a bug or something i did not understand.
Closes #58.
2023-07-04 17:55:58 +00:00
|
|
|
data-hx-boost="true"
|
|
|
|
data-hx-swap="innerHTML show:false"
|
|
|
|
>
|
2023-03-13 14:00:35 +00:00
|
|
|
{{ csrfToken }}
|
|
|
|
|
|
|
|
{{ with .Form -}}
|
2023-05-28 22:01:11 +00:00
|
|
|
{{ if .RemovedProduct -}}
|
|
|
|
<div role="alert">
|
|
|
|
{{ with .RemovedProduct -}}
|
|
|
|
<p>{{printf (gettext "Product “%s” removed") .Name}}</p>
|
|
|
|
<button type="submit"
|
|
|
|
formnovalidate
|
|
|
|
name="action" value="restore-product"
|
|
|
|
>{{( pgettext "Undo" "action" )}}</button>
|
|
|
|
{{ template "hidden-field" .InvoiceProductId }}
|
|
|
|
{{ template "hidden-field" .ProductId }}
|
|
|
|
{{ template "hidden-field" .Name }}
|
|
|
|
{{ template "hidden-field" .Price }}
|
|
|
|
{{ template "hidden-field" .Quantity }}
|
|
|
|
{{ template "hidden-field" .Discount }}
|
|
|
|
{{ template "hidden-field" .Description }}
|
|
|
|
{{ template "hidden-select-field" .Tax }}
|
|
|
|
{{- end }}
|
|
|
|
</div>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
<div class="invoice-data">
|
|
|
|
{{ template "select-field" .Customer }}
|
|
|
|
{{ template "hidden-field" .Date }}
|
|
|
|
{{ template "tags-field" .Tags }}
|
|
|
|
{{ template "select-field" .PaymentMethod }}
|
|
|
|
{{ template "select-field" .InvoiceStatus }}
|
2023-07-12 18:06:53 +00:00
|
|
|
{{ template "file-field" .File }}
|
2023-05-28 22:01:11 +00:00
|
|
|
{{ template "input-field" .Notes }}
|
|
|
|
</div>
|
2023-03-13 14:00:35 +00:00
|
|
|
|
|
|
|
{{- range $product := .Products }}
|
2023-04-24 00:00:38 +00:00
|
|
|
{{ template "invoice-product-form" . }}
|
2023-03-13 14:00:35 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-04-24 00:00:38 +00:00
|
|
|
<table id="invoice-summary">
|
2023-03-13 14:00:35 +00:00
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{(pgettext "Subtotal" "title")}}</th>
|
|
|
|
<td class="numeric">{{ .Subtotal | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- range $tax := .Taxes }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{ index . 0 }}</th>
|
|
|
|
<td class="numeric">{{ index . 1 | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
<tr>
|
|
|
|
<th scope="row">{{(pgettext "Total" "title")}}</th>
|
|
|
|
<td class="numeric">{{ .Total | formatPrice }}</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2023-05-23 21:13:21 +00:00
|
|
|
<fieldset class="button-bar">
|
2023-05-28 22:01:11 +00:00
|
|
|
<button formnovalidate
|
2023-03-13 14:00:35 +00:00
|
|
|
name="action" value="select-products"
|
2023-04-24 00:00:38 +00:00
|
|
|
data-hx-get="{{ companyURI "/invoices/product-form" }}"
|
Remove scroll after update quote or invoice form
By default, when using hx-boost, HTMx adds the `show:top` modifier to
`hx-swap`. This is actually the wanted behaviour in these cases,
because it means that you are following a link to a “different” page,
and it makes sense to start from the top.
However, for quote and invoice forms is a hindrance because you are
usually editing the bottom-most product, as new lines are appended,
therefore you are all the time having to scroll down to the line.
Every. Single. Time.
Here i reverted the show:top to just show:false to keep the scroll as
is. I also added the show:bottom to the new product button, because
that way the window show entirely the new line.
I could not use `show:window:bottom`, however, despite appearing in the
documentation, because that, somehow, ended up doing the same as
`show:window:top`. Not sure if a bug or something i did not understand.
Closes #58.
2023-07-04 17:55:58 +00:00
|
|
|
data-hx-target="#invoice-summary"
|
|
|
|
data-hx-swap="beforebegin show:bottom"
|
2023-04-24 00:00:38 +00:00
|
|
|
data-hx-select="unset"
|
|
|
|
data-hx-vals="js:{index: document.querySelectorAll('.new-invoice-product').length}"
|
2023-03-13 14:00:35 +00:00
|
|
|
type="submit">{{( pgettext "Add products" "action" )}}</button>
|
2023-05-28 22:01:11 +00:00
|
|
|
<button formnovalidate
|
2023-04-24 00:00:38 +00:00
|
|
|
id="recompute-button"
|
2023-03-13 14:00:35 +00:00
|
|
|
name="action" value="update"
|
|
|
|
type="submit">{{( pgettext "Update" "action" )}}</button>
|
|
|
|
<button class="primary" name="_method" value="PUT"
|
2023-05-28 22:01:11 +00:00
|
|
|
formaction="{{ companyURI "/invoices" }}/{{ .Slug }}"
|
2023-05-23 12:18:26 +00:00
|
|
|
type="submit">{{( pgettext "Save" "action" )}}</button>
|
2023-03-13 14:00:35 +00:00
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
</section>
|
2023-05-23 21:13:21 +00:00
|
|
|
|
2023-04-24 00:00:38 +00:00
|
|
|
<script>
|
|
|
|
document.body.addEventListener('recompute', function () {
|
|
|
|
document.getElementById('recompute-button').click();
|
|
|
|
});
|
|
|
|
</script>
|
2023-03-13 14:00:35 +00:00
|
|
|
{{- end }}
|