mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 03:25:50 +00:00
Fixed recipeposform edit when "Only check if a single unit is in stock" is set (again closes #535)
This commit is contained in:
@@ -21,20 +21,20 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
|
||||
});
|
||||
}
|
||||
|
||||
if (!Grocy.Components.ProductAmountPicker.InitalValueSet || forceInitialDisplayQu)
|
||||
if (!Grocy.Components.ProductAmountPicker.InitialValueSet || forceInitialDisplayQu)
|
||||
{
|
||||
$("#qu_id").val($("#qu_id").attr("data-inital-qu-id"));
|
||||
$("#qu_id").val($("#qu_id").attr("data-initial-qu-id"));
|
||||
}
|
||||
|
||||
if (!Grocy.Components.ProductAmountPicker.InitalValueSet)
|
||||
if (!Grocy.Components.ProductAmountPicker.InitialValueSet)
|
||||
{
|
||||
var convertedAmount = $("#display_amount").val() * $("#qu_id option:selected").attr("data-qu-factor");
|
||||
$("#display_amount").val(convertedAmount);
|
||||
|
||||
Grocy.Components.ProductAmountPicker.InitalValueSet = true;
|
||||
Grocy.Components.ProductAmountPicker.InitialValueSet = true;
|
||||
}
|
||||
|
||||
if (conversionsForProduct.length === 1)
|
||||
if (conversionsForProduct.length === 1 && !forceInitialDisplayQu)
|
||||
{
|
||||
$("#qu_id").val($("#qu_id option:first").val());
|
||||
}
|
||||
@@ -42,12 +42,12 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
}
|
||||
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit = function()
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit = function(quId)
|
||||
{
|
||||
$("#qu_id").val(quId);
|
||||
}
|
||||
|
||||
Grocy.Components.ProductAmountPicker.AllowAnyQu = function(quId)
|
||||
Grocy.Components.ProductAmountPicker.AllowAnyQu = function(keepInitialQu = false)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled = true;
|
||||
|
||||
@@ -57,6 +57,11 @@ Grocy.Components.ProductAmountPicker.AllowAnyQu = function(quId)
|
||||
$("#qu_id").append('<option value="' + qu.id + '" data-qu-factor="1">' + qu.name + '</option>');
|
||||
});
|
||||
|
||||
if (keepInitialQu)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit($("#qu_id").attr("data-initial-qu-id"));
|
||||
}
|
||||
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user