You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemmionic5/Mohem/src/app/eit/home/home.component.ts

82 lines
3.0 KiB
TypeScript

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';
import { TerminationServiceService } from 'src/app/termination/service/termination-service.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;
direction: string;
pageType: string;
constructor(private cs: CommonService, private ts: TranslatorService, public terminationService: TerminationServiceService) {
this.direction = TranslatorService.getCurrentLanguageName();
this.menu = this.cs.sharedService.getSharedData('menuEntries', false);
this.pageType = this.cs.sharedService.getSharedData('homemenuentries', false);
this.selMenu = this.cs.sharedService.getSharedData(MenuResponse.SHARED_DATA, false);
const title: string = this.ts.trPK('eit', 'my-requests');
this.headerTitle = this.menu.PROMPT ? this.menu.PROMPT : title;
}
ngOnInit() { }
openPage(page, index) {
console.log(page + "index" + 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;
}
}
if (page['FUNCTION_NAME'] == 'HR_TERM_SS') {
this.cs.sharedService.setSharedData(page, TerminationServiceService.TERMINATION_PAGE);
this.cs.openTermination();
}
console.log('selected>>>>>>>' + this.selectedMenu);
}
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();
} else if (menuEntry.REQUEST_TYPE === 'BASIC_DETAILS') {
this.cs.openProfile('basicDetails');
} else if (menuEntry.REQUEST_TYPE === 'ADDRESS' || menuEntry.REQUEST_TYPE === 'PHONE_NUMBERS') {
this.cs.openProfile('contact');
} else if (menuEntry.REQUEST_TYPE === 'CONTACT') {
this.cs.openProfile('family');
}
if (menuEntry.REQUEST_TYPE === 'PAYSLIP') {
this.cs.openPayslipPage();
}
if (menuEntry.REQUEST_TYPE === 'TIME_CARD') {
this.cs.openTimeCardPage();
}
}
}