2018-07-09 19:27:22 +02:00
|
|
|
|
var quantityUnitsTable = $('#quantityunits-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-07-09 19:27:22 +02:00
|
|
|
|
});
|
2019-01-05 20:06:35 +01:00
|
|
|
|
$('#quantityunits-table tbody').removeClass("d-none");
|
2019-03-04 17:43:12 +01:00
|
|
|
|
quantityUnitsTable.columns.adjust().draw();
|
2018-07-09 19:27:22 +02:00
|
|
|
|
|
2019-10-15 19:59:14 +02:00
|
|
|
|
$("#search").on("keyup", Delay(function()
|
2018-07-09 19:27:22 +02:00
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
2019-01-19 00:37:21 -07:00
|
|
|
|
|
2018-07-09 19:27:22 +02:00
|
|
|
|
quantityUnitsTable.search(value).draw();
|
2019-10-15 19:59:14 +02:00
|
|
|
|
}, 200));
|
2018-07-09 19:27:22 +02:00
|
|
|
|
|
2020-11-07 14:53:45 +01:00
|
|
|
|
$("#clear-filter-button").on("click", function()
|
|
|
|
|
{
|
|
|
|
|
$("#search").val("");
|
2021-06-27 18:42:15 +02:00
|
|
|
|
quantityUnitsTable.search("").draw();
|
2020-11-07 14:53:45 +01:00
|
|
|
|
});
|
|
|
|
|
|
2020-08-30 12:18:16 +02:00
|
|
|
|
$(document).on('click', '.quantityunit-delete-button', function(e)
|
2017-04-15 23:16:20 +02:00
|
|
|
|
{
|
2020-10-14 22:58:26 +02:00
|
|
|
|
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
2018-04-21 19:18:00 +02:00
|
|
|
|
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
|
|
|
|
|
2017-04-15 23:16:20 +02:00
|
|
|
|
bootbox.confirm({
|
2024-12-26 10:46:54 +01:00
|
|
|
|
message: __t('Are you sure you want to delete quantity unit "%s"?', objectName),
|
2019-09-24 10:24:47 +02:00
|
|
|
|
closeButton: false,
|
2017-04-15 23:16:20 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
|
|
|
|
label: 'Yes',
|
|
|
|
|
className: 'btn-success'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: 'No',
|
|
|
|
|
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
|
|
|
|
{
|
2019-01-19 14:51:51 +01:00
|
|
|
|
Grocy.Api.Delete('objects/quantity_units/' + objectId, {},
|
2017-04-15 23:16:20 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
2018-04-18 19:03:39 +02:00
|
|
|
|
window.location.href = U('/quantityunits');
|
2017-04-15 23:16:20 +02:00
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-05-13 14:24:52 +02:00
|
|
|
|
|
|
|
|
|
$("#show-disabled").change(function()
|
|
|
|
|
{
|
|
|
|
|
if (this.checked)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = U('/quantityunits?include_disabled');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
window.location.href = U('/quantityunits');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (GetUriParam('include_disabled'))
|
|
|
|
|
{
|
|
|
|
|
$("#show-disabled").prop('checked', true);
|
|
|
|
|
}
|