parent
7427957e9c
commit
f28b2d34e1
@ -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 { |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue