From ad9b10c9c1b2c8b3d4baaff4078fe916c78ebd5b Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 22 Sep 2020 12:17:22 +0200 Subject: [PATCH] allow entry deletion --- cookbook/templates/shopping_list.html | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cookbook/templates/shopping_list.html b/cookbook/templates/shopping_list.html index 95f5ca7ec..37e99432e 100644 --- a/cookbook/templates/shopping_list.html +++ b/cookbook/templates/shopping_list.html @@ -76,6 +76,10 @@ @@ -112,6 +116,11 @@ [[x.amount]] [[x.unit.name]] [[x.food.name]] + + + @@ -429,8 +438,6 @@ }) }, entryChecked: function (entry) { - - this.shopping_list.entries.forEach((item) => { if (item.id === entry.id) { //TODO unwrap once same entries are merged item.checked = entry.checked @@ -445,8 +452,6 @@ } }) - - }, addEntry: function () { if (this.new_entry.food !== undefined) { @@ -490,8 +495,6 @@ return '{% url 'view_recipe' 123456 %}'.replace('123456', id) }, addRecipeToList: function (recipe) { - - let slr = { "created": true, "id": Math.random() * 1000, @@ -516,6 +519,10 @@ } } }, + removeRecipeFromList: function (slr) { + this.shopping_list.entries = this.shopping_list.entries.filter(item => item.list_recipe !== slr.id) + this.shopping_list.recipes = this.shopping_list.recipes.filter(item => item !== slr) + }, searchKeywords: function (query) { this.keywords_loading = true this.$http.get("{% url 'api:keyword-list' %}" + '?query=' + query + '&limit=10').then((response) => {