From 5842022d0a1e53ba2c0096f01c382aca26279e82 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 23 Jan 2024 17:49:03 +0100 Subject: [PATCH] fixed some exports --- .../ShoppingListView/ShoppingListView.vue | 39 +++---------------- vue/src/stores/ShoppingListStore.js | 18 ++++++++- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 6c0550df..ad29b01b 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -16,13 +16,13 @@ @@ -442,12 +442,12 @@ - - - @@ -521,12 +521,6 @@ export default { } }, computed: { - csvData() { - // return this.items.map((x) => { - // return {amount: x.amount, unit: x.unit?.name ?? "", food: x.food?.name ?? ""} - // }) - return [] - }, editingSupermarket() { return this.shopping_list_store.supermarkets.filter((el) => { return el.editing @@ -605,27 +599,6 @@ export default { StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err) }) }, - - onHand: function (item) { - let api = new ApiApiFactory() - let food = { - id: item?.[0]?.food.id ?? item?.food?.id, - food_onhand: true, - } - - this.updateFood(food, "food_onhand") - .then((result) => { - let entries = this.items.filter((x) => x.food.id == food.id).map((x) => x.id) - this.items = this.items.filter((x) => x.food.id !== food.id) - return entries - }) - .then((entries) => { - entries.forEach((x) => { - api.destroyShoppingListEntry(x).then((result) => { - }) - }) - }) - }, /** * change number of servings of a shopping list recipe * backend handles scaling of associated entries diff --git a/vue/src/stores/ShoppingListStore.js b/vue/src/stores/ShoppingListStore.js index b06617f2..d7fcbae0 100644 --- a/vue/src/stores/ShoppingListStore.js +++ b/vue/src/stores/ShoppingListStore.js @@ -100,7 +100,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, { this.total_checked_food = total_checked_food // ordering - if (this.UNDEFINED_CATEGORY in structure) { + if (this.UNDEFINED_CATEGORY in structure) { ordered_structure.push(structure[this.UNDEFINED_CATEGORY]) Vue.delete(structure, this.UNDEFINED_CATEGORY) } @@ -125,6 +125,22 @@ export const useShoppingListStore = defineStore(_STORE_ID, { return ordered_structure }, + get_flat_entries: function () { + //{amount: x.amount, unit: x.unit?.name ?? "", food: x.food?.name ?? ""} + let items = [] + for (let i in this.get_entries_by_group) { + for (let f in this.get_entries_by_group[i]['foods']) { + for (let e in this.get_entries_by_group[i]['foods'][f]['entries']) { + items.push({ + amount: this.get_entries_by_group[i]['foods'][f]['entries'][e].amount, + unit: this.get_entries_by_group[i]['foods'][f]['entries'][e].unit?.name ?? '', + food: this.get_entries_by_group[i]['foods'][f]['entries'][e].food?.name ?? '', + }) + } + } + } + return items + }, /** * list of options available for grouping entry display * @return {[{id: *, translatable_label: string},{id: *, translatable_label: string},{id: *, translatable_label: string}]}