mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
* Restful routes * Change public/viewjs to match API routes * Move the GET and POST together. Fixed Typos. PUT for object/user edits. * Verb-less Generic Entity Interactions * Create Grocy.Api.Put * Create Grocy.Api.Delete * Fix Volatile Slim Error order in routes and adjust to english noun
69 lines
1.3 KiB
JavaScript
69 lines
1.3 KiB
JavaScript
var groupsTable = $('#productgroups-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 = "";
|
|
|
|
data.columns.forEach(column =>
|
|
{
|
|
column.search.search = "";
|
|
});
|
|
}
|
|
});
|
|
$('#productgroups-table tbody').removeClass("d-none");
|
|
|
|
$("#search").on("keyup", function()
|
|
{
|
|
var value = $(this).val();
|
|
if (value === "all")
|
|
{
|
|
value = "";
|
|
}
|
|
|
|
groupsTable.search(value).draw();
|
|
});
|
|
|
|
$(document).on('click', '.product-group-delete-button', function(e)
|
|
{
|
|
var objectName = $(e.currentTarget).attr('data-group-name');
|
|
var objectId = $(e.currentTarget).attr('data-group-id');
|
|
|
|
bootbox.confirm({
|
|
message: L('Are you sure to delete product group "#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.Delete('object/product_groups/' + objectId,
|
|
function(result)
|
|
{
|
|
window.location.href = U('/productgroups');
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
});
|
|
});
|