diff --git a/src/app/components/board/board.component.html b/src/app/components/board/board.component.html
index ca4b5db..c5a8ef9 100644
--- a/src/app/components/board/board.component.html
+++ b/src/app/components/board/board.component.html
@@ -32,7 +32,7 @@
>
- @for(task of todoTasks; ; track task) {
+ @for(task of todoTasks; track task) {
} @empty {
No tasks
diff --git a/src/app/components/board/board.component.ts b/src/app/components/board/board.component.ts
index 30e3869..38bc8f0 100644
--- a/src/app/components/board/board.component.ts
+++ b/src/app/components/board/board.component.ts
@@ -24,19 +24,21 @@ export class BoardComponent {
constructor(
public dragDropService: DragDropService,
private taskService: TaskService
- ) {}
-
- ngOnInit() {
- this.dragDropService.itemDropped.subscribe(({ id, status }) => {
- this.handleItemDropped(id, status);
- });
+ ) {
this.taskService.subTaskList().subscribe(() => {
this.loadAllTasks();
});
}
+ ngOnInit() {
+ this.dragDropService.itemDropped.subscribe(({ id, status }) => {
+ this.handleItemDropped(id, status);
+ });
+ }
+
getTask(status: string): Task[] {
- if (this.taskService.filteredTasks.length > 0) {
+ const search = this.searchField.nativeElement.value.toLowerCase();
+ if (this.taskService.filteredTasks.length >= 0 && search !== '') {
return this.taskService.filteredTasks.filter(
(task) => task.status === status
);
@@ -74,5 +76,6 @@ export class BoardComponent {
task.description.toLowerCase().includes(search) ||
task.category.toLowerCase().includes(search)
);
+ this.loadAllTasks();
}
}
diff --git a/src/app/services/task.service.ts b/src/app/services/task.service.ts
index 14de255..e03a624 100644
--- a/src/app/services/task.service.ts
+++ b/src/app/services/task.service.ts
@@ -22,24 +22,21 @@ export class TaskService {
subTaskList() {
return new Observable
((observer) => {
- const unsubscribe = onSnapshot(this.getTaskRef(), (list) => {
- this.allTasks = [];
- list.forEach((element) => {
- const taskData = { ...(element.data() as Task), id: element.id };
- this.allTasks.push(taskData);
- });
- observer.next();
- });
-
- // Cleanup function
+ const unsubscribe = onSnapshot(
+ collection(this.firestore, 'tasks'),
+ (list) => {
+ this.allTasks = [];
+ list.forEach((element) => {
+ const taskData = { ...(element.data() as Task), id: element.id };
+ this.allTasks.push(taskData);
+ });
+ observer.next();
+ }
+ );
return () => unsubscribe();
});
}
- getTaskRef() {
- return collection(this.firestore, 'tasks');
- }
-
async updateTask(taskId: any, index: number) {
await updateDoc(
doc(collection(this.firestore, 'tasks'), taskId),