From 9b7478c0c762873036a712f3641d0f09f5135f9b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 17 Oct 2018 11:19:10 -0400 Subject: [PATCH] manager sees their assigned collections from org vault view --- jslib | 2 +- .../vault/groupings.component.ts | 29 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/jslib b/jslib index 00efae2616..0d8e09b3f1 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 00efae261684eb97e7fcd8fd77aa04bca5e87a72 +Subproject commit 0d8e09b3f1da8e1377bad5cfea2bc0dfcc7701c0 diff --git a/src/app/organizations/vault/groupings.component.ts b/src/app/organizations/vault/groupings.component.ts index 6b853fe954..92c7ca5655 100644 --- a/src/app/organizations/vault/groupings.component.ts +++ b/src/app/organizations/vault/groupings.component.ts @@ -8,7 +8,11 @@ import { I18nService } from 'jslib/abstractions/i18n.service'; import { CollectionData } from 'jslib/models/data/collectionData'; import { Collection } from 'jslib/models/domain/collection'; import { Organization } from 'jslib/models/domain/organization'; -import { CollectionDetailsResponse } from 'jslib/models/response/collectionResponse'; +import { + CollectionDetailsResponse, + CollectionResponse, +} from 'jslib/models/response/collectionResponse'; +import { ListResponse } from 'jslib/models/response/listResponse'; import { CollectionView } from 'jslib/models/view/collectionView'; import { GroupingsComponent as BaseGroupingsComponent } from '../../vault/groupings.component'; @@ -26,11 +30,16 @@ export class GroupingsComponent extends BaseGroupingsComponent { } async loadCollections() { - if (!this.organization.isAdmin) { + if (!this.organization.isManager) { await super.loadCollections(this.organization.id); return; } - const collections = await this.apiService.getCollections(this.organization.id); + let collections: ListResponse; + if (this.organization.isAdmin) { + collections = await this.apiService.getCollections(this.organization.id); + } else { + collections = await this.apiService.getUserCollections(); + } if (collections != null && collections.data != null && collections.data.length) { const collectionDomains = collections.data.map((r) => new Collection(new CollectionData(r as CollectionDetailsResponse))); @@ -39,11 +48,13 @@ export class GroupingsComponent extends BaseGroupingsComponent { this.collections = []; } - const unassignedCollection = new CollectionView(); - unassignedCollection.name = this.i18nService.t('unassigned'); - unassignedCollection.id = 'unassigned'; - unassignedCollection.organizationId = this.organization.id; - unassignedCollection.readOnly = true; - this.collections.push(unassignedCollection); + if (this.organization.isAdmin) { + const unassignedCollection = new CollectionView(); + unassignedCollection.name = this.i18nService.t('unassigned'); + unassignedCollection.id = 'unassigned'; + unassignedCollection.organizationId = this.organization.id; + unassignedCollection.readOnly = true; + this.collections.push(unassignedCollection); + } } }