mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Added the possibility to mark a shopping list item as "done" (closes #257)
This commit is contained in:
parent
e4d26bb8fd
commit
b24683f954
@ -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)
|
||||
|
2
migrations/0075.sql
Normal file
2
migrations/0075.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE shopping_list
|
||||
ADD done INT DEFAULT 0;
|
@ -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)
|
||||
|
@ -85,8 +85,13 @@
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@foreach($listItems as $listItem)
|
||||
<tr id="shoppinglistitem-{{ $listItem->id }}-row" class="@if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) table-info @endif">
|
||||
<tr id="shoppinglistitem-{{ $listItem->id }}-row" class="@if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) table-info @endif @if($listItem->done == 1) text-muted text-strike-through @endif">
|
||||
<td class="fit-content border-right">
|
||||
<a class="btn btn-success btn-sm order-listitem-button" href="#"
|
||||
data-item-id="{{ $listItem->id }}"
|
||||
data-item-done="{{ $listItem->done }}">
|
||||
<i class="fas fa-check"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-info" href="{{ $U('/shoppinglistitem/') . $listItem->id . '?list=' . $selectedShoppingListId }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user