2018-07-09 19:27:22 +02:00
|
|
|
|
var shoppingListTable = $('#shoppinglist-table').DataTable({
|
|
|
|
|
'paginate': false,
|
|
|
|
|
'order': [[1, 'asc']],
|
|
|
|
|
'columnDefs': [
|
|
|
|
|
{ 'orderable': false, 'targets': 0 }
|
|
|
|
|
],
|
2018-07-10 20:37:13 +02:00
|
|
|
|
'language': JSON.parse(L('datatables_localization')),
|
2018-07-14 08:48:14 +02:00
|
|
|
|
'scrollY': false,
|
2018-07-14 10:17:12 +02:00
|
|
|
|
'colReorder': true,
|
|
|
|
|
'stateSave': true
|
2018-07-09 19:27:22 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$("#search").on("keyup", function()
|
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shoppingListTable.search(value).draw();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '.shoppinglist-delete-button', function (e)
|
2017-04-21 15:36:04 +02:00
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
Grocy.Api.Get('delete-object/shopping_list/' + $(e.currentTarget).attr('data-shoppinglist-id'),
|
2017-04-21 15:36:04 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
window.location.href = U('/shoppinglist');
|
2017-04-21 15:36:04 +02:00
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '#add-products-below-min-stock-amount', function(e)
|
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
Grocy.Api.Get('stock/add-missing-products-to-shoppinglist',
|
2017-04-21 15:36:04 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
window.location.href = U('/shoppinglist');
|
2017-04-21 15:36:04 +02:00
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|