mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Better approach for stock overview filtering by location (references #11)
This commit is contained in:
@@ -182,3 +182,15 @@ a.discrete-link:focus {
|
||||
#toast-container > div {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.no-gutters {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.dataTables_filter,
|
||||
.dataTables_info {
|
||||
display: none;
|
||||
}
|
||||
|
@@ -1,46 +1,33 @@
|
||||
var stockOverviewTable = $('#stock-overview-table').DataTable({
|
||||
'bPaginate': false,
|
||||
'paginate': false,
|
||||
'order': [[3, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 },
|
||||
{ 'visible': false, 'targets': 4 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
"dom": '<"filter-by-location">f'
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
});
|
||||
|
||||
$("div.filter-by-location").html('<div class="dataTables_filter"><label>' + L('Filter by location') + ':<select id="location-filter" class="form-control input-sm" style="margin-left: 0.5em;"></label></div>');
|
||||
|
||||
$('#stock-overview-table_wrapper').on("DOMSubtreeModified", function()
|
||||
$("#location-filter").on("change", function()
|
||||
{
|
||||
$('#stock-overview-table_wrapper').off("DOMSubtreeModified");
|
||||
|
||||
Grocy.Api.Get('get-objects/locations',
|
||||
function(locations)
|
||||
{
|
||||
$('#location-filter').append($('<option></option>').val("all").html(L("All")));
|
||||
$.each(locations, function(index)
|
||||
{
|
||||
var locationName = locations[index].name;
|
||||
$('#location-filter').append($('<option></option>').val(locationName).html(locationName));
|
||||
});
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
|
||||
$("#location-filter").on("change", function()
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
value = "";
|
||||
}
|
||||
|
||||
stockOverviewTable.column(4).search(value).draw();
|
||||
});
|
||||
|
||||
stockOverviewTable.column(4).search(value).draw();
|
||||
});
|
||||
$("#search").on("keyup", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
stockOverviewTable.search(value).draw();
|
||||
});
|
||||
|
||||
$(document).on('click', '.product-consume-button', function(e)
|
||||
|
Reference in New Issue
Block a user