mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
59 lines
1.1 KiB
JavaScript
59 lines
1.1 KiB
JavaScript
var recipesTables = $('#recipes-table').DataTable({
|
|
'paginate': false,
|
|
'order': [[1, 'asc']],
|
|
'columnDefs': [
|
|
{ 'orderable': false, 'targets': 0 }
|
|
],
|
|
'language': JSON.parse(L('datatables_localization')),
|
|
'scrollY': false,
|
|
'colReorder': true,
|
|
'stateSave': true
|
|
});
|
|
|
|
$("#search").on("keyup", function()
|
|
{
|
|
var value = $(this).val();
|
|
if (value === "all")
|
|
{
|
|
value = "";
|
|
}
|
|
|
|
recipesTables.search(value).draw();
|
|
});
|
|
|
|
$(document).on('click', '.recipe-delete-button', function(e)
|
|
{
|
|
var objectName = $(e.currentTarget).attr('data-recipe-name');
|
|
var objectId = $(e.currentTarget).attr('data-recipe-id');
|
|
|
|
bootbox.confirm({
|
|
message: L('Are you sure to delete recipe "#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/recipes/' + objectId,
|
|
function(result)
|
|
{
|
|
window.location.href = U('/recipes');
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
});
|
|
});
|