diff --git a/controllers/StockController.php b/controllers/StockController.php index 72d8d74a..504eb7a7 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -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, diff --git a/localization/de.php b/localization/de.php index 630ed2d7..e95237ed 100644 --- a/localization/de.php +++ b/localization/de.php @@ -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', diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 98c22481..c4ec4e87 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -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('
'); + +$('#stock-overview-table_wrapper').on("DOMSubtreeModified", function() +{ + $('#stock-overview-table_wrapper').off("DOMSubtreeModified"); + + Grocy.Api.Get('get-objects/locations', + function(locations) + { + $('#location-filter').append($('').val("all").html(L("All"))); + $.each(locations, function(index) + { + var locationName = locations[index].name; + $('#location-filter').append($('').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) diff --git a/version.json b/version.json index 8d0f5f32..d04f61c4 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "Version": "1.11.0", - "ReleaseDate": "2018-06-15" + "Version": "1.12.0", + "ReleaseDate": "2018-07-08" } diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 93d7b52d..498ab8f8 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -29,6 +29,7 @@