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

FIX #17436 TIME 0:49 can associate groups to user

parent 8507aa19
......@@ -119,7 +119,7 @@
<ng-container *ngIf="currentTool === 'groups'">
<ion-content>
<ion-list *ngIf="user.groups.length > 0">
<ion-item *ngFor="let group of user.groups" [disabled]="!group.checked && creationMode">
<ion-item *ngFor="let group of user.groups">
<ion-label>{{group.label}}</ion-label>
<ion-checkbox *ngIf="creationMode" slot="end" [value]="group.id" (ionChange)="group.checked = !group.checked"></ion-checkbox>
<ion-button *ngIf="!creationMode" slot="end" fill="clear" shape="round"
......
......@@ -191,6 +191,10 @@ export class UserComponent implements OnInit {
createUser() {
this.loading = true;
this.user['groups'] = this.user['groups'].filter((group: any) => group.checked).map((item: any) => ({
id: item.id,
label: item.label
}));
this.http.post('../rest/users', this.user)
.pipe(
finalize(() => this.loading = false),
......@@ -372,14 +376,15 @@ export class UserComponent implements OnInit {
tap((data: any) => {
const groups: any[] = [];
data.groups.forEach((element: any) => {
groups.push(
{
id: element.id,
label: element.label,
checked: this.manageableGroups.indexOf(element.id) > -1 ? true : false
}
);
if (this.manageableGroups.indexOf(element.id) > -1) {
groups.push(
{
id: element.id,
label: element.label,
checked: false
}
);
}
});
this.user['groups'] = groups;
resolve(true);
......
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