Revert changes no longer needed

This commit is contained in:
Rosemary Orchard 2022-04-18 10:17:23 +01:00
parent cb8898e046
commit 40721aa421

View File

@ -373,11 +373,9 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$(".input-group-productamountpicker").trigger("change");
var defaultLocationId = productDetails.location.id;
var defaultConsumeLocationId = productDetails.product.default_consume_location_id;
if (defaultConsumeLocationId != null && !defaultConsumeLocationId.isEmpty())
if (productDetails.product.default_consume_location_id != null && !productDetails.product.default_consume_location_id.isEmpty())
{
defaultLocationId = defaultConsumeLocationId;
defaultLocationId = productDetails.product.default_consume_location_id;
}
$("#location_id").find("option").remove().end().append("<option></option>");
@ -388,22 +386,26 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
var stockAmountAtDefaultLocation = 0;
stockLocations.forEach(stockLocation =>
{
var stockLocationName = stockLocation.location_name;
if (stockLocation.location_id == defaultLocationId) {
stockLocationName += " (" + __t("Default location") + ")";
if (stockLocation.location_id == defaultLocationId)
{
$("#location_id").append($("<option>", {
value: stockLocation.location_id,
text: stockLocation.location_name + " (" + __t("Default location") + ")"
}));
$("#location_id").val(defaultLocationId);
$("#location_id").trigger('change');
setDefault = 1;
stockAmountAtDefaultLocation += Number.parseFloat(stockLocation.amount);
}
$("#location_id").append($("<option>", {
value: stockLocation.location_id,
text: stockLocationName
}));
$("#location_id").val(defaultLocationId);
$("#location_id").trigger('change');
setDefault = 1;
stockAmountAtDefaultLocation += Number.parseFloat(stockLocation.amount);
else
{
$("#location_id").append($("<option>", {
value: stockLocation.location_id,
text: stockLocation.location_name
}));
}
if (!setDefault)
if (setDefault == 0)
{
$("#location_id").val(defaultLocationId);
$("#location_id").trigger('change');