Forked from ninoalamokmc/gist:8f1e2de45eb8d4fc93215a88b1456192
Created
February 20, 2018 04:44
-
-
Save tuldok89/1f1fe286df97d6bca806c381a11ab89e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { Http, Headers } from '@angular/http'; | |
import { NgForm, FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; | |
import { Router, ActivatedRoute } from '@angular/router'; | |
import { JobRequirementService } from '../../../services/jobrequirements.service'; | |
import { ClientService } from '../../../services/clients.service'; | |
import { ClientData } from '../../client/clientdata'; | |
import { IData } from '../../model/IData'; | |
import { CategoryData } from '../../model/categorydata'; | |
import { GenericService } from '../../../services/generic.service'; | |
@Component({ | |
selector: 'createJobrequirement', | |
templateUrl: './addJobRequirement.component.html' | |
}) | |
export class CreateJobRequirement implements OnInit { | |
jobRequirementForm: FormGroup; | |
title: string = "Create"; | |
id: string; | |
errorMessage: any; | |
public clientList: ClientData[]; | |
public categories: IData[]; | |
public jobLevels: IData[]; | |
public employmentTypes: IData[]; | |
public employmentTerms: IData[]; | |
public shifts: IData[]; | |
public workweeks: IData[]; | |
public holidays: IData[]; | |
public hmoEntitlment: IData[]; | |
constructor( | |
private _fb: FormBuilder, | |
private _avRoute: ActivatedRoute, | |
private _jobRequirementService: JobRequirementService, | |
private _clientService: ClientService, | |
private _genericService: GenericService, | |
private _router: Router) { | |
if (this._avRoute.snapshot.params["id"]) { | |
this.id = this._avRoute.snapshot.params["id"]; | |
} | |
this.jobRequirementForm = this._fb.group({ | |
id: [''], | |
name: ['', [Validators.required]], | |
poc: ['', [Validators.required]], | |
immediateSuperior: ['', [Validators.required]], | |
immediateSuperiorTitle: ['', [Validators.required]], | |
educationalAttainment: ['', [Validators.required]], | |
degrees: '', | |
minWorkExperience: [1, [Validators.required]], | |
maxWorkExperience: [2, [Validators.required]], | |
quantity: [1, [Validators.required]], | |
postingDate: ['', [Validators.required]], | |
dueDate: ['', [Validators.required]], | |
workdays: '', | |
restdays: '', | |
skills: ['', [Validators.required]], | |
jobDescription: ['', [Validators.required]], | |
clientId: ['', [Validators.required]], | |
jobLevelId: ['', [Validators.required]], | |
jobCategoryId: ['', [Validators.required]], | |
shiftId: ['', [Validators.required]], | |
workWeekId: ['', [Validators.required]], | |
holidaysToFollowId: ['', [Validators.required]], | |
employmentTypeId: ['', [Validators.required]], | |
termsOfEmploymentId: ['', [Validators.required]], | |
overtimePay: true, | |
holidayPremiumPay: true, | |
nightDiffential: true, | |
leaveEntitlement: '', | |
leaveCredits: '', | |
numberOfLeaveMonetized: '', | |
hmoEntitlement: '', | |
hmoCoverage: '', | |
yearEndShutdown: true, | |
basicSalary: 0.00, | |
deMinimis: 0.00, | |
reimbursableAllowance: 0.00, | |
regularizationIncrease: 0.00, | |
signingBonus: 0.00, | |
additional: '' | |
}) | |
} | |
ngOnInit() { | |
if (!(this.id == '' || this.id == undefined || this.id == 'undefined' || this.id == '00000000-0000-0000-0000-000000000000')){ | |
this.title = "Edit"; | |
this._jobRequirementService.getJobRequirementById(this.id) | |
.subscribe(resp => this.jobRequirementForm.setValue(resp) | |
, error => this.errorMessage = error); | |
} | |
this._clientService.getClients().subscribe(data => this.clientList = data); | |
this._genericService.getCategories().subscribe(data => this.categories = data); | |
this._genericService.getJobLevels().subscribe(data => this.jobLevels = data); | |
this._genericService.getEmploymentTypes().subscribe(data => this.employmentTypes = data); | |
this._genericService.getEmploymentTerms().subscribe(data => this.employmentTerms = data); | |
this._genericService.getShifts().subscribe(data => this.shifts = data); | |
this._genericService.getWorkWeeks().subscribe(data => this.workweeks = data); | |
this._genericService.getHolidayss().subscribe(data => this.holidays = data); | |
} | |
save() { | |
if (!this.jobRequirementForm.valid) { | |
return; | |
} | |
if (this.title == "Create") { | |
this._jobRequirementService.saveJobRequirement(this.jobRequirementForm.value) | |
.subscribe((data) => { | |
this._router.navigate(['/fetch-jobrequirement']); | |
}, error => this.errorMessage = error) | |
} | |
else if (this.title == "Edit") { | |
this._jobRequirementService.updateJobRequirement(this.jobRequirementForm.value) | |
.subscribe((data) => { | |
this._router.navigate(['/fetch-jobrequirement']); | |
}, error => this.errorMessage = error) | |
} | |
} | |
cancel() { | |
this._router.navigate(['/fetch-jobrequirement']); | |
} | |
get name() { return this.jobRequirementForm.get('name'); } | |
get poc() { return this.jobRequirementForm.get('poc'); } | |
get immediateSuperior() { return this.jobRequirementForm.get('immediateSuperior'); } | |
get immediateSuperiorTitle() { return this.jobRequirementForm.get('immediateSuperiorTitle'); } | |
get educationalAttainment() { return this.jobRequirementForm.get('educationalAttainment'); } | |
get degrees() { return this.jobRequirementForm.get('degrees'); } | |
get minWorkExperience() { return this.jobRequirementForm.get('minWorkExperience'); } | |
get maxWorkExperience() { return this.jobRequirementForm.get('maxWorkExperience'); } | |
get quantity() { return this.jobRequirementForm.get('quantity'); } | |
get postingDate() { return this.jobRequirementForm.get('postingDate'); } | |
get dueDate() { return this.jobRequirementForm.get('dueDate'); } | |
get workdays() { return this.jobRequirementForm.get('workdays'); } | |
get restdays() { return this.jobRequirementForm.get('restdays'); } | |
get skills() { return this.jobRequirementForm.get('skills'); } | |
get jobDescription() { return this.jobRequirementForm.get('jobDescription'); } | |
get clientId() { return this.jobRequirementForm.get('clientId'); } | |
get jobLevelId() { return this.jobRequirementForm.get('jobLevelId'); } | |
get jobCategoryId() { return this.jobRequirementForm.get('jobCategoryId'); } | |
get shiftId() { return this.jobRequirementForm.get('shiftId'); } | |
get workWeekId() { return this.jobRequirementForm.get('workWeekId'); } | |
get holidaysToFollowId() { return this.jobRequirementForm.get('holidaysToFollowId'); } | |
get employmentTypeId() { return this.jobRequirementForm.get('employmentTypeId'); } | |
get termsOfEmploymentId() { return this.jobRequirementForm.get('termsOfEmploymentId'); } | |
get overtimePay() { return this.jobRequirementForm.get('overtimePay'); } | |
get holidayPremiumPay() { return this.jobRequirementForm.get('holidayPremiumPay'); } | |
get nightDifferential() { return this.jobRequirementForm.get('nightDifferential'); } | |
get leaveEntitlement() { return this.jobRequirementForm.get('leaveEntitlement'); } | |
get leaveCredits() { return this.jobRequirementForm.get('leaveCredits'); } | |
get numberOfLeaveMonetized() { return this.jobRequirementForm.get('numberOfLeaveMonetized'); } | |
get hmoEntitlement() { return this.jobRequirementForm.get('hmoEntitlement'); } | |
get hmoCoverage() { return this.jobRequirementForm.get('hmoCoverage'); } | |
get yearEndShutdown() { return this.jobRequirementForm.get('yearEndShutdown'); } | |
get basicSalary() { return this.jobRequirementForm.get('basicSalary'); } | |
get deMinimis() { return this.jobRequirementForm.get('deMinimis'); } | |
get reimbursableAllowance() { return this.jobRequirementForm.get('reimbursableAllowance'); } | |
get regularizationIncrease() { return this.jobRequirementForm.get('regularizationIncrease'); } | |
get signingBonus() { return this.jobRequirementForm.get('signingBonus'); } | |
get additional() { return this.jobRequirementForm.get('additional'); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment