From 02163c4305ee07eea5af240c481a0f1da464249f Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 26 Nov 2018 19:47:07 +0100 Subject: [PATCH] Properly refresh opened product amount after consume on stock overview page (fixes #114) --- public/viewjs/stockoverview.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 649cf538..d150873b 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -135,6 +135,20 @@ $(document).on('click', '.product-consume-button', function(e) $(this).text(result.next_best_before_date).fadeIn(500); }); $('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date); + + var openedAmount = result.stock_amount_opened || 0; + $('#product-' + productId + '-opened-amount').parent().effect('highlight', {}, 500); + $('#product-' + productId + '-opened-amount').fadeOut(500, function () + { + if (openedAmount > 0) + { + $(this).text(L('#1 opened', openedAmount)).fadeIn(500); + } + else + { + $(this).text("").fadeIn(500); + } + }); } Grocy.FrontendHelpers.EndUiBusy();