54 lines
1.2 KiB
TypeScript
54 lines
1.2 KiB
TypeScript
import { Component, OnInit, Input } from '@angular/core';
|
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
import {
|
|
BackendService,
|
|
ScrumTask,
|
|
Priority,
|
|
ScrumStatus,
|
|
ScrumCategory,
|
|
ScrumUser,
|
|
ScrumProject
|
|
} from '../services/backend.service';
|
|
|
|
@Component({
|
|
selector: 'app-task-form',
|
|
templateUrl: './task-form.component.html',
|
|
styleUrls: [ './task-form.component.css' ]
|
|
})
|
|
export class TaskFormComponent implements OnInit {
|
|
@Input() public task: ScrumTask;
|
|
public editing: Boolean;
|
|
|
|
constructor(private backendService: BackendService, private activeModalService: NgbActiveModal) {}
|
|
|
|
ngOnInit(): void {
|
|
if (this.task === null || this.task === undefined) {
|
|
this.task = { title: '' };
|
|
this.editing = false;
|
|
} else {
|
|
this.editing = true;
|
|
}
|
|
}
|
|
|
|
onSubmit() {
|
|
if (this.editing) {
|
|
this.backendService.putTask(this.task).subscribe((response) => {
|
|
if (response.status > 399) {
|
|
alert('Fehler');
|
|
}
|
|
});
|
|
} else {
|
|
this.backendService.postTask(this.task).subscribe((response) => {
|
|
if (response.status > 399) {
|
|
alert('Fehler');
|
|
}
|
|
});
|
|
}
|
|
this.activeModalService.close(this.task);
|
|
}
|
|
|
|
onClose() {
|
|
this.activeModalService.dismiss(this.task);
|
|
}
|
|
}
|