diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 082ac1d1..1554d63a 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -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) diff --git a/public/viewjs/components/productpicker.js b/public/viewjs/components/productpicker.js index 6345acb5..9b32c570 100644 --- a/public/viewjs/components/productpicker.js +++ b/public/viewjs/components/productpicker.js @@ -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: { diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js index 196274df..f38f4f79 100644 --- a/public/viewjs/shoppinglistitemform.js +++ b/public/viewjs/shoppinglistitemform.js @@ -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;