From 62730d53b663558e515b2021e7f92d829628ed3e Mon Sep 17 00:00:00 2001 From: test Date: Tue, 7 Jul 2020 12:04:59 +0200 Subject: [PATCH] sprint form code clean up --- .../sprint-form/sprint-form.component.html | 17 +++++----- src/app/sprint-form/sprint-form.component.ts | 33 ++++++++++++------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/app/sprint-form/sprint-form.component.html b/src/app/sprint-form/sprint-form.component.html index 7b197d2..bb00ac8 100644 --- a/src/app/sprint-form/sprint-form.component.html +++ b/src/app/sprint-form/sprint-form.component.html @@ -1,3 +1,5 @@ + +
@@ -9,28 +11,25 @@
+ id="titleField">
+ [value]="sprint.startDate | date: 'yyyy-MM-dd'" (change)="sprint.startDate=startDate.value" + id="startDateField">
+ [value]="sprint.endDate | date: 'yyyy-MM-dd'" (change)="sprint.endDate=endDate.value" id="endDateField">
-
-
-
+ \ No newline at end of file diff --git a/src/app/sprint-form/sprint-form.component.ts b/src/app/sprint-form/sprint-form.component.ts index d08d8b1..ad55a0f 100644 --- a/src/app/sprint-form/sprint-form.component.ts +++ b/src/app/sprint-form/sprint-form.component.ts @@ -1,3 +1,4 @@ +// Importing necessary components and interfaces. import { Component, OnInit, Input } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { @@ -8,25 +9,31 @@ import { @Component({ selector: 'app-task-form', templateUrl: './sprint-form.component.html', - styleUrls: [ './sprint-form.component.css' ] + styleUrls: ['./sprint-form.component.css'] }) + +// Class implements the logic for a popup window form to create and modify sprints. export class SprintFormComponent implements OnInit { @Input() public sprint: ScrumSprint; public editing: Boolean; public sprintid: string; - constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {} + constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { } - ngOnInit(): void { - if (this.sprint === null || this.sprint === undefined) { - this.sprint = { title: '', startDate: '', endDate: ''}; //project id missing... - this.editing = false; - } else { - this.editing = true; - } - document.getElementById('titleField').focus(); - } + // If no sprint exists a new one will be created. + // In other cases the sprint exists and gets modifiable. + ngOnInit(): void { + if (this.sprint === null || this.sprint === undefined) { + this.sprint = { title: '', startDate: '', endDate: '' }; + this.editing = false; + } else { + this.editing = true; + } + document.getElementById('titleField').focus(); + } + // A new created sprint will be saved in backend (POST). + // If a sprint already exists, modifying results an update (PUT) to the backend. onSubmit() { if (this.editing) { this.backendService.putSprint(this.sprint).subscribe((response) => { @@ -42,10 +49,12 @@ export class SprintFormComponent implements OnInit { } }); } + // Closes the popup window after submitting/canceling. this.activeModalService.close(this.sprint); } + // Closes the popup form window (by clicking "close button"). onClose() { this.activeModalService.dismiss(this.sprint); } -} +} \ No newline at end of file