Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Menu item is displaying as selected(#277) #231

Merged
merged 6 commits into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 54 additions & 19 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
</ion-header>
<ion-content>
<ion-list>
<ion-item v-if="hasPermission('APP_SELECT_PRODUCT_VIEW')" button @click="closeMenu(); router.push('/select-product')">
<ion-icon :icon="optionsOutline" slot="start" />
<ion-label>{{ $t("Create Rule") }}</ion-label>
</ion-item>
<ion-item v-if="hasPermission('APP_THRESHOLD_UPDATES_VIEW')" button @click="closeMenu(); router.push('/threshold-updates')">
<ion-icon :icon="pulseOutline" slot="start" />
<ion-label>{{ $t("Rule Pipeline") }}</ion-label>
</ion-item>
<ion-item button @click="closeMenu(); router.push('/settings')">
<ion-icon :icon="settingsOutline" slot="start" />
<ion-label>{{ $t("Settings") }}</ion-label>
</ion-item>
<ion-menu-toggle auto-hide="false" v-for="(page, index) in getValidMenuItems(appPages)" :key="index">
<ion-item
button
router-direction="root"
:router-link="page.url"
class="hydrated"
:class="{ selected: selectedIndex === index}">
<ion-icon slot="start" :ios="page.iosIcon" :md="page.mdIcon"></ion-icon>
<ion-label>{{ page.title }}</ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
</ion-content>
<ion-footer>
Expand Down Expand Up @@ -54,14 +53,14 @@
IonLabel,
IonList,
IonMenu,
IonMenuToggle,
IonNote,
IonSelect,
IonSelectOption,
IonTitle,
IonToolbar,
menuController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { defineComponent, computed } from "vue";
import { mapGetters } from "vuex";
import { useStore } from "@/store";
import { hasPermission } from "@/authorization";
Expand All @@ -80,6 +79,7 @@
IonLabel,
IonList,
IonMenu,
IonMenuToggle,
IonNote,
IonSelect,
IonSelectOption,
Expand All @@ -95,26 +95,61 @@
})
},
methods: {
async closeMenu() {
await menuController.close();
},
async setEComStore(event: CustomEvent) {
if(this.eComStore.productStoreId !== event.detail.value) {
await this.store.dispatch('user/setEcomStore', { 'productStoreId': event.detail.value })
emitter.emit("productStoreChanged")
}
},
getValidMenuItems(appPages: any) {
return appPages.filter((appPage: any) => (!appPage.meta || !appPage.meta.permissionId) || hasPermission(appPage.meta.permissionId));
}
},
setup() {
const store = useStore();
const router = useRouter();
const appPages = [
{
title: "Create Rule",
url: "/select-product",
iosIcon: optionsOutline,
mdIcon: optionsOutline,
meta: {
permissionId: "APP_SELECT_PRODUCT_VIEW"

}
},
{
title: "Rule Pipeline",
url: "/threshold-updates",
iosIcon: pulseOutline,
mdIcon: pulseOutline,
meta: {
permissionId: "APP_THRESHOLD_UPDATES_VIEW"
}
},
{
title: "Settings",
url: "/settings",
iosIcon: settingsOutline,
mdIcon: settingsOutline
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
}
];

const selectedIndex = computed(() => {
const path = router.currentRoute.value.path;
return appPages.findIndex((screen) => screen.url === path);
});

return {
appPages,
hasPermission,
router,
pulseOutline,
hasPermission,
optionsOutline,
settingsOutline,
store
selectedIndex,
store,
};
},
});
Expand Down
Loading