Optimized embedded productpicker workflows (references #1226)

This commit is contained in:
Bernd Bestel 2020-12-29 21:18:51 +01:00
parent 9f1692e31f
commit d79adc4660
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 14 additions and 2 deletions

View File

@ -172,6 +172,12 @@ $('#product_id_text_input').on('blur', function(e)
addProductWorkflowsAdditionalCssClasses = "d-none"; addProductWorkflowsAdditionalCssClasses = "d-none";
} }
var embedded = "";
if (GetUriParam("embedded") !== undefined)
{
embedded = "embedded";
}
var buttons = { var buttons = {
cancel: { cancel: {
label: __t('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, className: 'btn-success add-new-product-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
callback: function() callback: function()
{ {
Grocy.Components.ProductPicker.PopupOpen = false; 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: { addbarcode: {
@ -206,7 +213,7 @@ $('#product_id_text_input').on('blur', function(e)
callback: function() callback: function()
{ {
Grocy.Components.ProductPicker.PopupOpen = false; 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);
} }
} }
}; };

View File

@ -250,4 +250,9 @@ eitherRequiredFields.on("input", function()
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form'); Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
}); });
if (GetUriParam("product-name") != null)
{
Grocy.Components.ProductPicker.GetPicker().trigger('change');
}
Grocy.Components.UserfieldsForm.Load(); Grocy.Components.UserfieldsForm.Load();