Redirection vers la page de la nouvelle formation lors de sa création

master
Yanaël GRETTE 4 years ago
parent 569a820c2c
commit 766414f17a
  1. 26
      src/app/formations/formations.component.ts
  2. 6
      src/app/formations/new-formation/new-formation.component.ts
  3. 10
      src/app/home/home-rh/home-rh.component.html
  4. 27
      src/app/home/home-rh/home-rh.component.ts

@ -59,7 +59,6 @@ export class FormationsComponent implements OnInit {
initFormations(formations:FormationModel[]) {
this.formationsDisponibles = [];
console.log(formations);
let formationDisplay : DisplayFormation;
for(let formation of formations) {
formationDisplay = new DisplayFormation();
@ -71,9 +70,6 @@ export class FormationsComponent implements OnInit {
}
formationDisplay.datePrevu = formation.dateDebut;
formationDisplay.origine = formation.origine;
console.log(formation.origine);
console.log(formationDisplay.origine);
console.log("");
formationDisplay.statut = formation.statut;
this.formationsDisponibles.push(formationDisplay);
}
@ -83,28 +79,6 @@ export class FormationsComponent implements OnInit {
this.dataSource.sort = this.sort;
}
/*
getStatut(statut:number) {
let value ="";
switch(statut) {
case 0:
value = "Plannifiée";
break;
case 1:
value = "Replannifiée";
break;
case 2:
value = "Réalisée";
break;
case 3:
value = "Annulée";
break;
}
return value;
}
*/
ngOnDestroy() {
if(this.formationsDisponiblesSubscription != undefined) {
this.formationsDisponiblesSubscription.unsubscribe();

@ -36,15 +36,13 @@ export class NewFormationComponent implements OnInit {
constructor(private fb: FormBuilder, private service:FormationsService, private router: Router) { }
ngOnInit() {
console.log(FormationModel.StatutEnum);
}
ajouterFormation() {
this.nouvelleformation = this.formationForm.value;
this.formationSubscription = this.service.ajouterFormation(this.nouvelleformation).subscribe(
reponse => {
console.log(reponse);
this.router.navigate(['']);
response => {
this.router.navigate(['/formations',response["id"]]);
}
);
}

@ -16,14 +16,14 @@
<mat-cell *matCellDef="let row">{{ row.datePrevu | date:'dd/MM/yyyy à hh:mm' }}</mat-cell>
</ng-container>
<!--<ng-container matColumnDef="origine">
<mat-header-cell></mat-header-cell>
<mat-cell *matCellDef="let row"></mat-cell>
</ng-container>-->
<ng-container matColumnDef="origine">
<mat-header-cell *matHeaderCellDef>Origine</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.origine}}</mat-cell>
</ng-container>
<ng-container matColumnDef="statut">
<mat-header-cell *matHeaderCellDef>Statut</mat-header-cell>
<mat-cell *matCellDef="let row">{{ getStatut(row.statut) }}</mat-cell>
<mat-cell *matCellDef="let row">{{row.statut}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>

@ -29,7 +29,7 @@ export class HomeRHComponent implements OnInit {
private formationsDisponiblesSubscription : Subscription;
//displayedColumns: string[] = ["intitule", "participants", "date", "origine", "statut"]
displayedColumns: string[] = ["intitule", "participants", "date", "statut"]
displayedColumns: string[] = ["intitule", "origine", "participants", "date", "statut"]
/**
* source pour l'affichage des formations dans le tableau qui est affichée.
@ -59,14 +59,13 @@ export class HomeRHComponent implements OnInit {
}
ngOnInit() {
this.formationsDisponiblesSubscription = this.service.getFormations(undefined, 1).subscribe(
this.formationsDisponiblesSubscription = this.service.getProchainesFormation(undefined, 1).subscribe(
formations => this.initFormations(formations)
);
}
initFormations(formations:FormationModel[]) {
this.formationsDisponibles = [];
console.log(formations);
let formationDisplay : DisplayFormation;
for(let formation of formations) {
formationDisplay = new DisplayFormation();
@ -87,28 +86,6 @@ export class HomeRHComponent implements OnInit {
this.dataSource.sort = this.sort;
}
getStatut(statut:number) {
let value ="";
switch(statut) {
case 0:
value = "Plannifiée";
break;
case 1:
value = "Replannifiée";
break;
case 2:
value = "Réalisée";
break;
case 3:
value = "Annulée";
break;
}
return value;
}
ngOnDestroy() {
if(this.formationsDisponiblesSubscription != undefined) {
this.formationsDisponiblesSubscription.unsubscribe();

Loading…
Cancel
Save