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.
125 lines
4.3 KiB
TypeScript
125 lines
4.3 KiB
TypeScript
import { vacationRuleResponse } from './../model/vacationRule.Respond';
|
|
import { notificationTypeRequest } from './../model/notification.Request';
|
|
import { DeleteVacationRuleRequest } from './../model/deleteVacationRule.Request';
|
|
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
|
|
import { VacationRuleServiceService } from './../service/vacation-rule-service.service';
|
|
import { VacationRuleRequest } from './../model/VacationRuleRequest';
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
|
|
import { NavigationExtras, Router } from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'app-home',
|
|
templateUrl: './home.component.html',
|
|
styleUrls: ['./home.component.scss'],
|
|
})
|
|
export class HomeComponent implements OnInit {
|
|
|
|
userName: any;
|
|
P_PAGE_NUM: number;
|
|
P_PAGE_LIMIT: number;
|
|
GetVacationRulesList: any = [];
|
|
isUpdate: boolean = false;
|
|
IsReachEnd: boolean = false;
|
|
RespondAttributeList: any;
|
|
|
|
|
|
constructor(public vacationRuleService: VacationRuleServiceService, public ts: TranslatorService, public cs: CommonService, private router: Router) {
|
|
this.P_PAGE_NUM = 1;
|
|
this.P_PAGE_LIMIT = 50;
|
|
}
|
|
|
|
ngOnInit() {
|
|
console.log('OnInit');
|
|
this.getVacationRules();
|
|
console.log(this.GetVacationRulesList);
|
|
}
|
|
|
|
Vacation_Type() {
|
|
this.cs.navigateForward('/vacation-rule/vacation-type');
|
|
}
|
|
|
|
getVacationRules() {
|
|
this.GetVacationRulesList = [];
|
|
this.P_PAGE_NUM = 1;
|
|
this.IsReachEnd = false;
|
|
let request: VacationRuleRequest = new VacationRuleRequest();
|
|
request.P_PAGE_LIMIT = this.P_PAGE_LIMIT;
|
|
request.P_PAGE_NUM = this.P_PAGE_NUM;
|
|
|
|
this.vacationRuleService.getVacationRule(request, () => {
|
|
this.getVacationRules();
|
|
}, this.ts.trPK('general', 'retry')).subscribe((result) => {
|
|
if (this.cs.validResponse(result)) {
|
|
// console.log(result);
|
|
// console.log(JSON.stringify(result));
|
|
this.GetVacationRulesList = result.GetVacationRulesList;
|
|
} else {
|
|
this.cs.presentAlert(result.ErrorEndUserMessage);
|
|
}
|
|
});
|
|
}
|
|
|
|
deleteFunc(i) {
|
|
let alert = this.cs.confirmAlertDialog(() => {
|
|
this.deleteVacationRule(i);
|
|
}, this.ts.trPK('general', 'ok'), () => {
|
|
}, this.ts.trPK('general', 'cancel'), this.ts.trPK('vacation-rule', 'confirmation'), this.ts.trPK('vacation-rule', 'deleteVR'));
|
|
}
|
|
|
|
deleteVacationRule(i) {
|
|
let request: DeleteVacationRuleRequest = new DeleteVacationRuleRequest();
|
|
request.P_RULE_ID = this.GetVacationRulesList[i].RULE_ID;
|
|
this.vacationRuleService.deleteVacationRule(request, () => {
|
|
this.deleteVacationRule(i);
|
|
}, this.ts.trPK('general', 'retry')).subscribe((result) => {
|
|
if (this.cs.validResponse(result)) {
|
|
this.handleDeleteVacationRuleResult(result)
|
|
} else {
|
|
this.cs.presentAlert(result.ErrorEndUserMessage);
|
|
}
|
|
});
|
|
}
|
|
|
|
handleDeleteVacationRuleResult(result) {
|
|
if (this.cs.validResponse(result)) {
|
|
//this.navCtrl.push('HomePage');
|
|
this.cs.JustAlertDialog(this.ts.trPK('general', 'ok'), this.ts.trPK('vacation-rule', 'rule-delete-success'));
|
|
this.getVacationRules();
|
|
}
|
|
}
|
|
|
|
updateFunc(i) {
|
|
this.respondAttributes(i);
|
|
|
|
this.cs.sharedService.setSharedData(this.GetVacationRulesList[i], vacationRuleResponse.SHARED_DATA);
|
|
this.isUpdate = true;
|
|
|
|
this.cs.sharedService.setSharedData(this.isUpdate, 'isUpdate');
|
|
this.router.navigate(['/vacation-rule/create-vacation-rule']);
|
|
}
|
|
|
|
|
|
respondAttributes(i) {
|
|
let request: notificationTypeRequest = new notificationTypeRequest();
|
|
request.P_NOTIFICATION_NAME = this.GetVacationRulesList[i].NOTIFICATION_NAME;
|
|
request.P_ITEM_TYPE = this.GetVacationRulesList[i].ITEM_TYPE;
|
|
this.vacationRuleService.respondAttributes(request, () => {
|
|
this.respondAttributes(i);
|
|
}, this.ts.trPK('general', 'retry')).subscribe((result) => {
|
|
this.handlerespondAttributesResult(result, i);
|
|
});
|
|
|
|
}
|
|
handlerespondAttributesResult(result, i) {
|
|
// console.log("Respond att: ")
|
|
if (this.cs.validResponse(result)) {
|
|
// console.log(result.RespondAttributesList);
|
|
this.RespondAttributeList = result.RespondAttributesList;
|
|
this.GetVacationRulesList[i].RespondAttributeList = this.RespondAttributeList;
|
|
}
|
|
}
|
|
|
|
|
|
}
|