mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Implemented frontend external barcode lookup workflow + a plugin for Open Food Facts (closes #158)
This commit is contained in:
@@ -403,7 +403,8 @@ Grocy.FrontendHelpers.ShowGenericError = function(message, exception)
|
||||
bootbox.alert({
|
||||
title: __t('Error details'),
|
||||
message: '<p class="text-monospace my-0">' + errorDetails + '</p>',
|
||||
closeButton: false
|
||||
closeButton: false,
|
||||
className: "wider"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@@ -257,6 +257,7 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
callback: function()
|
||||
{
|
||||
Grocy.Components.ProductPicker.PopupOpen = false;
|
||||
Grocy.FrontendHelpers.BeginUiBusy($("form").first().attr("id"));
|
||||
|
||||
Grocy.Api.Get("stock/barcodes/external-lookup/" + encodeURIComponent(input) + "?add=true",
|
||||
function(pluginResponse)
|
||||
@@ -264,15 +265,17 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
if (pluginResponse == null)
|
||||
{
|
||||
toastr.warning(__t("Nothing was found for the given barcode"));
|
||||
Grocy.FrontendHelpers.EndUiBusy($("form").first().attr("id"));
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = U("/product/" + pluginResponse.id + "?flow=InplaceNewProductByPlugin&returnto=" + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceNewProductWithName&" + embedded) + "&" + embedded);
|
||||
window.location.href = U("/product/" + pluginResponse.id + "?flow=InplaceNewProductByExternalBarcodeLookupPlugin&returnto=" + encodeURIComponent(Grocy.CurrentUrlRelative + "?flow=InplaceNewProductWithName&" + embedded) + "&" + embedded);
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
Grocy.FrontendHelpers.ShowGenericError("Error while executing the barcode lookup plugin", xhr.response);
|
||||
Grocy.FrontendHelpers.EndUiBusy($("form").first().attr("id"));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user