From 5853ca9243d12e49b2a025dd39f9eb705f875d3e Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 28 Jan 2024 12:06:27 +0100 Subject: [PATCH] handle partially delayed/checked --- vue/src/components/ShoppingLineItem.vue | 63 ++++++++++++++++--------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/vue/src/components/ShoppingLineItem.vue b/vue/src/components/ShoppingLineItem.vue index fbc9957f..522b1e19 100644 --- a/vue/src/components/ShoppingLineItem.vue +++ b/vue/src/components/ShoppingLineItem.vue @@ -13,7 +13,10 @@
- {{ a.amount }} {{ a.unit }}
+ + + {{ a.amount }} {{ a.unit }} +
{{ food.name }} @@ -22,8 +25,8 @@ {{ info_row }}
- + @@ -50,8 +53,7 @@ @change="detail_modal_visible = false; updateFoodCategory(food)" > - - + {{ $t("Ignore_Shopping") }} @@ -67,7 +69,7 @@
- {{ e.amount }} {{ e.unit?.name }} {{ food.name }} + {{ e.amount }} {{ e.unit?.name }} {{ food.name }} {{ @@ -175,23 +177,27 @@ export default { for (let i in this.entries) { let e = this.entries[i] - let unit = -1 - if (e.unit !== undefined && e.unit !== null) { - unit = e.unit.id - } - if (e.amount > 0) { - if (unit in unit_amounts) { - unit_amounts[unit]['amount'] += e.amount - } else { - if (unit === -1) { - unit_amounts[unit] = {id: -1, unit: "", amount: e.amount} - } else { - unit_amounts[unit] = {id: e.unit.id, unit: e.unit.name, amount: e.amount} - } + if (!e.checked && e.delay_until === null + || (e.checked && useUserPreferenceStore().device_settings.shopping_show_checked_entries) + || (e.delay_until !== null && useUserPreferenceStore().device_settings.shopping_show_delayed_entries)) { + let unit = -1 + if (e.unit !== undefined && e.unit !== null) { + unit = e.unit.id + } + if (e.amount > 0) { + if (unit in unit_amounts) { + unit_amounts[unit]['amount'] += e.amount + } else { + if (unit === -1) { + unit_amounts[unit] = {id: -1, unit: "", amount: e.amount, checked: e.checked} + } else { + unit_amounts[unit] = {id: e.unit.id, unit: e.unit.name, amount: e.amount, checked: e.checked} + } + + } } } - } return unit_amounts }, @@ -266,6 +272,21 @@ export default { StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) }) }, + /** + * set food on_hand status to true and check all associated entries + * @param food + */ + setFoodIgnoredAndChecked: function (food) { + let apiClient = new ApiApiFactory() + + food.ignore_shopping = true + apiClient.updateFood(food.id, food).then(r => { + }).catch((err) => { + StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err) + }) + + useShoppingListStore().setEntriesCheckedState(this.entries, true, false) + }, /** * function triggered by touchend event of swipe container * check if min distance is reached and execute desired action @@ -276,7 +297,7 @@ export default { // get the distance the user swiped const swipeDistance = container.scrollLeft - container.clientWidth; if (swipeDistance < minDistance * -1) { - useShoppingListStore().setEntriesCheckedState(this.entries, !this.is_checked) + useShoppingListStore().setEntriesCheckedState(this.entries, !this.is_checked, true) } else if (swipeDistance > minDistance) { useShoppingListStore().delayEntries(this.entries, !this.is_delayed, true) }