diff --git a/jslib b/jslib
index 0d8e09b3f1..2b8ffea494 160000
--- a/jslib
+++ b/jslib
@@ -1 +1 @@
-Subproject commit 0d8e09b3f1da8e1377bad5cfea2bc0dfcc7701c0
+Subproject commit 2b8ffea494a82aef30a7b0ee741f5f986bd027cc
diff --git a/src/app/organizations/manage/collections.component.ts b/src/app/organizations/manage/collections.component.ts
index 2dcdda9128..79db2c2242 100644
--- a/src/app/organizations/manage/collections.component.ts
+++ b/src/app/organizations/manage/collections.component.ts
@@ -135,6 +135,10 @@ export class CollectionsComponent implements OnInit {
childComponent.entityId = collection.id;
childComponent.entityName = collection.name;
+ childComponent.onEditedUsers.subscribe(() => {
+ this.load();
+ this.modal.close();
+ });
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
diff --git a/src/app/organizations/manage/entity-users.component.html b/src/app/organizations/manage/entity-users.component.html
index f80ac90f3d..8e917871fd 100644
--- a/src/app/organizations/manage/entity-users.component.html
+++ b/src/app/organizations/manage/entity-users.component.html
@@ -1,6 +1,6 @@
diff --git a/src/app/organizations/manage/entity-users.component.ts b/src/app/organizations/manage/entity-users.component.ts
index 7b2b0395b4..2016da9192 100644
--- a/src/app/organizations/manage/entity-users.component.ts
+++ b/src/app/organizations/manage/entity-users.component.ts
@@ -15,6 +15,8 @@ import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
import { OrganizationUserType } from 'jslib/enums/organizationUserType';
+import { SelectionReadOnlyRequest } from 'jslib/models/request/selectionReadOnlyRequest';
+import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse';
import { Utils } from 'jslib/misc/utils';
@@ -27,14 +29,14 @@ export class EntityUsersComponent implements OnInit {
@Input() entityId: string;
@Input() entityName: string;
@Input() organizationId: string;
- @Output() onRemovedUser = new EventEmitter();
+ @Output() onEditedUsers = new EventEmitter();
organizationUserType = OrganizationUserType;
organizationUserStatusType = OrganizationUserStatusType;
loading = true;
- users: any[] = [];
- actionPromise: Promise;
+ users: OrganizationUserUserDetailsResponse[] = [];
+ formPromise: Promise;
constructor(private apiService: ApiService, private i18nService: I18nService,
private analytics: Angulartics2, private toasterService: ToasterService,
@@ -46,49 +48,54 @@ export class EntityUsersComponent implements OnInit {
}
async loadUsers() {
- let users: any[] = [];
+ const users = await this.apiService.getOrganizationUsers(this.organizationId);
+ 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);
- users = response.data.map((r) => r);
} else if (this.entity === 'collection') {
const response = await this.apiService.getCollectionUsers(this.organizationId, this.entityId);
- users = response.data.map((r) => r);
+ if (response != null && users.data.length > 0) {
+ response.data.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;
+ (user[0] as any).readOnly = s.readOnly;
+ }
+ });
+ }
}
- users.sort(Utils.getSortFunction(this.i18nService, 'email'));
- this.users = users;
+
+ this.users.forEach((u) => {
+ if (u.accessAll) {
+ (u as any).checked = true;
+ }
+ });
}
- async remove(user: any) {
- if (this.actionPromise != null || (this.entity === 'collection' && user.accessAll)) {
+ check(u: OrganizationUserUserDetailsResponse) {
+ if (u.accessAll) {
return;
}
+ (u as any).checked = !(u as any).checked;
+ }
- const confirmed = await this.platformUtilsService.showDialog(
- this.i18nService.t('removeUserConfirmation'), user.email,
- this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
- if (!confirmed) {
- return false;
- }
+ 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') {
- this.actionPromise = this.apiService.deleteGroupUser(this.organizationId, this.entityId,
- user.organizationUserId);
- await this.actionPromise;
- this.analytics.eventTrack.next({ action: 'Removed User From Group' });
- } else if (this.entity === 'collection') {
- this.actionPromise = this.apiService.deleteCollectionUser(this.organizationId, this.entityId,
- user.organizationUserId);
- await this.actionPromise;
- this.analytics.eventTrack.next({ action: 'Removed User From Collection' });
- }
-
- this.toasterService.popAsync('success', null, this.i18nService.t('removedUserId', user.email));
- this.onRemovedUser.emit();
- const index = this.users.indexOf(user);
- if (index > -1) {
- this.users.splice(index, 1);
+ //
+ } else {
+ 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',
+ });
+ this.toasterService.popAsync('success', null, this.i18nService.t('updatedUsers'));
+ this.onEditedUsers.emit();
} catch { }
}
}
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index c0c5a017cb..993e881870 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -2492,5 +2492,8 @@
},
"licenseIsExpired": {
"message": "License is expired."
+ },
+ "updatedUsers": {
+ "message": "Updated users"
}
}