EchoTex_Payroll/HRM.UI/ClientApp/src/app/payroll-ot/term-parameters/term-parameters.component.ts
2024-10-14 10:01:49 +06:00

130 lines
4.3 KiB
TypeScript

import {Component, OnInit} from '@angular/core';
import {OvertimeService} from '../../_services/payroll/overtime.service';
import {DataTransferService} from '../../data.transfer.service';
import {AppWindowPopUp} from '../../app.windowPopup.service';
import {UntilityHandlerService} from '../../utility.hanldler.service';
import {HRMNotificationService} from '../../app.notification.service';
import {BasicService} from '../../_services/Basic/basic.service';
import {Router} from '@angular/router';
import {EnumOverTimeType, EnumStatus} from '../../_models/enums';
import {TermParameter} from '../../_models/Payroll/termParameter';
import {Term} from '../../_models/Payroll/term';
import { ApiService } from '../../app.api.service';
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
@Component({
selector: 'app-term-parameters',
templateUrl: './term-parameters.component.html',
styleUrls: ['./term-parameters.component.css']
})
export class TermParametersComponent implements OnInit {
_termParams: TermParameter[];
constructor(public otService: OvertimeService,
public datatransferservice: DataTransferService, public WindowPopUp: AppWindowPopUp,
public loadingPanelService: loadingPanelService,
public notificationService: HRMNotificationService,
public basicService: BasicService, public router: Router, public apiService: ApiService) {
this.apiService.selectedMenuName = "OT Policy Parametarization";
}
ngOnInit() {
this.basicService.getAllTerm(EnumStatus.Regardless).subscribe(
(x) => {
this.otService.terms = x;
this.loadingPanelService.ShowLoadingPanel = false;
},
(x) => {
this.notificationService.showError(x);
},
() => {
this.FreserchList();
});
this.otService.getAllTermParameters().subscribe(
(x) => {
this._termParams = x;
console.log(this._termParams);
debugger;
this.loadingPanelService.ShowLoadingPanel = false;
},
(x) => {
this.notificationService.showError(x);
},
() => {
this.FreserchList();
});
}
public FreserchList() {
if (this._termParams !== undefined && this.otService.terms !== undefined) {
this._termParams.forEach(x => {
const item: Term = this.otService.terms.find(ot => ot.id === x.termID);
if (item !== undefined) {
x.termName = item.name;
}
});
}
}
//public getTypeName(ottype:number): string {
// var str = "";
// switch (ottype) {
// case EnumOverTimeType.DailyBasicPercent:
// str = "Percent of Basic";
// default:
// }
// return str;
//}
edit({dataItem}) {
this.datatransferservice.setData(dataItem);
this.router.navigateByUrl('/payroll-ot/overtime-parameterization-entry');
}
removeHandler({ dataItem }) {
if (!confirm("Are you sure to delete the Item")) {
return;
}
const item: TermParameter = dataItem;
this.loadingPanelService.ShowLoadingPanel = true;
this.otService.deleteTermParameter(item).subscribe(
(x) => {
},
(x) => {
this.notificationService.showError(x);
this.loadingPanelService.ShowLoadingPanel = false;
},
() => {
this._termParams.splice(this._termParams.findIndex(x => x.id == item.id), 1);
this.loadingPanelService.ShowLoadingPanel = false;
this.notificationService.showSuccess("Data deleted successfully.")
});
}
editHandler({dataItem}) {
const Item: TermParameter = dataItem;
this.datatransferservice.setData(Item);
this.router.navigateByUrl('/payroll-ot/overtime-parameterization-entry');
}
addHandler() {
this.datatransferservice.setData(new TermParameter());
this.router.navigateByUrl('/payroll-ot/overtime-parameterization-entry');
}
onSubmit() {
}
cancel() {
}
}