From dae5bb2b34b88131c8516bdf6a76e0229c6830bc Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 3 May 2019 19:22:58 +0200 Subject: [PATCH] Make it possible to filter recipes by stock availability (closes #231) --- changelog/47_UNRELEASED_xxxx-xx-xx.md | 3 ++- localization/strings.pot | 6 ++++++ public/viewjs/recipes.js | 15 +++++++++++++++ views/recipes.blade.php | 22 ++++++++++++++++++++-- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/changelog/47_UNRELEASED_xxxx-xx-xx.md b/changelog/47_UNRELEASED_xxxx-xx-xx.md index dcb71605..74793629 100644 --- a/changelog/47_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/47_UNRELEASED_xxxx-xx-xx.md @@ -20,5 +20,6 @@ - This involved some string changes which results in a needed (re)translation of about 20 strings (excluding demo data) - Also applies to quantity units, n-plural forms can be entered on the quantity unit edit page - It's not required to install the PHP gettext extension, on both, server and client, managed implementations of gettext are used ([oscarotero/Gettext](https://github.com/oscarotero/Gettext) & [oscarotero/gettext-translator](https://github.com/oscarotero/gettext-translator)) -- Some other small fixes +- Some other small fixes and improvements - 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 diff --git a/localization/strings.pot b/localization/strings.pot index 570ff550..f09bb615 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1206,3 +1206,9 @@ msgstr "" msgid "The amount cannot be lower than %s or equal %s" msgstr "" + +msgid "Not enough in stock, but already on the shopping list" +msgstr "" + +msgid "Not enough in stock" +msgstr "" diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index 654849a3..c1dde598 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -59,6 +59,21 @@ $("#search").on("keyup", function() $(".recipe-gallery-item-container .card-title:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().parent().addClass("d-none"); }); +$("#status-filter").on("change", function() +{ + var value = $(this).val(); + if (value === "all") + { + value = ""; + } + + // Transfer CSS classes of selected element to dropdown element (for background) + $(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control"); + + recipesTables.column(4).search(value).draw(); +}); + + $("#selectedRecipeDeleteButton").on('click', function(e) { var objectName = $(e.currentTarget).attr('data-recipe-name'); diff --git a/views/recipes.blade.php b/views/recipes.blade.php index 6914a6f5..b37e5601 100644 --- a/views/recipes.blade.php +++ b/views/recipes.blade.php @@ -15,8 +15,22 @@ - - +
+
+ + +
+ +
+ + +
+