mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
63 lines
1.2 KiB
JavaScript
63 lines
1.2 KiB
JavaScript
var batteriesTable = $('#batteries-table').DataTable({
|
|
'paginate': false,
|
|
'order': [[1, 'asc']],
|
|
'columnDefs': [
|
|
{ 'orderable': false, 'targets': 0 }
|
|
],
|
|
'language': JSON.parse(L('datatables_localization')),
|
|
'scrollY': false,
|
|
'colReorder': true,
|
|
'stateSave': true,
|
|
'stateSaveParams': function(settings, data)
|
|
{
|
|
data.search.search = "";
|
|
}
|
|
});
|
|
|
|
$("#search").on("keyup", function()
|
|
{
|
|
var value = $(this).val();
|
|
if (value === "all")
|
|
{
|
|
value = "";
|
|
}
|
|
|
|
batteriesTable.search(value).draw();
|
|
});
|
|
|
|
$(document).on('click', '.battery-delete-button', function (e)
|
|
{
|
|
var objectName = $(e.currentTarget).attr('data-battery-name');
|
|
var objectId = $(e.currentTarget).attr('data-battery-id');
|
|
|
|
bootbox.confirm({
|
|
message: L('Are you sure to delete battery "#1"?', objectName),
|
|
buttons: {
|
|
confirm: {
|
|
label: L('Yes'),
|
|
className: 'btn-success'
|
|
},
|
|
cancel: {
|
|
label: L('No'),
|
|
className: 'btn-danger'
|
|
}
|
|
},
|
|
callback: function(result)
|
|
{
|
|
if (result === true)
|
|
{
|
|
Grocy.Api.Get('delete-object/batteries/' + objectId,
|
|
function(result)
|
|
{
|
|
window.location.href = U('/batteries');
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
});
|
|
});
|