|
|
@ -10,7 +10,7 @@ import {MatPaginator} from '@angular/material/paginator'; |
|
|
|
import {MatSort} from '@angular/material/sort'; |
|
|
|
import {MatSort} from '@angular/material/sort'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { FormationModel } from '@shared/api-swagger/model/models'; |
|
|
|
import { FormationDTO, ModeFormationDTO, TypeFormationDTO, StatutFormationDTO, OrigineFormationDTO } from '@shared/api-swagger/model/models'; |
|
|
|
import { FormationsService } from '@shared/api-swagger/api/api'; |
|
|
|
import { FormationsService } from '@shared/api-swagger/api/api'; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -21,53 +21,94 @@ import { FormationsService } from '@shared/api-swagger/api/api'; |
|
|
|
styleUrls: ["edit-formation.component.css"] |
|
|
|
styleUrls: ["edit-formation.component.css"] |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class EditFormationComponent implements OnInit { |
|
|
|
export class EditFormationComponent implements OnInit { |
|
|
|
formation:FormationModel; |
|
|
|
|
|
|
|
formationSubscription: Subscription; |
|
|
|
formationSubscription: Subscription; |
|
|
|
|
|
|
|
origineSubscription: Subscription; |
|
|
|
|
|
|
|
typeSubscription: Subscription; |
|
|
|
|
|
|
|
modeSubscription: Subscription; |
|
|
|
|
|
|
|
statutSubscription: Subscription; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modes: ModeFormationDTO[]; |
|
|
|
|
|
|
|
types: TypeFormationDTO[]; |
|
|
|
|
|
|
|
origines: OrigineFormationDTO[]; |
|
|
|
|
|
|
|
statuts: StatutFormationDTO[]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//formation: FormationDTO;
|
|
|
|
formationForm: FormGroup; |
|
|
|
formationForm: FormGroup; |
|
|
|
id :any; |
|
|
|
id :any; |
|
|
|
statuts = FormationModel.StatutEnum; |
|
|
|
|
|
|
|
modes = FormationModel.ModeEnum; |
|
|
|
|
|
|
|
types = FormationModel.TypeEnum; |
|
|
|
|
|
|
|
keysStatuts: any[]; |
|
|
|
|
|
|
|
keysModes: any[]; |
|
|
|
|
|
|
|
keysTypes: any[]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private service: FormationsService, private fb: FormBuilder, |
|
|
|
constructor(private service: FormationsService, private fb: FormBuilder, |
|
|
|
private activatedRoute:ActivatedRoute, private router: Router) {} |
|
|
|
private activatedRoute:ActivatedRoute, private router: Router) { |
|
|
|
|
|
|
|
this.formationForm= this.fb.group( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: [""], |
|
|
|
|
|
|
|
intitule: [""], |
|
|
|
|
|
|
|
origine: [""], |
|
|
|
|
|
|
|
statut : [""], |
|
|
|
|
|
|
|
dateDebut: [""], |
|
|
|
|
|
|
|
dateFin: [""], |
|
|
|
|
|
|
|
heure: [""], |
|
|
|
|
|
|
|
jour: [""], |
|
|
|
|
|
|
|
organisme: [""], |
|
|
|
|
|
|
|
mode: [""], |
|
|
|
|
|
|
|
type: [""], |
|
|
|
|
|
|
|
estCertifie: [""] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.modeSubscription = this.service.getModesFormation().subscribe( |
|
|
|
|
|
|
|
modes => this.modes = modes, |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.origineSubscription = this.service.getOriginesFormation().subscribe( |
|
|
|
|
|
|
|
origines => this.origines = origines, |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.statutSubscription = this.service.getStatutsFormation().subscribe( |
|
|
|
|
|
|
|
statuts => this.statuts = statuts, |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.typeSubscription = this.service.getTypesFormation().subscribe( |
|
|
|
|
|
|
|
types => this.types = types, |
|
|
|
|
|
|
|
err => console.log(err) |
|
|
|
|
|
|
|
); |
|
|
|
this.id = this.activatedRoute.snapshot.paramMap.get('id'); |
|
|
|
this.id = this.activatedRoute.snapshot.paramMap.get('id'); |
|
|
|
this.formationSubscription = this.service.getFormationById(this.id).subscribe( |
|
|
|
this.formationSubscription = this.service.getFormationById(this.id).subscribe( |
|
|
|
formation => this.initFormation(formation) |
|
|
|
formation => this.initFormation(formation) |
|
|
|
); |
|
|
|
); |
|
|
|
this.keysStatuts = Object.keys(this.statuts).filter(String); |
|
|
|
|
|
|
|
this.keysModes = Object.keys(this.modes).filter(String); |
|
|
|
|
|
|
|
this.keysTypes = Object.keys(this.types).filter(String); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
initFormation(formation:FormationModel) { |
|
|
|
initFormation(formation:FormationDTO) { |
|
|
|
this.formation = formation; |
|
|
|
|
|
|
|
|
|
|
|
//this.formation = formation;
|
|
|
|
this.formationForm= this.fb.group( |
|
|
|
this.formationForm= this.fb.group( |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
id: [formation.id], |
|
|
|
|
|
|
|
intitule: [formation.intitule], |
|
|
|
|
|
|
|
origine: [formation.origine], |
|
|
|
|
|
|
|
statut : [formation.statut], |
|
|
|
|
|
|
|
dateDebut: [new Date(formation.dateDebut)], |
|
|
|
|
|
|
|
dateFin: [new Date(formation.dateFin)], |
|
|
|
|
|
|
|
heure: [formation.heure], |
|
|
|
|
|
|
|
jour: [formation.jour], |
|
|
|
|
|
|
|
organisme: [formation.organisme], |
|
|
|
|
|
|
|
mode: [formation.mode], |
|
|
|
|
|
|
|
type: [formation.type], |
|
|
|
|
|
|
|
estCertifie: [formation.estCertifie] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
intitule: [this.formation.intitule], |
|
|
|
|
|
|
|
origine: [this.formation.origine], |
|
|
|
|
|
|
|
statut : [this.formation.statut], |
|
|
|
|
|
|
|
dateDebut: [new Date(this.formation.dateDebut)], |
|
|
|
|
|
|
|
dateFin: [new Date(this.formation.dateFin)], |
|
|
|
|
|
|
|
heure: [this.formation.heure], |
|
|
|
|
|
|
|
jour: [this.formation.jour], |
|
|
|
|
|
|
|
organisme: [this.formation.organisme], |
|
|
|
|
|
|
|
mode: [this.formation.mode], |
|
|
|
|
|
|
|
type: [this.formation.type], |
|
|
|
|
|
|
|
estCertifie: [this.formation.estCertifie] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateFormation() { |
|
|
|
updateFormation() { |
|
|
|
this.formation = this.formationForm.value; |
|
|
|
//this.formation = this.formationForm.value;
|
|
|
|
this.formation.id = this.id; |
|
|
|
this.formationSubscription = this.service.updateFormation(this.formationForm.value, this.formationForm.value.id).subscribe( |
|
|
|
this.formationSubscription = this.service.updateFormation(this.formation).subscribe( |
|
|
|
|
|
|
|
response => { |
|
|
|
response => { |
|
|
|
this.router.navigate(['/formations',this.id]); |
|
|
|
this.router.navigate(['/formations',this.id]); |
|
|
|
} |
|
|
|
} |
|
|
@ -75,7 +116,7 @@ export class EditFormationComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
supprimerFormation() { |
|
|
|
supprimerFormation() { |
|
|
|
this.formationSubscription = this.service.deleteFormation(this.formation.id).subscribe( |
|
|
|
this.formationSubscription = this.service.deleteFormation(this.id).subscribe( |
|
|
|
response => this.router.navigate([""]) |
|
|
|
response => this.router.navigate([""]) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@ -86,3 +127,39 @@ export class EditFormationComponent implements OnInit { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
this.formationForm= this.fb.group( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: [formation.id], |
|
|
|
|
|
|
|
intitule: [formation.intitule], |
|
|
|
|
|
|
|
origine: [formation.origine], |
|
|
|
|
|
|
|
statut : [formation.statut], |
|
|
|
|
|
|
|
dateDebut: [new Date(formation.dateDebut)], |
|
|
|
|
|
|
|
dateFin: [new Date(formation.dateFin)], |
|
|
|
|
|
|
|
heure: [formation.heure], |
|
|
|
|
|
|
|
jour: [formation.jour], |
|
|
|
|
|
|
|
organisme: [formation.organisme], |
|
|
|
|
|
|
|
mode: [formation.mode], |
|
|
|
|
|
|
|
type: [formation.type], |
|
|
|
|
|
|
|
estCertifie: [formation.estCertifie] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
this.formationForm.setValue( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
id: formation.id, |
|
|
|
|
|
|
|
intitule: formation.intitule, |
|
|
|
|
|
|
|
origine: formation.origine, |
|
|
|
|
|
|
|
statut : formation.statut, |
|
|
|
|
|
|
|
dateDebut: new Date(formation.dateDebut), |
|
|
|
|
|
|
|
dateFin: new Date(formation.dateFin), |
|
|
|
|
|
|
|
heure: formation.heure, |
|
|
|
|
|
|
|
jour: formation.jour, |
|
|
|
|
|
|
|
organisme: formation.organisme, |
|
|
|
|
|
|
|
mode: formation.mode, |
|
|
|
|
|
|
|
type: formation.type, |
|
|
|
|
|
|
|
estCertifie: formation.estCertifie |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
*/ |
|
|
|