Commit 95102482 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #17436 TIME 0:35 can associate groups to user + send authorized groups

parent cdbb37da
......@@ -626,6 +626,7 @@
"originaleize": "Taille originale",
"scalingDocWith": "{{value}} % de la largeur du document",
"azure_samlConnection": "Azure SAML",
"groupsToManage": "Choisir les groupes d'affectations autorisés"
"groupsToManage": "Choisir les groupes d'affectations autorisés",
"unlinkGroup": "Dissocier le groupe"
}
}
......@@ -152,7 +152,7 @@ export class GroupComponent implements OnInit {
data = data.groups.map((item: any) => ({
id: item.id,
label: item.label,
checked: false
checked: true
}));
return data;
}),
......@@ -257,6 +257,7 @@ export class GroupComponent implements OnInit {
}
modifyGroup() {
this.group['authorized'] = this.groups;
this.loading = true;
this.http.put('../rest/groups/' + this.group.id, this.group)
.pipe(
......@@ -273,6 +274,7 @@ export class GroupComponent implements OnInit {
}
createGroup() {
this.group['authorized'] = this.groups;
this.loading = true;
this.http.post('../rest/groups', this.group)
.pipe(
......@@ -349,6 +351,9 @@ export class GroupComponent implements OnInit {
});
await alert.present();
} else {
if (privilege.id === 'manage_users' && !privilege.checked) {
this.groups = [];
}
if (!toggle) {
privilege.checked = !privilege.checked;
}
......
......@@ -18,7 +18,7 @@
<ion-label>{{'lang.informations' | translate}}</ion-label>
<ion-icon name="information-circle"></ion-icon>
</ion-segment-button>
<ion-segment-button [disabled]="creationMode" value="groups">
<ion-segment-button value="groups">
<ion-label>{{'lang.manage_groups' | translate}}</ion-label>
<ion-icon name="people-sharp"></ion-icon>
</ion-segment-button>
......@@ -121,6 +121,11 @@
<ion-list *ngIf="user.groups.length > 0">
<ion-item *ngFor="let group of user.groups">
<ion-label>{{group.label}}</ion-label>
<ion-checkbox *ngIf="creationMode" slot="end" [value]="group.id" [checked]="group.checked" (ionChange)="group.checked = !group.checked"></ion-checkbox>
<ion-button *ngIf="!creationMode" slot="end" fill="clear" shape="round"
(click)="$event.stopPropagation();" [title]="'lang.unlinkGroup' | translate">
<ion-icon color="danger" slot="icon-only" name="close-outline"></ion-icon>
</ion-button>
</ion-item>
</ion-list>
<ion-list class="no-result" *ngIf="user.groups.length === 0">
......
......@@ -91,7 +91,7 @@ export class UserComponent implements OnInit {
}
ngOnInit(): void {
this.route.params.subscribe((params: any) => {
this.route.params.subscribe(async (params: any) => {
if (params['id'] === undefined) {
this.creationMode = true;
this.title = this.translate.instant('lang.userCreation');
......@@ -107,6 +107,7 @@ export class UserComponent implements OnInit {
isRest: false,
canSendActivationNotification: false
};
await this.getGroups();
this.loading = false;
} else {
this.creationMode = false;
......@@ -361,4 +362,19 @@ export class UserComponent implements OnInit {
await alert.present();
}
getGroups() {
return new Promise((resolve) => {
this.http.get('../rest/groups').pipe(
tap((data: any) => {
this.user['groups'] = data.groups;
resolve(true);
}),
catchError((err: any) => {
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
});
}
}
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