diff --git a/changelog/50_2.4.3_2019-xx-xx.md b/changelog/50_2.4.3_2019-xx-xx.md index 0273776e..6c50b76e 100644 --- a/changelog/50_2.4.3_2019-xx-xx.md +++ b/changelog/50_2.4.3_2019-xx-xx.md @@ -5,4 +5,6 @@ - Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex) - Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown) - Improved date display for dates of today and no time (instead of the hours since midnight now just "Today" will be shown) -- Improved shopping list handling, items can now be switched between lists (there is a shopping list dropdown on the item edit page) +- Improved shopping list handling + - Items can now be switched between lists (there is a shopping list dropdown on the item edit page) + - Items can now be marked as "done" (new check mark button per item, when clicked, the item will be displayed greyed out, when clicked again the item will be displayed normally again) diff --git a/migrations/0075.sql b/migrations/0075.sql new file mode 100644 index 00000000..8bcf7e8b --- /dev/null +++ b/migrations/0075.sql @@ -0,0 +1,2 @@ +ALTER TABLE shopping_list +ADD done INT DEFAULT 0; diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 15ff902d..e625692b 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -259,6 +259,46 @@ $(document).on('click', '#shopping-list-stock-add-workflow-skip-button', functio window.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl); }); +$(document).on('click', '.order-listitem-button', function(e) +{ + e.preventDefault(); + + Grocy.FrontendHelpers.BeginUiBusy(); + + var listItemId = $(e.currentTarget).attr('data-item-id'); + + var done = 1; + if ($(e.currentTarget).attr('data-item-done') == 1) + { + done = 0; + } + + $(e.currentTarget).attr('data-item-done', done); + + Grocy.Api.Put('objects/shopping_list/' + listItemId, { 'done': done }, + function() + { + if (done == 1) + { + $('#shoppinglistitem-' + listItemId + '-row').addClass("text-muted"); + $('#shoppinglistitem-' + listItemId + '-row').addClass("text-strike-through"); + } + else + { + $('#shoppinglistitem-' + listItemId + '-row').removeClass("text-muted"); + $('#shoppinglistitem-' + listItemId + '-row').removeClass("text-strike-through"); + } + + Grocy.FrontendHelpers.EndUiBusy(); + }, + function(xhr) + { + Grocy.FrontendHelpers.EndUiBusy(); + console.error(xhr); + } + ); +}); + function OnListItemRemoved() { if ($(".shopping-list-stock-add-workflow-list-item-button").length === 0) diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index c0c7b673..8a669370 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -85,8 +85,13 @@ @foreach($listItems as $listItem) - + + + +