diff --git a/config-dist.php b/config-dist.php index 4402f82b..c68fb6b6 100644 --- a/config-dist.php +++ b/config-dist.php @@ -41,6 +41,8 @@ Setting('STOCK_BARCODE_LOOKUP_PLUGIN', 'DemoBarcodeLookupPlugin'); Setting('DISABLE_URL_REWRITING', false); + + # Default user settings # These settings can be changed per user, here the defaults # are defined which are used when the user has not changed the setting so far @@ -67,3 +69,19 @@ DefaultUserSetting('show_clock_in_header', false); # Automatically do the booking using the last price and the amount # of the shopping list item, if the product has "Default best before days" set DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); + + + + +# Feature flags +# grocy was initially about "stock management for your household", many other things +# 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 +# (set the setting to "false" to disable the corresponding part, which should be self explanatory) +Setting('FEATURE_FLAG_SHOPPINGLIST', true); +Setting('FEATURE_FLAG_RECIPES', true); +Setting('FEATURE_FLAG_CHORES', true); +Setting('FEATURE_FLAG_TASKS', true); +Setting('FEATURE_FLAG_BATTERIES', true); +Setting('FEATURE_FLAG_EQUIPMENT', true); +Setting('FEATURE_FLAG_CALENDAR', true); diff --git a/routes.php b/routes.php index b4f91538..a66f656b 100644 --- a/routes.php +++ b/routes.php @@ -34,43 +34,64 @@ $app->group('', function() $this->get('/quantityunit/{quantityunitId}', '\Grocy\Controllers\StockController:QuantityUnitEditForm'); $this->get('/productgroups', '\Grocy\Controllers\StockController:ProductGroupsList'); $this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm'); - $this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList'); - $this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); $this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal'); + // Shopping list routes + if (GROCY_FEATURE_FLAG_SHOPPINGLIST) + { + $this->get('/shoppinglist', '\Grocy\Controllers\StockController:ShoppingList'); + $this->get('/shoppinglistitem/{itemId}', '\Grocy\Controllers\StockController:ShoppingListItemEditForm'); + } + // Recipe routes - $this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview'); - $this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm'); - $this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm'); + if (GROCY_FEATURE_FLAG_RECIPES) + { + $this->get('/recipes', '\Grocy\Controllers\RecipesController:Overview'); + $this->get('/recipe/{recipeId}', '\Grocy\Controllers\RecipesController:RecipeEditForm'); + $this->get('/recipe/{recipeId}/pos/{recipePosId}', '\Grocy\Controllers\RecipesController:RecipePosEditForm'); + } // Chore routes - $this->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview'); - $this->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution'); - $this->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal'); - - $this->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList'); - $this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm'); + if (GROCY_FEATURE_FLAG_CHORES) + { + $this->get('/choresoverview', '\Grocy\Controllers\ChoresController:Overview'); + $this->get('/choretracking', '\Grocy\Controllers\ChoresController:TrackChoreExecution'); + $this->get('/choresjournal', '\Grocy\Controllers\ChoresController:Journal'); + $this->get('/chores', '\Grocy\Controllers\ChoresController:ChoresList'); + $this->get('/chore/{choreId}', '\Grocy\Controllers\ChoresController:ChoreEditForm'); + } // Battery routes - $this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview'); - $this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle'); - $this->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal'); - - $this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList'); - $this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm'); + if (GROCY_FEATURE_FLAG_BATTERIES) + { + $this->get('/batteriesoverview', '\Grocy\Controllers\BatteriesController:Overview'); + $this->get('/batterytracking', '\Grocy\Controllers\BatteriesController:TrackChargeCycle'); + $this->get('/batteriesjournal', '\Grocy\Controllers\BatteriesController:Journal'); + $this->get('/batteries', '\Grocy\Controllers\BatteriesController:BatteriesList'); + $this->get('/battery/{batteryId}', '\Grocy\Controllers\BatteriesController:BatteryEditForm'); + } // Task routes - $this->get('/tasks', '\Grocy\Controllers\TasksController:Overview'); - $this->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm'); - $this->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList'); - $this->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm'); + if (GROCY_FEATURE_FLAG_TASKS) + { + $this->get('/tasks', '\Grocy\Controllers\TasksController:Overview'); + $this->get('/task/{taskId}', '\Grocy\Controllers\TasksController:TaskEditForm'); + $this->get('/taskcategories', '\Grocy\Controllers\TasksController:TaskCategoriesList'); + $this->get('/taskcategory/{categoryId}', '\Grocy\Controllers\TasksController:TaskCategoryEditForm'); + } // Equipment routes - $this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview'); - $this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm'); - - // Other routes - $this->get('/calendar', '\Grocy\Controllers\CalendarController:Overview'); + if (GROCY_FEATURE_FLAG_EQUIPMENT) + { + $this->get('/equipment', '\Grocy\Controllers\EquipmentController:Overview'); + $this->get('/equipment/{equipmentId}', '\Grocy\Controllers\EquipmentController:EditForm'); + } + + // Calendar routes + if (GROCY_FEATURE_FLAG_CALENDAR) + { + $this->get('/calendar', '\Grocy\Controllers\CalendarController:Overview'); + } // OpenAPI routes $this->get('/api', '\Grocy\Controllers\OpenApiController:DocumentationUi'); @@ -120,30 +141,47 @@ $app->group('/api', function() $this->post('/stock/products/{productId}/consume', '\Grocy\Controllers\StockApiController:ConsumeProduct'); $this->post('/stock/products/{productId}/inventory', '\Grocy\Controllers\StockApiController:InventoryProduct'); $this->post('/stock/products/{productId}/open', '\Grocy\Controllers\StockApiController:OpenProduct'); - $this->post('/stock/shoppinglist/add-missing-products', '\Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList'); - $this->post('/stock/shoppinglist/clear', '\Grocy\Controllers\StockApiController:ClearShoppingList'); $this->post('/stock/bookings/{bookingId}/undo', '\Grocy\Controllers\StockApiController:UndoBooking'); $this->get('/stock/barcodes/external-lookup', '\Grocy\Controllers\StockApiController:ExternalBarcodeLookup'); + // Shopping list + if (GROCY_FEATURE_FLAG_SHOPPINGLIST) + { + $this->post('/stock/shoppinglist/add-missing-products', '\Grocy\Controllers\StockApiController:AddMissingProductsToShoppingList'); + $this->post('/stock/shoppinglist/clear', '\Grocy\Controllers\StockApiController:ClearShoppingList'); + } + // Recipes - $this->post('/recipes/{recipeId}/add-not-fulfilled-products-to-shoppinglist', '\Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList'); - $this->post('/recipes/{recipeId}/consume', '\Grocy\Controllers\RecipesApiController:ConsumeRecipe'); + if (GROCY_FEATURE_FLAG_RECIPES) + { + $this->post('/recipes/{recipeId}/add-not-fulfilled-products-to-shoppinglist', '\Grocy\Controllers\RecipesApiController:AddNotFulfilledProductsToShoppingList'); + $this->post('/recipes/{recipeId}/consume', '\Grocy\Controllers\RecipesApiController:ConsumeRecipe'); + } // Chores - $this->get('/chores', '\Grocy\Controllers\ChoresApiController:Current'); - $this->get('/chores/{choreId}', '\Grocy\Controllers\ChoresApiController:ChoreDetails'); - $this->post('/chores/{choreId}/execute', '\Grocy\Controllers\ChoresApiController:TrackChoreExecution'); - $this->post('/chores/executions/{executionId}/undo', '\Grocy\Controllers\ChoresApiController:UndoChoreExecution'); + if (GROCY_FEATURE_FLAG_CHORES) + { + $this->get('/chores', '\Grocy\Controllers\ChoresApiController:Current'); + $this->get('/chores/{choreId}', '\Grocy\Controllers\ChoresApiController:ChoreDetails'); + $this->post('/chores/{choreId}/execute', '\Grocy\Controllers\ChoresApiController:TrackChoreExecution'); + $this->post('/chores/executions/{executionId}/undo', '\Grocy\Controllers\ChoresApiController:UndoChoreExecution'); + } // Batteries - $this->get('/batteries', '\Grocy\Controllers\BatteriesApiController:Current'); - $this->get('/batteries/{batteryId}', '\Grocy\Controllers\BatteriesApiController:BatteryDetails'); - $this->post('/batteries/{batteryId}/charge', '\Grocy\Controllers\BatteriesApiController:TrackChargeCycle'); - $this->post('/batteries/charge-cycles/{chargeCycleId}/undo', '\Grocy\Controllers\BatteriesApiController:UndoChargeCycle'); + if (GROCY_FEATURE_FLAG_BATTERIES) + { + $this->get('/batteries', '\Grocy\Controllers\BatteriesApiController:Current'); + $this->get('/batteries/{batteryId}', '\Grocy\Controllers\BatteriesApiController:BatteryDetails'); + $this->post('/batteries/{batteryId}/charge', '\Grocy\Controllers\BatteriesApiController:TrackChargeCycle'); + $this->post('/batteries/charge-cycles/{chargeCycleId}/undo', '\Grocy\Controllers\BatteriesApiController:UndoChargeCycle'); + } // Tasks - $this->get('/tasks', '\Grocy\Controllers\TasksApiController:Current'); - $this->post('/tasks/{taskId}/complete', '\Grocy\Controllers\TasksApiController:MarkTaskAsCompleted'); + if (GROCY_FEATURE_FLAG_TASKS) + { + $this->get('/tasks', '\Grocy\Controllers\TasksApiController:Current'); + $this->post('/tasks/{taskId}/complete', '\Grocy\Controllers\TasksApiController:MarkTaskAsCompleted'); + } })->add(new ApiKeyAuthMiddleware($appContainer, $appContainer->LoginControllerInstance->GetSessionCookieName(), $appContainer->ApiKeyHeaderName)) ->add(JsonMiddleware::class) ->add(new CorsMiddleware([ diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 8517ec60..59899d80 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -69,42 +69,54 @@ {{ $L('Stock overview') }} + @if(GROCY_FEATURE_FLAG_SHOPPINGLIST) + @endif + @if(GROCY_FEATURE_FLAG_RECIPES) + @endif + @if(GROCY_FEATURE_FLAG_CHORES) + @endif + @if(GROCY_FEATURE_FLAG_TASKS) + @endif + @if(GROCY_FEATURE_FLAG_BATTERIES) + @endif + @if(GROCY_FEATURE_FLAG_EQUIPMENT) + @endif + @if(GROCY_FEATURE_FLAG_CHORES) + @endif + @if(GROCY_FEATURE_FLAG_BATTERIES) + @endif + @if(GROCY_FEATURE_FLAG_CALENDAR) + @endif + @if(GROCY_FEATURE_FLAG_CHORES)
  • {{ $L('Chores') }}
  • + @endif + @if(GROCY_FEATURE_FLAG_BATTERIES)
  • {{ $L('Batteries') }}
  • + @endif + @if(GROCY_FEATURE_FLAG_TASKS)
  • {{ $L('Task categories') }}
  • + @endif diff --git a/views/stocksettings.blade.php b/views/stocksettings.blade.php index bd93ee38..02e7c941 100644 --- a/views/stocksettings.blade.php +++ b/views/stocksettings.blade.php @@ -43,6 +43,7 @@ + @if(GROCY_FEATURE_FLAG_SHOPPINGLIST)

    {{ $L('Shopping list to stock workflow') }}

    @@ -52,6 +53,7 @@
    + @endif {{ $L('OK') }}