Skip to content

Commit

Permalink
Improved: trimming the queryString on scanning (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Jan 15, 2025
1 parent 17e1927 commit 1e7f995
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/views/CountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function selectSearchBarText(event) {
}
async function scanProduct() {
if(!queryString.value) {
if(!queryString.value.trim()) {
showToast(translate("Please provide a valid barcode identifier."))
return;
}
Expand All @@ -389,14 +389,14 @@ async function scanProduct() {
if(cycleCount.value.statusId === 'INV_COUNT_ASSIGNED') {
selectedItem = itemsList.value.find((item) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, cachedProducts[item.productId]) : item.internalName;
return itemVal === queryString.value && item.itemStatusId === "INV_COUNT_CREATED";
return itemVal === queryString.value.trim() && item.itemStatusId === "INV_COUNT_CREATED";
});
}
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, cachedProducts[item.productId]) : item.internalName;
return itemVal === queryString.value;
return itemVal === queryString.value.trim();
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/HardCountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function removeCountItem(current: any) {
async function scanProduct() {
let isNewlyAdded = false;
if(!queryString.value) {
if(!queryString.value.trim()) {
showToast(translate("Please provide a valid barcode identifier."))
return;
}
Expand All @@ -367,18 +367,18 @@ async function scanProduct() {
selectedItem = itemsList.value.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct.value(item.productId)) : item.internalName;
return itemVal === queryString.value && item.itemStatusId === "INV_COUNT_CREATED";
return itemVal === queryString.value.trim() && item.itemStatusId === "INV_COUNT_CREATED";
});
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct.value(item.productId)) : item.internalName;
return itemVal === queryString.value;
return itemVal === queryString.value.trim();
});
}
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item: any) => item.scannedId === queryString.value)
selectedItem = itemsList.value.find((item: any) => item.scannedId === queryString.value.trim())
}
if(!selectedItem || !Object.keys(selectedItem).length) {
Expand Down Expand Up @@ -417,7 +417,7 @@ function scrollToProduct(product: any) {
async function addProductToItemsList() {
const newItem = {
scannedId: queryString.value,
scannedId: queryString.value.trim(),
isMatching: true,
itemStatusId: "INV_COUNT_CREATED",
statusId: "INV_COUNT_ASSIGNED",
Expand All @@ -428,7 +428,7 @@ async function addProductToItemsList() {
items.push(newItem);
await store.dispatch("count/updateCycleCountItems", items);
initializeObserver()
findProductFromIdentifier(queryString.value);
findProductFromIdentifier(queryString.value.trim());
return newItem;
}
Expand Down

0 comments on commit 1e7f995

Please sign in to comment.