mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 03:25:50 +00:00
Implemented a way to use the external barcode lookup plugin also from within the frontend as a product picker workflow
This commit is contained in:
@@ -249,6 +249,32 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||
window.location.href = U('/product/new?flow=InplaceNewProductWithBarcode&barcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceAddBarcodeToExistingProduct&barcode=" + input + "&" + embedded) + "&" + embedded);
|
||||
}
|
||||
},
|
||||
barcodepluginlookup: {
|
||||
label: '<strong>E</strong> ' + __t('External barcode lookup (via plugin)'),
|
||||
className: 'btn-dark add-new-product-plugin-dialog-button responsive-button ' + addProductWorkflowsAdditionalCssClasses,
|
||||
callback: function()
|
||||
{
|
||||
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||
|
||||
Grocy.Api.Get("stock/barcodes/external-lookup/" + encodeURIComponent(input) + "?add=true",
|
||||
function(pluginResponse)
|
||||
{
|
||||
if (pluginResponse == null)
|
||||
{
|
||||
toastr.warning(__t("Nothing was found for the given barcode"));
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = U("/product/" + pluginResponse.id + "?flow=InplaceNewProductByPlugin&returnto=" + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceNewProductWithName&" + embedded) + "&" + embedded);
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError("Error while executing the barcode lookup plugin", xhr.response);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -321,6 +347,10 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
{
|
||||
$('.retry-camera-scanning-button').not(".d-none").click();
|
||||
}
|
||||
if (e.key === 'e' || e.key === 'E')
|
||||
{
|
||||
$('.add-new-product-plugin-dialog-button').not(".d-none").click();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user