diff --git a/jslib b/jslib index 2b8ffea494..d1f7a97011 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 2b8ffea494a82aef30a7b0ee741f5f986bd027cc +Subproject commit d1f7a97011f043a6225f603e71f0565acbe7dcdd diff --git a/src/app/organizations/manage/entity-users.component.ts b/src/app/organizations/manage/entity-users.component.ts index 2016da9192..17eb974566 100644 --- a/src/app/organizations/manage/entity-users.component.ts +++ b/src/app/organizations/manage/entity-users.component.ts @@ -11,7 +11,6 @@ import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; -import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType'; import { OrganizationUserType } from 'jslib/enums/organizationUserType'; @@ -39,8 +38,7 @@ export class EntityUsersComponent implements OnInit { formPromise: Promise; constructor(private apiService: ApiService, private i18nService: I18nService, - private analytics: Angulartics2, private toasterService: ToasterService, - private platformUtilsService: PlatformUtilsService) { } + private analytics: Angulartics2, private toasterService: ToasterService) { } async ngOnInit() { await this.loadUsers(); @@ -52,10 +50,18 @@ export class EntityUsersComponent implements OnInit { this.users = users.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'email')); if (this.entity === 'group') { const response = await this.apiService.getGroupUsers(this.organizationId, this.entityId); + if (response != null && users.data.length > 0) { + response.forEach((s) => { + const user = users.data.filter((u) => !u.accessAll && u.id === s); + if (user != null && user.length > 0) { + (user[0] as any).checked = true; + } + }); + } } else if (this.entity === 'collection') { const response = await this.apiService.getCollectionUsers(this.organizationId, this.entityId); if (response != null && users.data.length > 0) { - response.data.forEach((s) => { + response.forEach((s) => { const user = users.data.filter((u) => !u.accessAll && u.id === s.id); if (user != null && user.length > 0) { (user[0] as any).checked = true; @@ -80,19 +86,18 @@ export class EntityUsersComponent implements OnInit { } async submit() { - const selections = this.users.filter((u) => (u as any).checked && !u.accessAll) - .map((u) => new SelectionReadOnlyRequest(u.id, !!(u as any).readOnly)); - try { if (this.entity === 'group') { - // + const selections = this.users.filter((u) => (u as any).checked && !u.accessAll).map((u) => u.id); + this.formPromise = this.apiService.putGroupUsers(this.organizationId, this.entityId, selections); } else { + const selections = this.users.filter((u) => (u as any).checked && !u.accessAll) + .map((u) => new SelectionReadOnlyRequest(u.id, !!(u as any).readOnly)); this.formPromise = this.apiService.putCollectionUsers(this.organizationId, this.entityId, selections); } await this.formPromise; this.analytics.eventTrack.next({ - action: this.entity === 'group' ? 'Edited Group Users' : - 'Edited Collection Users', + action: this.entity === 'group' ? 'Edited Group Users' : 'Edited Collection Users', }); this.toasterService.popAsync('success', null, this.i18nService.t('updatedUsers')); this.onEditedUsers.emit(); diff --git a/src/app/organizations/manage/groups.component.ts b/src/app/organizations/manage/groups.component.ts index fda699fd9e..75c113675c 100644 --- a/src/app/organizations/manage/groups.component.ts +++ b/src/app/organizations/manage/groups.component.ts @@ -131,6 +131,9 @@ export class GroupsComponent implements OnInit { childComponent.entityId = group.id; childComponent.entityName = group.name; + childComponent.onEditedUsers.subscribe(() => { + this.modal.close(); + }); this.modal.onClosed.subscribe(() => { this.modal = null; });