mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 03:04:36 +00:00
Added a feature flag to also be able to hide all stock related UI elements and routes (closes #228)
This commit is contained in:
@@ -23,3 +23,4 @@
|
|||||||
- Some other small fixes and improvements
|
- Some other small fixes and improvements
|
||||||
- The "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product
|
- The "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product
|
||||||
- Recipes can now be filter by stock availability
|
- Recipes can now be filter by stock availability
|
||||||
|
- Added a feature flag (`config.php` setting) to also be able to hide all stock related UI elements and routes
|
||||||
|
@@ -91,6 +91,7 @@ DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled',
|
|||||||
# came and still come by, because they are useful - here you can disable the parts
|
# came and still come by, because they are useful - here you can disable the parts
|
||||||
# which you don't need to have a less cluttered UI
|
# which you don't need to have a less cluttered UI
|
||||||
# (set the setting to "false" to disable the corresponding part, which should be self explanatory)
|
# (set the setting to "false" to disable the corresponding part, which should be self explanatory)
|
||||||
|
Setting('FEATURE_FLAG_STOCK', true);
|
||||||
Setting('FEATURE_FLAG_SHOPPINGLIST', true);
|
Setting('FEATURE_FLAG_SHOPPINGLIST', true);
|
||||||
Setting('FEATURE_FLAG_RECIPES', true);
|
Setting('FEATURE_FLAG_RECIPES', true);
|
||||||
Setting('FEATURE_FLAG_CHORES', true);
|
Setting('FEATURE_FLAG_CHORES', true);
|
||||||
|
@@ -28,7 +28,7 @@ class SystemController extends BaseController
|
|||||||
$demoDataGeneratorService->PopulateDemoData();
|
$demoDataGeneratorService->PopulateDemoData();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/stockoverview'));
|
return $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl($this->GetEntryPageRelative()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
public function About(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
@@ -38,4 +38,24 @@ class SystemController extends BaseController
|
|||||||
'changelog' => $this->ApplicationService->GetChangelog()
|
'changelog' => $this->ApplicationService->GetChangelog()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function GetEntryPageRelative()
|
||||||
|
{
|
||||||
|
$entryPage = '/stockoverview';
|
||||||
|
|
||||||
|
if (!GROCY_FEATURE_FLAG_STOCK)
|
||||||
|
{
|
||||||
|
$entryPage = '/choresoverview';
|
||||||
|
}
|
||||||
|
if (!GROCY_FEATURE_FLAG_CHORES)
|
||||||
|
{
|
||||||
|
$entryPage = '/batteriesoverview';
|
||||||
|
}
|
||||||
|
if (!GROCY_FEATURE_FLAG_BATTERIES)
|
||||||
|
{
|
||||||
|
$entryPage = '/equipment';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $entryPage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
58
routes.php
58
routes.php
@@ -25,20 +25,23 @@ $app->group('', function()
|
|||||||
$this->get('/user/{userId}', '\Grocy\Controllers\UsersController:UserEditForm');
|
$this->get('/user/{userId}', '\Grocy\Controllers\UsersController:UserEditForm');
|
||||||
|
|
||||||
// Stock routes
|
// Stock routes
|
||||||
$this->get('/stockoverview', '\Grocy\Controllers\StockController:Overview');
|
if (GROCY_FEATURE_FLAG_STOCK)
|
||||||
$this->get('/purchase', '\Grocy\Controllers\StockController:Purchase');
|
{
|
||||||
$this->get('/consume', '\Grocy\Controllers\StockController:Consume');
|
$this->get('/stockoverview', '\Grocy\Controllers\StockController:Overview');
|
||||||
$this->get('/inventory', '\Grocy\Controllers\StockController:Inventory');
|
$this->get('/purchase', '\Grocy\Controllers\StockController:Purchase');
|
||||||
$this->get('/products', '\Grocy\Controllers\StockController:ProductsList');
|
$this->get('/consume', '\Grocy\Controllers\StockController:Consume');
|
||||||
$this->get('/product/{productId}', '\Grocy\Controllers\StockController:ProductEditForm');
|
$this->get('/inventory', '\Grocy\Controllers\StockController:Inventory');
|
||||||
$this->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings');
|
$this->get('/products', '\Grocy\Controllers\StockController:ProductsList');
|
||||||
$this->get('/locations', '\Grocy\Controllers\StockController:LocationsList');
|
$this->get('/product/{productId}', '\Grocy\Controllers\StockController:ProductEditForm');
|
||||||
$this->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm');
|
$this->get('/stocksettings', '\Grocy\Controllers\StockController:StockSettings');
|
||||||
$this->get('/quantityunits', '\Grocy\Controllers\StockController:QuantityUnitsList');
|
$this->get('/locations', '\Grocy\Controllers\StockController:LocationsList');
|
||||||
$this->get('/quantityunit/{quantityunitId}', '\Grocy\Controllers\StockController:QuantityUnitEditForm');
|
$this->get('/location/{locationId}', '\Grocy\Controllers\StockController:LocationEditForm');
|
||||||
$this->get('/productgroups', '\Grocy\Controllers\StockController:ProductGroupsList');
|
$this->get('/quantityunits', '\Grocy\Controllers\StockController:QuantityUnitsList');
|
||||||
$this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm');
|
$this->get('/quantityunit/{quantityunitId}', '\Grocy\Controllers\StockController:QuantityUnitEditForm');
|
||||||
$this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
|
$this->get('/productgroups', '\Grocy\Controllers\StockController:ProductGroupsList');
|
||||||
|
$this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm');
|
||||||
|
$this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal');
|
||||||
|
}
|
||||||
|
|
||||||
// Shopping list routes
|
// Shopping list routes
|
||||||
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
||||||
@@ -142,18 +145,21 @@ $app->group('/api', function()
|
|||||||
$this->put('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:SetUserSetting');
|
$this->put('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:SetUserSetting');
|
||||||
|
|
||||||
// Stock
|
// Stock
|
||||||
$this->get('/stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
if (GROCY_FEATURE_FLAG_STOCK)
|
||||||
$this->get('/stock/volatile', '\Grocy\Controllers\StockApiController:CurrentVolatilStock');
|
{
|
||||||
$this->get('/stock/products/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
$this->get('/stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
||||||
$this->get('/stock/products/by-barcode/{barcode}', '\Grocy\Controllers\StockApiController:ProductDetailsByBarcode');
|
$this->get('/stock/volatile', '\Grocy\Controllers\StockApiController:CurrentVolatilStock');
|
||||||
$this->get('/stock/products/{productId}/entries', '\Grocy\Controllers\StockApiController:ProductStockEntries');
|
$this->get('/stock/products/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
||||||
$this->get('/stock/products/{productId}/price-history', '\Grocy\Controllers\StockApiController:ProductPriceHistory');
|
$this->get('/stock/products/by-barcode/{barcode}', '\Grocy\Controllers\StockApiController:ProductDetailsByBarcode');
|
||||||
$this->post('/stock/products/{productId}/add', '\Grocy\Controllers\StockApiController:AddProduct');
|
$this->get('/stock/products/{productId}/entries', '\Grocy\Controllers\StockApiController:ProductStockEntries');
|
||||||
$this->post('/stock/products/{productId}/consume', '\Grocy\Controllers\StockApiController:ConsumeProduct');
|
$this->get('/stock/products/{productId}/price-history', '\Grocy\Controllers\StockApiController:ProductPriceHistory');
|
||||||
$this->post('/stock/products/{productId}/inventory', '\Grocy\Controllers\StockApiController:InventoryProduct');
|
$this->post('/stock/products/{productId}/add', '\Grocy\Controllers\StockApiController:AddProduct');
|
||||||
$this->post('/stock/products/{productId}/open', '\Grocy\Controllers\StockApiController:OpenProduct');
|
$this->post('/stock/products/{productId}/consume', '\Grocy\Controllers\StockApiController:ConsumeProduct');
|
||||||
$this->post('/stock/bookings/{bookingId}/undo', '\Grocy\Controllers\StockApiController:UndoBooking');
|
$this->post('/stock/products/{productId}/inventory', '\Grocy\Controllers\StockApiController:InventoryProduct');
|
||||||
$this->get('/stock/barcodes/external-lookup', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
$this->post('/stock/products/{productId}/open', '\Grocy\Controllers\StockApiController:OpenProduct');
|
||||||
|
$this->post('/stock/bookings/{bookingId}/undo', '\Grocy\Controllers\StockApiController:UndoBooking');
|
||||||
|
$this->get('/stock/barcodes/external-lookup', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup');
|
||||||
|
}
|
||||||
|
|
||||||
// Shopping list
|
// Shopping list
|
||||||
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
if (GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
||||||
|
@@ -75,12 +75,14 @@
|
|||||||
<div id="sidebarResponsive" class="collapse navbar-collapse">
|
<div id="sidebarResponsive" class="collapse navbar-collapse">
|
||||||
<ul class="navbar-nav navbar-sidenav pt-2">
|
<ul class="navbar-nav navbar-sidenav pt-2">
|
||||||
|
|
||||||
|
@if(GROCY_FEATURE_FLAG_STOCK)
|
||||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Stock overview') }}" data-nav-for-page="stockoverview">
|
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Stock overview') }}" data-nav-for-page="stockoverview">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/stockoverview') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/stockoverview') }}">
|
||||||
<i class="fas fa-box"></i>
|
<i class="fas fa-box"></i>
|
||||||
<span class="nav-link-text">{{ $__t('Stock overview') }}</span>
|
<span class="nav-link-text">{{ $__t('Stock overview') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@endif
|
||||||
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
@if(GROCY_FEATURE_FLAG_SHOPPINGLIST)
|
||||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Shopping list') }}" data-nav-for-page="shoppinglist">
|
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Shopping list') }}" data-nav-for-page="shoppinglist">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/shoppinglist') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/shoppinglist') }}">
|
||||||
@@ -130,6 +132,7 @@
|
|||||||
</li>
|
</li>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if(GROCY_FEATURE_FLAG_STOCK)
|
||||||
<li class="nav-item mt-4" data-toggle="tooltip" data-placement="right" title="{{ $__t('Purchase') }}" data-nav-for-page="purchase">
|
<li class="nav-item mt-4" data-toggle="tooltip" data-placement="right" title="{{ $__t('Purchase') }}" data-nav-for-page="purchase">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/purchase') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/purchase') }}">
|
||||||
<i class="fas fa-shopping-cart"></i>
|
<i class="fas fa-shopping-cart"></i>
|
||||||
@@ -148,6 +151,7 @@
|
|||||||
<span class="nav-link-text">{{ $__t('Inventory') }}</span>
|
<span class="nav-link-text">{{ $__t('Inventory') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@endif
|
||||||
@if(GROCY_FEATURE_FLAG_CHORES)
|
@if(GROCY_FEATURE_FLAG_CHORES)
|
||||||
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Chore tracking') }}" data-nav-for-page="choretracking">
|
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $__t('Chore tracking') }}" data-nav-for-page="choretracking">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/choretracking') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/choretracking') }}">
|
||||||
@@ -179,6 +183,7 @@
|
|||||||
<span class="nav-link-text">{{ $__t('Manage master data') }}</span>
|
<span class="nav-link-text">{{ $__t('Manage master data') }}</span>
|
||||||
</a>
|
</a>
|
||||||
<ul id="top-nav-manager-master-data" class="sidenav-second-level collapse">
|
<ul id="top-nav-manager-master-data" class="sidenav-second-level collapse">
|
||||||
|
@if(GROCY_FEATURE_FLAG_STOCK)
|
||||||
<li data-nav-for-page="products" data-sub-menu-of="#top-nav-manager-master-data">
|
<li data-nav-for-page="products" data-sub-menu-of="#top-nav-manager-master-data">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/products') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/products') }}">
|
||||||
<i class="fab fa-product-hunt"></i>
|
<i class="fab fa-product-hunt"></i>
|
||||||
@@ -203,6 +208,7 @@
|
|||||||
<span class="nav-link-text">{{ $__t('Product groups') }}</span>
|
<span class="nav-link-text">{{ $__t('Product groups') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@endif
|
||||||
@if(GROCY_FEATURE_FLAG_CHORES)
|
@if(GROCY_FEATURE_FLAG_CHORES)
|
||||||
<li data-nav-for-page="chores" data-sub-menu-of="#top-nav-manager-master-data">
|
<li data-nav-for-page="chores" data-sub-menu-of="#top-nav-manager-master-data">
|
||||||
<a class="nav-link discrete-link" href="{{ $U('/chores') }}">
|
<a class="nav-link discrete-link" href="{{ $U('/chores') }}">
|
||||||
|
Reference in New Issue
Block a user