Affichage des détails d'une note

develop
Yanaël GRETTE 4 years ago
parent 2f62e3bbf3
commit e3896087fc
  1. 18
      src/app/notes/details-note/details-note.component.html
  2. 28
      src/app/notes/details-note/details-note.component.ts
  3. 2
      src/app/notes/notes.component.html
  4. 5
      src/app/notes/notes.module.ts
  5. 4
      src/app/notes/notes.routing.module.ts
  6. 2
      src/app/notes/nouvelle-note/nouvelle-note.component.ts

@ -0,0 +1,18 @@
<app-nav-menu></app-nav-menu>
<ng-container *ngIf="note == undefined">
<mat-spinner></mat-spinner>
</ng-container>
<ng-container *ngIf="note != undefined">
<p>Collaborateur : {{ note.collaborateur.nom }} {{ note.collaborateur.prenom }} <button mat-raised-button [routerLink]="['/collaborateurs', note.collaborateur.id]">Voir les détails</button></p>
<p>Créé le {{ note.dateCreation | date : 'dd/MM/yyyy à hh:mm'}}</p>
<p>Dernère mise à jour le {{ note.dateMiseAjour | date : 'dd/MM/yyyy à hh:mm'}}</p>
<h2>Titre</h2>
<div>
<mat-form-field appearance="fill">
<mat-label>Contenu de la note</mat-label>
<textarea matInput disabled >{{note.texte}}</textarea>
</mat-form-field>
</div>
</ng-container>

@ -0,0 +1,28 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { DetailsNoteDTO, NotesService } from "@shared/api-swagger";
import { Subscription } from "rxjs";
@Component({
selector: "app-details-note",
templateUrl: "./details-note.component.html"
})
export class DetailsNoteComponent implements OnInit{
note: DetailsNoteDTO;
noteSubscription: Subscription;
constructor(private noteService: NotesService, private activatedRoute: ActivatedRoute) {}
ngOnInit() {
const id: any = this.activatedRoute.snapshot.paramMap.get("id");
if(id != undefined) {
this.noteSubscription = this.noteService.getNoteById(id).subscribe(
note => this.note = note,
err => console.log(err)
)
}
}
}

@ -39,7 +39,7 @@
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/notes',row.id]"></mat-row>
</mat-table>

@ -9,11 +9,14 @@ import { NotesComponent } from "./notes.component";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { DialogChoixCollaborateurNoteComponent, NouvelleNoteComponent } from "./nouvelle-note/nouvelle-note.component";
import { MatTablesModule } from "@shared/mat-tables/mat-tables.module";
import { DetailsNoteComponent } from "./details-note/details-note.component";
@NgModule({
declarations: [
NotesComponent, NouvelleNoteComponent, DialogChoixCollaborateurNoteComponent
NotesComponent, NouvelleNoteComponent,
DialogChoixCollaborateurNoteComponent,
DetailsNoteComponent
],
imports: [
CommonModule,

@ -8,10 +8,12 @@ import { AuthGuard } from "@shared/auth/auth.guard";
import { paths_notes } from "@shared/utils/paths";
import { NouvelleNoteComponent } from './nouvelle-note/nouvelle-note.component';
import { DetailsNoteComponent } from './details-note/details-note.component';
const routes: Routes = [
{ path: paths_notes.ajoutNote, component: NouvelleNoteComponent, canActivate: [AuthGuard]},
{path: "", component: NotesComponent, canActivate: [AuthGuard]},
{ path: paths_notes.get, component: DetailsNoteComponent, canActivate: [AuthGuard]},
{ path: "", component: NotesComponent, canActivate: [AuthGuard]},
]

@ -42,7 +42,7 @@ export class NouvelleNoteComponent {
this.noteSubscription = this.noteService.addNote(nouvelleNote).subscribe(
note => {
console.log(note);
this.router.navigate(["/notes"]);
this.router.navigate(["/notes", note.id]);
},
err => console.log(err)
);

Loading…
Cancel
Save