mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Optimized product Grocycode handling on consume page (and others / general) (fixes #2571)
This commit is contained in:
@@ -170,6 +170,7 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
{
|
||||
possibleOptionElement = $("#product_id option[value=\"" + gc[2] + "\"]").first();
|
||||
$("#product_id").data("grocycode", true);
|
||||
$('#product_id').attr("barcode", input);
|
||||
}
|
||||
}
|
||||
else // Normal product barcode handling
|
||||
@@ -298,7 +299,7 @@ $('#product_id_text_input').on('blur', function(e)
|
||||
// otherwise an error validation message that the product is not in stock
|
||||
var existsAsProduct = false;
|
||||
var existsAsBarcode = false;
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + input,
|
||||
Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + input,
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult.length > 0)
|
||||
|
@@ -257,6 +257,10 @@ $("#location_id").on('change', function(e)
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
OnLocationChange(locationId, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -326,7 +330,7 @@ function OnLocationChange(locationId, stockId)
|
||||
}
|
||||
);
|
||||
|
||||
if (document.getElementById("product_id").getAttribute("barcode") == "null")
|
||||
if (document.getElementById("product_id").getAttribute("barcode") == "null" || $("#product_id").data("grocycode"))
|
||||
{
|
||||
ScanModeSubmit();
|
||||
}
|
||||
|
@@ -270,7 +270,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
|
||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||
{
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult)
|
||||
|
@@ -355,7 +355,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
|
||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||
{
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult && barcodeResult.length > 0)
|
||||
|
@@ -213,7 +213,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
|
||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
||||
{
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult != null)
|
||||
|
Reference in New Issue
Block a user