260 lines
9.4 KiB
TypeScript
260 lines
9.4 KiB
TypeScript
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation, OnDestroy } from '@angular/core';
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|
import { ApiService } from '../app.api.service';
|
|
import { EmployeeServices } from '../_services/employee/employee.service';
|
|
import { SelectableSettings } from '@progress/kendo-angular-grid';
|
|
import { SearchEmployee, SearchManager } from '../_models/Employee/searchEmployee';
|
|
import { EnumExtension, EnumGender, EnumSearchFrom, EnumSearchObjDataType, EnumSearchParameter, EnumSQLOperator, EnumRequisitionApprovalStatus, EnumOnBoradStatus } from '../_models/enums';
|
|
import { DynamicPicker, EnumDynamicpickerType } from './dynamic-picker/Dynamic-Picker';
|
|
import { BasicService } from '../_services/Basic/basic.service';
|
|
import { Subscription } from 'rxjs';
|
|
import { PickerDataTransferService } from '../data.transfer.service';
|
|
import { loadingPanelService } from '../hrm-loding panel/loding.panel.service';
|
|
import { RecruitmentRequisition } from '../_models/Requisition/recruitmentRequisition';
|
|
import { RecruitmentService } from '../_services/recruitment/recruitment.service';
|
|
import { InternalRecruitment } from '../_models/Requisition/InternalRecruitment';
|
|
|
|
@Component({
|
|
selector: 'app-recruitement-recuisition-picker',
|
|
templateUrl: './recruitement-recuisition-picker.component.html',
|
|
// styleUrls: ['../../assets/kendo-grid/grid.css'],
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
})
|
|
|
|
export class RecruitementRecuisitionPickerComponent implements OnInit, OnDestroy {
|
|
valueChangedSubscription: Subscription;
|
|
genders: any = EnumExtension.getNamesAndValues(EnumGender);
|
|
public active = true;
|
|
public showPopUp = false;
|
|
public checkboxOnly = false;
|
|
public mode = 'multiple';
|
|
public selectableSettings: SelectableSettings;
|
|
taggedSelection: number[] = [];
|
|
/*public searchItems: RecruitmentRequisition[];*/
|
|
public searchItems: InternalRecruitment[];
|
|
public selectedItems: RecruitmentRequisition[] = [];
|
|
public selectedItem: InternalRecruitment;
|
|
public selectedRequisition: InternalRecruitment;
|
|
public searchRequisitions: InternalRecruitment[];
|
|
requisitionName: string;
|
|
requisitionApprovalStatus: EnumRequisitionApprovalStatus;
|
|
requisitionOnBoardStatuses: string;
|
|
public selectedAutoRequisition: string;
|
|
searchIcon: string = 'Search';
|
|
ItemCount: number = 0;
|
|
public requisitionNameList: Array<string>;
|
|
public empCodeNameListSource: Array<string>;
|
|
@Input() pickerFormGroup: FormGroup;
|
|
@Output() ItemSelected: EventEmitter<any> = new EventEmitter();
|
|
@Input()
|
|
public set setSelectedItem(inputedItem: InternalRecruitment) {
|
|
debugger;
|
|
if (inputedItem !== undefined) {
|
|
this.selectedAutoRequisition = inputedItem.positionNo;
|
|
/* this.selectedItem = inputedItem;*/
|
|
this.taggedSelection = [];
|
|
this.taggedSelection.push(this.selectedItem.id);
|
|
this.selectedItemText = this.selectedItem.positionNo;
|
|
} else {
|
|
this.selectedItem = new InternalRecruitment();
|
|
this.selectedItemText = '';
|
|
|
|
}
|
|
}
|
|
|
|
//private empCodeNameList: Array<string>;
|
|
//private empCodeNameListSource: Array<string>;
|
|
public selectedItemText: string;
|
|
public gridMultiSelect = false;
|
|
|
|
@Input()
|
|
public set MultiSelect(ismultiselect: boolean) {
|
|
if (ismultiselect !== undefined) {
|
|
/* this.gridMultiSelect = true;*/
|
|
this.gridMultiSelect = ismultiselect;
|
|
this.setSelectableSettings();
|
|
}
|
|
}
|
|
|
|
@Input()
|
|
public set isActive(isActive: boolean) {
|
|
this.active = isActive;
|
|
|
|
}
|
|
|
|
@Input()
|
|
public set GetApprovalStatus(approvalStatus: EnumRequisitionApprovalStatus) {
|
|
if (approvalStatus !== undefined) {
|
|
this.requisitionApprovalStatus = approvalStatus;
|
|
} else {
|
|
this.requisitionApprovalStatus = null;
|
|
}
|
|
}
|
|
@Input()
|
|
public set GetOnBoardStatus(onBoardStatus: string) {
|
|
this.requisitionOnBoardStatuses = onBoardStatus;
|
|
}
|
|
/** role-permission-entry ctor */
|
|
constructor(public api: ApiService,
|
|
public formBuilder: FormBuilder,
|
|
public router: Router,
|
|
public route: ActivatedRoute,
|
|
public empSrvc: EmployeeServices,
|
|
public basicService: BasicService,
|
|
public pickerService: PickerDataTransferService,
|
|
public loadingService: loadingPanelService,
|
|
public recruitmentService: RecruitmentService
|
|
) {
|
|
if (this.pickerFormGroup === undefined) {
|
|
this.pickerFormGroup = new FormGroup({
|
|
});
|
|
}
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.setSelectableSettings();
|
|
this.valueChangedSubscription == this.pickerService.dataChanged.subscribe(
|
|
x => {
|
|
if (x) {
|
|
//this.employeeCount = x;
|
|
}
|
|
}
|
|
);
|
|
|
|
}
|
|
|
|
setSelectableSettings(): void {
|
|
if (this.gridMultiSelect === false) {
|
|
this.selectableSettings = {
|
|
checkboxOnly: true,
|
|
mode: 'single', // this.mode
|
|
};
|
|
} else {
|
|
this.selectableSettings = {
|
|
checkboxOnly: true,
|
|
mode: 'multiple', // this.mode
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
search() {
|
|
let approvalStatus = (this.requisitionApprovalStatus === undefined || this.requisitionApprovalStatus === null) ? EnumRequisitionApprovalStatus.Not_Initiated : this.requisitionApprovalStatus;
|
|
|
|
let onBoardStatus = (this.requisitionOnBoardStatuses === undefined || this.requisitionOnBoardStatuses === ""
|
|
) ? null : this.requisitionOnBoardStatuses;
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.recruitmentService.getApprovesRecruitmentsPicker(approvalStatus, onBoardStatus).subscribe(
|
|
(resp) => {
|
|
this.searchItems = resp;
|
|
console.log(this.searchItems);
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
);
|
|
}
|
|
|
|
public onCancel(e): void {
|
|
this.closeForm();
|
|
}
|
|
|
|
public onSelect(e): void {
|
|
this.searchRequisitions = [];
|
|
this.selectedRequisition = new InternalRecruitment();
|
|
if (this.taggedSelection.length > 0) {
|
|
if (this.gridMultiSelect === true) {
|
|
this.taggedSelection.forEach(positionid => {
|
|
this.searchRequisitions.push(this.searchItems.find(x => x.id === positionid));
|
|
});
|
|
} else {
|
|
this.taggedSelection.forEach(positionid => {
|
|
this.selectedRequisition = this.searchItems.find(x => x.id === positionid);
|
|
});
|
|
}
|
|
}
|
|
if (this.gridMultiSelect === false) {
|
|
// this.selectedAutoCmptEmp = this.se
|
|
this.selectedAutoRequisition = this.selectedRequisition.positionName;
|
|
this.ItemSelected.emit(this.selectedRequisition);
|
|
this.requisitionName = this.selectedRequisition.positionName;
|
|
} else {
|
|
this.ItemSelected.emit(this.searchRequisitions);
|
|
}
|
|
this.showPopUp = false;
|
|
}
|
|
|
|
|
|
public closeForm(): void {
|
|
this.showPopUp = false;
|
|
}
|
|
|
|
public handleFilter(value) {
|
|
const str: string = value;
|
|
if (value.length === 0 || this.requisitionNameList === undefined) {
|
|
this.requisitionNameList = [];
|
|
this.empCodeNameListSource = [];
|
|
}
|
|
if (str !== '') {
|
|
if (this.requisitionNameList.length === 0) {
|
|
let code = '';
|
|
let name = '';
|
|
|
|
if (isNaN(value) === false) {
|
|
code = value;
|
|
} else {
|
|
name = value;
|
|
}
|
|
this.empCodeNameListSource = [];
|
|
this.searchItems.forEach(x => {
|
|
|
|
this.empCodeNameListSource.push(x.positionName);
|
|
});
|
|
this.requisitionNameList = this.empCodeNameListSource.filter((s) =>
|
|
s.toLowerCase().indexOf(value.toLowerCase()) !== -1);
|
|
} else {
|
|
|
|
this.requisitionNameList = this.empCodeNameListSource.filter((s) =>
|
|
s.toLowerCase().indexOf(value.toLowerCase()) !== -1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public valueChange(value: string): void {
|
|
if (value !== undefined && value !== '') {
|
|
/* const str: string[] = value.trim().split(' ');*/
|
|
const Searchreq = this.searchItems.find(x => x.positionName === value);
|
|
if (Searchreq !== undefined) {
|
|
this.selectedRequisition = Searchreq;
|
|
this.ItemSelected.emit(this.selectedRequisition);
|
|
} else {
|
|
this.selectedRequisition = undefined;
|
|
this.ItemSelected.emit(undefined);
|
|
}
|
|
} else {
|
|
this.selectedRequisition = undefined;
|
|
this.ItemSelected.emit(undefined);
|
|
}
|
|
}
|
|
|
|
public OpenForm(): void {
|
|
//this.selectedEmployees = [];
|
|
//this.selectedEmployee = new SearchEmployee();
|
|
//this.taggedSelection = [];
|
|
this.showPopUp = true;
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
|
|
|
|
|
|
}
|