Fix Location Content Sheet filter checkbox

Previously, the query parameter functioned as expected, but the
checkbox always appeared checked. Additionally, clicking the checkbox
would always result in the "unchecked" state despite remaining visually
checked.

This adds the required context to the controller and an @if directive to
the checkbox's checked attribute in the view to match.
This commit is contained in:
David Mouse 2025-02-06 03:12:11 -05:00
parent ebcc9a422e
commit 40ed85f096
2 changed files with 3 additions and 2 deletions

View File

@ -93,7 +93,8 @@ class StockController extends BaseController
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock']))
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock'])),
'includeOutOfStockProductsAtTheDefaultLocation' => isset($request->getQueryParams()['include_out_of_stock'])
]);
}

View File

@ -40,7 +40,7 @@
<input class="form-check-input custom-control-input"
type="checkbox"
id="include-out-of-stock"
checked>
@if(!$includeOutOfStockProductsAtTheDefaultLocation) checked @endif>
<label class="form-check-label custom-control-label"
for="include-out-of-stock">
{{ $__t('Show only in stock products') }}