From ea00e9b9595ab0927af86b47a58eb714754c59a5 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Tue, 26 Mar 2024 23:11:38 +0100 Subject: [PATCH] update task query from firebase --- src/app/components/board/board.component.html | 8 ++++---- src/app/components/board/board.component.ts | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/app/components/board/board.component.html b/src/app/components/board/board.component.html index aa012db..ca4b5db 100644 --- a/src/app/components/board/board.component.html +++ b/src/app/components/board/board.component.html @@ -32,7 +32,7 @@ >add
- @for(task of getTask('todo'); track task) { + @for(task of todoTasks; ; track task) { } @empty { No tasks @@ -49,7 +49,7 @@ >add
- @for(task of getTask('inprogress'); track task) { + @for(task of inprogressTasks; track task) { } @empty { No tasks @@ -66,7 +66,7 @@ >add
- @for(task of getTask('awaitfeedback'); track task) { + @for(task of awaitfeedbackTasks; track task) { } @empty { No tasks @@ -83,7 +83,7 @@ >add
- @for(task of getTask('done'); track task) { + @for(task of doneTasks; track task) { } @empty { No tasks diff --git a/src/app/components/board/board.component.ts b/src/app/components/board/board.component.ts index 04b1775..30e3869 100644 --- a/src/app/components/board/board.component.ts +++ b/src/app/components/board/board.component.ts @@ -16,6 +16,10 @@ import { TaskEmptyComponent } from './task/task-empty/task-empty.component'; }) export class BoardComponent { @ViewChild('searchField') searchField!: ElementRef; + todoTasks: Task[] = []; + inprogressTasks: Task[] = []; + awaitfeedbackTasks: Task[] = []; + doneTasks: Task[] = []; constructor( public dragDropService: DragDropService, @@ -26,9 +30,12 @@ export class BoardComponent { this.dragDropService.itemDropped.subscribe(({ id, status }) => { this.handleItemDropped(id, status); }); + this.taskService.subTaskList().subscribe(() => { + this.loadAllTasks(); + }); } - getTask(status: string) { + getTask(status: string): Task[] { if (this.taskService.filteredTasks.length > 0) { return this.taskService.filteredTasks.filter( (task) => task.status === status @@ -38,6 +45,13 @@ export class BoardComponent { } } + loadAllTasks() { + this.todoTasks = this.getTask('todo'); + this.inprogressTasks = this.getTask('inprogress'); + this.awaitfeedbackTasks = this.getTask('awaitfeedback'); + this.doneTasks = this.getTask('done'); + } + handleItemDropped(id: string, status: string): void { const index = this.taskService.allTasks.findIndex((task) => task.id === id); const filteredIndex = this.taskService.filteredTasks.findIndex(