avancées et bloquage sur delete
This commit is contained in:
parent
b7e4e1ad18
commit
4b90b0e1b2
@ -30,7 +30,7 @@ const routes: Routes = [
|
|||||||
{ path: 'ajout-membre', canActivate: [AuthGuard], component: PageAddMemberComponent },
|
{ path: 'ajout-membre', canActivate: [AuthGuard], component: PageAddMemberComponent },
|
||||||
{ path: 'agenda', canActivate: [AuthGuard], component: PageAgendaComponent },
|
{ path: 'agenda', canActivate: [AuthGuard], component: PageAgendaComponent },
|
||||||
{ path: 'tableau-de-bord', canActivate: [AuthGuard], component: PageDashboardComponent },
|
{ path: 'tableau-de-bord', canActivate: [AuthGuard], component: PageDashboardComponent },
|
||||||
{ path: 'supprimer-membre', canActivate: [AuthGuard], component: PageDeleteMemberComponent },
|
{ path: 'supprimer-membre/:id', canActivate: [AuthGuard], component: PageDeleteMemberComponent },
|
||||||
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
{ path: 'password-oublie', component: PageForgotPasswordComponent },
|
||||||
{ path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent },
|
{ path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent },
|
||||||
{ path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent },
|
{ path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent },
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
routerLinkActive="active-custom">
|
routerLinkActive="active-custom">
|
||||||
Modifier
|
Modifier
|
||||||
</button><button button type="button" class="btn btn-primary px-4"
|
</button><button button type="button" class="btn btn-primary px-4"
|
||||||
routerLink="../supprimer-membre"
|
routerLink="../supprimer-membre/{{membre.id}}"
|
||||||
routerLinkActive="active-custom">
|
routerLinkActive="active-custom">
|
||||||
Supprimer
|
Supprimer
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { MembreService } from 'src/app/services/membre.service';
|
import { MembreService } from 'src/app/services/membre.service';
|
||||||
import { TeamService } from 'src/app/services/team.service';
|
import { TeamService } from 'src/app/services/team.service';
|
||||||
import { TokenService } from 'src/app/services/token.service';
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
@ -19,8 +18,7 @@ export class PageAccountComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(private membreService: MembreService,
|
constructor(private membreService: MembreService,
|
||||||
private teamService: TeamService,
|
private teamService: TeamService,
|
||||||
private tokenService: TokenService,
|
private tokenService: TokenService) {
|
||||||
private router: Router) {
|
|
||||||
this.listMembres = [];
|
this.listMembres = [];
|
||||||
this.parent = false;
|
this.parent = false;
|
||||||
}
|
}
|
||||||
@ -46,16 +44,4 @@ export class PageAccountComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Méthode qui au click va supprimer un contact en faisant appel au service dédié dans Membre Service **/
|
|
||||||
onClickDelete(membreId: number){
|
|
||||||
this.membreService.deleteMembre(membreId).subscribe((resp) => {
|
|
||||||
if(membreId) {
|
|
||||||
this.listMembres.forEach(membreId => console.log(membreId))
|
|
||||||
}else{
|
|
||||||
window.alert("Le profil ne peut pas être supprimé!")
|
|
||||||
}
|
|
||||||
this.router.navigate(['compte/']);
|
|
||||||
});
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
id = "bouton-ajout"
|
id = "bouton-ajout"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-primary btn-lg bouton-non"
|
class="btn btn-primary btn-lg bouton-non"
|
||||||
routerLink="../compte"
|
routerLink="/compte"
|
||||||
routerLinkActive="active-custom"
|
routerLinkActive="active-custom"
|
||||||
>Non, je ne souhaite pas supprimer ce compte
|
>Non, je ne souhaite pas supprimer ce compte
|
||||||
</button>
|
</button>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
id = "bouton-ajout"
|
id = "bouton-ajout"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-primary btn-lg bouton-oui"
|
class="btn btn-primary btn-lg bouton-oui"
|
||||||
(clickDelete)="onClickDelete($event)"
|
(clickDelete)="onClickDelete()"
|
||||||
>Oui, je souhaite supprimer ce compte
|
>Oui, je souhaite supprimer ce compte
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Membre } from 'src/app/models/membre';
|
import { Membre } from 'src/app/models/membre';
|
||||||
import { MembreService } from 'src/app/services/membre.service';
|
import { MembreService } from 'src/app/services/membre.service';
|
||||||
import { TokenService } from 'src/app/services/token.service';
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
@ -12,13 +12,31 @@ import { TokenService } from 'src/app/services/token.service';
|
|||||||
export class PageDeleteMemberComponent implements OnInit {
|
export class PageDeleteMemberComponent implements OnInit {
|
||||||
@Output() clickDelete = new EventEmitter();
|
@Output() clickDelete = new EventEmitter();
|
||||||
parent: boolean;
|
parent: boolean;
|
||||||
|
public membreId: any;
|
||||||
|
public membreInfos: any;
|
||||||
|
|
||||||
constructor(private membreService: MembreService, private tokenService: TokenService) {
|
|
||||||
|
constructor(private membreService: MembreService,
|
||||||
|
private tokenService: TokenService,
|
||||||
|
private router: Router,
|
||||||
|
private route: ActivatedRoute) {
|
||||||
|
this.membreInfos = '';
|
||||||
this.parent = false;
|
this.parent = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
/** Pour récuperer l'id du membre à modifier **/
|
||||||
|
this.membreId = this.route.snapshot.paramMap.get('id');
|
||||||
|
|
||||||
|
/** Appel Api **/
|
||||||
|
this.membreService
|
||||||
|
.getMembreId(this.membreId)
|
||||||
|
.subscribe((membreInfos: any) => {
|
||||||
|
this.membreInfos = membreInfos;
|
||||||
|
console.log(membreInfos.id);
|
||||||
|
});
|
||||||
|
|
||||||
const roleUser = this.tokenService.getRole();
|
const roleUser = this.tokenService.getRole();
|
||||||
|
|
||||||
if(roleUser == "ROLE_PARENT"){
|
if(roleUser == "ROLE_PARENT"){
|
||||||
@ -27,9 +45,11 @@ export class PageDeleteMemberComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickDelete(membreId: any){
|
/** Suppresion d'un membre au clik */
|
||||||
window.alert("Le profil à bien été supprimé!")
|
onClickDelete(): void {
|
||||||
this.clickDelete.emit(membreId);
|
console.log(this.membreInfos);
|
||||||
|
this.membreService.deleteMembre(this.membreInfos.id).subscribe((resp) => {
|
||||||
|
return resp
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export class PageUpdateMemberComponent implements OnInit {
|
|||||||
console.log(membre);
|
console.log(membre);
|
||||||
|
|
||||||
this.membreService.updateMembre(membre)?.subscribe((resp) => {
|
this.membreService.updateMembre(membre)?.subscribe((resp) => {
|
||||||
//this.router.navigate(['compte']);
|
this.router.navigate(['compte']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ export class MembreService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMembre(membreId: number): Observable<any>{
|
deleteMembre(membre: Membre): Observable<any>{
|
||||||
return this.http.delete(`${this.apiUrl}/membres/delete/${membreId}`);
|
return this.http.delete(`${this.apiUrl}/membres/delete/${membre.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMembre(membre: Membre): Observable<any> | void {
|
updateMembre(membre: Membre): Observable<any> | void {
|
||||||
|
Loading…
Reference in New Issue
Block a user