Make it possible to provide a different location for added product during inventory (closes #183)

This commit is contained in:
Bernd Bestel
2019-04-05 21:26:44 +02:00
parent 886e272c03
commit b6e80580ed
6 changed files with 25 additions and 4 deletions

View File

@@ -11,6 +11,7 @@
var jsonData = { };
jsonData.new_amount = jsonForm.new_amount;
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
Grocy.Api.Post('stock/products/' + jsonForm.product_id + '/inventory', jsonData,
function(result)
@@ -112,6 +113,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$("#tare-weight-handling-info").addClass("d-none");
}
Grocy.Components.LocationPicker.SetId(productDetails.location.id);
$('#new_amount').focus();
},
function(xhr)
@@ -212,11 +214,13 @@ $('#new_amount').on('keyup', function(e)
{
$('#inventory-change-info').text(L('This means #1 will be added to stock', estimatedBookingAmount.toLocaleString() + ' ' + Pluralize(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)));
Grocy.Components.DateTimePicker.GetInputElement().attr('required', '');
Grocy.Components.LocationPicker.GetInputElement().attr('required', '');
}
else if (newAmount < productStockAmount + containerWeight)
{
$('#inventory-change-info').text(L('This means #1 will be removed from stock', estimatedBookingAmount.toLocaleString() + ' ' + Pluralize(estimatedBookingAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)));
Grocy.Components.DateTimePicker.GetInputElement().removeAttr('required');
Grocy.Components.LocationPicker.GetInputElement().removeAttr('required');
}
Grocy.FrontendHelpers.ValidateForm('inventory-form');