Fixed the "Add as barcode to existing product" productpicker workflow failed to add the barcode to the given product (fixes #222)

This commit is contained in:
Bernd Bestel
2019-05-03 18:29:09 +02:00
parent b310aa55c5
commit 94c6e634b8
4 changed files with 53 additions and 25 deletions

View File

@@ -32,6 +32,33 @@
Grocy.Api.Post(apiUrl, jsonData,
function(result)
{
var addBarcode = GetUriParam('addbarcodetoselection');
if (addBarcode !== undefined)
{
var existingBarcodes = productDetails.product.barcode || '';
if (existingBarcodes.length === 0)
{
productDetails.product.barcode = addBarcode;
}
else
{
productDetails.product.barcode += ',' + addBarcode;
}
Grocy.Api.Put('objects/products/' + productDetails.product.id, productDetails.product,
function(result)
{
$("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
window.history.replaceState({ }, document.title, U("/consume"));
},
function(xhr)
{
console.error(xhr);
}
);
}
$("#specific_stock_entry").find("option").remove().end().append("<option></option>");
if ($("#use_specific_stock_entry").is(":checked"))
{