From 367a3e52dec276c55af1659d2ce89f4c046c2733 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 24 Nov 2018 19:59:24 +0100 Subject: [PATCH] Properly sort recipes fulfillment column (closes #113) --- public/viewjs/recipes.js | 3 +++ views/recipes.blade.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index d24131ae..2b46c16b 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -1,6 +1,9 @@ var recipesTables = $('#recipes-table').DataTable({ 'paginate': false, 'order': [[0, 'asc']], + 'columnDefs': [ + { 'orderData': 2, 'targets': 1 } + ], 'language': JSON.parse(L('datatables_localization')), 'scrollY': false, 'colReorder': true, diff --git a/views/recipes.blade.php b/views/recipes.blade.php index 3dc4552c..85f09de4 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -23,6 +23,7 @@ {{ $L('Name') }} {{ $L('Requirements fulfilled') }} + Hidden status for sorting of "Requirements fulfilled" column @@ -35,6 +36,9 @@ @if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1)@elseif(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1)@else@endif @if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1){{ $L('Enough in stock') }}@elseif(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1){{ $L('Not enough in stock, #1 ingredients missing but already on the shopping list', FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->missing_products_count) }}@else{{ $L('Not enough in stock, #1 ingredients missing', FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->missing_products_count) }}@endif + + @if(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled == 1) 1 @elseif(FindObjectInArrayByPropertyValue($recipesSumFulfillment, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) 2 @else 3 @endif + @endforeach