From e6f7f0722029465ec24902a590cbe7c7aa5d0af3 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 22 Dec 2023 23:31:28 +0100 Subject: [PATCH] some things actually working --- .../ShoppingListView/ShoppingListView.vue | 175 +++++------------- vue/src/components/ShoppingLineItem.vue | 18 +- vue/src/locales/en.json | 1 + vue/src/stores/ShoppingListStore.js | 27 +-- 4 files changed, 77 insertions(+), 144 deletions(-) diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 712b5c1ed..9fa95d7e6 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -4,10 +4,7 @@
- - - + @@ -37,102 +34,41 @@ {{ $t('Shopping_list') + ` (${items.filter(x => x.checked === false).length})` }} -
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ $t("QuickEntry") }} - - - - - + + + + + + + + + + + + -
- + - - - - - {{$t('Undefined')}} - {{ c.name}} - - - + + + + + {{ $t('Undefined') }} + {{ c.name }} + + + - + - - -
-
-
-
+ + + @@ -530,7 +466,7 @@
- + @@ -597,7 +533,6 @@ export default { ContextMenuItem, ShoppingLineItem, GenericMultiselect, - LookupInput, DownloadPDF, DownloadCSV, CopyToClipboard, @@ -918,43 +853,27 @@ export default { }, // this.genericAPI inherited from ApiMixin addItem: function () { - if (this.ui.entry_mode_simple) { - if (this.new_item.ingredient !== "" && this.new_item.ingredient !== undefined) { - this.genericPostAPI("api_ingredient_from_string", {text: this.new_item.ingredient}).then((result) => { - let unit = null - if (result.data.unit !== null) { - unit = {name: result.data.unit} - } - this.new_item = { - amount: result.data.amount, - unit: unit, - food: {name: result.data.food}, - } - this.addEntry() - }) - } - } else { - this.addEntry() - } - this.setFocus() - }, - addEntry: function (x) { - let api = new ApiApiFactory() - api.createShoppingListEntry(this.new_item) - .then((results) => { - if (results?.data) { - this.items.push(results.data) - StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_CREATE) - } else { - console.log("no data returned") + if (this.new_item.ingredient !== "" && this.new_item.ingredient !== undefined) { + this.genericPostAPI("api_ingredient_from_string", {text: this.new_item.ingredient}).then((result) => { + let unit = null + if (result.data.unit !== null) { + unit = {name: result.data.unit} } + + //TODO clean up from here on + this.new_item = { + amount: result.data.amount, + unit: unit, + food: {name: result.data.food, supermarket_category: null}, + } + this.useShoppingListStore().createObject(this.new_item) this.new_item = {amount: 1, unit: undefined, food: undefined, ingredient: undefined} this.clear += 1 }) - .catch((err) => { - StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE, err) - }) + } + + this.setFocus() }, resetFilters: function () { this.ui.selected_supermarket = undefined diff --git a/vue/src/components/ShoppingLineItem.vue b/vue/src/components/ShoppingLineItem.vue index ed4ee4927..67a5ff446 100644 --- a/vue/src/components/ShoppingLineItem.vue +++ b/vue/src/components/ShoppingLineItem.vue @@ -1,8 +1,8 @@