-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented: barcode identifier selector and scanning based on selected identifier (#845) #846
Changes from 3 commits
66d226c
29db781
54e738f
340b767
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -585,9 +585,134 @@ const actions: ActionTree<UtilState, RootState> = { | |||||
} | ||||||
commit(types.UTIL_FORCE_SCAN_STATUS_UPDATED, prefValue) | ||||||
}, | ||||||
|
||||||
async fetchBarcodeIdentificationPref({ commit, dispatch }, eComStoreId) { | ||||||
const payload = { | ||||||
"inputFields": { | ||||||
"productStoreId": eComStoreId, | ||||||
"settingTypeEnumId": "BARCODE_IDEN_PREF" | ||||||
}, | ||||||
"filterByDate": 'Y', | ||||||
"entityName": "ProductStoreSetting", | ||||||
"fieldList": ["settingValue", "fromDate"], | ||||||
"viewSize": 1 | ||||||
} | ||||||
|
||||||
try { | ||||||
const resp = await UtilService.getProductStoreSetting(payload) as any | ||||||
if(!hasError(resp)) { | ||||||
const respValue = resp.data.docs[0].settingValue | ||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, respValue) | ||||||
} else { | ||||||
dispatch("createBarcodeIdentificationPref"); | ||||||
} | ||||||
} catch(err) { | ||||||
console.error(err) | ||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "internalName") | ||||||
} | ||||||
}, | ||||||
|
||||||
async createBarcodeIdentificationPref({ commit }) { | ||||||
const ecomStore = store.getters['user/getCurrentEComStore']; | ||||||
const fromDate = Date.now() | ||||||
|
||||||
try { | ||||||
if(!await UtilService.isEnumExists("BARCODE_IDEN_PREF")) { | ||||||
const resp = await UtilService.createEnumeration({ | ||||||
"enumId": "BARCODE_IDEN_PREF", | ||||||
"enumTypeId": "PROD_STR_STNG", | ||||||
"description": "Identification preference to be used for scanning items.", | ||||||
"enumName": "Barcode Identification Preference", | ||||||
"enumCode": "BARCODE_IDEN_PREF" | ||||||
}) | ||||||
|
||||||
if(hasError(resp)) { | ||||||
throw resp.data; | ||||||
} | ||||||
} | ||||||
|
||||||
const params = { | ||||||
fromDate, | ||||||
"productStoreId": ecomStore.productStoreId, | ||||||
"settingTypeEnumId": "BARCODE_IDEN_PREF", | ||||||
"settingValue": "internalName" | ||||||
} | ||||||
|
||||||
await UtilService.createBarcodeIdentificationPref(params) as any | ||||||
} catch(err) { | ||||||
console.error(err) | ||||||
} | ||||||
|
||||||
// not checking for resp success and fail case as every time we need to update the state with the | ||||||
// default value when creating a scan setting | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "internalName") | ||||||
return fromDate; | ||||||
}, | ||||||
|
||||||
async setBarcodeIdentificationPref({ commit, dispatch, state }, value) { | ||||||
let prefValue = state.barcodeIdentificationPref | ||||||
const eComStoreId = store.getters['user/getCurrentEComStore'].productStoreId; | ||||||
|
||||||
// when selecting none as ecom store, not updating the pref as it's not possible to save pref with empty productStoreId | ||||||
if(!eComStoreId) { | ||||||
showToast(translate("Unable to update barcode identification preference since no product store config found.")) | ||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, prefValue) | ||||||
return; | ||||||
} | ||||||
|
||||||
let fromDate; | ||||||
|
||||||
try { | ||||||
const resp = await UtilService.getProductStoreSetting({ | ||||||
"inputFields": { | ||||||
"productStoreId": eComStoreId, | ||||||
"settingTypeEnumId": "BARCODE_IDEN_PREF" | ||||||
}, | ||||||
"filterByDate": 'Y', | ||||||
"entityName": "ProductStoreSetting", | ||||||
"fieldList": ["fromDate"], | ||||||
"viewSize": 1 | ||||||
}) as any | ||||||
if(!hasError(resp)) { | ||||||
fromDate = resp.data.docs[0]?.fromDate | ||||||
} | ||||||
} catch(err) { | ||||||
console.error(err) | ||||||
} | ||||||
|
||||||
if(!fromDate) { | ||||||
fromDate = await dispatch("createBarcodeIdentificationPref"); | ||||||
} | ||||||
|
||||||
const params = { | ||||||
"fromDate": fromDate, | ||||||
"productStoreId": eComStoreId, | ||||||
"settingTypeEnumId": "BARCODE_IDEN_PREF", | ||||||
"settingValue": value | ||||||
} | ||||||
|
||||||
try { | ||||||
const resp = await UtilService.updateBarcodeIdentificationPref(params) as any | ||||||
|
||||||
if((!hasError(resp))) { | ||||||
showToast(translate("Barcode identification preference updated successfully.")) | ||||||
prefValue = value | ||||||
} else { | ||||||
throw resp.data; | ||||||
} | ||||||
} catch(err) { | ||||||
showToast(translate("Failed to update barcode identification preference.")) | ||||||
console.error(err) | ||||||
} | ||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, prefValue) | ||||||
}, | ||||||
|
||||||
async updateForceScanStatus({ commit }, payload) { | ||||||
commit(types.UTIL_FORCE_SCAN_STATUS_UPDATED, payload) | ||||||
}, | ||||||
|
||||||
async updateBarcodeIdentificationPref({ commit }, payload) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action is not used anywhere, we should use this method wherever we are updating the state for barcode identifier, also we need to clear the barcode identifier value of logout. |
||||||
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, payload) | ||||||
} | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ const utilModule: Module<UtilState, RootState> = { | |
productStores: [], | ||
facilities: [], | ||
shipmentGatewayConfigs: [], | ||
isForceScanEnabled: false | ||
isForceScanEnabled: false, | ||
barcodeIdentificationPref: "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we have defined |
||
}, | ||
getters, | ||
actions, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.