limitations au ROLE_ENFANT sur page account/ modifier, supprimer et ajouter membre ok
This commit is contained in:
parent
2dd153198e
commit
95d9ab28f0
10 changed files with 56 additions and 15 deletions
src/app
components
models
pages
page-account
page-delete-member
page-signup
|
@ -8,11 +8,13 @@
|
|||
<h3 class="mt-2 mb-0">{{membre.prenom }} {{membre.nom }}</h3>
|
||||
<div class="buttons text-center"><button button type="button" class="btn btn-outline-primary px-4"
|
||||
routerLink="../modifier-membre/{{membre.id}}"
|
||||
routerLinkActive="active-custom">
|
||||
routerLinkActive="active-custom"
|
||||
[hidden]="parent == false">
|
||||
Modifier
|
||||
</button><button button type="button" class="btn btn-primary px-4"
|
||||
routerLink="../supprimer-membre/{{membre.id}}"
|
||||
routerLinkActive="active-custom">
|
||||
routerLinkActive="active-custom"
|
||||
[hidden]="parent == false">
|
||||
Supprimer
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { TokenService } from 'src/app/services/token.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-card-member',
|
||||
|
@ -7,10 +8,24 @@ import { Component, Input, OnInit } from '@angular/core';
|
|||
})
|
||||
export class CardMemberComponent implements OnInit {
|
||||
@Input() membre: any;
|
||||
parent: boolean;
|
||||
|
||||
constructor() { }
|
||||
constructor(private tokenService: TokenService) {
|
||||
this.parent = false;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||
const userRole = this.tokenService.getRole();
|
||||
if(userRole == "ROLE_PARENT"){
|
||||
this.parent = true;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
else if(userRole== "ROLE_ENFANT"){
|
||||
this.parent = false;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
width: auto;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
//background-color: #c3c3e7;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.nav{
|
||||
margin-top: 20px;
|
||||
|
@ -19,5 +20,9 @@ li {
|
|||
|
||||
a{
|
||||
color: black;
|
||||
background-color: white;
|
||||
font-weight: bold;
|
||||
padding: none;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Team } from "./team";
|
||||
|
||||
export interface Membre {
|
||||
id: string;
|
||||
nom: string;
|
||||
|
@ -7,6 +9,6 @@ export interface Membre {
|
|||
dateNaissance: Date;
|
||||
couleur: string;
|
||||
passwordConfirm: string;
|
||||
// smiley: string;
|
||||
//team: Team;
|
||||
roleList: string[];
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
export interface Team {
|
||||
id: string;
|
||||
nom : string;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<app-header></app-header>
|
||||
<app-side-bar></app-side-bar>
|
||||
<app-side-bar [backgroundColor]="'#7879F1'"></app-side-bar>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-9 offset-2" id="main">
|
||||
|
@ -16,6 +16,7 @@
|
|||
class="btn btn-primary btn-lg"
|
||||
routerLink="../ajout-membre"
|
||||
routerLinkActive="active-custom"
|
||||
[hidden]="parent == false"
|
||||
>
|
||||
Ajouter un membre
|
||||
</button>
|
||||
|
|
|
@ -37,10 +37,16 @@ export class PageAccountComponent implements OnInit {
|
|||
this.listMembres = membres;
|
||||
});
|
||||
|
||||
/***Gestion des limatations en fonction du role (parent ou enfant) */
|
||||
const roleUser = this.tokenService.getRole();
|
||||
if(roleUser == "ROLE_PARENT"){
|
||||
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||
const userRole = this.tokenService.getRole();
|
||||
if(userRole == "ROLE_PARENT"){
|
||||
this.parent = true;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
else if(userRole== "ROLE_ENFANT"){
|
||||
this.parent = false;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
class="btn btn-primary btn-lg bouton-non"
|
||||
routerLink="/compte"
|
||||
routerLinkActive="active-custom"
|
||||
[hidden]="parent == false"
|
||||
>Non, je ne souhaite pas supprimer ce compte
|
||||
</button>
|
||||
</div>
|
||||
|
@ -23,6 +24,7 @@
|
|||
type="button"
|
||||
class="btn btn-primary btn-lg bouton-oui"
|
||||
(clickDelete)="onClickDelete()"
|
||||
[hidden]="parent == false"
|
||||
>Oui, je souhaite supprimer ce compte
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -9,10 +9,9 @@ import { TokenService } from 'src/app/services/token.service';
|
|||
styleUrls: ['./page-delete-member.component.scss']
|
||||
})
|
||||
export class PageDeleteMemberComponent implements OnInit {
|
||||
@Output() clickDelete = new EventEmitter();
|
||||
parent: boolean;
|
||||
public membreId: any;
|
||||
public membreInfos: any;
|
||||
parent: boolean;
|
||||
|
||||
|
||||
constructor(private membreService: MembreService,
|
||||
|
@ -36,12 +35,17 @@ export class PageDeleteMemberComponent implements OnInit {
|
|||
console.log(membreInfos.id);
|
||||
});
|
||||
|
||||
const roleUser = this.tokenService.getRole();
|
||||
|
||||
if(roleUser == "ROLE_PARENT"){
|
||||
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||
const userRole = this.tokenService.getRole();
|
||||
if(userRole == "ROLE_PARENT"){
|
||||
this.parent = true;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
else if(userRole== "ROLE_ENFANT"){
|
||||
this.parent = false;
|
||||
console.log('Rôle : ' + userRole);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/********************** Suppresion d'un membre au click ********************/
|
||||
|
|
|
@ -59,6 +59,7 @@ export class PageSignupComponent implements OnInit {
|
|||
}
|
||||
|
||||
public onSubmit(): void {
|
||||
const teamIdValue = this.signupForm.value[''];
|
||||
const teamNameValue = this.signupForm.value['teamNameFc'];
|
||||
const idValue = this.signupForm.value[''];
|
||||
const prenomValue = this.signupForm.value['firstNameFc'];
|
||||
|
@ -71,6 +72,7 @@ export class PageSignupComponent implements OnInit {
|
|||
const roleValue = ['ROLE_PARENT'];
|
||||
|
||||
const team: Team = {
|
||||
id : teamIdValue,
|
||||
nom : teamNameValue,
|
||||
};
|
||||
|
||||
|
@ -83,6 +85,7 @@ export class PageSignupComponent implements OnInit {
|
|||
couleur: couleurValue,
|
||||
dateNaissance: dateNaissanceValue,
|
||||
passwordConfirm: passwordConfirmValue,
|
||||
//team: teamIdValue,
|
||||
roleList: roleValue,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue