2019-09-18 16:18:15 +02:00
|
|
|
|
var userentitiesTable = $('#userentities-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)
|
2019-09-18 16:18:15 +02:00
|
|
|
|
});
|
|
|
|
|
$('#userentities-table tbody').removeClass("d-none");
|
|
|
|
|
userentitiesTable.columns.adjust().draw();
|
|
|
|
|
|
2019-10-15 19:59:14 +02:00
|
|
|
|
$("#search").on("keyup", Delay(function()
|
2019-09-18 16:18:15 +02:00
|
|
|
|
{
|
|
|
|
|
var value = $(this).val();
|
|
|
|
|
if (value === "all")
|
|
|
|
|
{
|
|
|
|
|
value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userentitiesTable.search(value).draw();
|
2019-10-15 19:59:14 +02:00
|
|
|
|
}, 200));
|
2019-09-18 16:18:15 +02:00
|
|
|
|
|
2020-11-07 14:53:45 +01:00
|
|
|
|
$("#clear-filter-button").on("click", function()
|
|
|
|
|
{
|
|
|
|
|
$("#search").val("");
|
|
|
|
|
userentitiesTable.search("").draw();
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-30 12:18:16 +02:00
|
|
|
|
$(document).on('click', '.userentity-delete-button', function(e)
|
2019-09-18 16:18:15 +02:00
|
|
|
|
{
|
2020-10-14 22:58:26 +02:00
|
|
|
|
var objectName = $(e.currentTarget).attr('data-userentity-name');
|
2019-09-18 16:18:15 +02:00
|
|
|
|
var objectId = $(e.currentTarget).attr('data-userentity-id');
|
|
|
|
|
|
|
|
|
|
bootbox.confirm({
|
2024-12-26 10:46:54 +01:00
|
|
|
|
message: __t('Are you sure you want to delete userentity "%s"?', objectName),
|
2019-09-24 10:24:47 +02:00
|
|
|
|
closeButton: false,
|
2019-09-18 16:18:15 +02:00
|
|
|
|
buttons: {
|
|
|
|
|
confirm: {
|
|
|
|
|
label: __t('Yes'),
|
|
|
|
|
className: 'btn-success'
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
label: __t('No'),
|
|
|
|
|
className: 'btn-danger'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
callback: function(result)
|
|
|
|
|
{
|
|
|
|
|
if (result === true)
|
|
|
|
|
{
|
2020-08-30 12:18:16 +02:00
|
|
|
|
Grocy.Api.Delete('objects/userentities/' + objectId, {},
|
2019-09-18 16:18:15 +02:00
|
|
|
|
function(result)
|
|
|
|
|
{
|
|
|
|
|
window.location.href = U('/userentities');
|
|
|
|
|
},
|
|
|
|
|
function(xhr)
|
|
|
|
|
{
|
|
|
|
|
console.error(xhr);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|