From c2f6d299b47a0bcefb9af5bdcb293ba420a80986 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Thu, 20 Apr 2023 15:37:22 +0200 Subject: [PATCH] Refactor the invoice product form template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I was using the exact same form from edit and new pages of invoice, which is not too bad considering it won’t change very often, but i now want to be able to add new empty product lines with the add product button, and i will need to have a template for that form, which would mean a third copy. --- web/template/form.gohtml | 11 +++++++++++ web/template/invoices/edit.gohtml | 8 +------- web/template/invoices/new.gohtml | 8 +------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/web/template/form.gohtml b/web/template/form.gohtml index 5204f65..a9c6de9 100644 --- a/web/template/form.gohtml +++ b/web/template/form.gohtml @@ -109,3 +109,14 @@ {{- end }} + +{{ define "invoice-product-form" -}} + {{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.invoiceProductForm*/ -}} + {{ template "hidden-field" .ProductId }} + {{ template "input-field" .Name }} + {{ template "input-field" .Price }} + {{ template "input-field" .Quantity }} + {{ template "input-field" .Discount }} + {{ template "input-field" .Description }} + {{ template "select-field" .Tax }} +{{- end }} diff --git a/web/template/invoices/edit.gohtml b/web/template/invoices/edit.gohtml index bcab216..39877d0 100644 --- a/web/template/invoices/edit.gohtml +++ b/web/template/invoices/edit.gohtml @@ -32,13 +32,7 @@ {{- range $product := .Products }}
{{ template "hidden-field" .InvoiceProductId }} - {{ template "hidden-field" .ProductId }} - {{ template "input-field" .Name }} - {{ template "input-field" .Price }} - {{ template "input-field" .Quantity }} - {{ template "input-field" .Discount }} - {{ template "input-field" .Description }} - {{ template "select-field" .Tax }} + {{ template "invoice-product-form" . }}
{{- end }} {{- end }} diff --git a/web/template/invoices/new.gohtml b/web/template/invoices/new.gohtml index 118cdb2..5387237 100644 --- a/web/template/invoices/new.gohtml +++ b/web/template/invoices/new.gohtml @@ -31,13 +31,7 @@ {{- range $product := .Products }}
- {{ template "hidden-field" .ProductId }} - {{ template "input-field" .Name }} - {{ template "input-field" .Price }} - {{ template "input-field" .Quantity }} - {{ template "input-field" .Discount }} - {{ template "input-field" .Description }} - {{ template "select-field" .Tax }} + {{ template "invoice-product-form" . }}
{{- end }} {{- end }}