From da98efa8332bb56cb1823ae7e8b10d785ce4fcb3 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 27 Oct 2018 10:37:31 +0200 Subject: [PATCH] Finalize nested recipes / group recipe positions feature (closes #77) --- controllers/RecipesController.php | 2 +- localization/de.php | 6 +++++- public/viewjs/recipeform.js | 7 ++++++- services/DemoDataGeneratorService.php | 8 ++++---- views/recipeform.blade.php | 7 +++++++ views/recipeposform.blade.php | 2 +- views/recipes.blade.php | 7 ++++++- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/controllers/RecipesController.php b/controllers/RecipesController.php index 4b975d2f..192fe5ca 100644 --- a/controllers/RecipesController.php +++ b/controllers/RecipesController.php @@ -23,7 +23,7 @@ class RecipesController extends BaseController if (isset($request->getQueryParams()['recipe'])) { $selectedRecipe = $this->Database->recipes($request->getQueryParams()['recipe']); - $selectedRecipePositions = $this->Database->recipes_pos()->where('recipe_id', $request->getQueryParams()['recipe']); + $selectedRecipePositions = $this->Database->recipes_pos()->where('recipe_id', $request->getQueryParams()['recipe'])->orderBy('ingredient_group'); } else { diff --git a/localization/de.php b/localization/de.php index 2470808d..3b1cf5ad 100644 --- a/localization/de.php +++ b/localization/de.php @@ -284,6 +284,8 @@ return array( 'A recipe is required' => 'Ein Rezept ist erforderlich', 'Add included recipe' => 'Enthaltenes Rezept hinzufügen', 'Edit included recipe' => 'Enthaltenes Rezept bearbeiten', + 'Group' => 'Gruppe', + 'This will be used as a headline to group ingredients together' => 'Dies wird als Überschrift verwendet, um Zutaten zusammenzufassen', //Constants 'manually' => 'Manuell', @@ -376,5 +378,7 @@ return array( 'Milk' => 'Milch', 'Chocolate sauce' => 'Schokoladensoße', 'Milliliters' => 'Milliliter', - 'Milliliter' => 'Milliliter' + 'Milliliter' => 'Milliliter', + 'Bottom' => 'Boden', + 'Topping' => 'Belag' ); diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 66ea483b..54d16231 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -17,8 +17,10 @@ var recipesPosTables = $('#recipes-pos-table').DataTable({ 'paginate': false, 'order': [[1, 'asc']], + "orderFixed": [[4, 'asc']], 'columnDefs': [ - { 'orderable': false, 'targets': 0 } + { 'orderable': false, 'targets': 0 }, + { 'visible': false, 'targets': 4 } ], 'language': JSON.parse(L('datatables_localization')), 'scrollY': false, @@ -32,6 +34,9 @@ var recipesPosTables = $('#recipes-pos-table').DataTable({ { column.search.search = ""; }); + }, + 'rowGroup': { + dataSrc: 4 } }); diff --git a/services/DemoDataGeneratorService.php b/services/DemoDataGeneratorService.php index 6b494926..a9588e6b 100644 --- a/services/DemoDataGeneratorService.php +++ b/services/DemoDataGeneratorService.php @@ -78,10 +78,10 @@ class DemoDataGeneratorService extends BaseService INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Chocolate sauce')}', '{$loremIpsumWithHtmlFormattings}'); --5 INSERT INTO recipes (name, description) VALUES ('{$localizationService->Localize('Pancakes')} / {$localizationService->Localize('Chocolate sauce')}', '{$loremIpsumWithHtmlFormattings}'); --6 - INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (1, 16, 1); - INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (1, 17, 1); - INSERT INTO recipes_pos (recipe_id, product_id, amount, note) VALUES (1, 18, 1, '{$localizationService->Localize('This is the note content of the recipe ingredient')}'); - INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (1, 10, 1); + INSERT INTO recipes_pos (recipe_id, product_id, amount, ingredient_group) VALUES (1, 16, 1, '{$localizationService->Localize('Bottom')}'); + INSERT INTO recipes_pos (recipe_id, product_id, amount, ingredient_group) VALUES (1, 17, 1, '{$localizationService->Localize('Topping')}'); + INSERT INTO recipes_pos (recipe_id, product_id, amount, note, ingredient_group) VALUES (1, 18, 1, '{$localizationService->Localize('This is the note content of the recipe ingredient')}', '{$localizationService->Localize('Topping')}'); + INSERT INTO recipes_pos (recipe_id, product_id, amount, ingredient_group) VALUES (1, 10, 1, '{$localizationService->Localize('Bottom')}'); INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (2, 6, 1); INSERT INTO recipes_pos (recipe_id, product_id, amount) VALUES (2, 10, 1); INSERT INTO recipes_pos (recipe_id, product_id, amount, note) VALUES (2, 17, 1, '{$localizationService->Localize('This is the note content of the recipe ingredient')}'); diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index a9751dae..e7b8f8e9 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -11,10 +11,13 @@ @push('pageScripts') @if(!empty($L('summernote_locale')))@endif + + @endpush @push('pageStyles') + @endpush @section('content') @@ -66,6 +69,7 @@ {{ $L('Product') }} {{ $L('Amount') }} {{ $L('Note') }} + Hiden ingredient group @@ -95,6 +99,9 @@ + + {{ $recipePosition->ingredient_group }} + @endforeach @endif diff --git a/views/recipeposform.blade.php b/views/recipeposform.blade.php index 574f51fe..9dcb9119 100644 --- a/views/recipeposform.blade.php +++ b/views/recipeposform.blade.php @@ -69,7 +69,7 @@
- +
diff --git a/views/recipes.blade.php b/views/recipes.blade.php index e671be2c..f347da93 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -75,7 +75,11 @@
{{ $L('Ingredients') }}
@endif @@ -104,7 +109,7 @@ @php $lastGroup = 'undefined'; @endphp @foreach($selectedRecipePositions as $selectedRecipePosition) @if($lastGroup != $selectedRecipePosition->ingredient_group) -
{{ $selectedRecipePosition->ingredient_group }}
+
{{ $selectedRecipePosition->ingredient_group }}
@endif
  • {{ $selectedRecipePosition->amount }} {{ Pluralize($selectedRecipePosition->amount, FindObjectInArrayByPropertyValue($quantityunits, 'id', $selectedRecipePosition->qu_id)->name, FindObjectInArrayByPropertyValue($quantityunits, 'id', $selectedRecipePosition->qu_id)->name_plural) }} {{ FindObjectInArrayByPropertyValue($products, 'id', $selectedRecipePosition->product_id)->name }}