From 4aa575e0e89635797e5586626deb6f726f7b42e5 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 27 Sep 2019 14:04:44 +0200 Subject: [PATCH] Display just "unlimited" on the product card for the average shelf life if it is > 200 years --- changelog/53_UNRELEASED_2019-xx-xx.md | 1 + localization/strings.pot | 3 +++ public/viewjs/components/productcard.js | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/changelog/53_UNRELEASED_2019-xx-xx.md b/changelog/53_UNRELEASED_2019-xx-xx.md index 69ca005b..a660fdea 100644 --- a/changelog/53_UNRELEASED_2019-xx-xx.md +++ b/changelog/53_UNRELEASED_2019-xx-xx.md @@ -6,6 +6,7 @@ - It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be "missing" then, only the parent product) - When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item - On the purchase page there is now an option to select that the price is the total price (for the whole amount) - below the price field, defaults to "Unit price" (as it was until now), when set to "Total price", the entered price will be divided by the amount before posting +- "Average shelf life" on the product card now displays just "Unlimited" when the resulting value would be > 200 years (for products which never expire, as they have a best before date of 2999-12-31) ### Recipe improvements/fixes - Fixed a problem regarding quantity unit conversion handling for recipe ingredients of products with no unit relations, but only a different purchase/stock quantity unit diff --git a/localization/strings.pot b/localization/strings.pot index 5593f8d7..181a7698 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1537,3 +1537,6 @@ msgstr "" msgid "in %s and based on the purchase quantity unit" msgstr "" + +msgid "Unlimited" +msgstr "" diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js index fa994310..48a2dcad 100644 --- a/public/viewjs/components/productcard.js +++ b/public/viewjs/components/productcard.js @@ -52,6 +52,10 @@ Grocy.Components.ProductCard.Refresh = function(productId) { $('#productcard-product-average-shelf-life').text(__t("Unknown")); } + else if (parseInt(productDetails.average_shelf_life_days) > 73000) // > 200 years aka forever + { + $('#productcard-product-average-shelf-life').text(__t("Unlimited")); + } else { $('#productcard-product-average-shelf-life').text(moment.duration(productDetails.average_shelf_life_days, "days").humanize());