mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed consume page location dropdown handling (fixes #2328)
This commit is contained in:
@@ -389,27 +389,36 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
{
|
||||
var setDefault = 0;
|
||||
var stockAmountAtDefaultLocation = 0;
|
||||
var addedLocations = [];
|
||||
stockLocations.forEach(stockLocation =>
|
||||
{
|
||||
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;
|
||||
if (!addedLocations.includes(stockLocation.location_id))
|
||||
{
|
||||
$("#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 += stockLocation.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#location_id").append($("<option>", {
|
||||
value: stockLocation.location_id,
|
||||
text: stockLocation.location_name
|
||||
}));
|
||||
if (!addedLocations.includes(stockLocation.location_id))
|
||||
{
|
||||
$("#location_id").append($("<option>", {
|
||||
value: stockLocation.location_id,
|
||||
text: stockLocation.location_name
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
addedLocations.push(stockLocation.location_id);
|
||||
|
||||
if (setDefault == 0)
|
||||
{
|
||||
$("#location_id").val(defaultLocationId);
|
||||
|
Reference in New Issue
Block a user