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
// creates controls inside each day of week | |
initDayTaskInfo(day: DayInfoProject, date: Date) { | |
let dayTask = this.fb.group({ | |
comments: new FormControl(day.comments), | |
day: new FormControl(date), | |
hours: new FormControl(day.hours, (Validators.min(0), Validators.max(24))), | |
open: new FormControl(day.open), | |
tasks: this.initTaskInfo(day.tasks) | |
}) |
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
// creates controls for each day of week in hoursHashMap form group | |
initHoursHashMap(data: HoursHashMap) { | |
return this.fb.group({ | |
Sunday: this.initDayTaskInfo(data.Sunday, this.sunday), | |
Monday: this.initDayTaskInfo(data.Monday, this.monday), | |
Tuesday: this.initDayTaskInfo(data.Tuesday, this.tuesday), | |
Wednesday: this.initDayTaskInfo(data.Wednesday, this.wednesday), | |
Thursday: this.initDayTaskInfo(data.Thursday, this.thursday), | |
Friday: this.initDayTaskInfo(data.Friday, this.friday), |
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
addProjects() { | |
this.projectTimesheet.forEach(d => { | |
let group; | |
group = this.fb.group({ | |
clientId: d.clientId, | |
clientName: d.clientName, | |
endDate: d.endDate, | |
hoursHashMap: this.initHoursHashMap(d.hoursHashMap), | |
projectCode: d.projectCode, | |
projectDesc: d.projectDesc, |
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, Input, Output, EventEmitter } from '@angular/core'; | |
import { FormGroup, FormBuilder, FormArray, FormControl, Validators } from '@angular/forms'; | |
@Component({ | |
selector: 'app-project-timesheet', | |
templateUrl: './project-timesheet.component.html', | |
styleUrls: ['./project-timesheet.component.scss'] | |
}) |
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
<app-project-timesheet (project)="getProjectForm($event)"></app-project-timesheet> | |
<app-admin-timesheet (admin)="getAdminForm($event)"></app-admin-timesheet> |
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
// gets form data for adminTime from child component admin timesheet | |
getAdminForm(adminFormData: FormGroup) { | |
this.adminForm = adminFormData.get('adminTime').value; | |
this.timesheetForm.get('adminTime').patchValue(this.adminForm); | |
} | |
// get form data for projectTime from child component project timesheet | |
getProjectForm(projectFormData: FormGroup) { | |
this.projectForm = projectFormData.get('projectTime').value; |
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
patchValues(timesheetData: any) { | |
this.timesheetForm.get('comments').patchValue(timesheetData.comments); | |
this.timesheetForm.get('projectTime').patchValue(timesheetData.projectTime); | |
this.timesheetForm.get('adminTime').patchValue(timesheetData.adminTime); | |
} |
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
initDataSource(data: any) { | |
this.adminTimesheet = data.adminTime; | |
this.projectTimesheet = data.projectTime; | |
this.patchValues(data); | |
} |
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
createTimesheetForm() { | |
this.timesheetForm = this.fb.group({ | |
comments: new FormControl(null), | |
projectTime: new FormControl(null), // project timesheet component | |
adminTime: new FormControl(null), // admin timesheet component | |
}) | |
} |
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
export class TimesheetSubmitComponent implements OnInit { | |
adminTimesheet = []; | |
projectTimesheet = []; | |
timesheetForm: FormGroup; | |
adminForm: FormGroup; | |
projectForm: FormGroup; |