Added a "Clear done items" button to the shopping list (closes #1999)

This commit is contained in:
Bernd Bestel 2022-11-19 19:45:00 +01:00
parent 605ceb1b19
commit 6affa01f81
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 30 additions and 6 deletions

View File

@ -12,7 +12,7 @@
### Shopping list ### Shopping list
- xxx - Added a new button "Clear done items" (to clear all done items with one click)
### Recipes ### Recipes

View File

@ -2338,3 +2338,6 @@ msgstr ""
msgid "Decimal places allowed for prices (display)" msgid "Decimal places allowed for prices (display)"
msgstr "" msgstr ""
msgid "Clear done items"
msgstr ""

View File

@ -236,6 +236,20 @@ $(document).on('click', '#clear-shopping-list', function(e)
}); });
}); });
$(document).on("click", "#clear-done-items", function(e)
{
Grocy.Api.Post('stock/shoppinglist/clear', { "list_id": $("#selected-shopping-list").val(), "done_only": true },
function(result)
{
window.location.reload();
},
function(xhr)
{
console.error(xhr);
}
);
});
$(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', function(e) $(document).on('click', '.shopping-list-stock-add-workflow-list-item-button', function(e)
{ {
e.preventDefault(); e.preventDefault();

View File

@ -92,11 +92,18 @@
href="{{ $U('/shoppinglistitem/new?embedded&list=' . $selectedShoppingListId) }}"> href="{{ $U('/shoppinglistitem/new?embedded&list=' . $selectedShoppingListId) }}">
{{ $__t('Add item') }} {{ $__t('Add item') }}
</a> </a>
<div class="btn-group">
<a id="clear-shopping-list" <a id="clear-shopping-list"
class="btn btn-outline-danger btn-sm mb-1 responsive-button @if($listItems->count() == 0) disabled @endif" class="btn btn-outline-danger btn-sm mb-1 responsive-button @if($listItems->count() == 0) disabled @endif"
href="#"> href="#">
{{ $__t('Clear list') }} {{ $__t('Clear list') }}
</a> </a>
<a id="clear-done-items"
class="btn btn-outline-danger btn-sm mb-1 responsive-button @if($listItems->count() == 0) disabled @endif"
href="#">
{{ $__t('Clear done items') }}
</a>
</div>
<a id="add-all-items-to-stock-button" <a id="add-all-items-to-stock-button"
class="btn btn-outline-primary btn-sm mb-1 responsive-button @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif" class="btn btn-outline-primary btn-sm mb-1 responsive-button @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif"
href="#"> href="#">