2018-09-24 13:02:52 +02:00
|
|
|
|
var groupsTable = $('#productgroups-table').DataTable({
|
|
|
|
|
'order': [[1, 'asc']],
|
|
|
|
|
'columnDefs': [
|
2020-01-03 14:18:56 +01:00
|
|
|
|
{ 'orderable': false, 'targets': 0 },
|
|
|
|
|
{ 'searchable': false, "targets": 0 }
|
2020-12-07 19:48:33 +01:00
|
|
|
|
].concat($.fn.dataTable.defaults.columnDefs)
|
2018-09-24 13:02:52 +02:00
|
|
|
|
});
|
2019-01-05 20:06:35 +01:00
|
|
|
|
$('#productgroups-table tbody').removeClass("d-none");
|
2019-03-04 17:43:12 +01:00
|
|
|
|
groupsTable.columns.adjust().draw();
|
2018-09-24 13:02:52 +02:00
|
|
|
|
|
2019-10-15 19:59:14 +02:00
|
|
|
|
$("#search").on("keyup", Delay(function()
|
2018-09-24 13:02:52 +02:00
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
2019-01-19 00:37:21 -07:00
|
|
|
|
|
2018-09-24 13:02:52 +02:00
|
|
|
|
groupsTable.search(value).draw();
|
2019-10-15 19:59:14 +02:00
|
|
|
|
}, 200));
|
2018-09-24 13:02:52 +02:00
|
|
|
|
|
2020-11-07 14:53:45 +01:00
|
|
|
|
$("#clear-filter-button").on("click", function()
|
|
|
|
|
{
|
|
|
|
|
$("#search").val("");
|
|
|
|
|
groupsTable.search("").draw();
|
|
|
|
|
});
|
|
|
|
|
|
2018-09-24 13:02:52 +02:00
|
|
|
|
$(document).on('click', '.product-group-delete-button', function(e)
|
|
|
|
|
{
|
2020-10-14 22:58:26 +02:00
|
|
|
|
var objectName = $(e.currentTarget).attr('data-group-name');
|
2018-09-24 13:02:52 +02:00
|
|
|
|
var objectId = $(e.currentTarget).attr('data-group-id');
|
|
|
|
|
|
|
|
|
|
bootbox.confirm({
|
2019-05-01 20:19:18 +02:00
|
|
|
|
message: __t('Are you sure to delete product group "%s"?', objectName),
|
2019-09-24 10:24:47 +02:00
|
|
|
|
closeButton: false,
|
2018-09-24 13:02:52 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
2019-05-01 20:19:18 +02:00
|
|
|
|
label: __t('Yes'),
|
2018-09-24 13:02:52 +02:00
|
|
|
|
className: 'btn-success'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
2019-05-01 20:19:18 +02:00
|
|
|
|
label: __t('No'),
|
2018-09-24 13:02:52 +02:00
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callback: function(result)
|
|
|
|
|
{
|
|
|
|
|
if (result === true)
|
|
|
|
|
{
|
2019-01-19 14:51:51 +01:00
|
|
|
|
Grocy.Api.Delete('objects/product_groups/' + objectId, {},
|
2018-09-24 13:02:52 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = U('/productgroups');
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2020-08-17 14:47:33 -05:00
|
|
|
|
$(window).on("message", function(e)
|
|
|
|
|
{
|
|
|
|
|
var data = e.originalEvent.data;
|
|
|
|
|
|
|
|
|
|
if (data.Message === "CloseAllModals")
|
|
|
|
|
{
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}
|
|
|
|
|
});
|