Skip to content

Commit

Permalink
Imporved: archived rule item rendering in list in case of rules and n…
Browse files Browse the repository at this point in the history
…o rules (#386)
  • Loading branch information
amansinghbais committed Nov 27, 2024
1 parent 2b7908b commit ebf3585
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/RuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 0 additions & 10 deletions src/store/modules/rule/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ const actions: ActionTree<RuleState, RootState> = {
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)
},
Expand Down
6 changes: 3 additions & 3 deletions src/views/SafetyStock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</ion-header>

<ion-content>
<main v-if="ruleGroup.ruleGroupId && rules.length">
<ScheduleRuleItem />
<main v-if="ruleGroup.ruleGroupId && (rules.length || archivedRules.length)">
<ScheduleRuleItem v-if="rules.length" />
<ArchivedRuleItem v-if="archivedRules?.length" />

<section>
<section v-if="rules.length">
<ion-reorder-group :disabled="false" @ionItemReorder="updateReorderingRules($event)">
<RuleItem v-for="(rule, ruleIndex) in (isReorderActive ? reorderingRules : rules)" :rule="rule" :ruleIndex="ruleIndex" :key="rule.ruleId" />
</ion-reorder-group>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Shipping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

<ion-content ref="contentRef" :scroll-events="true" @ionScroll="enableScrolling()">
<main v-if="selectedSegment !== 'SHIPPING_FACILITY'">
<template v-if="ruleGroup.ruleGroupId && rules.length">
<ScheduleRuleItem />
<template v-if="ruleGroup.ruleGroupId && (rules.length || archivedRules.length)">
<ScheduleRuleItem v-if="rules.length" />
<ArchivedRuleItem v-if="archivedRules?.length" />

<section>
<section v-if="rules.length">
<ion-reorder-group :disabled="false" @ionItemReorder="updateReorderingRules($event)">
<RuleItem v-for="(rule, ruleIndex) in (isReorderActive ? reorderingRules : rules)" :rule="rule" :ruleIndex="ruleIndex" :key="rule.ruleId" />
</ion-reorder-group>
Expand Down
6 changes: 3 additions & 3 deletions src/views/StorePickup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

<ion-content ref="contentRef" :scroll-events="true" @ionScroll="enableScrolling()">
<main v-if="selectedSegment !== 'PICKUP_FACILITY'">
<template v-if="ruleGroup.ruleGroupId && rules.length">
<ScheduleRuleItem />
<template v-if="ruleGroup.ruleGroupId && (rules.length || archivedRules.length)">
<ScheduleRuleItem v-if="rules.length" />
<ArchivedRuleItem v-if="archivedRules?.length" />

<section>
<section v-if="rules.length">
<ion-reorder-group :disabled="false" @ionItemReorder="updateReorderingRules($event)">
<RuleItem v-for="(rule, ruleIndex) in (isReorderActive ? reorderingRules : rules)" :rule="rule" :ruleIndex="ruleIndex" :key="rule.ruleId" />
</ion-reorder-group>
Expand Down
6 changes: 3 additions & 3 deletions src/views/Threshold.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</ion-header>

<ion-content>
<main v-if="ruleGroup.ruleGroupId && rules.length">
<ScheduleRuleItem />
<main v-if="ruleGroup.ruleGroupId && (rules.length || archivedRules.length)">
<ScheduleRuleItem v-if="rules.length" />
<ArchivedRuleItem v-if="archivedRules?.length" />

<section>
<section v-if="rules.length">
<ion-reorder-group :disabled="false" @ionItemReorder="updateReorderingRules($event)">
<RuleItem v-for="(rule, ruleIndex) in (isReorderActive ? reorderingRules : rules)" :rule="rule" :ruleIndex="ruleIndex" :key="rule.ruleId" />
</ion-reorder-group>
Expand Down

0 comments on commit ebf3585

Please sign in to comment.