Added that products can now also be consumed as spoiled from the stock overview page (option in the more/context menu per line) (closes #251)

This commit is contained in:
Bernd Bestel
2019-07-06 18:15:53 +02:00
parent b24683f954
commit 8c205941c7
4 changed files with 21 additions and 2 deletions

View File

@@ -90,8 +90,9 @@ $(document).on('click', '.product-consume-button', function(e)
var productId = $(e.currentTarget).attr('data-product-id');
var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
var wasSpoiled = $(e.currentTarget).hasClass("product-consume-button-spoiled");
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount },
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled },
function()
{
Grocy.Api.Get('stock/products/' + productId,
@@ -155,8 +156,14 @@ $(document).on('click', '.product-consume-button', function(e)
});
}
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name);
if (wasSpoiled)
{
toastMessage += " (" + __t("Spoiled") + ")";
}
Grocy.FrontendHelpers.EndUiBusy();
toastr.success(__t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name));
toastr.success(toastMessage);
RefreshContextualTimeago();
RefreshStatistics();
},