Files
grocy/public/viewjs/chores.js

64 lines
1.2 KiB
JavaScript
Raw Normal View History

var choresTable = $('#chores-table').DataTable({
2018-07-09 19:27:22 +02:00
'order': [[1, 'asc']],
'columnDefs': [
{ 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 }
]
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", Delay(function()
2018-07-09 19:27:22 +02:00
{
var value = $(this).val();
if (value === "all")
{
value = "";
}
choresTable.search(value).draw();
}, 200));
2018-07-09 19:27:22 +02:00
$("#clear-filter-button").on("click", function()
{
$("#search").val("");
choresTable.search("").draw();
});
2020-08-30 12:18:16 +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: __t('Are you sure to delete chore "%s"?', objectName),
closeButton: false,
2017-07-25 20:03:31 +02:00
buttons: {
confirm: {
label: __t('Yes'),
2017-07-25 20:03:31 +02:00
className: 'btn-success'
},
cancel: {
label: __t('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);
}
);
}
}
});
});