2017-04-15 23:16:20 +02:00
|
|
|
|
$(document).on('click', '.product-delete-button', function(e)
|
|
|
|
|
{
|
2018-04-21 19:18:00 +02:00
|
|
|
|
var objectName = $(e.currentTarget).attr('data-product-name');
|
|
|
|
|
var objectId = $(e.currentTarget).attr('data-product-id');
|
|
|
|
|
|
2017-04-15 23:16:20 +02:00
|
|
|
|
bootbox.confirm({
|
2018-04-21 19:18:00 +02:00
|
|
|
|
message: L('Are you sure to delete product "#1"?', objectName),
|
2017-04-15 23:16:20 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
2018-04-18 19:37:36 +02:00
|
|
|
|
label: L('Yes'),
|
2017-04-15 23:16:20 +02:00
|
|
|
|
className: 'btn-success'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
2018-04-18 19:37:36 +02:00
|
|
|
|
label: L('No'),
|
2017-04-15 23:16:20 +02:00
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callback: function(result)
|
|
|
|
|
{
|
2017-04-20 22:01:14 +02:00
|
|
|
|
if (result === true)
|
2017-04-15 23:16:20 +02:00
|
|
|
|
{
|
2018-04-21 19:18:00 +02:00
|
|
|
|
Grocy.Api.Get('delete-object/products/' + objectId,
|
2017-04-15 23:16:20 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
window.location.href = U('/products');
|
2017-04-15 23:16:20 +02:00
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2017-04-16 23:11:03 +02:00
|
|
|
|
|
2018-04-16 19:11:32 +02:00
|
|
|
|
$('#products-table').DataTable({
|
2018-07-08 13:50:52 +02:00
|
|
|
|
'bPaginate': false,
|
2018-04-16 19:11:32 +02:00
|
|
|
|
'order': [[1, 'asc']],
|
|
|
|
|
'columnDefs': [
|
|
|
|
|
{ 'orderable': false, 'targets': 0 }
|
|
|
|
|
],
|
|
|
|
|
'language': JSON.parse(L('datatables_localization'))
|
2017-04-16 23:11:03 +02:00
|
|
|
|
});
|