mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Add possibility to filter products by location (references #10)
This commit is contained in:
parent
92e648490a
commit
ecf96252b9
@ -24,6 +24,7 @@ class StockController extends BaseController
|
||||
return $this->AppContainer->view->render($response, 'stockoverview', [
|
||||
'products' => $this->Database->products()->orderBy('name'),
|
||||
'quantityunits' => $this->Database->quantity_units()->orderBy('name'),
|
||||
'locations' => $this->Database->locations()->orderBy('name'),
|
||||
'currentStock' => $currentStock,
|
||||
'missingProducts' => $this->StockService->GetMissingProducts(),
|
||||
'nextXDays' => $nextXDays,
|
||||
|
@ -129,6 +129,7 @@ return array(
|
||||
'All' => 'Alle',
|
||||
'Track charge cycle of battery #1' => 'Erfasse einen Ladezyklus für Batterie #1',
|
||||
'Track execution of habit #1' => 'Erfasse eine Ausführung von #1',
|
||||
'Filter by location' => 'Nach Standort filtern',
|
||||
|
||||
//Constants
|
||||
'manually' => 'Manuell',
|
||||
|
@ -1,10 +1,46 @@
|
||||
$('#stock-overview-table').DataTable({
|
||||
var stockOverviewTable = $('#stock-overview-table').DataTable({
|
||||
'bPaginate': false,
|
||||
'order': [[3, 'asc']],
|
||||
'columnDefs': [
|
||||
{ 'orderable': false, 'targets': 0 }
|
||||
{ 'orderable': false, 'targets': 0 },
|
||||
{ 'visible': false, 'targets': 4 }
|
||||
],
|
||||
'language': JSON.parse(L('datatables_localization'))
|
||||
'language': JSON.parse(L('datatables_localization')),
|
||||
"dom": '<"filter-by-location">f'
|
||||
});
|
||||
|
||||
$("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()
|
||||
{
|
||||
$('#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")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
stockOverviewTable.column(4).search(value).draw();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.product-consume-button', function(e)
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"Version": "1.11.0",
|
||||
"ReleaseDate": "2018-06-15"
|
||||
"Version": "1.12.0",
|
||||
"ReleaseDate": "2018-07-08"
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
<th>{{ $L('Product') }}</th>
|
||||
<th>{{ $L('Amount') }}</th>
|
||||
<th>{{ $L('Next best before date') }}</th>
|
||||
<th class="hidden">Hidden location</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -60,6 +61,9 @@
|
||||
{{ $currentStockEntry->best_before_date }}
|
||||
<time class="timeago timeago-contextual" datetime="{{ $currentStockEntry->best_before_date }}"></time>
|
||||
</td>
|
||||
<td class="hidden">
|
||||
{{ FindObjectInArrayByPropertyValue($locations, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->location_id)->name }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
Loading…
x
Reference in New Issue
Block a user