From 9422e8194245c9cdbfa09b38c20173964349e2a2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 24 Oct 2024 17:24:00 +0200 Subject: view: Order ingredient summary by ingredient name This makes it easier to write a shopping list for the required ingredients. --- model/ingredient.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'model/ingredient.go') diff --git a/model/ingredient.go b/model/ingredient.go index 9922060..e4570ff 100644 --- a/model/ingredient.go +++ b/model/ingredient.go @@ -45,6 +45,22 @@ func (i *Ingredient) Validate() error { return nil } +func (i Ingredient) String() string { + str := "" + + if i.Amount != "" { + str += i.Amount + " " + } + + if i.Unit != "" { + str += i.Unit + " " + } + + str += i.Type + + return str +} + func (i *Ingredient) Create(tx *sql.Tx) error { if i.Id != "" { return fmt.Errorf("Cannot create ingredient if ID is given") -- cgit v1.2.3-70-g09d2