mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Show product count per group on the product groups page and added a link to the products page filtered by the current product group (closes #174)
This commit is contained in:
parent
40cc0ff280
commit
886e272c03
@ -92,7 +92,8 @@ class StockController extends BaseController
|
||||
public function ProductGroupsList(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->AppContainer->view->render($response, 'productgroups', [
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name')
|
||||
'productGroups' => $this->Database->product_groups()->orderBy('name'),
|
||||
'products' => $this->Database->products()->orderBy('name')
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,23 @@ $("#search").on("keyup", function()
|
||||
productsTable.search(value).draw();
|
||||
});
|
||||
|
||||
$("#product-group-filter").on("change", function()
|
||||
{
|
||||
var value = $("#product-group-filter option:selected").text();
|
||||
if (value === L("All"))
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
productsTable.column(7).search(value).draw();
|
||||
});
|
||||
|
||||
if (typeof GetUriParam("product-group") !== "undefined")
|
||||
{
|
||||
$("#product-group-filter").val(GetUriParam("product-group"));
|
||||
$("#product-group-filter").trigger("change");
|
||||
}
|
||||
|
||||
$(document).on('click', '.product-delete-button', function (e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-product-name');
|
||||
|
@ -31,6 +31,7 @@
|
||||
<th class="border-right"></th>
|
||||
<th>{{ $L('Name') }}</th>
|
||||
<th>{{ $L('Description') }}</th>
|
||||
<th>{{ $L('Product count') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="d-none">
|
||||
@ -50,6 +51,12 @@
|
||||
<td>
|
||||
{{ $productGroup->description }}
|
||||
</td>
|
||||
<td>
|
||||
{{ count(FindAllObjectsInArrayByPropertyValue($products, 'product_group_id', $productGroup->id)) }}
|
||||
<a class="btn btn-link btn-sm text-body" href="{{ $U('/products?product-group=') . $productGroup->id }}">
|
||||
<i class="fas fa-external-link-alt"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
@ -24,6 +24,15 @@
|
||||
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
|
||||
<input type="text" class="form-control" id="search">
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 col-xl-3">
|
||||
<label for="location-filter">{{ $L('Filter by product group') }}</label> <i class="fas fa-filter"></i>
|
||||
<select class="form-control" id="product-group-filter">
|
||||
<option value="all">{{ $L('All') }}</option>
|
||||
@foreach($productGroups as $productGroup)
|
||||
<option value="{{ $productGroup->id }}">{{ $productGroup->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
Loading…
x
Reference in New Issue
Block a user