bugfixes search
This commit is contained in:
parent
ea00e9b959
commit
df42767b75
3 changed files with 22 additions and 22 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
><img src="./../../../assets/img/board/add.svg" alt="add" />
|
><img src="./../../../assets/img/board/add.svg" alt="add" />
|
||||||
</div>
|
</div>
|
||||||
<div id="todo" class="details">
|
<div id="todo" class="details">
|
||||||
@for(task of todoTasks; ; track task) {
|
@for(task of todoTasks; track task) {
|
||||||
<app-task [task]="task"></app-task>
|
<app-task [task]="task"></app-task>
|
||||||
} @empty {
|
} @empty {
|
||||||
<app-task-empty>No tasks</app-task-empty>
|
<app-task-empty>No tasks</app-task-empty>
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,21 @@ export class BoardComponent {
|
||||||
constructor(
|
constructor(
|
||||||
public dragDropService: DragDropService,
|
public dragDropService: DragDropService,
|
||||||
private taskService: TaskService
|
private taskService: TaskService
|
||||||
) {}
|
) {
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.dragDropService.itemDropped.subscribe(({ id, status }) => {
|
|
||||||
this.handleItemDropped(id, status);
|
|
||||||
});
|
|
||||||
this.taskService.subTaskList().subscribe(() => {
|
this.taskService.subTaskList().subscribe(() => {
|
||||||
this.loadAllTasks();
|
this.loadAllTasks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.dragDropService.itemDropped.subscribe(({ id, status }) => {
|
||||||
|
this.handleItemDropped(id, status);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getTask(status: string): Task[] {
|
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(
|
return this.taskService.filteredTasks.filter(
|
||||||
(task) => task.status === status
|
(task) => task.status === status
|
||||||
);
|
);
|
||||||
|
|
@ -74,5 +76,6 @@ export class BoardComponent {
|
||||||
task.description.toLowerCase().includes(search) ||
|
task.description.toLowerCase().includes(search) ||
|
||||||
task.category.toLowerCase().includes(search)
|
task.category.toLowerCase().includes(search)
|
||||||
);
|
);
|
||||||
|
this.loadAllTasks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,24 +22,21 @@ export class TaskService {
|
||||||
|
|
||||||
subTaskList() {
|
subTaskList() {
|
||||||
return new Observable<void>((observer) => {
|
return new Observable<void>((observer) => {
|
||||||
const unsubscribe = onSnapshot(this.getTaskRef(), (list) => {
|
const unsubscribe = onSnapshot(
|
||||||
this.allTasks = [];
|
collection(this.firestore, 'tasks'),
|
||||||
list.forEach((element) => {
|
(list) => {
|
||||||
const taskData = { ...(element.data() as Task), id: element.id };
|
this.allTasks = [];
|
||||||
this.allTasks.push(taskData);
|
list.forEach((element) => {
|
||||||
});
|
const taskData = { ...(element.data() as Task), id: element.id };
|
||||||
observer.next();
|
this.allTasks.push(taskData);
|
||||||
});
|
});
|
||||||
|
observer.next();
|
||||||
// Cleanup function
|
}
|
||||||
|
);
|
||||||
return () => unsubscribe();
|
return () => unsubscribe();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTaskRef() {
|
|
||||||
return collection(this.firestore, 'tasks');
|
|
||||||
}
|
|
||||||
|
|
||||||
async updateTask(taskId: any, index: number) {
|
async updateTask(taskId: any, index: number) {
|
||||||
await updateDoc(
|
await updateDoc(
|
||||||
doc(collection(this.firestore, 'tasks'), taskId),
|
doc(collection(this.firestore, 'tasks'), taskId),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue