Déplacement du code dans ngOnChanges + ajout des filtres pour statut et intitulé

develop
jboinembalome 4 years ago
parent 3af7f2dda4
commit 85cd6c2b86
  1. 16
      src/app/shared/mat-tables/participations-formation-table/participations-formation.table.ts

@ -1,4 +1,4 @@
import { Component, Input, OnInit, ViewChild, AfterViewInit} from "@angular/core"; import { Component, Input, OnInit, OnChanges, ViewChild, AfterViewInit} from "@angular/core";
import {MatPaginator} from '@angular/material/paginator'; import {MatPaginator} from '@angular/material/paginator';
import {MatSort} from '@angular/material/sort'; import {MatSort} from '@angular/material/sort';
@ -13,7 +13,7 @@ import { DatePipe } from "@angular/common";
templateUrl: "./participations-formation.table.html", templateUrl: "./participations-formation.table.html",
styleUrls: ["./participations-formation.table.css"] styleUrls: ["./participations-formation.table.css"]
}) })
export class ParticipationsFormationTableComponent implements OnInit, AfterViewInit { export class ParticipationsFormationTableComponent implements OnInit, OnChanges, AfterViewInit {
@ViewChild(MatPaginator) paginator: MatPaginator; @ViewChild(MatPaginator) paginator: MatPaginator;
@ -56,12 +56,18 @@ export class ParticipationsFormationTableComponent implements OnInit, AfterViewI
} }
ngOnInit() { ngOnInit() {
}
ngOnChanges() {
if(this.participations.length > 0) {
this.dataSource = new MatTableDataSource(this.participations); this.dataSource = new MatTableDataSource(this.participations);
this.dataSource.sortingDataAccessor = (item, property) => { this.dataSource.sortingDataAccessor = (item, property) => {
switch(property) { switch(property) {
case 'collaborateur': return item.collaborateur.nom + " "+ item.collaborateur.prenom; case 'collaborateur': return item.collaborateur.nom + " "+ item.collaborateur.prenom;
case 'ep': return item.ep.statut; case 'ep': return item.ep.statut;
case 'evaluation': return item.estEvaluee; case 'evaluation': return item.estEvaluee;
case 'statut': return item.statut.libelle;
default: return item[property]; default: return item[property];
} }
}; };
@ -69,10 +75,14 @@ export class ParticipationsFormationTableComponent implements OnInit, AfterViewI
const formatted=this.pipe.transform(data.dateCreation,'dd/MM/yyyy'); const formatted=this.pipe.transform(data.dateCreation,'dd/MM/yyyy');
return formatted.indexOf(filter) >= 0 || return formatted.indexOf(filter) >= 0 ||
data.collaborateur.nom.toLocaleLowerCase().includes(filter) || data.collaborateur.nom.toLocaleLowerCase().includes(filter) ||
data.collaborateur.prenom.toLocaleLowerCase().includes(filter); data.collaborateur.prenom.toLocaleLowerCase().includes(filter) ||
data.intitule.toLocaleLowerCase().includes(filter) ||
data.statut.libelle.toLocaleLowerCase().includes(filter);
}; };
} }
}
ngAfterViewInit() { ngAfterViewInit() {
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;

Loading…
Cancel
Save