mirror of
https://github.com/grocy/grocy.git
synced 2025-08-13 01:06:23 +00:00
Continue working on tasks feature
This commit is contained in:
62
public/viewjs/taskcategories.js
Normal file
62
public/viewjs/taskcategories.js
Normal file
@@ -0,0 +1,62 @@
|
||||
var categoriesTable = $('#task-categories-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 = "";
|
||||
}
|
||||
|
||||
categoriesTable.search(value).draw();
|
||||
});
|
||||
|
||||
$(document).on('click', '.task-category-delete-button', function (e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-category-name');
|
||||
var objectId = $(e.currentTarget).attr('data-category-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: L('Are you sure to delete task category "#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/task_categories/' + objectId,
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/taskcategories');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user