Fixed the "Add as barcode to existing product" productpicker workflow from the /shoppinglistitem page (fixes #1262)

This commit is contained in:
Bernd Bestel 2021-07-04 15:46:19 +02:00
parent 4086a63ebd
commit 734e174442
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 23 additions and 1 deletions

View File

@ -41,6 +41,7 @@
- Fixed the form validation on the shopping list item page (thanks @Forceu)
- Fixed that when adding products to the shopping list from the stock overview page, the used quantity unit was always the products default purchase QU (and not the selected one)
- Fixed that the displayed last unit/total price was wrong when the used quantity unit was not the products stock QU
- Fixed that the "Add as barcode to existing product" productpicker workflow did not work
### Recipe improvements/fixes
- Recipe printing improvements (thanks @Ape)

View File

@ -220,7 +220,7 @@ $('#product_id_text_input').on('blur', function(e)
callback: function()
{
Grocy.Components.ProductPicker.PopupOpen = false;
window.location.href = U(Grocy.CurrentUrlRelative + '?flow=InplaceAddBarcodeToExistingProduct&barcode=' + encodeURIComponent(input));
window.location.href = U(Grocy.CurrentUrlRelative + '?flow=InplaceAddBarcodeToExistingProduct&barcode=' + encodeURIComponent(input) + "&" + embedded);
}
},
addnewproductwithbarcode: {

View File

@ -19,6 +19,27 @@ $('#save-shoppinglist-button').on('click', function(e)
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
{
var jsonDataBarcode = {};
jsonDataBarcode.barcode = GetUriParam("barcode");
jsonDataBarcode.product_id = jsonData.product_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
{
$("#flow-info-InplaceAddBarcodeToExistingProduct").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
$('#barcode-lookup-hint').removeClass('d-none');
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("shoppinglist-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
}
if (GetUriParam("updateexistingproduct") !== undefined)
{
jsonData.product_amount = jsonData.amount;