From 9e326fde549858e0a7efab911b01185d752f5eee Mon Sep 17 00:00:00 2001 From: jboinembalome Date: Fri, 19 Feb 2021 10:28:12 +0100 Subject: [PATCH] Ajout du composant FormationsTableComponent dans homme-rh et formations --- src/app/formations/formations.component.html | 40 +------ src/app/formations/formations.component.ts | 105 ++--------------- src/app/formations/formations.module.ts | 2 + src/app/home/home-rh/home-rh.component.html | 46 +------- src/app/home/home-rh/home-rh.component.ts | 116 ++----------------- src/app/home/home.module.ts | 2 + 6 files changed, 24 insertions(+), 287 deletions(-) diff --git a/src/app/formations/formations.component.html b/src/app/formations/formations.component.html index a70b540..53d3f5b 100644 --- a/src/app/formations/formations.component.html +++ b/src/app/formations/formations.component.html @@ -1,42 +1,4 @@

Liste des formations

- - - - Intitulé - {{ row.intitule }} - - - - Nb participants - {{ row.nbParticipants }} - - - - Date prévisionnelle - {{ row.dateDebut | date:'dd/MM/yy à hh:mm' }} - - - - Origine - {{ row.origine.libelle}} - - - - Statut - {{row.statut.libelle}} - - - - - - - - + \ No newline at end of file diff --git a/src/app/formations/formations.component.ts b/src/app/formations/formations.component.ts index 6635e80..bf31dcd 100644 --- a/src/app/formations/formations.component.ts +++ b/src/app/formations/formations.component.ts @@ -1,13 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; - -import { Observable, Subscription } from 'rxjs'; - -import {MatTableDataSource} from '@angular/material/table'; -import {MatPaginator, PageEvent} from '@angular/material/paginator'; -import {MatSort} from '@angular/material/sort'; - -import { FormationDetailsDTO } from "@shared/api-swagger/model/models"; -import { FormationsService } from "@shared/api-swagger/api/api"; +import { Component } from '@angular/core'; /** */ @@ -15,96 +6,16 @@ import { FormationsService } from "@shared/api-swagger/api/api"; selector: 'app-formations', templateUrl: './formations.component.html' }) -export class FormationsComponent implements OnInit { - +export class FormationsComponent { /** - * Ordre de tri à envoyer au serveur (true : croissant, false : décroissantà). + * Liste des colonnes du tableau à afficher. */ - asc = true; - /** - * Numéro de la page à afficher dans le tableau. - */ - numPage = 1; - /** - * Nombre d'élément du tableau à affiche en une page. - */ - parPage = 5; - - etat = 0; - - - /** - * Observable permettant de faire des requêtes sur le service formation. - */ - private formationsDisponiblesSubscription : Subscription; - - //displayedColumns: string[] = ["intitule", "participants", "date", "origine", "statut"] - /** - * Les colonnes à afficher dans le Mat Table - */ - displayedColumns: string[] = ["intitule", "origine", "participants", "date", "statut"] - - /** - * source pour l'affichage des formations dans le tableau qui est affichée. - */ - dataSource : MatTableDataSource; + displayedColumns: string[] = ["intitule", "origine", "participants", "date", "statut","certification"]; /** - * contenu de la recherche. - */ - search = ""; - tri = ""; - - - taille = 100; - - pageOption = [ 5, 15, 20, 30, 50]; - - pageEvent: PageEvent; - /** - * Pagination du tableau. - */ - @ViewChild(MatPaginator) paginator: MatPaginator; - - /** - * Tri par les éléments du tableau selon la colonne choisie. - */ - @ViewChild(MatSort) sort: MatSort; - - /** - * Spécifie si la liste des EP est en cours de chargement et d'écriture dans le tableau. - */ - chargement = true; - - constructor(private service:FormationsService) { - } - - ngOnInit() { - this.updateDataSource(); - } - - updateDataSource() { - this.formationsDisponiblesSubscription = this.service.getFormations(1,[1,2,3,4], this.asc,this.numPage, this.parPage, this.search, this.tri).subscribe( - formations => this.dataSource = new MatTableDataSource(formations), - err => console.log(err) - ); - //this.dataSource.paginator = this.paginator; - //this.dataSource.sort = this.sort; - } - - updatePageInfo(event) : PageEvent{ - console.log("update") - console.log(event); - this.parPage = event.pageSize; - this.numPage = event.pageIndex+1; - this.updateDataSource(); - return event; - } - - ngOnDestroy() { - if(this.formationsDisponiblesSubscription != undefined) { - this.formationsDisponiblesSubscription.unsubscribe(); - } - } + * Indique si la recherche par statut de formation est activée ou non + */ + rechercherParStatutFormation: boolean = true; + } diff --git a/src/app/formations/formations.module.ts b/src/app/formations/formations.module.ts index 427d569..c6ac76e 100644 --- a/src/app/formations/formations.module.ts +++ b/src/app/formations/formations.module.ts @@ -5,6 +5,7 @@ import { RouterModule } from '@angular/router'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MaterialModule } from "@shared/angular-material/angular-material.module"; +import { MatTablesModule } from "@shared/mat-tables/mat-tables.module"; import {NavMenuModule} from '@shared/nav-menu/nav-menu.module'; @@ -29,6 +30,7 @@ import { FormationsRoutingModule } from './formations.routing.module'; CommonModule, MaterialModule, NavMenuModule, + MatTablesModule, RouterModule, FormationsRoutingModule, ReactiveFormsModule diff --git a/src/app/home/home-rh/home-rh.component.html b/src/app/home/home-rh/home-rh.component.html index 725b7ef..c673d9a 100644 --- a/src/app/home/home-rh/home-rh.component.html +++ b/src/app/home/home-rh/home-rh.component.html @@ -1,47 +1,3 @@

Page RH

- - - - Intitulé - {{ row.intitule }} - - - - Nb participants - {{ row.nbParticipants }} - - - - Date prévisionnelle - {{ row.dateDebut | date:'dd/MM/yyyy à hh:mm' }} - - - - Origine - {{row.origine.libelle}} - - - - Statut - {{row.statut.libelle}} - - - - Certifiée - {{estCertifiee(row.estCertifiee)}} - - - - - - - - - + \ No newline at end of file diff --git a/src/app/home/home-rh/home-rh.component.ts b/src/app/home/home-rh/home-rh.component.ts index 6cf56ec..1ad0e48 100644 --- a/src/app/home/home-rh/home-rh.component.ts +++ b/src/app/home/home-rh/home-rh.component.ts @@ -1,12 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; - -import { Observable, Subscription } from 'rxjs'; - -import {MatTableDataSource} from '@angular/material/table'; -import {MatPaginator, PageEvent} from '@angular/material/paginator'; -import {MatSort} from '@angular/material/sort'; -import { FormationDetailsDTO } from "@shared/api-swagger/model/models"; -import { FormationsService } from "@shared/api-swagger/api/api"; +import { Component } from '@angular/core'; /** @@ -19,107 +11,19 @@ import { FormationsService } from "@shared/api-swagger/api/api"; selector : 'home-rh', templateUrl : 'home-rh.component.html' }) -export class HomeRHComponent implements OnInit { +export class HomeRHComponent { + /** - * Ordre de tri à envoyer au serveur (true : croissant, false : décroissantà). - */ - asc = true; - /** - * Numéro de la page à afficher dans le tableau. - */ - numPage = 1; - /** - * Nombre d'élément du tableau à affiche en une page. - */ - parPage = 15; - /** - * Permet d'indiquer au serveur sur quel attribut de l'objet CollaborateurDTO on souhaite faire le tri + * Liste des colonnes du tableau à afficher. */ - tri = ""; - - taille = 100; - - pageOption = [ 5, 15, 20, 30, 50]; + displayedColumns: string[] = ["intitule", "origine", "participants", "date", "statut","certification"]; - pageEvent: PageEvent; - - /** - * Observable pour faire des requêtes sur le service formation. - */ - private formationsDisponiblesSubscription : Subscription; /** - * Colonnes du tableau à afficher - */ - displayedColumns: string[] = ["intitule", "origine", "participants", "date", "statut","certification"]; - //displayedColumns: string[] = ["intitule", "participants", "date", "origine", "statut"] - //displayedColumns: string[] = ["intitule", "participants", "date", "statut","certification"]; + * Indique si la recherche par statut de formation est activée ou non + */ + rechercherParStatutFormation: boolean = true; + + constructor() {} - /** - * source pour l'affichage des formations dans le tableau Mat Table. - */ - dataSource : MatTableDataSource; - - /** - * contenu de la recherche. - */ - search = ""; - - /** - * Pagination du tableau. - */ - @ViewChild(MatPaginator) paginator: MatPaginator; - - /** - * Tri par les éléments du tableau selon la colonne choisie. - */ - @ViewChild(MatSort) sort: MatSort; - - /** - * Spécifie si la liste des EP est en cours de chargement et d'écriture dans le tableau. - */ - chargement = true; - constructor(private service:FormationsService) { - } - - ngOnInit() { - this.updateFormations(); - } - - /** - * Mettre à jour les informations à afficher dans la tableau. - * Devra se faire à l'ouverture de la page, au changement de page ou du nombre d'éléments à afficher, au moment d'un tri ou encore lors de l'utilisation de la barre de recherche. - */ - updateFormations() { - console.log(this.numPage); - console.log(this.parPage); - this.formationsDisponiblesSubscription = this.service.getFormations(1,[1,2],this.asc, this.numPage, this.parPage, this.search, this.tri).subscribe( - formations => this.dataSource = new MatTableDataSource(formations), - err => console.log(err) - ) - } - - estCertifiee(certifiee: boolean) { - if(certifiee) - return "Oui"; - return "Non"; - } - - updatePageInfo(event) : PageEvent{ - console.log("update") - console.log(event); - this.parPage = event.pageSize; - this.numPage = event.pageIndex+1; - this.updateFormations(); - return event; - } - - /** - * Une fois la page fermée, il est nécessaire de se désabonner des Oberservable afin d'éviter les fuites mémoires. - */ - ngOnDestroy() { - if(this.formationsDisponiblesSubscription != undefined) { - this.formationsDisponiblesSubscription.unsubscribe(); - } - } } diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts index c43375e..8be69f1 100644 --- a/src/app/home/home.module.ts +++ b/src/app/home/home.module.ts @@ -4,6 +4,7 @@ import { RouterModule } from '@angular/router'; import { FormsModule } from '@angular/forms'; import { MaterialModule } from "@shared/angular-material/angular-material.module"; +import { MatTablesModule } from "@shared/mat-tables/mat-tables.module"; import {HomeAssistanteComponent} from './home-assistante/home-assistante.component'; import {HomeRHComponent} from './home-rh/home-rh.component'; @@ -30,6 +31,7 @@ import {NavMenuModule} from '@shared/nav-menu/nav-menu.module'; FormsModule, MaterialModule, NavMenuModule, + MatTablesModule, RouterModule ], })