Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
<div class="menu-css">
<ion-list lines="none" class="sub-menu-list">
<ion-menu-toggle auto-hide="false" [class]="adminPage?.class" *ngIf="isOrgAdmin">
<ion-item [routerLink]="adminPage?.url" lines="none" detail="false" (click)="menuItemAction(adminPage)">
<ion-item [routerLink]="adminPage?.url" lines="none" detail="false" (click)="menuItemAction(adminPage)">
<ion-icon class="side-menu-icon" slot="start" [ios]="adminPage.icon + '-outline'" [md]="adminPage.icon + '-outline'"></ion-icon>
<ion-label class="sub-menu-list-label"><strong>{{ adminPage.title | translate}}</strong></ion-label>
<ion-label class="sub-menu-list-label"><strong [ngClass]="{'active': adminPage?.active}">{{adminPage.title | translate}}</strong></ion-label>
</ion-item>
</ion-menu-toggle>
<ion-menu-toggle auto-hide="false" *ngFor="let p of appPages; let i = index" [class]="p?.class">
<ion-item [routerLink]="p.url" lines="none" detail="false" (click)="menuItemAction(p)">
<ion-item [routerLink]="p.url" lines="none" detail="false" (click)="menuItemAction(p)">
<ion-icon class="side-menu-icon" slot="start" [ios]="p.icon + '-outline'" [md]="p.icon + '-outline'"></ion-icon>
<ion-label class="sub-menu-list-label"><strong>{{ p.title | translate}}</strong></ion-label>
<ion-label class="sub-menu-list-label"><strong [ngClass]="{'active': p.active}">{{p.title | translate}}</strong></ion-label>
</ion-item>
</ion-menu-toggle>
</ion-list>
Expand Down
3 changes: 3 additions & 0 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@
}
.cursor {
cursor: pointer;
}
.active {
color: var(--ion-color-primary);
}
56 changes: 46 additions & 10 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ export class AppComponent {
showMenu: boolean = false;
user;
public appPages = [
{ title: 'HOME', action: "home", icon: 'home', class:"hide-on-small-screen" , url: CommonRoutes.TABS+'/'+CommonRoutes.HOME},
{ title: 'MENTORS', action: "mentor-directory", icon: 'people', class:"hide-on-small-screen", url: CommonRoutes.TABS+'/'+CommonRoutes.MENTOR_DIRECTORY},
{ title: 'DASHBOARD', action: "dashboard", icon: 'stats-chart', class:"hide-on-small-screen", url: CommonRoutes.TABS+'/'+CommonRoutes.DASHBOARD },
{ title: 'HELP', action: "help", icon: 'help-circle', url: CommonRoutes.HELP},
{ title: 'FAQ', action: "faq", icon: 'alert-circle', url: CommonRoutes.FAQ},
{ title: 'HELP_VIDEOS', action: "help videos", icon: 'videocam',url: CommonRoutes.HELP_VIDEOS },
{ title: 'LANGUAGE', action: "selectLanguage", icon: 'language', url: CommonRoutes.LANGUAGE },
{ title: 'HOME', action: "home", icon: 'home', class:"hide-on-small-screen" , url: CommonRoutes.TABS+'/'+CommonRoutes.HOME, active: false, childrens : ['session-detail', 'home-search']},
{ title: 'MENTORS', action: "mentor-directory", icon: 'people', class:"hide-on-small-screen", url: CommonRoutes.TABS+'/'+CommonRoutes.MENTOR_DIRECTORY, active: false, childrens : ['mentor-profile', 'mentor-directory?search']},
{ title: 'DASHBOARD', action: "dashboard", icon: 'stats-chart', class:"hide-on-small-screen", url: CommonRoutes.TABS+'/'+CommonRoutes.DASHBOARD, active: false},
{ title: 'HELP', action: "help", icon: 'help-circle', url: CommonRoutes.HELP, active: false},
{ title: 'FAQ', action: "faq", icon: 'alert-circle', url: CommonRoutes.FAQ, active: false},
{ title: 'HELP_VIDEOS', action: "help videos", icon: 'videocam',url: CommonRoutes.HELP_VIDEOS , active: false},
{ title: 'LANGUAGE', action: "selectLanguage", icon: 'language', url: CommonRoutes.LANGUAGE, active: false },
];

adminPage = {title: 'ADMIN_WORKSPACE', action: "admin", icon: 'briefcase' ,class:'', url: CommonRoutes.ADMIN+'/'+CommonRoutes.ADMIN_DASHBOARD}
adminPage = {title: 'ADMIN_WORKSPACE', action: "admin", icon: 'briefcase' ,class:'', url: CommonRoutes.ADMIN+'/'+CommonRoutes.ADMIN_DASHBOARD, active:false, childrens : ['manage-user', 'manage-session', 'admin']}


isMentor:boolean
Expand All @@ -44,6 +44,7 @@ export class AppComponent {
backButtonSubscription: any;
menuSubscription: any;
routerSubscription: any;
activeUrl : string;
constructor(
private translate :TranslateService,
private platform : Platform,
Expand Down Expand Up @@ -88,8 +89,10 @@ export class AppComponent {
}
});
}
this.permissionService.fetchPermissions();
this.setActiveTab();
}

shouldHideMenu(url: string): boolean {
if(url.includes('/auth')){
return false;
Expand Down Expand Up @@ -223,6 +226,10 @@ export class AppComponent {
}

async menuItemAction(menu) {
this.appPages.forEach((element) => {
element.active = false
})
menu.active = true
switch (menu.title) {
case 'LANGUAGE': {
this.alert.create({
Expand All @@ -237,6 +244,35 @@ export class AppComponent {
}
}

setActiveTab() {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
this.activeUrl = this.router.url.substring(1);
//using the children array from apppage object
this.appPages.forEach((element) => {
let checkUrl = [];
switch (true) {
case (element.childrens && element.childrens.length > 0):
element.childrens.forEach((el) => {
checkUrl.push(el);
});
const isChildActive = checkUrl.some((child) => this.activeUrl.includes(child));
element.active = (isChildActive && (element.title === 'MENTORS' || element.title === 'HOME') ) || (this.activeUrl === element.url)
break;
default:
element.active = this.activeUrl === element.url;
}
});
let adminUrl = [];
this.adminPage.childrens.forEach((el) => {
adminUrl.push(el);
});
const isAdminChildActive = adminUrl.some((child) => this.activeUrl.includes(child));
this.adminPage.active = isAdminChildActive && (this.adminPage.title === 'ADMIN_WORKSPACE');
}
})
}

ngOnDestroy(): void {
if (this.userEventSubscription) {
this.userEventSubscription.unsubscribe();
Expand All @@ -249,7 +285,7 @@ export class AppComponent {
}
if (this.routerSubscription) {
this.routerSubscription.unsubscribe();
}
}
}
@HostListener('window:popstate', ['$event'])
onPopState(event: any) {
Expand Down