added search function
This commit is contained in:
parent
cf508534fa
commit
3337482415
4 changed files with 93 additions and 87 deletions
|
|
@ -10,18 +10,18 @@
|
||||||
></div>
|
></div>
|
||||||
<section>
|
<section>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>Board</h1>
|
<div class="title">Board</div>
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<div>
|
<div>
|
||||||
<input
|
<input
|
||||||
id="searchfield"
|
#searchField
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Find Task"
|
placeholder="Find Task"
|
||||||
oninput="searchTask()"
|
(input)="searchTask()"
|
||||||
/>
|
/>
|
||||||
<span class="line"></span>
|
<span class="line"></span>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn-addtask" type="submit" onclick="openAddTaskPage()">
|
<button class="btn" type="submit" onclick="openAddTaskPage()">
|
||||||
<div class="btn-inside">
|
<div class="btn-inside">
|
||||||
<span>Add Task</span>
|
<span>Add Task</span>
|
||||||
<img src="./../../../assets/img/board/add_white.svg" alt="check" />
|
<img src="./../../../assets/img/board/add_white.svg" alt="check" />
|
||||||
|
|
@ -30,13 +30,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div id="content-headline">
|
<div class="status">
|
||||||
<div
|
<div
|
||||||
class="content-column"
|
class="column"
|
||||||
(dragover)="dragDropService.allowDrop($event)"
|
(dragover)="dragDropService.allowDrop($event)"
|
||||||
(drop)="dragDropService.drop($event, 'todo')"
|
(drop)="dragDropService.drop($event, 'todo')"
|
||||||
>
|
>
|
||||||
<div class="content-headline">
|
<div class="headline">
|
||||||
<span>To do</span
|
<span>To do</span
|
||||||
><img
|
><img
|
||||||
src="./../../../assets/img/board/add.svg"
|
src="./../../../assets/img/board/add.svg"
|
||||||
|
|
@ -44,12 +44,12 @@
|
||||||
onclick="openAddTaskPage('todo')"
|
onclick="openAddTaskPage('todo')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="content-todo">
|
<div id="todo">
|
||||||
<ng-container *ngIf="!isTaskRendered('todo')">
|
<ng-container *ngIf="!isTaskRendered('todo')">
|
||||||
<app-task [index]="undefined"></app-task>
|
<app-task [index]="undefined"></app-task>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
*ngFor="let task of firebaseService.filteredTasks; index as i"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="task.status === 'todo'">
|
<ng-container *ngIf="task.status === 'todo'">
|
||||||
<app-task [index]="i"></app-task>
|
<app-task [index]="i"></app-task>
|
||||||
|
|
@ -58,11 +58,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="content-column"
|
class="column"
|
||||||
(dragover)="dragDropService.allowDrop($event)"
|
(dragover)="dragDropService.allowDrop($event)"
|
||||||
(drop)="dragDropService.drop($event, 'inprogress')"
|
(drop)="dragDropService.drop($event, 'inprogress')"
|
||||||
>
|
>
|
||||||
<div class="content-headline">
|
<div class="headline">
|
||||||
<span>In progress</span
|
<span>In progress</span
|
||||||
><img
|
><img
|
||||||
src="./../../../assets/img/board/add.svg"
|
src="./../../../assets/img/board/add.svg"
|
||||||
|
|
@ -70,12 +70,12 @@
|
||||||
onclick="openAddTaskPage('inprogress')"
|
onclick="openAddTaskPage('inprogress')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="content-inprogress">
|
<div id="inprogress">
|
||||||
<ng-container *ngIf="!isTaskRendered('inprogress')">
|
<ng-container *ngIf="!isTaskRendered('inprogress')">
|
||||||
<app-task [index]="undefined"></app-task>
|
<app-task [index]="undefined"></app-task>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
*ngFor="let task of firebaseService.filteredTasks; index as i"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="task.status === 'inprogress'">
|
<ng-container *ngIf="task.status === 'inprogress'">
|
||||||
<app-task [index]="i"></app-task>
|
<app-task [index]="i"></app-task>
|
||||||
|
|
@ -84,11 +84,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="content-column"
|
class="column"
|
||||||
(dragover)="dragDropService.allowDrop($event)"
|
(dragover)="dragDropService.allowDrop($event)"
|
||||||
(drop)="dragDropService.drop($event, 'awaitfeedback')"
|
(drop)="dragDropService.drop($event, 'awaitfeedback')"
|
||||||
>
|
>
|
||||||
<div class="content-headline">
|
<div class="headline">
|
||||||
<span>Await feedback</span
|
<span>Await feedback</span
|
||||||
><img
|
><img
|
||||||
src="./../../../assets/img/board/add.svg"
|
src="./../../../assets/img/board/add.svg"
|
||||||
|
|
@ -96,12 +96,12 @@
|
||||||
onclick="openAddTaskPage('awaitfeedback')"
|
onclick="openAddTaskPage('awaitfeedback')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="content-awaitfeedback">
|
<div id="awaitfeedback">
|
||||||
<ng-container *ngIf="!isTaskRendered('awaitfeedback')">
|
<ng-container *ngIf="!isTaskRendered('awaitfeedback')">
|
||||||
<app-task [index]="undefined"></app-task>
|
<app-task [index]="undefined"></app-task>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
*ngFor="let task of firebaseService.filteredTasks; index as i"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="task.status === 'awaitfeedback'">
|
<ng-container *ngIf="task.status === 'awaitfeedback'">
|
||||||
<app-task [index]="i"></app-task>
|
<app-task [index]="i"></app-task>
|
||||||
|
|
@ -110,11 +110,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="content-column"
|
class="column"
|
||||||
(dragover)="dragDropService.allowDrop($event)"
|
(dragover)="dragDropService.allowDrop($event)"
|
||||||
(drop)="dragDropService.drop($event, 'done')"
|
(drop)="dragDropService.drop($event, 'done')"
|
||||||
>
|
>
|
||||||
<div class="content-headline">
|
<div class="headline">
|
||||||
<span>Done</span
|
<span>Done</span
|
||||||
><img
|
><img
|
||||||
src="./../../../assets/img/board/add.svg"
|
src="./../../../assets/img/board/add.svg"
|
||||||
|
|
@ -122,12 +122,12 @@
|
||||||
onclick="openAddTaskPage('done')"
|
onclick="openAddTaskPage('done')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div id="content-done">
|
<div id="done">
|
||||||
<ng-container *ngIf="!isTaskRendered('done')">
|
<ng-container *ngIf="!isTaskRendered('done')">
|
||||||
<app-task [index]="undefined"></app-task>
|
<app-task [index]="undefined"></app-task>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngFor="let task of firebaseService.allTasks; index as i"
|
*ngFor="let task of firebaseService.filteredTasks; index as i"
|
||||||
>
|
>
|
||||||
<ng-container *ngIf="task.status === 'done'">
|
<ng-container *ngIf="task.status === 'done'">
|
||||||
<app-task [index]="i"></app-task>
|
<app-task [index]="i"></app-task>
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,10 @@ section {
|
||||||
padding-right: 24px;
|
padding-right: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
.title {
|
||||||
margin: 0;
|
font-size: 61px;
|
||||||
}
|
font-weight: 700;
|
||||||
|
padding-right: 24px;
|
||||||
.blue {
|
|
||||||
background-color: var(--blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------- HEADER -------------*/
|
/*------------- HEADER -------------*/
|
||||||
|
|
@ -25,19 +23,41 @@ h1 {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
input {
|
||||||
|
width: 312px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
align-items: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid var(--gray);
|
||||||
|
background-color: var(--white);
|
||||||
|
background-image: url("./../../../assets/img/board/search.svg");
|
||||||
|
background-position-x: calc(100% - 10px);
|
||||||
|
background-position-y: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.line {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 215px;
|
||||||
|
height: 18px;
|
||||||
|
width: 1px;
|
||||||
|
background-color: var(--gray);
|
||||||
|
margin: 0 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-inside {
|
.btn-inside {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
span {
|
||||||
|
|
||||||
.btn-inside span {
|
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.btn-addtask {
|
.btn {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -52,35 +72,10 @@ h1 {
|
||||||
font-size: 21px;
|
font-size: 21px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
margin-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
&:hover {
|
||||||
|
|
||||||
.btn-addtask:hover {
|
|
||||||
background-color: var(--light-blue);
|
background-color: var(--light-blue);
|
||||||
box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 2px 0px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
.search input {
|
|
||||||
width: 312px;
|
|
||||||
padding: 8px 16px;
|
|
||||||
align-items: center;
|
|
||||||
border-radius: 10px;
|
|
||||||
border: 1px solid var(--gray);
|
|
||||||
background-color: var(--white);
|
|
||||||
background-image: url("./../../../assets/img/board/search.svg");
|
|
||||||
background-position-x: calc(100% - 10px);
|
|
||||||
background-position-y: center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-size: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.line {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
right: 215px;
|
|
||||||
height: 18px;
|
|
||||||
width: 1px;
|
|
||||||
background-color: var(--gray);
|
|
||||||
margin: 0 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------- HEADLINE -------------*/
|
/*------------- HEADLINE -------------*/
|
||||||
|
|
@ -89,7 +84,7 @@ h1 {
|
||||||
max-width: calc(1080px + 32px);
|
max-width: calc(1080px + 32px);
|
||||||
}
|
}
|
||||||
|
|
||||||
#content-headline {
|
.status {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
@ -97,37 +92,32 @@ h1 {
|
||||||
margin-top: 48px;
|
margin-top: 48px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-headline {
|
.headline {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
min-width: 246px;
|
min-width: 246px;
|
||||||
}
|
span {
|
||||||
|
|
||||||
.content-headline span {
|
|
||||||
color: var(--blue-gray);
|
color: var(--blue-gray);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
img {
|
||||||
.content-headline img {
|
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 2px solid var(--dark-blue);
|
border: 2px solid var(--dark-blue);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
filter: invert(60%) sepia(58%) saturate(1629%) hue-rotate(165deg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content-headline img:hover {
|
|
||||||
filter: invert(60%) sepia(58%) saturate(1629%) hue-rotate(165deg)
|
|
||||||
brightness(92%) contrast(92%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------- CONTENT -------------*/
|
/*------------- CONTENT -------------*/
|
||||||
|
|
||||||
.content-column {
|
.column {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding-right: 32px;
|
padding-right: 32px;
|
||||||
}
|
&:first-child {
|
||||||
|
|
||||||
.content-column:first-child {
|
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component, ElementRef, ViewChild } from '@angular/core';
|
||||||
import { TaskComponent } from './task/task.component';
|
import { TaskComponent } from './task/task.component';
|
||||||
import { DragDropService } from '../../services/drag-drop.service';
|
import { DragDropService } from '../../services/drag-drop.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
@ -12,6 +12,8 @@ import { FirebaseService } from '../../services/firebase.service';
|
||||||
styleUrl: './board.component.scss',
|
styleUrl: './board.component.scss',
|
||||||
})
|
})
|
||||||
export class BoardComponent {
|
export class BoardComponent {
|
||||||
|
@ViewChild('searchField') searchField!: ElementRef;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dragDropService: DragDropService,
|
public dragDropService: DragDropService,
|
||||||
public firebaseService: FirebaseService
|
public firebaseService: FirebaseService
|
||||||
|
|
@ -28,14 +30,25 @@ export class BoardComponent {
|
||||||
let firebaseId = this.firebaseService.allTasks[index].id;
|
let firebaseId = this.firebaseService.allTasks[index].id;
|
||||||
this.firebaseService.allTasks[index].status = status;
|
this.firebaseService.allTasks[index].status = status;
|
||||||
this.firebaseService.updateTask(firebaseId, index);
|
this.firebaseService.updateTask(firebaseId, index);
|
||||||
|
this.searchField.nativeElement.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
isTaskRendered(taskColumn: string): boolean {
|
isTaskRendered(taskColumn: string): boolean {
|
||||||
for (let task of this.firebaseService.allTasks) {
|
for (let task of this.firebaseService.filteredTasks) {
|
||||||
if (task.status === taskColumn) {
|
if (task.status === taskColumn) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchTask(): void {
|
||||||
|
const search = this.searchField.nativeElement.value.toLowerCase();
|
||||||
|
this.firebaseService.filteredTasks = this.firebaseService.allTasks.filter(
|
||||||
|
(task) =>
|
||||||
|
task.title.toLowerCase().includes(search) ||
|
||||||
|
task.description.toLowerCase().includes(search) ||
|
||||||
|
task.category.toLowerCase().includes(search)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,18 @@ export class FirebaseService {
|
||||||
firestore: Firestore = inject(Firestore);
|
firestore: Firestore = inject(Firestore);
|
||||||
|
|
||||||
allTasks: any[] = [];
|
allTasks: any[] = [];
|
||||||
|
filteredTasks: any[] = [];
|
||||||
|
|
||||||
updateAllTasks() {
|
updateAllTasks() {
|
||||||
onSnapshot(collection(this.firestore, 'tasks'), (list) => {
|
onSnapshot(collection(this.firestore, 'tasks'), (list) => {
|
||||||
if (!list.empty) {
|
if (!list.empty) {
|
||||||
this.allTasks = [];
|
this.allTasks = [];
|
||||||
|
this.filteredTasks = [];
|
||||||
list.forEach((doc) => {
|
list.forEach((doc) => {
|
||||||
const taskData = doc.data();
|
const taskData = doc.data();
|
||||||
taskData['id'] = doc.id;
|
taskData['id'] = doc.id;
|
||||||
this.allTasks.push(taskData);
|
this.allTasks.push(taskData);
|
||||||
|
this.filteredTasks.push(taskData);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.info('No such document!');
|
console.info('No such document!');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue