Show amount of opened products on stock overview page and in product card

This commit is contained in:
Bernd Bestel
2018-11-18 13:17:36 +01:00
parent 5966a3d678
commit a403bb687a
7 changed files with 34 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
function(productDetails)
{
var stockAmount = productDetails.stock_amount || '0';
var stockAmountOpened = productDetails.stock_amount_opened || '0';
$('#productcard-product-name').text(productDetails.product.name);
$('#productcard-product-stock-amount').text(stockAmount);
$('#productcard-product-stock-qu-name').text(productDetails.quantity_unit_stock.name);
@@ -15,6 +16,15 @@ Grocy.Components.ProductCard.Refresh = function(productId)
$('#productcard-product-last-used').text((productDetails.last_used || L('never')).substring(0, 10));
$('#productcard-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
if (stockAmountOpened > 0)
{
$('#productcard-product-stock-opened-amount').text(L('#1 opened', stockAmountOpened));
}
else
{
$('#productcard-product-stock-opened-amount').text("");
}
$('#productcard-product-edit-button').attr("href", U("/product/" + productDetails.product.id.toString()));
$('#productcard-product-edit-button').removeClass("disabled");

View File

@@ -193,6 +193,12 @@ $(document).on('click', '.product-open-button', function(e)
});
$('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date);
$('#product-' + productId + '-opened-amount').parent().effect('highlight', {}, 500);
$('#product-' + productId + '-opened-amount').fadeOut(500, function ()
{
$(this).text(L('#1 opened', result.stock_amount_opened)).fadeIn(500);
});
toastr.success(L('Marked #1 #2 of #3 as opened', 1, productQuName, productName));
RefreshContextualTimeago();
RefreshStatistics();