mirror of
https://github.com/grocy/grocy.git
synced 2026-03-28 07:39:25 +01:00
direct-content-only switch makes more sense than leaf_only
This commit is contained in:
parent
d5878dbb47
commit
62448ba63d
|
|
@ -95,7 +95,7 @@ class StockController extends BaseController
|
|||
'locations' => $this->getDatabase()->locations_hierarchy()->orderBy('location_path', 'COLLATE NOCASE'),
|
||||
'locationsResolved' => $this->getDatabase()->locations_resolved(),
|
||||
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock'])),
|
||||
'showLeafLocationsOnly' => isset($request->getQueryParams()['leaf_locations_only'])
|
||||
'showDirectContentOnly' => isset($request->getQueryParams()['direct_content_only'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2477,8 +2477,8 @@ msgstr ""
|
|||
msgid "List actions"
|
||||
msgstr ""
|
||||
|
||||
msgid "Show only leaf locations"
|
||||
msgid "Show direct content only"
|
||||
msgstr ""
|
||||
|
||||
msgid "When enabled, only locations without sub-locations are shown. When disabled, parent locations show aggregated content from all sub-locations."
|
||||
msgid "When enabled, each location shows only products stored directly there. When disabled, locations include products from all sub-locations."
|
||||
msgstr ""
|
||||
|
|
|
|||
|
|
@ -32,15 +32,15 @@ if (GetUriParam("include_out_of_stock"))
|
|||
$("#include-out-of-stock").prop("checked", false);
|
||||
}
|
||||
|
||||
$(document).on("change", "#leaf-locations-only", function()
|
||||
$(document).on("change", "#direct-content-only", function()
|
||||
{
|
||||
if (this.checked)
|
||||
{
|
||||
UpdateUriParam("leaf_locations_only", true);
|
||||
UpdateUriParam("direct_content_only", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveUriParam("leaf_locations_only");
|
||||
RemoveUriParam("direct_content_only");
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
|
|
|
|||
|
|
@ -53,15 +53,15 @@
|
|||
<div class="form-check custom-control custom-checkbox">
|
||||
<input class="form-check-input custom-control-input"
|
||||
type="checkbox"
|
||||
id="leaf-locations-only"
|
||||
@if($showLeafLocationsOnly) checked @endif>
|
||||
id="direct-content-only"
|
||||
@if($showDirectContentOnly) checked @endif>
|
||||
<label class="form-check-label custom-control-label"
|
||||
for="leaf-locations-only">
|
||||
{{ $__t('Show only leaf locations') }}
|
||||
for="direct-content-only">
|
||||
{{ $__t('Show direct content only') }}
|
||||
<i class="fa-solid fa-question-circle text-muted"
|
||||
data-toggle="tooltip"
|
||||
data-trigger="hover click"
|
||||
title="{{ $__t('When enabled, only locations without sub-locations are shown. When disabled, parent locations show aggregated content from all sub-locations.') }}"></i>
|
||||
title="{{ $__t('When enabled, each location shows only products stored directly there. When disabled, locations include products from all sub-locations.') }}"></i>
|
||||
</label>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
|
|
@ -88,23 +88,13 @@
|
|||
$locationsArray = iterator_to_array($locations);
|
||||
$locationsResolvedArray = iterator_to_array($locationsResolved);
|
||||
$stockContentArray = iterator_to_array($currentStockLocationContent);
|
||||
@endphp
|
||||
@endphp
|
||||
|
||||
@foreach($locationsArray as $location)
|
||||
@php
|
||||
// Determine if this location has children
|
||||
$hasChildren = count(array_filter($locationsArray, function($loc) use ($location) {
|
||||
return $loc->parent_location_id == $location->id;
|
||||
})) > 0;
|
||||
|
||||
// Flag to skip this location
|
||||
$skipLocation = $showLeafLocationsOnly && $hasChildren;
|
||||
|
||||
$currentStockEntriesForLocation = [];
|
||||
|
||||
if (!$skipLocation) {
|
||||
// Get stock entries for this location
|
||||
if ($showLeafLocationsOnly) {
|
||||
if ($showDirectContentOnly) {
|
||||
// Only show products directly at this location
|
||||
$currentStockEntriesForLocation = array_filter($stockContentArray, function($entry) use ($location) {
|
||||
return $entry->location_id == $location->id;
|
||||
|
|
@ -138,9 +128,8 @@
|
|||
}
|
||||
$currentStockEntriesForLocation = array_values($aggregatedEntries);
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
@if($skipLocation || count($currentStockEntriesForLocation) == 0)
|
||||
@if(count($currentStockEntriesForLocation) == 0)
|
||||
@continue
|
||||
@endif
|
||||
<div class="page">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user