Files
grocy/public/viewjs/quantityunits.js

57 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-07-09 19:27:22 +02:00
var quantityUnitsTable = $('#quantityunits-table').DataTable({
'paginate': false,
'order': [[1, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 }
],
'language': JSON.parse(L('datatables_localization')),
'scrollY': false
2018-07-09 19:27:22 +02:00
});
$("#search").on("keyup", function()
{
var value = $(this).val();
if (value === "all")
{
value = "";
}
quantityUnitsTable.search(value).draw();
});
$(document).on('click', '.quantityunit-delete-button', function (e)
2017-04-15 23:16:20 +02:00
{
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
2017-04-15 23:16:20 +02:00
bootbox.confirm({
message: L('Are you sure to delete quantity unit "#1"?', objectName),
2017-04-15 23:16:20 +02:00
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function(result)
{
if (result === true)
2017-04-15 23:16:20 +02:00
{
Grocy.Api.Get('delete-object/quantity_units/' + objectId,
2017-04-15 23:16:20 +02:00
function(result)
{
window.location.href = U('/quantityunits');
2017-04-15 23:16:20 +02:00
},
function(xhr)
{
console.error(xhr);
}
);
}
}
});
});