Fixed recipe ingredient initial QU (fixes #1060)

This commit is contained in:
Bernd Bestel 2020-10-17 10:52:25 +02:00
parent 758a8d9708
commit 235b96d17f
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -1,4 +1,4 @@
Grocy.RecipePosFormProductChangeCount = 0;
Grocy.RecipePosFormInitialLoadDone = false;
$('#save-recipe-pos-button').on('click', function(e)
{
@ -53,9 +53,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
Grocy.RecipePosFormProductChangeCount++;
if (Grocy.RecipePosFormProductChangeCount < 3) // This triggers twice on initial page load, however
if (!Grocy.RecipePosFormInitialLoadDone)
{
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id, true);
}
@ -82,13 +80,14 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$("#not_check_stock_fulfillment").prop("checked", productDetails.product.not_check_stock_fulfillment_for_recipes == 1);
}
if (!$("#only_check_single_unit_in_stock").prop("checked"))
if (!$("#only_check_single_unit_in_stock").prop("checked") && Grocy.RecipePosFormInitialLoadDone)
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.quantity_unit_stock.id);
}
$('#display_amount').focus();
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
Grocy.RecipePosFormInitialLoadDone = true;
},
function(xhr)
{
@ -106,6 +105,11 @@ if (Grocy.Components.ProductPicker.InProductAddWorkflow() === false)
}
Grocy.Components.ProductPicker.GetPicker().trigger('change');
if (Grocy.EditMode == "create")
{
Grocy.RecipePosFormInitialLoadDone = true;
}
$('#display_amount').on('focus', function(e)
{
if (Grocy.Components.ProductPicker.GetValue().length === 0)