From 4df3d0c59acc8afc918a88454e6de0679ccde142 Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Tue, 1 Nov 2022 15:28:31 +0530 Subject: [PATCH 01/24] Implemented logic for storing and applying multiple field mappings(#2hran7u) --- src/components/Menu.vue | 2 +- src/locales/en.json | 3 + src/store/modules/user/UserState.ts | 1 + src/store/modules/user/actions.ts | 4 ++ src/store/modules/user/getters.ts | 3 + src/store/modules/user/index.ts | 1 + src/store/modules/user/mutation-types.ts | 3 +- src/store/modules/user/mutations.ts | 8 +++ src/views/PurchaseOrder.vue | 88 ++++++++++++++++-------- 9 files changed, 84 insertions(+), 29 deletions(-) diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 44032890..bc44efb5 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -30,7 +30,7 @@

{{ instanceUrl }}

- {{ userProfile.userTimeZone }} + {{ userProfile?.userTimeZone }} diff --git a/src/locales/en.json b/src/locales/en.json index 2dc73919..b9162acf 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -23,6 +23,7 @@ "Leave page": "Leave page", "Login": "Login", "Logout": "Logout", + "Mapping name": "Mapping name", "Missing SKUs": "Missing SKUs", "No time zone found": "No time zone found", "OMS": "OMS", @@ -40,9 +41,11 @@ "Review": "Review", "Reset": "Reset", "Safety stock": "Safety stock", + "Save mapping": "Save mapping", "Search products": "Search products", "Search time zones": "Search time zones", "Select": "Select", + "Select mapping": "Select mapping", "Select time zone": "Select time zone", "Select the column index for the following information in the uploaded CSV.": "Select the column index for the following information in the uploaded CSV.", "Something went wrong": "Something went wrong", diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index df4c21e2..d802583c 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -3,4 +3,5 @@ export default interface UserState { current: object | null; currentFacility: object; instanceUrl: string; + fieldMappings: any; } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 3cd1a7ff..9e926a13 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -112,6 +112,10 @@ const actions: ActionTree = { */ setUserInstanceUrl ({ state, commit }, payload){ commit(types.USER_INSTANCE_URL_UPDATED, payload) + }, + + updateFieldMappings({ commit }, payload){ + commit(types.USER_FIELD_MAPPINGS_UPDATED, payload); } } diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index e0fc2496..c943e755 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -21,6 +21,9 @@ const getters: GetterTree = { getInstanceUrl (state) { const baseUrl = process.env.VUE_APP_BASE_URL; return baseUrl ? baseUrl : state.instanceUrl; + }, + getFieldMappings(state) { + return state.fieldMappings; } } export default getters; \ No newline at end of file diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 6c3ee09d..bf548d20 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -12,6 +12,7 @@ const userModule: Module = { current: null, currentFacility: {}, instanceUrl: '', + fieldMappings: [] }, getters, actions, diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 9d9067dc..3b791dc7 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -3,4 +3,5 @@ export const USER_TOKEN_CHANGED = SN_USER + '/TOKEN_CHANGED' export const USER_END_SESSION = SN_USER + '/END_SESSION' export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED' export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED' -export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED' \ No newline at end of file +export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED' +export const USER_FIELD_MAPPINGS_UPDATED = SN_USER + '/FIELD_MAPPINGS_UPDATED' \ No newline at end of file diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index bd3239cc..d2ae04ef 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -19,6 +19,14 @@ const mutations: MutationTree = { }, [types.USER_INSTANCE_URL_UPDATED] (state, payload) { state.instanceUrl = payload; + }, + [types.USER_FIELD_MAPPINGS_UPDATED] (state, payload) { + const mapping = state.fieldMappings.find((mapping: any) => mapping.name === payload.name ); + if (mapping) { + mapping.fieldMapping = payload.fieldMapping; + } else { + state.fieldMappings.push(payload); + } } } export default mutations; \ No newline at end of file diff --git a/src/views/PurchaseOrder.vue b/src/views/PurchaseOrder.vue index 40d0d97b..cae458e2 100644 --- a/src/views/PurchaseOrder.vue +++ b/src/views/PurchaseOrder.vue @@ -17,55 +17,70 @@ {{ $t("Select the column index for the following information in the uploaded CSV.") }} + + + {{ $t("Select mapping") }} + + {{ mapping.name }} + + + {{ $t("Order ID") }} - - {{ prop }} + + {{ prop }} {{ $t("Shopify product SKU") }} - + {{ prop }} {{ $t("Arrival date") }} - + {{ prop }} {{ $t("Ordered quantity") }} - + {{ prop }} {{ $t("Facility ID") }} - + {{ prop }} - + - + {{ $t("Review") }} + + + {{ $t("Mapping name") }} + + + {{ $t("Save mapping") }} +