import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { Component, OnInit } from '@angular/core'; import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; @Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.scss'], }) export class HomeComponent implements OnInit { menu: any; pages: any; headerTitle: string; selMenu: MenuResponse = new MenuResponse(); // Selected Side Menu selectedMenu: any; constructor(private cs: CommonService, private ts: TranslatorService) { this.menu = this.cs.sharedService.getSharedData('menuEntries', false); this.selMenu = this.cs.sharedService.getSharedData(MenuResponse.SHARED_DATA, false); let title: string = this.ts.trPK('eit', 'my-requests'); this.headerTitle = this.selMenu.List_Menu.MENU_NAME ? this.selMenu.List_Menu.MENU_NAME : title; } ngOnInit() { } openPage(page, index) { // Reset the content nav to have just this page // we wouldn't want the back button to show in this scenario if (page.children.length == 0) { this.goToRequest(page); } else { if (this.selectedMenu == 0) { this.selectedMenu = -1; } else if (this.selectedMenu != -1) { this.selectedMenu = -1; } else { this.selectedMenu = index; } } } goToRequest(menuEntry) { let selMenu: MenuResponse = new MenuResponse(); selMenu = this.cs.sharedService.getSharedData(MenuResponse.SHARED_DATA, false); selMenu.GetMenuEntriesList = menuEntry; this.cs.sharedService.setSharedData(selMenu, MenuResponse.SHARED_DATA); if (menuEntry.REQUEST_TYPE == 'ABSENCE') { this.cs.openAbsencePage(); } else if (menuEntry.REQUEST_TYPE == 'EIT') { this.cs.openEitListPage(); } } }