From dc4f02ea93314599ad3e326721a170068b5c770d Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 27 Nov 2024 11:44:25 +0530 Subject: [PATCH 1/5] Implemented: support to unArchive archived rules (#386) --- src/components/ArchivedRuleItem.vue | 63 ++++++++++++++++++++++ src/components/ArchivedRuleModal.vue | 66 ++++++++++++++++++++++++ src/components/RuleItem.vue | 1 + src/store/modules/rule/RuleState.ts | 1 + src/store/modules/rule/actions.ts | 37 +++++++++++-- src/store/modules/rule/getters.ts | 3 ++ src/store/modules/rule/index.ts | 3 +- src/store/modules/rule/mutation-types.ts | 1 + src/store/modules/rule/mutations.ts | 3 ++ src/views/SafetyStock.vue | 4 ++ src/views/Shipping.vue | 5 ++ src/views/StorePickup.vue | 5 ++ src/views/Threshold.vue | 4 ++ 13 files changed, 192 insertions(+), 4 deletions(-) create mode 100644 src/components/ArchivedRuleItem.vue create mode 100644 src/components/ArchivedRuleModal.vue diff --git a/src/components/ArchivedRuleItem.vue b/src/components/ArchivedRuleItem.vue new file mode 100644 index 00000000..229d8237 --- /dev/null +++ b/src/components/ArchivedRuleItem.vue @@ -0,0 +1,63 @@ + + + \ No newline at end of file diff --git a/src/components/ArchivedRuleModal.vue b/src/components/ArchivedRuleModal.vue new file mode 100644 index 00000000..5eff7f38 --- /dev/null +++ b/src/components/ArchivedRuleModal.vue @@ -0,0 +1,66 @@ + + + + + \ No newline at end of file diff --git a/src/components/RuleItem.vue b/src/components/RuleItem.vue index c1d53a8d..feea0ae9 100644 --- a/src/components/RuleItem.vue +++ b/src/components/RuleItem.vue @@ -315,6 +315,7 @@ async function archiveRule() { try { await RuleService.updateRule(rule, props.rule.ruleId) await store.dispatch('rule/archiveRule', { rule }) + await store.dispatch('rule/fetchArchivedRules') showToast(translate("Rule archived successfully.")) alertController.dismiss() } catch(err: any) { diff --git a/src/store/modules/rule/RuleState.ts b/src/store/modules/rule/RuleState.ts index a5902ff1..853e2559 100644 --- a/src/store/modules/rule/RuleState.ts +++ b/src/store/modules/rule/RuleState.ts @@ -2,4 +2,5 @@ export default interface RuleState { rules: any; ruleGroup: any; isReorderActive: boolean; + archivedRules: any; } \ No newline at end of file diff --git a/src/store/modules/rule/actions.ts b/src/store/modules/rule/actions.ts index 8c135a59..01314e92 100644 --- a/src/store/modules/rule/actions.ts +++ b/src/store/modules/rule/actions.ts @@ -37,17 +37,21 @@ const actions: ActionTree = { async fetchRules({ commit, dispatch }, payload) { let rules = [] as any; + let ruleGroupId = payload.ruleGroupId; try { - const ruleGroup = await dispatch('fetchRuleGroup', payload) + if(!ruleGroupId) { + const ruleGroup = await dispatch('fetchRuleGroup', payload) + ruleGroupId = ruleGroup.ruleGroupId + } - if(!ruleGroup.ruleGroupId) { + if(!ruleGroupId) { throw new Error("No rule founds") return; } const resp = await RuleService.fetchRules({ - "ruleGroupId": ruleGroup.ruleGroupId, + ruleGroupId, "statusId": "ATP_RULE_ACTIVE", "orderByField": "sequenceNum" }) @@ -63,6 +67,33 @@ const actions: ActionTree = { commit(types.RULE_RULES_UPDATED, { list: rules, total: rules.length}); }, + async fetchArchivedRules({ commit }) { + const ruleGroup = await store.getters["rule/getRuleGroup"] + let archivedRules = [] as any; + + try { + if(!ruleGroup.ruleGroupId) { + return; + } + + const resp = await RuleService.fetchRules({ + "ruleGroupId": ruleGroup.ruleGroupId, + "statusId": "ATP_RULE_ARCHIVED", + "orderByField": "sequenceNum", + "pageSize": 200 + }) + + if(!hasError(resp)) { + archivedRules = resp.data; + } else { + throw resp.data + } + } catch(err: any) { + logger.error(err); + } + commit(types.RULE_ARCHIVED_RULES_UPDATED, archivedRules); + }, + updateRuleData({ commit, state }, payload) { const rules = JSON.parse(JSON.stringify(state.rules.list)) diff --git a/src/store/modules/rule/getters.ts b/src/store/modules/rule/getters.ts index 818858f4..fe120c10 100644 --- a/src/store/modules/rule/getters.ts +++ b/src/store/modules/rule/getters.ts @@ -14,6 +14,9 @@ const getters: GetterTree = { }, isReorderActive (state) { return state.isReorderActive + }, + getArchivedRules (state) { + return state.archivedRules } } export default getters; \ No newline at end of file diff --git a/src/store/modules/rule/index.ts b/src/store/modules/rule/index.ts index 62315378..a17931a8 100644 --- a/src/store/modules/rule/index.ts +++ b/src/store/modules/rule/index.ts @@ -13,7 +13,8 @@ const userModule: Module = { total: '' }, ruleGroup: {}, - isReorderActive: false + isReorderActive: false, + archivedRules: [] }, getters, actions, diff --git a/src/store/modules/rule/mutation-types.ts b/src/store/modules/rule/mutation-types.ts index 10dd7d65..6f60692b 100644 --- a/src/store/modules/rule/mutation-types.ts +++ b/src/store/modules/rule/mutation-types.ts @@ -2,4 +2,5 @@ export const SN_RULE = 'rule' export const RULE_RULES_UPDATED = SN_RULE + '/RULES_UPDATED' export const RULE_GROUP_UPDATED = SN_RULE + '/GROUP_UPDATED' export const RULE_REORDER_ACTIVE_UPDATED = SN_RULE + '/REORDER_ACTIVE_UPDATED' +export const RULE_ARCHIVED_RULES_UPDATED = SN_RULE + '/ARCHIVED_RULES_UPDATED' export const RULE_CLEARED = SN_RULE + "/CLEARED" \ No newline at end of file diff --git a/src/store/modules/rule/mutations.ts b/src/store/modules/rule/mutations.ts index 49cbfc23..3d22e644 100644 --- a/src/store/modules/rule/mutations.ts +++ b/src/store/modules/rule/mutations.ts @@ -13,6 +13,9 @@ const mutations: MutationTree = { [types.RULE_REORDER_ACTIVE_UPDATED] (state, payload) { state.isReorderActive = payload; }, + [types.RULE_ARCHIVED_RULES_UPDATED] (state, payload) { + state.archivedRules = payload; + }, [types.RULE_CLEARED](state) { state.rules = { list: [], diff --git a/src/views/SafetyStock.vue b/src/views/SafetyStock.vue index 5541902c..dffc270b 100644 --- a/src/views/SafetyStock.vue +++ b/src/views/SafetyStock.vue @@ -10,6 +10,7 @@
+
@@ -46,6 +47,7 @@ import { translate } from '@hotwax/dxp-components'; import emitter from '@/event-bus'; import { RuleService } from '@/services/RuleService'; import { doReorder, showToast } from '@/utils'; +import ArchivedRuleItem from '@/components/ArchivedRuleItem.vue'; const store = useStore(); const router = useRouter() @@ -53,6 +55,7 @@ const router = useRouter() const rules = computed(() => store.getters["rule/getRules"]); const ruleGroup = computed(() => store.getters["rule/getRuleGroup"]); const isReorderActive = computed(() => store.getters["rule/isReorderActive"]); +const archivedRules = computed(() => store.getters["rule/getArchivedRules"]); const reorderingRules = ref([]); onIonViewDidEnter(async() => { @@ -70,6 +73,7 @@ async function fetchRules() { store.dispatch("util/updateSelectedSegment", ""); store.dispatch("rule/updateIsReorderActive", false) await Promise.allSettled([store.dispatch('rule/fetchRules', { groupTypeEnumId: 'RG_SAFETY_STOCK', pageSize: 50 }), store.dispatch("util/fetchConfigFacilities"), store.dispatch("util/fetchFacilityGroups")]); + await store.dispatch('rule/fetchArchivedRules') emitter.emit("dismissLoader"); } diff --git a/src/views/Shipping.vue b/src/views/Shipping.vue index 52b85c88..98060635 100644 --- a/src/views/Shipping.vue +++ b/src/views/Shipping.vue @@ -23,6 +23,7 @@