Update shopping list total value when removing an item (fixes #2944)

This commit is contained in:
Bernd Bestel 2026-08-16 19:14:08 +02:00
parent 4732f4a186
commit 7687b12cdd
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -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": {

View File

@ -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();

View File

@ -26,7 +26,8 @@
</h2>
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
<h2 class="mb-0 mr-auto order-3 order-md-1 width-xs-sm-100">
<span class="text-muted small">{!! $__t('%s total value', '<span class="locale-number locale-number-currency">' . SumArrayValue($listItems, 'last_price_total') . '</span>') !!}</span>
<span class="text-muted small">{!! $__t('%s total value', '<span id="total-value"
class="locale-number locale-number-currency"></span>') !!}</span>
</h2>
@endif
<div class="float-right @if($embedded) pr-5 @endif">