From 7687b12cdd048e260ddd656a90724eaadc8d9a3b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 16 Aug 2026 19:14:08 +0200 Subject: [PATCH] Update shopping list total value when removing an item (fixes #2944) --- changelog/82_UNRELEASED_xxxx-xx-xx.md | 1 + grocy.openapi.json | 9 ++++++--- public/viewjs/shoppinglist.js | 12 ++++++++++++ views/shoppinglist.blade.php | 3 ++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/changelog/82_UNRELEASED_xxxx-xx-xx.md b/changelog/82_UNRELEASED_xxxx-xx-xx.md index 1b853a12..3fae669b 100644 --- a/changelog/82_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/82_UNRELEASED_xxxx-xx-xx.md @@ -20,6 +20,7 @@ - Fixed that the shopping list setting (top right corner settings menu) "Round up quantity amounts to the nearest whole number" wasn't applied to shopping list item amounts where a quantity unit conversion was involved - Fixed that printing the shopping list with "Group by product group" enabled created duplicated product group headlines in some cases +- Fixed that the total value at the top of the shopping list page wasn't updated after removing a shopping list item ### Recipes diff --git a/grocy.openapi.json b/grocy.openapi.json index 5ce20b44..e229b9f7 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -5907,7 +5907,8 @@ "recipes_pos_resolved", "battery_charge_cycles", "product_barcodes_view", - "permission_hierarchy" + "permission_hierarchy", + "uihelper_shopping_list" ] }, "ExposedEntityNoListing": { @@ -5930,7 +5931,8 @@ "recipes_pos_resolved", "battery_charge_cycles", "product_barcodes_view", - "permission_hierarchy" + "permission_hierarchy", + "uihelper_shopping_list" ] }, "ExposedEntityNoDelete": { @@ -5946,7 +5948,8 @@ "recipes_pos_resolved", "battery_charge_cycles", "product_barcodes_view", - "permission_hierarchy" + "permission_hierarchy", + "uihelper_shopping_list" ] }, "ExposedEntityEditRequiresAdmin": { diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 53791ac6..7aacb162 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -371,6 +371,18 @@ function OnListItemRemoved() { $("#add-all-items-to-stock-button").addClass("disabled"); } + + Grocy.Api.Get("objects/uihelper_shopping_list?" + "?query[]=shopping_list_id=" + $("#selected-shopping-list").val(), + function (items) + { + $("#total-value").text(items.reduce((x, { last_price_total }) => x + last_price_total, 0)); + RefreshLocaleNumberDisplay(); + }, + function (xhr) + { + console.error(xhr); + } + ); } OnListItemRemoved(); diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index c8a94c57..d919f15c 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -26,7 +26,8 @@ @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)

- {!! $__t('%s total value', '' . SumArrayValue($listItems, 'last_price_total') . '') !!} + {!! $__t('%s total value', '') !!}

@endif