mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Make it possible to provide a different location for added product during inventory (closes #183)
This commit is contained in:
@@ -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');
|
||||
|
Reference in New Issue
Block a user