diff --git a/changelog/67_UNRELEASED_xxxx-xx-xx.md b/changelog/67_UNRELEASED_xxxx-xx-xx.md index 4b6ba761..17ef3b74 100644 --- a/changelog/67_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/67_UNRELEASED_xxxx-xx-xx.md @@ -61,6 +61,7 @@ - Fixed that calories of recipe ingredients were displayed with an indefinite number of decimal places - Fixed that ingredient amounts were wrong for multi-nested (> 2 levels) recipes, when the included recipe used an serving amount other than 1 - Fixed that searching/filtering the recipe gallery view did not work correctly +- Fixed that searching/filtering recipes by products did not work (e.g. via the context-/more menu option "Search for recipes containing this product" on the stock overview page) ### Meal plan diff --git a/migrations/0181.sql b/migrations/0181.sql index 410897ca..dab0f6bc 100644 --- a/migrations/0181.sql +++ b/migrations/0181.sql @@ -72,7 +72,8 @@ SELECT WHEN 'overdue' THEN 10 WHEN 'expired' THEN 20 END AS due_score, - IFNULL(pcs.product_id_effective, rp.product_id) AS product_id_effective + IFNULL(pcs.product_id_effective, rp.product_id) AS product_id_effective, + p.name AS product_name FROM recipes r JOIN recipes_nestings_resolved rnr ON r.id = rnr.recipe_id @@ -138,7 +139,8 @@ SELECT WHEN 'overdue' THEN 10 WHEN 'expired' THEN 20 END AS due_score, - IFNULL(pcs.product_id_effective, rp.product_id) AS product_id_effective + IFNULL(pcs.product_id_effective, rp.product_id) AS product_id_effective, + p.name AS product_name FROM recipes r JOIN recipes_nestings_resolved rnr ON r.id = rnr.recipe_id @@ -170,3 +172,24 @@ LEFT JOIN products_current_price pcp LEFT JOIN products p_effective ON IFNULL(pcs.product_id_effective, rp.product_id) = p_effective.id WHERE rp.not_check_stock_fulfillment = 1; + +DROP VIEW recipes_resolved; +CREATE VIEW recipes_resolved +AS +SELECT + 1 AS id, -- Dummy, LessQL needs an id column + r.id AS recipe_id, + IFNULL(MIN(rpr.need_fulfilled), 1) AS need_fulfilled, + IFNULL(MIN(rpr.need_fulfilled_with_shopping_list), 1) AS need_fulfilled_with_shopping_list, + IFNULL(rmpc.missing_products_count, 0) AS missing_products_count, + IFNULL(SUM(rpr.costs), 0) AS costs, + IFNULL(SUM(rpr.costs) / CASE WHEN IFNULL(r.desired_servings, 0) = 0 THEN 1 ELSE r.desired_servings END, 0) AS costs_per_serving, + IFNULL(SUM(rpr.calories), 0) AS calories, + IFNULL(SUM(rpr.due_score), 0) AS due_score, + GROUP_CONCAT(rpr.product_name) AS product_names_comma_separated +FROM recipes r +LEFT JOIN recipes_pos_resolved rpr + ON r.id = rpr.recipe_id +LEFT JOIN recipes_missing_product_counts rmpc + ON r.id = rmpc.recipe_id +GROUP BY r.id; diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index 2fd9447f..ff0c4205 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -82,7 +82,7 @@ $("#search").on("keyup", Delay(function() } $(".recipe-gallery-item").removeClass("d-none"); - $(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().addClass("d-none"); + $(".recipe-gallery-item .card-title-search:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().addClass("d-none"); }, 200)); $("#clear-filter-button").on("click", function() diff --git a/views/recipes.blade.php b/views/recipes.blade.php index c566ced6..be595a92 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -207,9 +207,7 @@ @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 1) Xenoughinstock @elseif(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) enoughinstockwithshoppinglist @else notenoughinstock @endif
@if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 1)@elseif(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1)@else@endif @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 1){{ $__t('Enough in stock') }}@elseif(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1){{ $__n(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->missing_products_count, 'Not enough in stock, %s ingredient missing but already on the shopping list', 'Not enough in stock, %s ingredients missing but already on the shopping list') }}@else{{ $__n(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->missing_products_count, 'Not enough in stock, %s ingredient missing', 'Not enough in stock, %s ingredients missing') }}@endif