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