diff --git a/todo-app-frontend/src/app/core/enums/RouterPaths.ts b/todo-app-frontend/src/app/core/enums/RouterPaths.ts index 81ecf2b..ad71e4b 100644 --- a/todo-app-frontend/src/app/core/enums/RouterPaths.ts +++ b/todo-app-frontend/src/app/core/enums/RouterPaths.ts @@ -24,4 +24,5 @@ export enum RouterPaths { COLLABORATORS_DIRECT = "/home/collaborators", SEARCH_DIRECT = "/home/search", + SEARCH_PATH = "search", } diff --git a/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.html b/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.html index ae024f5..dbeb48a 100644 --- a/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.html +++ b/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.html @@ -8,7 +8,11 @@ - + + diff --git a/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.ts b/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.ts index 8d9de00..bd22f91 100644 --- a/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.ts +++ b/todo-app-frontend/src/app/pages/home/collaborators/collaborator/collaborator.component.ts @@ -8,9 +8,15 @@ import { Collaborator } from "@core/data/home/Collaborator"; }) export class CollaboratorComponent { @Input() collaborator !: Collaborator; + @Input() isAlreadyCollaborator: boolean = false; + @Output() readonly addCollaboratorEvent: EventEmitter = new EventEmitter(); @Output() readonly removeCollaboratorEvent: EventEmitter = new EventEmitter(); emitRemoveCollaboratorEvent(): void { this.removeCollaboratorEvent.emit(this.collaborator.collaboratorId); } + + emitAddCollaboratorEvent(): void { + this.addCollaboratorEvent.emit(this.collaborator); + } } diff --git a/todo-app-frontend/src/app/pages/home/collaborators/collaborators.component.html b/todo-app-frontend/src/app/pages/home/collaborators/collaborators.component.html index 0675f95..3cb55fd 100644 --- a/todo-app-frontend/src/app/pages/home/collaborators/collaborators.component.html +++ b/todo-app-frontend/src/app/pages/home/collaborators/collaborators.component.html @@ -49,6 +49,7 @@

Menu

diff --git a/todo-app-frontend/src/app/pages/home/collaborators/collaborators.module.ts b/todo-app-frontend/src/app/pages/home/collaborators/collaborators.module.ts index 3c756c4..25d6fa9 100644 --- a/todo-app-frontend/src/app/pages/home/collaborators/collaborators.module.ts +++ b/todo-app-frontend/src/app/pages/home/collaborators/collaborators.module.ts @@ -32,6 +32,9 @@ import { MatListModule } from "@angular/material/list"; MatToolbarModule, MatCardModule, MatListModule + ], + exports: [ + CollaboratorComponent ] }) export class CollaboratorsModule { diff --git a/todo-app-frontend/src/app/pages/home/groups/groups.component.html b/todo-app-frontend/src/app/pages/home/groups/groups.component.html index bc1f949..82dd0a4 100644 --- a/todo-app-frontend/src/app/pages/home/groups/groups.component.html +++ b/todo-app-frontend/src/app/pages/home/groups/groups.component.html @@ -20,7 +20,7 @@

Menu

Collaborators - diff --git a/todo-app-frontend/src/app/pages/home/home-routing.module.ts b/todo-app-frontend/src/app/pages/home/home-routing.module.ts index 2ef08a2..6136f9a 100644 --- a/todo-app-frontend/src/app/pages/home/home-routing.module.ts +++ b/todo-app-frontend/src/app/pages/home/home-routing.module.ts @@ -18,6 +18,11 @@ const routes: Routes = [ loadChildren: () => import("./collaborators/collaborators.module") .then(module => module.CollaboratorsModule) }, + { + path: RouterPaths.SEARCH_PATH, + loadChildren: () => import("./search/search.module") + .then(module => module.SearchModule) + }, { path: RouterPaths.PROFILE_PATH, loadChildren: () => import("./profile/profile.module") diff --git a/todo-app-frontend/src/app/pages/home/search/search-routing.module.ts b/todo-app-frontend/src/app/pages/home/search/search-routing.module.ts new file mode 100644 index 0000000..22aa5ee --- /dev/null +++ b/todo-app-frontend/src/app/pages/home/search/search-routing.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { RouterPaths } from "@enums/RouterPaths"; +import { SearchComponent } from "./search.component"; + +const routes: Routes = [ + { + path: RouterPaths.CURRENT_PATH, + component: SearchComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class SearchRoutingModule { +} diff --git a/todo-app-frontend/src/app/pages/home/search/search.component.html b/todo-app-frontend/src/app/pages/home/search/search.component.html new file mode 100644 index 0000000..78e8eee --- /dev/null +++ b/todo-app-frontend/src/app/pages/home/search/search.component.html @@ -0,0 +1,80 @@ + + +

Menu

+ + + +
+ + + + + + + + + +
+
+ + + + + ToDo + + +
+ + + + + + + + +
+
diff --git a/todo-app-frontend/src/app/pages/home/search/search.component.scss b/todo-app-frontend/src/app/pages/home/search/search.component.scss new file mode 100644 index 0000000..d4fef27 --- /dev/null +++ b/todo-app-frontend/src/app/pages/home/search/search.component.scss @@ -0,0 +1,23 @@ +@import "../sidebar"; + +.search-container { + margin-top: 3em; + margin-bottom: 3em; + min-width: 60em; + min-height: 50em; + padding: 2em; +} + +.search-input { + width: 100%; +} + +.search-bar { + display: flex; + justify-content: space-between; + gap: 2em; +} + +.search-submit-button { + margin-top: 0.5em; +} diff --git a/todo-app-frontend/src/app/pages/home/search/search.component.ts b/todo-app-frontend/src/app/pages/home/search/search.component.ts new file mode 100644 index 0000000..16574c4 --- /dev/null +++ b/todo-app-frontend/src/app/pages/home/search/search.component.ts @@ -0,0 +1,82 @@ +import { Component, OnInit } from '@angular/core'; +import { SideMenuActions } from "@core/interfaces/home/SideMenuActions"; +import { map, Observable, of, startWith, Subject, takeUntil } from "rxjs"; +import { AuthService } from "@core/services/auth/auth.service"; +import { SideMenuService } from "@core/services/home/side-menu.service"; +import { FormControl } from "@angular/forms"; +import { Collaborator } from "@core/data/home/Collaborator"; + +@Component({ + selector: 'app-search', + templateUrl: './search.component.html', + styleUrls: ['./search.component.scss'] +}) +export class SearchComponent implements SideMenuActions, OnInit { + private destroyLogout$: Subject = new Subject(); + private options !: string[]; + suggestionControl: FormControl = new FormControl(""); + suggestions$ !: Observable; + visibleCollaborators$ !: Observable; + + constructor(private authService: AuthService, + private sideMenuService: SideMenuService) { + } + + changeToGroupsView(): void { + this.sideMenuService.changeToGroupsView(); + } + + changeToProfileView(): void { + this.sideMenuService.changeToProfileView(); + } + + changeToCollaboratorsView(): void { + this.sideMenuService.changeToCollaboratorsView(); + } + + changeToSearchView(): void { + this.sideMenuService.changeToSearchView(); + } + + logoutUser(): void { + this.authService.logoutUser() + .pipe(takeUntil(this.destroyLogout$)) + .subscribe(() => this.sideMenuService.logoutUser()); + } + + ngOnInit(): void { + this.options = ["Szymon Kowalski", "Janusz Balcerzak", "Tomasz Kopernik", "Jacek Krakowski", "Szymon Wlodarczyk"]; + + this.suggestions$ = this.suggestionControl.valueChanges.pipe( + startWith(""), + map((option: string) => this.filterValues(option || "")) + ); + } + + private filterValues(value: string): string[] { + const filterValue: string = value.toLowerCase(); + + return this.options.filter((option: string) => option.toLowerCase().includes(filterValue)); + } + + findCollaboratorByName(): void { + let i: number = 0; + + const collaborators: Collaborator[] = this.filterValues(this.suggestionControl.value).map( + (name: string): Collaborator => { + return { + fullName: name, + username: `${name.replace(" ", "").toLowerCase()}@mail.com`, + collaboratorId: i++ + }; + } + ); + console.log(collaborators); + + this.visibleCollaborators$ = of(collaborators); + } + + addNewCollaborator(event: Collaborator): void { + console.log(event); + } +} diff --git a/todo-app-frontend/src/app/pages/home/search/search.module.ts b/todo-app-frontend/src/app/pages/home/search/search.module.ts new file mode 100644 index 0000000..83731e8 --- /dev/null +++ b/todo-app-frontend/src/app/pages/home/search/search.module.ts @@ -0,0 +1,40 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { SearchRoutingModule } from './search-routing.module'; +import { SearchComponent } from "./search.component"; +import { MatButtonModule } from "@angular/material/button"; +import { MatCardModule } from "@angular/material/card"; +import { MatDividerModule } from "@angular/material/divider"; +import { MatIconModule } from "@angular/material/icon"; +import { MatListModule } from "@angular/material/list"; +import { MatSidenavModule } from "@angular/material/sidenav"; +import { MatToolbarModule } from "@angular/material/toolbar"; +import { MatInputModule } from "@angular/material/input"; +import { MatAutocompleteModule } from "@angular/material/autocomplete"; +import { ReactiveFormsModule } from "@angular/forms"; +import { CollaboratorsModule } from "../collaborators/collaborators.module"; + + +@NgModule({ + declarations: [ + SearchComponent + ], + imports: [ + CommonModule, + SearchRoutingModule, + MatButtonModule, + MatCardModule, + MatDividerModule, + MatIconModule, + MatListModule, + MatSidenavModule, + MatToolbarModule, + MatInputModule, + MatAutocompleteModule, + ReactiveFormsModule, + CollaboratorsModule + ] +}) +export class SearchModule { +}