Commit ef517d1b authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FEAT #17436 TIME 0:45 front: disable unlink group button when group is not manageable

parent 89f7fbd2
......@@ -131,7 +131,7 @@
<ion-item *ngFor="let group of user.groups">
<ion-label>{{group.label}}</ion-label>
<ion-button slot="end" fill="clear" shape="round"
(click)="unlinkGroup(group);" [title]="'lang.unlinkGroup' | translate">
(click)="unlinkGroup(group);" [title]="'lang.unlinkGroup' | translate" [disabled]="!isManageableGroup(group.id)">
<ion-icon color="danger" slot="icon-only" name="close-outline"></ion-icon>
</ion-button>
</ion-item>
......
......@@ -80,6 +80,7 @@ export class UserComponent implements OnInit {
hasGroup: boolean = false;
userGroupsClone: any;
manageableGroups: any;
constructor(
public http: HttpClient,
......@@ -384,6 +385,7 @@ export class UserComponent implements OnInit {
return new Promise((resolve) => {
this.http.get('../rest/manageableGroups').pipe(
tap((data: any) => {
this.manageableGroups = JSON.parse(JSON.stringify(data.groups));
if (this.hasGroup) {
const groupIds: number[] = this.userGroupsClone.map((group: any) => group.id);
this.userGroupsClone = JSON.parse(JSON.stringify(data.groups.filter((group: any) => groupIds.indexOf(group.id) === -1)));
......@@ -401,6 +403,11 @@ export class UserComponent implements OnInit {
});
}
isManageableGroup(groupId: any) {
console.log(groupId, this.userGroupsClone);
return this.manageableGroups.find((userGroup: any) => userGroup.id === groupId) !== undefined;
}
async unlinkGroup(group: any) {
const cannotManage: boolean = this.user['groups'].length === 1 && this.user.id === this.authService.user.id && this.authService.user.administrativePrivileges.find((privilege: any) => privilege.id === 'manage_users') !== undefined;
const alert = await this.alertController.create({
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment