From f28b2d34e1cddc42c56977edac2ae82f46a6238c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yana=C3=ABl=20GRETTE?= Date: Tue, 16 Feb 2021 14:04:31 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20l'interface=20pour=20ajout?= =?UTF-8?q?er=20une=20nouvelle=20note?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/notes/notes.module.ts | 8 ++- src/app/notes/notes.routing.module.ts | 2 + .../dialog-choix-collaborateur-note.html | 0 .../nouvelle-note.component.html | 27 ++++++++ .../nouvelle-note/nouvelle-note.component.ts | 69 +++++++++++++++++++ .../nav-menu-commercial.component.html | 1 + 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 src/app/notes/nouvelle-note/dialog-choix-collaborateur-note.html create mode 100644 src/app/notes/nouvelle-note/nouvelle-note.component.html create mode 100644 src/app/notes/nouvelle-note/nouvelle-note.component.ts diff --git a/src/app/notes/notes.module.ts b/src/app/notes/notes.module.ts index fb9c805..90c1095 100644 --- a/src/app/notes/notes.module.ts +++ b/src/app/notes/notes.module.ts @@ -6,11 +6,13 @@ import { MaterialModule } from "@shared/angular-material/angular-material.module import {NavMenuModule} from '@shared/nav-menu/nav-menu.module'; import { NotesComponent } from "./notes.component"; -import { FormsModule } from "@angular/forms"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; +import { NouvelleNoteComponent } from "./nouvelle-note/nouvelle-note.component"; + @NgModule({ declarations: [ - NotesComponent + NotesComponent, NouvelleNoteComponent ], imports: [ CommonModule, @@ -18,7 +20,7 @@ import { FormsModule } from "@angular/forms"; NavMenuModule, RouterModule, NotesRoutingModule, - FormsModule + FormsModule, ReactiveFormsModule ], }) export class NotesModule {} \ No newline at end of file diff --git a/src/app/notes/notes.routing.module.ts b/src/app/notes/notes.routing.module.ts index 07cfa39..8b88bc7 100644 --- a/src/app/notes/notes.routing.module.ts +++ b/src/app/notes/notes.routing.module.ts @@ -7,8 +7,10 @@ import { AuthGuard } from "@shared/auth/auth.guard"; import { paths_notes } from "@shared/utils/paths"; +import { NouvelleNoteComponent } from './nouvelle-note/nouvelle-note.component'; const routes: Routes = [ + { path: paths_notes.ajoutNote, component: NouvelleNoteComponent, canActivate: [AuthGuard]}, {path: "", component: NotesComponent, canActivate: [AuthGuard]}, ] diff --git a/src/app/notes/nouvelle-note/dialog-choix-collaborateur-note.html b/src/app/notes/nouvelle-note/dialog-choix-collaborateur-note.html new file mode 100644 index 0000000..e69de29 diff --git a/src/app/notes/nouvelle-note/nouvelle-note.component.html b/src/app/notes/nouvelle-note/nouvelle-note.component.html new file mode 100644 index 0000000..70e2b5e --- /dev/null +++ b/src/app/notes/nouvelle-note/nouvelle-note.component.html @@ -0,0 +1,27 @@ + +

Nouvelle note

+ + + + +
+
+ + + +
+ +
+ + Commentaire référent + + +
+
+

{{ collaborateurChoisi == undefined ? 'Aucun collaborateur sélectionné' : collaborateurChoisi.nom+ " " +collaborateurChoisi.prenom}}

+
+ +
+ +
+
\ No newline at end of file diff --git a/src/app/notes/nouvelle-note/nouvelle-note.component.ts b/src/app/notes/nouvelle-note/nouvelle-note.component.ts new file mode 100644 index 0000000..dade3ed --- /dev/null +++ b/src/app/notes/nouvelle-note/nouvelle-note.component.ts @@ -0,0 +1,69 @@ +import { Component, OnInit } from "@angular/core"; +import { FormBuilder } from "@angular/forms"; +import { MatDialog } from "@angular/material/dialog"; +import { Router } from "@angular/router"; +import { CollaborateurDTO, DetailsNoteDTO, NotesService } from "@shared/api-swagger"; +import { cles } from "@shared/utils/cles"; +import { Subscription } from "rxjs"; + +@Component({ + selector: "nouvelle-note", + templateUrl: "./nouvelle-note.component.html" +}) +export class NouvelleNoteComponent { + + noteSubscription: Subscription; + + collaborateurChoisi: CollaborateurDTO; + + noteForm = this.fb.group( + { + titre: [""], + texte: [""], + collaborateur: [""], + dateCreation: [""], + dateMiseAjour: [""], + } + ) + constructor(private noteService: NotesService, private fb: FormBuilder, private router: Router, + private dialog: MatDialog) {} + + ajouterNote() { + console.log("ui"); + if(this.collaborateurChoisi == undefined) + return; + const today : Date = new Date(); + let nouvelleNote : DetailsNoteDTO = this.noteForm.value; + nouvelleNote.collaborateur = this.collaborateurChoisi; + nouvelleNote.dateCreation = today; + nouvelleNote.dateMiseAjour = today; + nouvelleNote.idAuteur = JSON.parse(sessionStorage.getItem(cles.sessionKeyConnectee)).id; + + this.noteSubscription = this.noteService.addNote(nouvelleNote).subscribe( + note => { + console.log(note); + this.router.navigate(["/notes"]); + }, + err => console.log(err) + ); + } + + choixCollaborateur() { + console.log("pas ui"); + } + + ngOnDestroy() { + if(this.noteSubscription != undefined) { + this.noteSubscription.unsubscribe(); + } + } +} + + +@Component({ + selector: "dialog-choix-collaborateur-note", + templateUrl: "./dialog-choix-collaborateur-note.html" +}) +export class DialogChoixCollaborateurNoteComponent { + +} \ No newline at end of file diff --git a/src/app/shared/nav-menu/nav-menu-commercial/nav-menu-commercial.component.html b/src/app/shared/nav-menu/nav-menu-commercial/nav-menu-commercial.component.html index 822a3c7..4b76b80 100644 --- a/src/app/shared/nav-menu/nav-menu-commercial/nav-menu-commercial.component.html +++ b/src/app/shared/nav-menu/nav-menu-commercial/nav-menu-commercial.component.html @@ -14,4 +14,5 @@ + \ No newline at end of file