diff --git a/src/app/components/msel-contributors/msel-contributors.component.html b/src/app/components/msel-contributors/msel-contributors.component.html index 2001ebdc..2381fc84 100644 --- a/src/app/components/msel-contributors/msel-contributors.component.html +++ b/src/app/components/msel-contributors/msel-contributors.component.html @@ -78,12 +78,62 @@ @for (user of getMselUnitUsers(element.unitId); track user) {
{{ user.name }}
- @for (mselRole of getMselRolesToDisplay(); track mselRole) { -
- {{ mselRole }} +
+ + MSEL Roles + + @for (role of getMselRolesToDisplay(); track role) { + {{ role }} + } + + +
+ @if (msel.useCite) { +
+ + CITE Role + + + @for (role of citeEvaluationRoles; track role) { + {{ role }} + } + + +
+ } + @if (msel.useGallery) { +
+ + Gallery Role + + + @for (role of galleryExhibitRoles; track role) { + {{ role }} + } + + +
+ } + @if (msel.useSteamfitter) { +
+ + Steamfitter Role + + + @for (role of steamfitterScenarioRoles; track role) { + {{ role }} + } + +
}
diff --git a/src/app/components/msel-contributors/msel-contributors.component.scss b/src/app/components/msel-contributors/msel-contributors.component.scss index 4fbfdaf9..545f3e48 100644 --- a/src/app/components/msel-contributors/msel-contributors.component.scss +++ b/src/app/components/msel-contributors/msel-contributors.component.scss @@ -80,6 +80,12 @@ table { display: flex; } +.role-select { + display: flex; + margin-right: 20px; + min-width: 180px; +} + .four-cell { flex: 4; min-width: 150px; diff --git a/src/app/components/msel-contributors/msel-contributors.component.ts b/src/app/components/msel-contributors/msel-contributors.component.ts index 36fa358e..fcaeb31a 100644 --- a/src/app/components/msel-contributors/msel-contributors.component.ts +++ b/src/app/components/msel-contributors/msel-contributors.component.ts @@ -68,6 +68,26 @@ export class MselContributorsComponent implements OnDestroy, OnInit { MselRole.Evaluator, MselRole.Viewer ]; + citeEvaluationRoles: string[] = [ + 'Owner', + 'Editor', + 'Viewer', + 'Facilitator', + 'Advancer', + 'Observer', + 'Member' + ]; + galleryExhibitRoles: string[] = [ + 'Manager', + 'Observer', + 'Member' + ]; + steamfitterScenarioRoles: string[] = [ + 'Manager', + 'Facilitator', + 'Member', + 'Observer' + ]; isEditEnabled = false; userList: User[] = []; mselUnitList: MselUnit[] = []; @@ -227,6 +247,62 @@ export class MselContributorsComponent implements OnDestroy, OnInit { } } + getSelectedMselRoles(userId: string): MselRole[] { + return this.userMselRoles + .filter(umr => umr.userId === userId && umr.mselId === this.msel.id) + .map(umr => umr.role); + } + + setMselRoles(userId: string, newRoles: MselRole[]) { + const current = this.getSelectedMselRoles(userId); + const toAdd = newRoles.filter(r => !current.includes(r)); + const toRemove = current.filter(r => !newRoles.includes(r)); + toAdd.forEach(r => this.toggleMselRole(userId, r, true)); + toRemove.forEach(r => this.toggleMselRole(userId, r, false)); + } + + getCiteEvaluationRole(userId: string): string | null { + const umr = this.userMselRoles.find(u => + u.userId === userId && u.mselId === this.msel.id); + return umr?.citeEvaluationRole ?? null; + } + + setCiteEvaluationRole(userId: string, role: string | null) { + this.userMselRoleDataService.setIntegrationRoles( + this.msel.id, userId, + role, + this.getGalleryExhibitRole(userId), + this.getSteamfitterScenarioRole(userId)); + } + + getGalleryExhibitRole(userId: string): string | null { + const umr = this.userMselRoles.find(u => + u.userId === userId && u.mselId === this.msel.id); + return umr?.galleryExhibitRole ?? null; + } + + setGalleryExhibitRole(userId: string, role: string | null) { + this.userMselRoleDataService.setIntegrationRoles( + this.msel.id, userId, + this.getCiteEvaluationRole(userId), + role, + this.getSteamfitterScenarioRole(userId)); + } + + getSteamfitterScenarioRole(userId: string): string | null { + const umr = this.userMselRoles.find(u => + u.userId === userId && u.mselId === this.msel.id); + return umr?.steamfitterScenarioRole ?? null; + } + + setSteamfitterScenarioRole(userId: string, role: string | null) { + this.userMselRoleDataService.setIntegrationRoles( + this.msel.id, userId, + this.getCiteEvaluationRole(userId), + this.getGalleryExhibitRole(userId), + role); + } + saveMselUnit(mselUnit: MselUnit) { this.mselUnitDataService.updateMselUnit(mselUnit); } diff --git a/src/app/data/user-msel-role/user-msel-role-data.service.ts b/src/app/data/user-msel-role/user-msel-role-data.service.ts index ed843e75..a9d8f783 100644 --- a/src/app/data/user-msel-role/user-msel-role-data.service.ts +++ b/src/app/data/user-msel-role/user-msel-role-data.service.ts @@ -126,6 +126,18 @@ export class UserMselRoleDataService { }); } + setIntegrationRoles(mselId: string, userId: string, citeEvaluationRole: string | null, galleryExhibitRole: string | null, steamfitterScenarioRole: string | null) { + this.userMselRoleService + .setUserMselIntegrationRoles(mselId, userId, { citeEvaluationRole, galleryExhibitRole, steamfitterScenarioRole }) + .pipe(take(1)) + .subscribe((updated) => { + updated.forEach(u => { + this.setAsDates(u); + this.userMselRoleStore.upsert(u.id, u); + }); + }); + } + setActive(id: string) { this.userMselRoleStore.setActive(id); } diff --git a/src/app/generated/blueprint.api/api/userMselRole.service.ts b/src/app/generated/blueprint.api/api/userMselRole.service.ts index 6cd66907..f18c9fd7 100644 --- a/src/app/generated/blueprint.api/api/userMselRole.service.ts +++ b/src/app/generated/blueprint.api/api/userMselRole.service.ts @@ -170,6 +170,31 @@ export class UserMselRoleService extends BaseService { ); } + /** + * Sets CITE Evaluation and Gallery Exhibit roles for a user on a MSEL + */ + public setUserMselIntegrationRoles(mselId: string, userId: string, update: { citeEvaluationRole?: string | null; galleryExhibitRole?: string | null; steamfitterScenarioRole?: string | null }): Observable> { + if (mselId === null || mselId === undefined) { + throw new Error('Required parameter mselId was null or undefined when calling setUserMselIntegrationRoles.'); + } + if (userId === null || userId === undefined) { + throw new Error('Required parameter userId was null or undefined when calling setUserMselIntegrationRoles.'); + } + let localVarHeaders = this.defaultHeaders; + localVarHeaders = this.configuration.addCredentialToHeaders('oauth2', 'Authorization', localVarHeaders, 'Bearer '); + localVarHeaders = localVarHeaders.set('Accept', 'application/json'); + localVarHeaders = localVarHeaders.set('Content-Type', 'application/json'); + const { basePath, withCredentials } = this.configuration; + const path = `/api/msels/${this.configuration.encodeParam({name: "mselId", value: mselId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid"})}/users/${this.configuration.encodeParam({name: "userId", value: userId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: "uuid"})}/integrationroles`; + return this.httpClient.request>('put', `${basePath}${path}`, { + body: update, + responseType: 'json', + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: 'body' + }); + } + /** * Gets a specific UserMselRole by id * Returns the UserMselRole with the id specified diff --git a/src/app/generated/blueprint.api/model/userMselRole.ts b/src/app/generated/blueprint.api/model/userMselRole.ts index fa2a1a6c..a4130448 100644 --- a/src/app/generated/blueprint.api/model/userMselRole.ts +++ b/src/app/generated/blueprint.api/model/userMselRole.ts @@ -25,6 +25,9 @@ export interface UserMselRole { mselId?: string; userId?: string; role?: MselRole; + citeEvaluationRole?: string | null; + galleryExhibitRole?: string | null; + steamfitterScenarioRole?: string | null; } export namespace UserMselRole { } diff --git a/src/app/services/signalr.service.ts b/src/app/services/signalr.service.ts index 6ea3fae3..fe95b8ab 100644 --- a/src/app/services/signalr.service.ts +++ b/src/app/services/signalr.service.ts @@ -601,6 +601,13 @@ export class SignalRService implements OnDestroy { } ); + this.hubConnection.on( + 'UserMselRoleUpdated', + (userMselRole: UserMselRole) => { + this.userMselRoleDataService.updateStore(userMselRole); + } + ); + this.hubConnection.on('UserMselRoleDeleted', (id: string) => { this.userMselRoleDataService.deleteFromStore(id); });