sprint form code clean up
This commit is contained in:
parent
f1ab3156e5
commit
62730d53b6
@ -1,3 +1,5 @@
|
|||||||
|
<!--Popup form to create a new sprint-->
|
||||||
|
|
||||||
<div class="card" style="width: 100%;">
|
<div class="card" style="width: 100%;">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -20,13 +22,10 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Date">Enddatum</label>
|
<label for="Date">Enddatum</label>
|
||||||
<input #endDate type="date" class="form-control" id="Date" required name="date"
|
<input #endDate type="date" class="form-control" id="Date" required name="date"
|
||||||
[value]="sprint.endDate | date: 'yyyy-MM-dd'" (change)="sprint.endDate=endDate.value"
|
[value]="sprint.endDate | date: 'yyyy-MM-dd'" (change)="sprint.endDate=endDate.value" id="endDateField">
|
||||||
id="endDateField">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button (click)="onClose()" type="dismiss" class="btn btn-secondary"
|
<button (click)="onClose()" type="dismiss" class="btn btn-secondary" data-dismiss="modal">Abbrechen
|
||||||
data-dismiss="modal">Abbrechen
|
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="btn btn-primary">Sprint starten</button>
|
<button type="submit" class="btn btn-primary">Sprint starten</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Importing necessary components and interfaces.
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import {
|
import {
|
||||||
@ -10,6 +11,8 @@ import {
|
|||||||
templateUrl: './sprint-form.component.html',
|
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 {
|
export class SprintFormComponent implements OnInit {
|
||||||
@Input() public sprint: ScrumSprint;
|
@Input() public sprint: ScrumSprint;
|
||||||
public editing: Boolean;
|
public editing: Boolean;
|
||||||
@ -17,9 +20,11 @@ export class SprintFormComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { }
|
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) { }
|
||||||
|
|
||||||
|
// If no sprint exists a new one will be created.
|
||||||
|
// In other cases the sprint exists and gets modifiable.
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.sprint === null || this.sprint === undefined) {
|
if (this.sprint === null || this.sprint === undefined) {
|
||||||
this.sprint = { title: '', startDate: '', endDate: ''}; //project id missing...
|
this.sprint = { title: '', startDate: '', endDate: '' };
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
} else {
|
} else {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
@ -27,6 +32,8 @@ export class SprintFormComponent implements OnInit {
|
|||||||
document.getElementById('titleField').focus();
|
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() {
|
onSubmit() {
|
||||||
if (this.editing) {
|
if (this.editing) {
|
||||||
this.backendService.putSprint(this.sprint).subscribe((response) => {
|
this.backendService.putSprint(this.sprint).subscribe((response) => {
|
||||||
@ -42,9 +49,11 @@ export class SprintFormComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Closes the popup window after submitting/canceling.
|
||||||
this.activeModalService.close(this.sprint);
|
this.activeModalService.close(this.sprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Closes the popup form window (by clicking "close button").
|
||||||
onClose() {
|
onClose() {
|
||||||
this.activeModalService.dismiss(this.sprint);
|
this.activeModalService.dismiss(this.sprint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user