diff --git a/src/locales/en.json b/src/locales/en.json index 12ba7dc1..ad62190b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -37,6 +37,7 @@ "Configure date time format": "Configure date time format", "Check sample": "Check sample", "Choosing a product identifier allows you to view products with your preferred identifiers.": "Choosing a product identifier allows you to view products with your preferred identifiers.", + "Choosing an identifier to map products by when uploading documents. If not explicitly specified Import will default to the identifier used during product import from Shopify.": "Choosing an identifier to map products by when uploading documents. If not explicitly specified Import will default to the identifier used during product import from Shopify.", "Click the backdrop to dismiss.": "Click the backdrop to dismiss.", "Completed": "Completed", "Confirm": "Confirm", @@ -44,6 +45,7 @@ "CSV input": "CSV input", "CSV Mapping": "CSV Mapping", "Custom date format": "Custom date format", + "Currently set to": "Currently set to {productIdentifierEnumId}", "Cycle count": "Cycle count", "Cycle count or similar": "Cycle count or similar", "Date Format": "Date Format", @@ -82,6 +84,7 @@ "Failed to update CSV mapping.": "Failed to update CSV mapping.", "Failed to update execution mode": "Failed to update execution mode", "Failed to update job": "Failed to update job", + "Failed to update product upload identifier.": "Failed to update product upload identifier.", "Failed to update shipment item quantity": "Failed to update shipment item quantity", "Facility: Use the internal ID of facilities in HotWax. Select external ID option if the uploaded CSV file is coming from a system like an ERP.": "Facility: Use the internal ID of facilities in HotWax. Select external ID option if the uploaded CSV file is coming from a system like an ERP.", "Fetching TimeZones": "Fetching TimeZones", @@ -179,6 +182,8 @@ "Product not found": "Product not found", "Product removed successfully": "Product removed successfully", "Product: Select the type of product identification used in the CSV. If the selected identification is not available on a row in the uploaded CSV, it will be skipped and presented in an error file.": "Product: Select the type of product identification used in the CSV. If the selected identification is not available on a row in the uploaded CSV, it will be skipped and presented in an error file.", + "Product Upload Identifier": "Product Upload Identifier", + "Product upload identifier updated successfully.": "Product upload identifier updated successfully.", "Purchase order": "Purchase order", "Purchase orders": "Purchase orders", "Quantity": "Quantity", @@ -285,8 +290,10 @@ "Uploaded files will be processed immediately": "Uploaded files will be processed immediately", "Uploaded files will be processed": "Uploaded files will be processed {runTime}", "Uploaded files will not be processed until the bulk file processing job is enabled.": "Uploaded files will not be processed until the bulk file processing job is enabled.", + "Upload Identifier": "Upload Identifier", "Upload purchase order": "Upload purchase order", "Username": "Username", + "Use default identifier": "Use default identifier", "Version: ": "Version: {appVersion}", "View all date time formats supported by the HotWax Import app.": "View all date time formats supported by the HotWax Import app.", "View": "View", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 45ce81dd..af745e4d 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -145,7 +145,7 @@ const getUserPermissions = async (payload: any, token: any): Promise => { async function getEComStores(): Promise { const params = { "viewSize": 200, - "fieldList": ["productStoreId", "storeName"], + "fieldList": ["productStoreId", "storeName", "productIdentifierEnumId"], "entityName": "ProductStore", "distinct": "Y", "noConditionFind": "Y" diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 9b52e185..40220c5a 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -33,6 +33,23 @@ const fetchShopifyShop = async (payload: any): Promise => { }) } +const fetchProductSelectorPref = async (payload: any): Promise => { + return api({ + url: "/performFind", + method: "GET", + params: payload, + cache: true + }) +} + +const updateProductSelectorPref = async (payload: any): Promise => { + return api({ + url: "service/updateProductStoreSetting", + method: "POST", + data: payload + }) +} + const fetchProductStores = async (payload: any): Promise => { return api({ url: "/performFind", @@ -137,6 +154,7 @@ export const UtilService = { fetchDataResource, fetchFileData, fetchProducts, + fetchProductSelectorPref, fetchProductStores, fetchShipmentItems, fetchGoodIdentificationTypes, @@ -146,5 +164,6 @@ export const UtilService = { getServiceStatusDesc, removeShipmentItem, updateShipmentItem, - updateDataManagerConfig + updateDataManagerConfig, + updateProductSelectorPref } \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 77a95b20..4245b6da 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -22,7 +22,7 @@ const state: any = { } const persistState = createPersistedState({ - paths: ['user', 'util.productStores', 'util.statusDesc'], + paths: ['user', 'util.productStores', 'util.statusDesc', 'util.useDefaultProductStoreIdentifier'], fetchBeforeUse: true }) diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 0c5945eb..628b8b05 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -76,6 +76,10 @@ const actions: ActionTree = { useUserStore().eComStores = ecomStores await useUserStore().getEComStorePreference("SELECTED_BRAND") const preferredStore: any = useUserStore().getCurrentEComStore + // If the user's preferred store has a productIdentifierEnumId, set the default identifier value in the state + if(!preferredStore?.productIdentifierEnumId) { + this.dispatch('util/updateDefaultProductStoreIdentifier', false); + } await useProductIdentificationStore().getIdentificationPref(preferredStore.productStoreId) .catch((error) => logger.error(error)); @@ -127,6 +131,7 @@ const actions: ActionTree = { this.dispatch('util/clearFacilities'); this.dispatch('util/clearProductStores'); this.dispatch('util/clearStatusDesc'); + this.dispatch('util/clearDefaultProductStoreIdentifier'); // clearing field mappings and current mapping when the user logout commit(types.USER_FIELD_MAPPINGS_UPDATED, {}) commit(types.USER_CURRENT_FIELD_MAPPING_UPDATED, {id: '', mappingType: '', name: '', value: {}}) diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index c69b77cf..4ff44cc1 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -8,4 +8,6 @@ export default interface UserState { shipmentItems: [], statusDesc: any; configDetails: {} + productSelectorPref: string; + useDefaultProductStoreIdentifier: boolean; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 507e94ee..6988077c 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -197,13 +197,64 @@ const actions: ActionTree = { } commit(types.UTIL_DATA_MANAGER_CONFIG_UPDATED, configDetails); }, + async fetchProductSelectorPref({ commit }, eComStore){ + let productSelectorPref = ""; + const payload = { + "inputFields": { + "productStoreId": eComStore.productStoreId, + "settingTypeEnumId": "PRD_SELECTOR_PREF" + }, + "entityName": "ProductStoreSetting", + "fieldList": ["settingValue", "settingTypeEnumId"], + "viewSize": 1 + } + + try { + const resp = await UtilService.fetchProductSelectorPref(payload) + if(!hasError(resp) && resp.data.docs?.length && resp.data.docs[0].settingValue) { + productSelectorPref = resp.data.docs[0].settingValue + } else { + throw resp.data + } + } catch(err) { + console.error(err) + } + commit(types.UTIL_SELECTOR_PREF_UPDATED, productSelectorPref); + }, + async updateProductSelectorPref({ commit }, payload) { + let productSelectorPref = ""; + const params = { + "productStoreId": payload.productStoreId, + "settingTypeEnumId": "PRD_SELECTOR_PREF", + "settingValue": payload.productSelectorPref + } + + try { + const resp = await UtilService.updateProductSelectorPref(params) + if(!hasError(resp)) { + productSelectorPref = payload.productSelectorPref + commit(types.UTIL_SELECTOR_PREF_UPDATED, productSelectorPref); + return true; + } else { + throw resp.data + } + } catch(err) { + console.error(err) + return false; + } + }, + async updateDefaultProductStoreIdentifier({ commit }, payload) { + commit(types.UTIL_STORE_DEFAULT_IDENTIFIER_UPDATED, payload); + }, async updateExactInventoryType({ commit }, type) { commit(types.UTIL_EXACT_INVENTORY_TYPE_UPDATED, type); }, async clearProductStores({ commit }) { commit(types.UTIL_PRODUCT_STORES_UPDATED, []); }, - + async clearDefaultProductStoreIdentifier({ commit }) { + commit(types.UTIL_STORE_DEFAULT_IDENTIFIER_UPDATED, true); + }, async updateFileProcessingStatus({ commit }, status){ commit(types.UTIL_FILE_PROCESSING_STATUS_UPDATED, { status }); }, diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index ad0a90f6..87f53fbe 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -29,6 +29,12 @@ const getters: GetterTree = { }, getDataManagerConfig(state) { return state.configDetails + }, + getProductSelectorPref: (state) => { + return state.productSelectorPref; + }, + isDefaultProductStoreIdentifierSelected: (state) => { + return state.useDefaultProductStoreIdentifier; } } export default getters; \ No newline at end of file diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index 54262c9e..972464bd 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -16,7 +16,9 @@ const userModule: Module = { exactInventoryType: {}, shipmentItems: [], statusDesc: {}, - configDetails: {} + configDetails: {}, + productSelectorPref: '', + useDefaultProductStoreIdentifier: true }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index f31f6067..942ba98c 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -7,4 +7,6 @@ export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED' export const UTIL_DATA_MANAGER_CONFIG_UPDATED = SN_UTIL + '/DATA_MANAGER_CONFIG_UPDATED' export const UTIL_EXACT_INVENTORY_TYPE_UPDATED = SN_UTIL + '/EXACT_INVENTORY_TYPE_UPDATED' export const UTIL_SERVICE_STATUS_DESC_UPDATED = SN_UTIL + '/SERVICE_STATUS_DESC_UPDATED' -export const UTIL_SHIPMENT_ITEMS_UPDATED = SN_UTIL + '/SHIPMENT_ITEMS_UPDATED' \ No newline at end of file +export const UTIL_SHIPMENT_ITEMS_UPDATED = SN_UTIL + '/SHIPMENT_ITEMS_UPDATED' +export const UTIL_SELECTOR_PREF_UPDATED = SN_UTIL + '/SELECTOR_PREF_UPDATED' +export const UTIL_STORE_DEFAULT_IDENTIFIER_UPDATED = SN_UTIL + '/DEFAULT_IDENTIFIER_UPDATED' \ No newline at end of file diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 13236f3b..88a2acbe 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -31,6 +31,12 @@ const mutations: MutationTree = { }, [types.UTIL_DATA_MANAGER_CONFIG_UPDATED] (state, payload) { state.configDetails = payload; + }, + [types.UTIL_SELECTOR_PREF_UPDATED](state, payload) { + state.productSelectorPref = payload + }, + [types.UTIL_STORE_DEFAULT_IDENTIFIER_UPDATED](state, payload) { + state.useDefaultProductStoreIdentifier = payload } } export default mutations; \ No newline at end of file diff --git a/src/views/ScheduledRestock.vue b/src/views/ScheduledRestock.vue index 7937c5e9..1ea501f7 100644 --- a/src/views/ScheduledRestock.vue +++ b/src/views/ScheduledRestock.vue @@ -41,7 +41,7 @@