update task query from firebase

This commit is contained in:
Chneemann 2024-03-26 23:11:38 +01:00
parent 136f280705
commit ea00e9b959
2 changed files with 19 additions and 5 deletions

View file

@ -32,7 +32,7 @@
><img src="./../../../assets/img/board/add.svg" alt="add" />
</div>
<div id="todo" class="details">
@for(task of getTask('todo'); track task) {
@for(task of todoTasks; ; track task) {
<app-task [task]="task"></app-task>
} @empty {
<app-task-empty>No tasks</app-task-empty>
@ -49,7 +49,7 @@
><img src="./../../../assets/img/board/add.svg" alt="add" />
</div>
<div id="inprogress" class="details">
@for(task of getTask('inprogress'); track task) {
@for(task of inprogressTasks; track task) {
<app-task [task]="task"></app-task>
} @empty {
<app-task-empty>No tasks</app-task-empty>
@ -66,7 +66,7 @@
><img src="./../../../assets/img/board/add.svg" alt="add" />
</div>
<div id="awaitfeedback" class="details">
@for(task of getTask('awaitfeedback'); track task) {
@for(task of awaitfeedbackTasks; track task) {
<app-task [task]="task"></app-task>
} @empty {
<app-task-empty>No tasks</app-task-empty>
@ -83,7 +83,7 @@
><img src="./../../../assets/img/board/add.svg" alt="add" />
</div>
<div id="done" class="details">
@for(task of getTask('done'); track task) {
@for(task of doneTasks; track task) {
<app-task [task]="task"></app-task>
} @empty {
<app-task-empty>No tasks</app-task-empty>

View file

@ -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(