diff --git a/src/components/ArchivedRuleItem.vue b/src/components/ArchivedRuleItem.vue new file mode 100644 index 00000000..f9916ca4 --- /dev/null +++ b/src/components/ArchivedRuleItem.vue @@ -0,0 +1,61 @@ + + + + + + + + {{ 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..99e20305 --- /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..a979922a 100644 --- a/src/components/RuleItem.vue +++ b/src/components/RuleItem.vue @@ -314,7 +314,7 @@ async function archiveRule() { try { await RuleService.updateRule(rule, props.rule.ruleId) - await store.dispatch('rule/archiveRule', { rule }) + await store.dispatch('rule/fetchRules', { ruleGroupId: props.rule.ruleGroupId }) showToast(translate("Rule archived successfully.")) alertController.dismiss() } catch(err: any) { diff --git a/src/locales/en.json b/src/locales/en.json index b769754d..ea938f7d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -9,6 +9,8 @@ "Any page made on this page will be lost. You will not be able to reverse this action.": "Any page made on this page will be lost. You will not be able to reverse this action.", "App": "App", "Apply": "Apply", + "Archived": "Archived", + "Archived Rules": "Archived Rules", "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?", "Are you sure you want to save these changes?": "Are you sure you want to save these changes?", "Authenticating": "Authenticating", @@ -80,6 +82,7 @@ "Failed to update threshold facility.": "Failed to update threshold facility.", "Failed to update sequence for some rules.": "Failed to update sequence for some rules.", "Failed to fetch rule information.": "Failed to fetch rule information.", + "Failed to unarchive some rules.": "Failed to unarchive some rules.", "Failed to update rules order.": "Failed to update rules order.", "Failed to update facility": "Failed to update facility", "Failed to update some jobs": "Failed to update some jobs", @@ -134,6 +137,7 @@ "New threshold rule": "New threshold rule", "New safety stock rule": "New safety stock rule", "No": "No", + "No archived rules": "No archived rules", "No available history for rule.": "No available history for {name} rule.", "No available history for this job.": "No available history for this job.", "No Capacity": "No Capacity", @@ -196,6 +200,8 @@ "reset": "reset", "retail facilities": "{count} retail facilities", "retry": "retry", + "rule": "rule", + "rules": "rules", "Rule Configuration": "Rule Configuration", "Rule created successfully.": "Rule created successfully.", "Rule group disabled successfully.": "Rule group disabled successfully.", @@ -282,6 +288,8 @@ "UI Components": "UI Components", "Unable to schedule service.": "Unable to schedule service.", "Unable to update threshold rule.": "Unable to update threshold rule.", + "Unarchive": "Unarchive", + "Unarchived": "Unarchived", "Update": "Update", "Edit shipping rule": "Edit shipping rule", "Edit store pickup rule": "Edit store pickup rule", 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..67f7e7aa 100644 --- a/src/store/modules/rule/actions.ts +++ b/src/store/modules/rule/actions.ts @@ -37,32 +37,41 @@ const actions: ActionTree = { async fetchRules({ commit, dispatch }, payload) { let rules = [] as any; + let archivedRules = [] 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, - "statusId": "ATP_RULE_ACTIVE", + ruleGroupId, + "statusId": ["ATP_RULE_ACTIVE", "ATP_RULE_ARCHIVED"], + "statusId_op": "in", "orderByField": "sequenceNum" }) if(!hasError(resp)) { - rules = resp.data; + rules = resp.data.filter((rule: any) => rule.statusId === "ATP_RULE_ACTIVE") + archivedRules = resp.data.filter((rule: any) => rule.statusId === "ATP_RULE_ARCHIVED") } else { throw resp.data } } catch(err: any) { logger.error(err); } + commit(types.RULE_RULES_UPDATED, { list: rules, total: rules.length}); + commit(types.RULE_ARCHIVED_RULES_UPDATED, archivedRules); }, - + updateRuleData({ commit, state }, payload) { const rules = JSON.parse(JSON.stringify(state.rules.list)) @@ -82,16 +91,6 @@ const actions: ActionTree = { commit(types.RULE_RULES_UPDATED, { list: payload.rules, total: payload.rules.length}); }, - archiveRule({ commit, state }, { rule }) { - const rules = JSON.parse(JSON.stringify(state.rules.list)) - - const index = rules.findIndex((currRule: any) => currRule.ruleId === rule.ruleId); - if (index !== -1) { - rules.splice(index, 1); - } - commit(types.RULE_RULES_UPDATED, { list: rules, total: state.rules.total - 1 }); - }, - async clearRuleState({ commit }) { commit(types.RULE_CLEARED) }, 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..9d04f3ee 100644 --- a/src/views/SafetyStock.vue +++ b/src/views/SafetyStock.vue @@ -8,10 +8,11 @@ - - + + + - + @@ -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() => { diff --git a/src/views/Shipping.vue b/src/views/Shipping.vue index 52b85c88..4ff188d5 100644 --- a/src/views/Shipping.vue +++ b/src/views/Shipping.vue @@ -21,10 +21,11 @@ - - + + + - + @@ -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); diff --git a/src/views/StorePickup.vue b/src/views/StorePickup.vue index 89da5497..50a5cf9d 100644 --- a/src/views/StorePickup.vue +++ b/src/views/StorePickup.vue @@ -21,10 +21,11 @@ - - + + + - + @@ -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); diff --git a/src/views/Threshold.vue b/src/views/Threshold.vue index 902e228c..4098ae16 100644 --- a/src/views/Threshold.vue +++ b/src/views/Threshold.vue @@ -8,10 +8,11 @@ - - + + + - + @@ -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() => {
+ {{ translate("No archived rules") }} +