From 14c94bf7ab2d209f480fe471d578bbff77dfe628 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 1 Sep 2020 11:31:29 +0200 Subject: [PATCH] WIP shopping list --- cookbook/templates/shopping_list.html | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cookbook/templates/shopping_list.html b/cookbook/templates/shopping_list.html index f4c4e24f2..c4d7111c1 100644 --- a/cookbook/templates/shopping_list.html +++ b/cookbook/templates/shopping_list.html @@ -116,6 +116,7 @@ this.shopping_list = { "recipes": [], "entries": [], + "entries_display": [], "shared": [], "created_by": 1 } @@ -167,10 +168,10 @@ } } }, - updateMultiplier: function(slr_id) { + updateMultiplier: function (slr_id) { console.log('searching', slr_id) let slr = undefined - for (let r of this.shopping_list.recipes){ + for (let r of this.shopping_list.recipes) { console.log(r, r.id) if (r.id === slr_id) { console.log('FOUND') @@ -178,10 +179,23 @@ } } - for (let e of this.shopping_list.entries){ + for (let e of this.shopping_list.entries) { e.amount = (e.amount * slr.multiplier) } }, + updateDisplay: function () { + //TODO merge multiple ingredients of same unit + this.shopping_list.entries_display = [] + + for (let e of this.shopping_list.entries) { + let de = e + de.amount = (e.amount * slr.multiplier) + + this.shopping_list.entries_display.push({ + + }) + } + }, searchKeywords: function (query) { this.keywords_loading = true this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query + '&limit=10').then((response) => {