234 lines
8.0 KiB
TypeScript
234 lines
8.0 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,EnumStatus,EnumAssetStatus} 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';
|
|
import {Asset,AssetSerial,AssetCategory} from '../_models/ExitClearance/existClearance';
|
|
import {ExitClearanceService} from '../_services/payroll/exitClearance.service';
|
|
import { Question, QuestionCategory } from '../_models/survey/survey';
|
|
import { SurveyService } from '../_services/survey/survey.service';
|
|
import { HRMNotificationService } from '../app.notification.service';
|
|
|
|
@Component({
|
|
selector: 'app-question-picker',
|
|
templateUrl: './question-picker.component.html',
|
|
//styleUrls: ['../../assets/kendo-grid/grid.css'],
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
})
|
|
|
|
export class QuestionPickerComponent implements OnInit, OnDestroy {
|
|
valueChangedSubscription: Subscription;
|
|
categoryID: number;
|
|
genders: any = EnumExtension.getNamesAndValues(EnumGender);
|
|
public active = false;
|
|
public showPopUp = false;
|
|
public checkboxOnly = false;
|
|
public mode = 'multiple';
|
|
public assetid:number;
|
|
public status:EnumAssetStatus;
|
|
public selectableSettings: SelectableSettings;
|
|
taggedSelection: number[] = [];
|
|
assetList:Asset[]=[];
|
|
/*public searchItems: RecruitmentRequisition[];*/
|
|
public searchItems: Question[];
|
|
public selectedQuestion: Question;
|
|
public searchQuestion: Question[]=[];
|
|
questionCategoryList: QuestionCategory[] = [];
|
|
requisitionName: string = 'Search Questions';
|
|
assetCategoryPicker: DynamicPicker;
|
|
searchIcon: string = 'Search';
|
|
ItemCount: number = 0;
|
|
searchItema: Question[] = [];
|
|
statusList: any = EnumExtension.getNamesAndValues(EnumAssetStatus);
|
|
@Input() pickerFormGroup: FormGroup;
|
|
@Output() ItemSelected: EventEmitter<any> = new EventEmitter();
|
|
@Input() pickerformControlName: string = "itemselected";
|
|
|
|
@Input()
|
|
public set setSelectedItem(inputedItem: Question) {
|
|
if (inputedItem !== undefined) {
|
|
this.selectedQuestion = inputedItem;
|
|
this.taggedSelection = [];
|
|
this.taggedSelection.push(this.selectedQuestion.id);
|
|
} else {
|
|
this.selectedQuestion = new Question();
|
|
|
|
}
|
|
}
|
|
|
|
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 isStatusActive(isActive: boolean) {
|
|
debugger;
|
|
this.active = isActive;
|
|
}
|
|
|
|
@Input()
|
|
public set setStatus(Status: EnumAssetStatus) {
|
|
debugger;
|
|
this.status = Status;
|
|
}
|
|
|
|
/** 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,
|
|
public exitClearanceService: ExitClearanceService,
|
|
public surveyService: SurveyService,
|
|
public notificationService: HRMNotificationService
|
|
) {
|
|
if (this.pickerFormGroup === undefined) {
|
|
this.pickerFormGroup = new FormGroup({});
|
|
}
|
|
this.getQuestionCategory();
|
|
}
|
|
|
|
public getQuestionCategory() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.surveyService.getQuestionCategories().subscribe(
|
|
(x) => {
|
|
this.questionCategoryList = x;
|
|
},
|
|
(x) => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.notificationService.showError(x);
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
|
|
});
|
|
}
|
|
|
|
ngOnInit() {
|
|
debugger;
|
|
this.assetCategoryPicker = new DynamicPicker(EnumDynamicpickerType.AssetCategory, true);
|
|
// this.status = EnumAssetStatus.Free;
|
|
this.setSelectableSettings();
|
|
this.valueChangedSubscription == this.pickerService.dataChanged.subscribe(
|
|
x => {
|
|
if (x) {
|
|
//this.employeeCount = x;
|
|
}
|
|
}
|
|
);
|
|
|
|
}
|
|
|
|
|
|
public clear() {
|
|
// this.dynamicPickerView.selectedID = 0;
|
|
// this.dynamicPickerView.selectedIDs = [];
|
|
// this.dynamicPickerView.selecteditemText = '';
|
|
|
|
}
|
|
|
|
setSelectableSettings(): void {
|
|
debugger;
|
|
if (this.gridMultiSelect === false) {
|
|
this.selectableSettings = {
|
|
checkboxOnly: true,
|
|
mode: 'single', // this.mode
|
|
};
|
|
} else {
|
|
this.selectableSettings = {
|
|
checkboxOnly: true,
|
|
mode: 'multiple', // this.mode
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
|
|
search() {
|
|
this.taggedSelection = [];
|
|
this.searchItems = [];
|
|
var categoryId = (this.categoryID == undefined || this.categoryID == null) ? 0 : this.categoryID;
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.surveyService.getByCategory(categoryId)
|
|
.subscribe(
|
|
(x) => { this.searchItems = x; },
|
|
|
|
(err) => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.notificationService.showError(err.error);
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
});
|
|
}
|
|
|
|
public onCancel(e): void {
|
|
this.closeForm();
|
|
}
|
|
|
|
public onSelect(e): void {
|
|
debugger;
|
|
this.searchQuestion = [];
|
|
this.selectedQuestion = new Question();
|
|
if (this.taggedSelection.length > 0) {
|
|
if (this.gridMultiSelect === true) {
|
|
this.taggedSelection.forEach(positionid => {
|
|
this.searchQuestion.push(this.searchItems.find(x => x.id === positionid));
|
|
});
|
|
} else {
|
|
this.taggedSelection.forEach(positionid => {
|
|
this.selectedQuestion = this.searchItems.find(x => x.id === positionid);
|
|
});
|
|
}
|
|
}
|
|
if (this.gridMultiSelect === false) {
|
|
this.ItemSelected.emit(this.selectedQuestion);
|
|
// this.requisitionName = this.selectedAssetSerial.serialNo;
|
|
} else {
|
|
this.ItemSelected.emit(this.searchQuestion);
|
|
}
|
|
this.showPopUp = false;
|
|
}
|
|
|
|
|
|
closeForm(): void {
|
|
this.showPopUp = false;
|
|
}
|
|
|
|
OpenForm(): void {
|
|
this.showPopUp = true;
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
|
|
|
|
}
|