Add task deletion.

This commit is contained in:
2022-03-05 12:11:41 +01:00
parent 5ad34da8f7
commit a5f4c18eb5
6 changed files with 63 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Task } from 'src/app/core/entity/task';
import { TaskListService } from 'src/app/core/service/task-list.service';
@@ -13,6 +13,7 @@ export class TaskDisplayComponent implements AfterViewInit {
@Input() task?: Task;
titleControl = new FormControl(this.task?.title);
isExpanded = false;
@ViewChild('titleInput', {static: true}) titleInput?: ElementRef<HTMLInputElement>;
constructor(
private _taskListService: TaskListService
@@ -34,4 +35,10 @@ export class TaskDisplayComponent implements AfterViewInit {
}
return result;
}
delete(): void {
if (this.task) {
this._taskListService.delete(this.task);
}
}
}