From b8f9d09afc9e23c08abb0ebac17512e31f33f605 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 26 Sep 2019 13:55:42 +0200 Subject: [PATCH] Don't remove products from stock overview on consuming all and the product has a min. stock amount & show it again on undo --- public/js/grocy.js | 13 +++++++++++++ public/viewjs/stockoverview.js | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/public/js/grocy.js b/public/js/grocy.js index 8d3e725e..a74f2502 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -298,8 +298,21 @@ RefreshContextualTimeago = function() $("time.timeago").each(function() { var element = $(this); + + if (!element.hasAttr("datetime")) + { + element.text("") + return + } + var timestamp = element.attr("datetime"); + if (timestamp.isEmpty()) + { + element.text("") + return + } + var isNever = timestamp && timestamp.substring(0, 10) == "2999-12-31"; var isToday = timestamp && timestamp.substring(0, 10) == moment().format("YYYY-MM-DD"); var isDateWithoutTime = element.hasClass("timeago-date-only"); diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index ac5d0788..d66f73c1 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -319,6 +319,9 @@ function RefreshProductRow(productId) productRow.removeClass("table-warning"); productRow.removeClass("table-danger"); + productRow.removeClass("table-info"); + productRow.removeClass("d-none"); + productRow.removeAttr("style"); if (now.isAfter(nextBestBeforeDate)) { productRow.addClass("table-danger"); @@ -328,12 +331,12 @@ function RefreshProductRow(productId) productRow.addClass("table-warning"); } - if (result.stock_amount <= 0) + if (result.stock_amount == 0 && result.product.min_stock_amount == 0) { $('#product-' + productId + '-row').fadeOut(500, function() { $(this).tooltip("hide"); - $(this).remove(); + $(this).addClass("d-none"); }); } else @@ -366,6 +369,11 @@ function RefreshProductRow(productId) $(this).text("").fadeIn(500); } }); + + if (result.stock_amount == 0 && result.product.min_stock_amount > 0) + { + productRow.addClass("table-info"); + } } $('#product-' + productId + '-next-best-before-date').parent().effect('highlight', {}, 500);