petites modifs

This commit is contained in:
Romain Verger 2022-03-10 13:14:32 +01:00
parent 65ab8cf9bc
commit 9403571d83
5 changed files with 14 additions and 5 deletions

View File

@ -148,6 +148,9 @@
</div> </div>
</div> </div>
<div *ngIf="successMessage" class="alert alert-success">
<p class="alert-link">{{successMessage}}</p>
</div>
<div *ngIf="errorMessage" class="alert alert-danger"> <div *ngIf="errorMessage" class="alert alert-danger">
<p class="alert-link">{{errorMessage}}</p> <p class="alert-link">{{errorMessage}}</p>
</div> </div>

View File

@ -20,6 +20,7 @@ export class AddRestauComponent implements OnInit {
public idRestau: Subscription | undefined; public idRestau: Subscription | undefined;
public formArrayCheckbox: FormArray; public formArrayCheckbox: FormArray;
public idRestauAModifier?: number = 0; // On instancie a 0 ou undefined = on est en CREATION de Restau public idRestauAModifier?: number = 0; // On instancie a 0 ou undefined = on est en CREATION de Restau
public successMessage?: string;
constructor(private router: Router, private apiBackService: ApiBackService) { constructor(private router: Router, private apiBackService: ApiBackService) {
this.signupForm = new FormGroup({}); this.signupForm = new FormGroup({});
@ -126,15 +127,16 @@ export class AddRestauComponent implements OnInit {
resp => {this.idRestauAModifier = 0 resp => {this.idRestauAModifier = 0
// Une fois le retour du subscribe qui est la preuve du bon enregistrement alors // Une fois le retour du subscribe qui est la preuve du bon enregistrement alors
// On reinitialise identifiant restau a 0 pour se remettre en mode CREATION // On reinitialise identifiant restau a 0 pour se remettre en mode CREATION
this.successMessage = "Restaurant modifié !"
this.router.navigate(['restaurants'])
} }
) )
} else { // sinon on crée un restau } else { // sinon on crée un restau
this.apiBackService.addRestaurant(restaurant).subscribe( this.apiBackService.addRestaurant(restaurant).subscribe(
resp => resp =>
this.router.navigate(['restaurants']) this.successMessage = "Restaurant ajouté !"
); );
this.initForm(EMPTY_RESTAU);
} }
} else { } else {

View File

@ -24,11 +24,13 @@ export class UpdateDelRestauComponent implements OnInit {
} }
deleteRestau(idRestau : number | undefined){ deleteRestau(idRestau : number | undefined){
if(confirm("Êtes-vous sur de vouloir supprimer ce restaurant ?")){
this.apiBackService.deleteRestau(idRestau).subscribe( this.apiBackService.deleteRestau(idRestau).subscribe(
resp =>{ resp =>{
this.restauList = this.restauList.filter(restaus => restaus.id != idRestau) this.restauList = this.restauList.filter(restaus => restaus.id != idRestau)
}); });
} }
}
modifRestau(restau : Restaurant){ modifRestau(restau : Restaurant){
this.apiBackService.idRestauAModifier(restau); this.apiBackService.idRestauAModifier(restau);

View File

@ -7,3 +7,4 @@ export interface User {
preference ?: object; preference ?: object;
roleList ?: string[]; roleList ?: string[];
} }

View File

@ -61,6 +61,7 @@ export class SignupComponent implements OnInit {
this.successMessage = "Membre ajouté !"; this.successMessage = "Membre ajouté !";
} }
) )
this.signupForm.reset()
} else { } else {
this.alertMessage = "Erreur d'ajout !"; this.alertMessage = "Erreur d'ajout !";
} }