Création de l'interface pour ajouter une nouvelle note

develop
Yanaël GRETTE 4 years ago
parent 7427957e9c
commit f28b2d34e1
  1. 8
      src/app/notes/notes.module.ts
  2. 2
      src/app/notes/notes.routing.module.ts
  3. 0
      src/app/notes/nouvelle-note/dialog-choix-collaborateur-note.html
  4. 27
      src/app/notes/nouvelle-note/nouvelle-note.component.html
  5. 69
      src/app/notes/nouvelle-note/nouvelle-note.component.ts
  6. 1
      src/app/shared/nav-menu/nav-menu-commercial/nav-menu-commercial.component.html

@ -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 {}

@ -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]},
]

@ -0,0 +1,27 @@
<app-nav-menu></app-nav-menu>
<h2>Nouvelle note</h2>
<!--Formulaire-->
<form [formGroup]="noteForm" >
<div>
<mat-form-field>
<input matInput placeholder="Titre" formControlName="titre">
</mat-form-field>
</div>
<div>
<mat-form-field appearance="fill">
<mat-label>Commentaire référent </mat-label>
<textarea matInput formControlName="texte"></textarea>
</mat-form-field>
</div>
<div>
<p>{{ collaborateurChoisi == undefined ? 'Aucun collaborateur sélectionné' : collaborateurChoisi.nom+ " " +collaborateurChoisi.prenom}}<button mat-stroked-button (click)="choixCollaborateur()">Choisir un collaborateur</button></p>
</div>
<div>
<button mat-raised-button (click)="ajouterNote()">Ajouter une nouvelle note</button>
</div>
</form>

@ -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 {
}

@ -14,4 +14,5 @@
</button>
<mat-menu #menuNotes="matMenu">
<button mat-menu-item routerLink="/notes">Vos notes</button>
<button mat-menu-item routerLink="/notes/nouvellenote">Ajouter une nouvelle note</button>
</mat-menu>
Loading…
Cancel
Save