From d79adc466092e76f38c1ccd8efef811175915bba Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 29 Dec 2020 21:18:51 +0100 Subject: [PATCH] Optimized embedded productpicker workflows (references #1226) --- public/viewjs/components/productpicker.js | 11 +++++++++-- public/viewjs/shoppinglistitemform.js | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/public/viewjs/components/productpicker.js b/public/viewjs/components/productpicker.js index 368554ea..42aa8126 100644 --- a/public/viewjs/components/productpicker.js +++ b/public/viewjs/components/productpicker.js @@ -172,6 +172,12 @@ $('#product_id_text_input').on('blur', function(e) addProductWorkflowsAdditionalCssClasses = "d-none"; } + var embedded = ""; + if (GetUriParam("embedded") !== undefined) + { + embedded = "embedded"; + } + var buttons = { cancel: { label: __t('Cancel'), @@ -187,8 +193,9 @@ $('#product_id_text_input').on('blur', function(e) className: 'btn-success add-new-product-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses, callback: function() { + Grocy.Components.ProductPicker.PopupOpen = false; - window.location.href = U('/product/new?flow=InplaceNewProductWithName&name=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceNewProductWithName")); + window.location.href = U('/product/new?flow=InplaceNewProductWithName&name=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceNewProductWithName&" + embedded) + "&" + embedded); } }, addbarcode: { @@ -206,7 +213,7 @@ $('#product_id_text_input').on('blur', function(e) callback: function() { Grocy.Components.ProductPicker.PopupOpen = false; - window.location.href = U('/product/new?flow=InplaceNewProductWithBarcode&barcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceAddBarcodeToExistingProduct&barcode=" + input)); + window.location.href = U('/product/new?flow=InplaceNewProductWithBarcode&barcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceAddBarcodeToExistingProduct&barcode=" + input + "&" + embedded) + "&" + embedded); } } }; diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js index 61ddce82..38bdfe65 100644 --- a/public/viewjs/shoppinglistitemform.js +++ b/public/viewjs/shoppinglistitemform.js @@ -250,4 +250,9 @@ eitherRequiredFields.on("input", function() Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); }); +if (GetUriParam("product-name") != null) +{ + Grocy.Components.ProductPicker.GetPicker().trigger('change'); +} + Grocy.Components.UserfieldsForm.Load();