125 lines
4.4 KiB
TypeScript
125 lines
4.4 KiB
TypeScript
|
import {Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation} from '@angular/core';
|
||
|
import {FormControl, FormGroup} from '@angular/forms';
|
||
|
import {Router} from '@angular/router';
|
||
|
import {HRMNotificationService} from '../app.notification.service';
|
||
|
import {DataTransferService} from '../data.transfer.service';
|
||
|
import {loadingPanelService} from '../hrm-loding panel/loding.panel.service';
|
||
|
import {UntilityHandlerService} from '../utility.hanldler.service';
|
||
|
import {OrganogramBasic} from '../_models/Payroll/organogramBasic';
|
||
|
import {BasicService} from '../_services/Basic/basic.service';
|
||
|
import {OrganogramService} from '../_services/payroll/organogram.service';
|
||
|
|
||
|
|
||
|
@Component({
|
||
|
selector: 'app-Organogram-picker',
|
||
|
templateUrl: './organogram-picker.component.html',
|
||
|
styleUrls: ['./organogram-picker.component.css']
|
||
|
})
|
||
|
export class OrganogramPickerComponent implements OnInit {
|
||
|
dropDownType: any;
|
||
|
dropDown: string;
|
||
|
showModal: boolean;
|
||
|
IsNew: boolean;
|
||
|
MultiSelect: boolean = false;
|
||
|
OrgCount: string;
|
||
|
@Input() VacantNodeSelection: boolean = true;
|
||
|
constructor(public organogramService: OrganogramService,
|
||
|
public datatransferservice: DataTransferService,
|
||
|
public utilityHandlerService: UntilityHandlerService,
|
||
|
public notificationService: HRMNotificationService,
|
||
|
public basicService: BasicService, public router: Router,
|
||
|
public panelService: loadingPanelService) {
|
||
|
}
|
||
|
|
||
|
_ogranograms: OrganogramBasic[];
|
||
|
selectedOrganograms: OrganogramBasic[];
|
||
|
selectedOrganogram: OrganogramBasic;
|
||
|
organogram: OrganogramBasic;
|
||
|
selectedNode: number[];
|
||
|
taggedSelection: number[] = [];
|
||
|
showPopUp: boolean;
|
||
|
active: boolean = false;
|
||
|
@Output() OnOrgPositionSelected: EventEmitter<any> = new EventEmitter();
|
||
|
|
||
|
ngOnInit() {
|
||
|
this.selectedNode = [];
|
||
|
this.organogram = new OrganogramBasic();
|
||
|
}
|
||
|
|
||
|
SearchOrg() {
|
||
|
this.panelService.ShowLoadingPanel = true;
|
||
|
this.organogramService.getOrganogramInfo().subscribe(
|
||
|
(resp: any) => {
|
||
|
this._ogranograms = resp;
|
||
|
},
|
||
|
(err: any) => {
|
||
|
this.panelService.ShowLoadingPanel = false;
|
||
|
},
|
||
|
() => {
|
||
|
|
||
|
this.panelService.ShowLoadingPanel = false;
|
||
|
this._ogranograms.forEach(x => {
|
||
|
if (x.employeeNoView != null || x.employeeNoView != undefined)
|
||
|
x.empNoNameView = x.positionName + '[' + x.employeeNoView + ' ' + x.employeeNameView + ']';
|
||
|
else x.empNoNameView = x.positionName;
|
||
|
});
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public OpenForm(): void {
|
||
|
this._ogranograms = [];
|
||
|
this.taggedSelection = [];
|
||
|
this.showPopUp = true;
|
||
|
}
|
||
|
|
||
|
public closeForm(): void {
|
||
|
this.showPopUp = false;
|
||
|
}
|
||
|
|
||
|
public iconClass(item: OrganogramBasic): any {
|
||
|
var str = 'blankPosition.png';
|
||
|
if (item.employeeNoView != null) {
|
||
|
str = 'assignedPosition.png';
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
|
||
|
public onSelect(e): void {
|
||
|
this.selectedOrganograms = [];
|
||
|
this.selectedOrganogram = undefined;
|
||
|
|
||
|
|
||
|
if (this.taggedSelection.length > 0) {
|
||
|
if (this.MultiSelect === true) {
|
||
|
this.taggedSelection.forEach(orgID => {
|
||
|
this.selectedOrganograms.push(this._ogranograms.find(x => x.id === orgID));
|
||
|
});
|
||
|
} else {
|
||
|
this.taggedSelection.forEach(orgID => {
|
||
|
this.selectedOrganogram = this._ogranograms.find(x => x.id === orgID);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
if (this.MultiSelect === false) {
|
||
|
if (this.VacantNodeSelection == true && this.OnOrgPositionSelected != undefined) {
|
||
|
if (this.selectedOrganogram.employeeNoView != undefined && this.selectedOrganogram.employeeNoView != '') {
|
||
|
this.notificationService.showWarning("please select a vacant Position");
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.OnOrgPositionSelected.emit(this.selectedOrganogram);
|
||
|
this.OrgCount = this.selectedOrganogram.positionName;
|
||
|
} else {
|
||
|
this.OnOrgPositionSelected.emit(this.selectedOrganograms);
|
||
|
this.OrgCount = this.selectedOrganograms.length.toString();
|
||
|
}
|
||
|
|
||
|
this.showPopUp = false;
|
||
|
}
|
||
|
|
||
|
}
|