Files
grocy/public/viewjs/chores.js

70 lines
1.3 KiB
JavaScript
Raw Normal View History

var choresTable = $('#chores-table').DataTable({
2018-07-09 19:27:22 +02:00
'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 = "";
data.columns.forEach(column =>
{
column.search.search = "";
});
}
2018-07-09 19:27:22 +02:00
});
$('#chores-table tbody').removeClass("d-none");
choresTable.columns.adjust().draw();
2018-07-09 19:27:22 +02:00
$("#search").on("keyup", function()
{
var value = $(this).val();
if (value === "all")
{
value = "";
}
choresTable.search(value).draw();
2018-07-09 19:27:22 +02:00
});
$(document).on('click', '.chore-delete-button', function (e)
2017-07-25 20:03:31 +02:00
{
var objectName = $(e.currentTarget).attr('data-chore-name');
var objectId = $(e.currentTarget).attr('data-chore-id');
2017-07-25 20:03:31 +02:00
bootbox.confirm({
message: L('Are you sure to delete chore "#1"?', objectName),
2017-07-25 20:03:31 +02:00
buttons: {
confirm: {
2018-04-18 19:37:36 +02:00
label: L('Yes'),
2017-07-25 20:03:31 +02:00
className: 'btn-success'
},
cancel: {
2018-04-18 19:37:36 +02:00
label: L('No'),
2017-07-25 20:03:31 +02:00
className: 'btn-danger'
}
},
callback: function(result)
{
if (result === true)
{
Grocy.Api.Delete('objects/chores/' + objectId, {},
2017-07-25 20:03:31 +02:00
function(result)
{
window.location.href = U('/chores');
2017-07-25 20:03:31 +02:00
},
function(xhr)
{
console.error(xhr);
}
);
}
}
});
});