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 @@ + + + + + + + + {{ translate("Archived") }} + {{ archivedRules.length }} {{ translate(archivedRules.length === 1 ? "rule" : "rules") }} + + + + + + + \ 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 @@ + + + + + + + + + {{ translate("Archived Rules") }} + + + + + + + {{ rule.ruleName }} + {{ translate("Unarchived") }} + {{ translate("Unarchive") }} + + + + {{ translate("No archived rules") }} + + + + + + + + + + + + + \ 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 @@ + @@ -79,6 +80,7 @@ import { useStore } from 'vuex'; 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() @@ -89,6 +91,7 @@ const isScrollable = computed(() => store.getters["util/isFacilitiesScrollable"] const facilities = computed(() => store.getters["util/getFacilities"]); const selectedSegment = computed(() => store.getters["util/getSelectedSegment"]); const isReorderActive = computed(() => store.getters["rule/isReorderActive"]); +const archivedRules = computed(() => store.getters["rule/getArchivedRules"]); const reorderingRules = ref([]); const isScrollingEnabled = ref(false); @@ -110,6 +113,7 @@ async function fetchRules() { store.dispatch("rule/updateIsReorderActive", false) if(!selectedSegment.value || (selectedSegment.value !== 'RG_SHIPPING_FACILITY' && selectedSegment.value !== 'RG_SHIPPING_CHANNEL' && selectedSegment.value !== 'SHIPPING_FACILITY')) store.dispatch("util/updateSelectedSegment", "RG_SHIPPING_FACILITY"); await Promise.allSettled([store.dispatch('rule/fetchRules', { groupTypeEnumId: selectedSegment.value, pageSize: 50 }), store.dispatch("util/fetchConfigFacilities"), store.dispatch("util/fetchFacilityGroups")]) + await store.dispatch('rule/fetchArchivedRules') if(selectedSegment.value === 'SHIPPING_FACILITY') fetchFacilities(); emitter.emit("dismissLoader"); } @@ -164,6 +168,7 @@ async function updateSegment(event: any) { store.dispatch("rule/updateIsReorderActive", false) reorderingRules.value = [] await store.dispatch('rule/fetchRules', { groupTypeEnumId: selectedSegment.value, pageSize: 50 }) + await store.dispatch('rule/fetchArchivedRules') } emitter.emit("dismissLoader"); } diff --git a/src/views/StorePickup.vue b/src/views/StorePickup.vue index 89da5497..b41e61ac 100644 --- a/src/views/StorePickup.vue +++ b/src/views/StorePickup.vue @@ -23,6 +23,7 @@ + @@ -83,6 +84,7 @@ import { useStore } from 'vuex'; import emitter from '@/event-bus'; import { doReorder, showToast } from '@/utils'; import { RuleService } from '@/services/RuleService'; +import ArchivedRuleItem from '@/components/ArchivedRuleItem.vue'; const store = useStore(); const router = useRouter() @@ -94,6 +96,7 @@ const facilities = computed(() => store.getters["util/getFacilities"]); const selectedSegment = computed(() => store.getters["util/getSelectedSegment"]); const isReorderActive = computed(() => store.getters["rule/isReorderActive"]); const pickupGroups = computed(() => store.getters["util/getPickupGroups"]); +const archivedRules = computed(() => store.getters["rule/getArchivedRules"]); const reorderingRules = ref([]); const isScrollingEnabled = ref(false); @@ -118,6 +121,7 @@ async function fetchRules() { await Promise.allSettled([fetchFacilities(), store.dispatch("util/fetchPickupGroups")]) ; } else { await Promise.allSettled([store.dispatch('rule/fetchRules', { groupTypeEnumId: selectedSegment.value, pageSize: 50 }), store.dispatch("util/fetchConfigFacilities"), store.dispatch("util/fetchFacilityGroups")]) + await store.dispatch('rule/fetchArchivedRules') } emitter.emit("dismissLoader"); } @@ -172,6 +176,7 @@ async function updateSegment(event: any) { store.dispatch("rule/updateIsReorderActive", false) reorderingRules.value = [] await store.dispatch('rule/fetchRules', { groupTypeEnumId: selectedSegment.value, pageSize: 50 }) + await store.dispatch('rule/fetchArchivedRules') } emitter.emit("dismissLoader"); } diff --git a/src/views/Threshold.vue b/src/views/Threshold.vue index 902e228c..62b8f7d8 100644 --- a/src/views/Threshold.vue +++ b/src/views/Threshold.vue @@ -10,6 +10,7 @@ + @@ -39,6 +40,7 @@ import { IonContent, IonFab, IonFabButton, IonHeader, IonIcon, IonMenuButton, Io import { addOutline, balloonOutline, saveOutline } from 'ionicons/icons'; import RuleItem from '@/components/RuleItem.vue' import ScheduleRuleItem from '@/components/ScheduleRuleItem.vue'; +import ArchivedRuleItem from '@/components/ArchivedRuleItem.vue'; import { useRouter } from 'vue-router'; import { computed, ref } from 'vue'; import { useStore } from 'vuex'; @@ -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_THRESHOLD', pageSize: 50 }), store.dispatch("util/fetchConfigFacilities"), store.dispatch("util/fetchFacilityGroups")]); + await store.dispatch('rule/fetchArchivedRules') emitter.emit("dismissLoader"); }
+ {{ translate("No archived rules") }} +