[develop]: Add roles in stakeholder configuration to handle naming of roles in different services.
This commit is contained in:
parent
e91830f2f8
commit
69cdb2cec2
|
@ -8,26 +8,26 @@
|
||||||
<div class="uk-flex uk-flex-left@m uk-flex-center uk-width-expand">
|
<div class="uk-flex uk-flex-left@m uk-flex-center uk-width-expand">
|
||||||
<ul class="uk-subnav uk-subnav-pill">
|
<ul class="uk-subnav uk-subnav-pill">
|
||||||
<li [class.uk-active]="showCurrent" (click)="showCurrent = true">
|
<li [class.uk-active]="showCurrent" (click)="showCurrent = true">
|
||||||
<a class="uk-text-capitalize">{{role}}s</a>
|
<a class="uk-text-capitalize">{{stakeholderUtils.roles[role]}}s</a>
|
||||||
</li>
|
</li>
|
||||||
<li [class.uk-active]="!showCurrent" (click)="showCurrent = false">
|
<li [class.uk-active]="!showCurrent" (click)="showCurrent = false">
|
||||||
<a>Pending {{role}}s</a>
|
<a>Pending {{stakeholderUtils.roles[role]}}s</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-expand@m uk-width-1-1 uk-grid uk-flex-right@m uk-flex-center uk-flex-middle" uk-grid>
|
<div class="uk-width-expand@m uk-width-1-1 uk-grid uk-flex-right@m uk-flex-center uk-flex-middle" uk-grid>
|
||||||
<div *ngIf="showCurrent" [disabled]="loadActive" search-input class="uk-width-expand@l uk-width-1-1"
|
<div *ngIf="showCurrent" [disabled]="loadActive" search-input class="uk-width-expand@l uk-width-1-1"
|
||||||
[searchControl]="filterForm.get('active')" [expandable]="true" [placeholder]="'Search ' + role + 's'" searchInputClass="outer">
|
[searchControl]="filterForm.get('active')" [expandable]="true" [placeholder]="'Search ' + stakeholderUtils.roles[role] + 's'" searchInputClass="outer">
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!showCurrent" [disabled]="loadPending" search-input class="uk-width-expand@l uk-width-1-1"
|
<div *ngIf="!showCurrent" [disabled]="loadPending" search-input class="uk-width-expand@l uk-width-1-1"
|
||||||
[searchControl]="filterForm.get('pending')" [expandable]="true" [placeholder]="'Search invitations'" searchInputClass="outer">
|
[searchControl]="filterForm.get('pending')" [expandable]="true" [placeholder]="'Search invitations'" searchInputClass="outer">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button *ngIf="exists" class="uk-button uk-button-default uk-flex uk-flex-middle"
|
<button *ngIf="canInvite" class="uk-button uk-button-default uk-flex uk-flex-middle"
|
||||||
[attr.uk-tooltip]="inviteDisableMessage" [class.uk-disabled]="loadPending || loadPending"
|
[attr.uk-tooltip]="inviteDisableMessage" [class.uk-disabled]="loadPending || loadPending"
|
||||||
[disabled]="loadActive || loadPending || !!inviteDisableMessage" (click)="openInviteModal()">
|
[disabled]="loadActive || loadPending || !!inviteDisableMessage" (click)="openInviteModal()">
|
||||||
<icon name="person_add" [flex]="true" type="filled"></icon>
|
<icon name="person_add" [flex]="true" type="filled"></icon>
|
||||||
<span class="uk-margin-small-left uk-text-bold uk-text-uppercase">Invite {{role}}</span>
|
<span class="uk-margin-small-left uk-text-bold uk-text-uppercase">Invite {{stakeholderUtils.roles[role]}}</span>
|
||||||
</button>
|
</button>
|
||||||
<button *ngIf="!exists && isCurator" class="uk-button uk-button-default uk-flex uk-flex-middle"
|
<button *ngIf="!exists && isCurator" class="uk-button uk-button-default uk-flex uk-flex-middle"
|
||||||
(click)="openCreateRoleModal()">
|
(click)="openCreateRoleModal()">
|
||||||
|
@ -47,16 +47,16 @@
|
||||||
<div *ngIf="!loadActive && !loadPending">
|
<div *ngIf="!loadActive && !loadPending">
|
||||||
<div *ngIf="(showCurrent && showActive.length == 0) || (!showCurrent && showPending.length == 0)"
|
<div *ngIf="(showCurrent && showActive.length == 0) || (!showCurrent && showPending.length == 0)"
|
||||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||||
<div *ngIf="showCurrent">No {{role}}s found</div>
|
<div *ngIf="showCurrent">No {{stakeholderUtils.roles[role]}}s found</div>
|
||||||
<div *ngIf="!showCurrent">No pending {{role}} invitations found</div>
|
<div *ngIf="!showCurrent">No pending {{stakeholderUtils.roles[role]}} invitations found</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="(showCurrent && showActive.length > 0) || (!showCurrent && showPending.length > 0)">
|
<div *ngIf="(showCurrent && showActive.length > 0) || (!showCurrent && showPending.length > 0)">
|
||||||
<no-load-paging *ngIf="showCurrent" [type]="(showActive.length > 1)?(role + 's'):role"
|
<no-load-paging *ngIf="showCurrent" [type]="(showActive.length > 1)?(stakeholderUtils.roles[role] + 's'):role"
|
||||||
(pageChange)="updateActivePage($event)"
|
(pageChange)="updateActivePage($event)"
|
||||||
[page]="activePage" [pageSize]="pageSize"
|
[page]="activePage" [pageSize]="pageSize"
|
||||||
[totalResults]="showActive.length">
|
[totalResults]="showActive.length">
|
||||||
</no-load-paging>
|
</no-load-paging>
|
||||||
<no-load-paging *ngIf="!showCurrent" [type]="role + ' ' + (showPending.length > 1?'invitations':'invitation')"
|
<no-load-paging *ngIf="!showCurrent" [type]="stakeholderUtils.roles[role] + ' ' + (showPending.length > 1?'invitations':'invitation')"
|
||||||
(pageChange)="updatePendingPage($event)"
|
(pageChange)="updatePendingPage($event)"
|
||||||
[page]="pendingPage" [pageSize]="pageSize"
|
[page]="pendingPage" [pageSize]="pageSize"
|
||||||
[totalResults]="showPending.length">
|
[totalResults]="showPending.length">
|
||||||
|
@ -109,12 +109,12 @@
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<modal-alert #deleteModal [overflowBody]="false" (alertOutput)="deleteActive()" classTitle="uk-background-primary uk-light">
|
<modal-alert #deleteModal [overflowBody]="false" (alertOutput)="deleteActive()" classTitle="uk-background-primary uk-light">
|
||||||
<div *ngIf="selectedUser">
|
<div *ngIf="selectedUser">
|
||||||
Are you sure you want to remove <span class="uk-text-bold">{{selectedUser}}</span> from {{role}}s?
|
Are you sure you want to remove <span class="uk-text-bold">{{selectedUser}}</span> from {{stakeholderUtils.roles[role]}}s?
|
||||||
</div>
|
</div>
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<modal-alert #deletePendingModal [overflowBody]="false" (alertOutput)="deletePending()" classTitle="uk-background-primary uk-light">
|
<modal-alert #deletePendingModal [overflowBody]="false" (alertOutput)="deletePending()" classTitle="uk-background-primary uk-light">
|
||||||
<div *ngIf="selectedUser">
|
<div *ngIf="selectedUser">
|
||||||
Are you sure you want to cancel {{role}} invitation of <span class="uk-text-bold">{{selectedUser}}</span>?
|
Are you sure you want to cancel {{stakeholderUtils.roles[role]}} invitation of <span class="uk-text-bold">{{selectedUser}}</span>?
|
||||||
</div>
|
</div>
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<modal-alert #createRoleModal [overflowBody]="false" (alertOutput)="createGroup()" classTitle="uk-background-primary uk-light"
|
<modal-alert #createRoleModal [overflowBody]="false" (alertOutput)="createGroup()" classTitle="uk-background-primary uk-light"
|
||||||
|
|
|
@ -23,6 +23,7 @@ import {NotificationHandler} from "../../../utils/notification-handler";
|
||||||
import {ClearCacheService} from "../../../services/clear-cache.service";
|
import {ClearCacheService} from "../../../services/clear-cache.service";
|
||||||
import {catchError, map, tap} from "rxjs/operators";
|
import {catchError, map, tap} from "rxjs/operators";
|
||||||
import {InputComponent} from "../../../sharedComponents/input/input.component";
|
import {InputComponent} from "../../../sharedComponents/input/input.component";
|
||||||
|
import {StakeholderUtils} from "../../../monitor-admin/utils/indicator-utils";
|
||||||
|
|
||||||
class InvitationResponse {
|
class InvitationResponse {
|
||||||
email: string;
|
email: string;
|
||||||
|
@ -53,6 +54,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
@Input()
|
@Input()
|
||||||
public deleteAuthorizationLevel: 'curator' | 'manager' = 'curator';
|
public deleteAuthorizationLevel: 'curator' | 'manager' = 'curator';
|
||||||
@Input()
|
@Input()
|
||||||
|
public inviteAuthorizationLevel: 'curator' | 'manager' = 'manager';
|
||||||
|
@Input()
|
||||||
public message: string = null;
|
public message: string = null;
|
||||||
@Input()
|
@Input()
|
||||||
public emailComposer: Function;
|
public emailComposer: Function;
|
||||||
|
@ -86,12 +89,12 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
@ViewChild('deleteModal') deleteModal: AlertModal;
|
@ViewChild('deleteModal') deleteModal: AlertModal;
|
||||||
@ViewChild('deletePendingModal') deletePendingModal: AlertModal;
|
@ViewChild('deletePendingModal') deletePendingModal: AlertModal;
|
||||||
@ViewChild('createRoleModal') createRoleModal: AlertModal;
|
@ViewChild('createRoleModal') createRoleModal: AlertModal;
|
||||||
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
||||||
|
|
||||||
constructor(private userRegistryService: UserRegistryService,
|
constructor(private userRegistryService: UserRegistryService,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private clearCacheService: ClearCacheService,
|
private clearCacheService: ClearCacheService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
private router: Router,
|
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private fb: UntypedFormBuilder) {
|
private fb: UntypedFormBuilder) {
|
||||||
}
|
}
|
||||||
|
@ -182,7 +185,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
openDeleteModal(item: any) {
|
openDeleteModal(item: any) {
|
||||||
if (this.showCurrent) {
|
if (this.showCurrent) {
|
||||||
this.selectedUser = item.email;
|
this.selectedUser = item.email;
|
||||||
this.deleteModal.alertTitle = 'Delete ' + this.role;
|
this.deleteModal.alertTitle = 'Delete ' + this.stakeholderUtils.roles[this.role];
|
||||||
this.deleteModal.open();
|
this.deleteModal.open();
|
||||||
} else {
|
} else {
|
||||||
this.selectedUser = item;
|
this.selectedUser = item;
|
||||||
|
@ -192,7 +195,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
openInviteModal() {
|
openInviteModal() {
|
||||||
this.inviteModal.alertTitle = 'Invite ' + this.role;
|
this.inviteModal.alertTitle = 'Invite ' + this.stakeholderUtils.roles[this.role];
|
||||||
this.inviteModal.okButtonLeft = false;
|
this.inviteModal.okButtonLeft = false;
|
||||||
this.inviteModal.okButtonText = 'Send';
|
this.inviteModal.okButtonText = 'Send';
|
||||||
this.emailsForm = this.fb.array([], Validators.required);
|
this.emailsForm = this.fb.array([], Validators.required);
|
||||||
|
@ -241,7 +244,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
if (this.currentPendingPage.length === 0) {
|
if (this.currentPendingPage.length === 0) {
|
||||||
this.pendingPage = 1;
|
this.pendingPage = 1;
|
||||||
}
|
}
|
||||||
NotificationHandler.rise(StringUtils.capitalize(this.role) + ' invitation to ' + this.selectedUser + ' has been <b>canceled</b>');
|
NotificationHandler.rise(StringUtils.capitalize(this.stakeholderUtils.roles[this.role]) + ' invitation to ' + this.selectedUser + ' has been <b>canceled</b>');
|
||||||
this.loadPending = false;
|
this.loadPending = false;
|
||||||
}, error => {
|
}, error => {
|
||||||
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
||||||
|
@ -309,7 +312,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
this.updateLists();
|
this.updateLists();
|
||||||
}, error => {
|
}, error => {
|
||||||
if(error.status === 409) {
|
if(error.status === 409) {
|
||||||
NotificationHandler.rise('Group already exists. You can try to invite a ' + this.role + ' instead.', 'warning');
|
NotificationHandler.rise('Group already exists. You can try to invite a ' + this.stakeholderUtils.roles[this.role] + ' instead.', 'warning');
|
||||||
this.updateLists();
|
this.updateLists();
|
||||||
} else {
|
} else {
|
||||||
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
|
||||||
|
@ -322,6 +325,10 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
public get canDelete() {
|
public get canDelete() {
|
||||||
return (this.deleteAuthorizationLevel === 'curator'?this.isCurator:this.isManager);
|
return (this.deleteAuthorizationLevel === 'curator'?this.isCurator:this.isManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get canInvite() {
|
||||||
|
return this.exists && (this.inviteAuthorizationLevel === 'curator'?this.isCurator:this.isManager);
|
||||||
|
}
|
||||||
|
|
||||||
public isMe(userId: string) {
|
public isMe(userId: string) {
|
||||||
return userId && userId.includes(this.user.id) && !this.isCurator;
|
return userId && userId.includes(this.user.id) && !this.isCurator;
|
||||||
|
|
|
@ -17,6 +17,11 @@ import {Session} from "../../login/utils/helper.class";
|
||||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||||
import {properties} from "src/environments/environment";
|
import {properties} from "src/environments/environment";
|
||||||
|
|
||||||
|
class Roles {
|
||||||
|
manager = 'manager';
|
||||||
|
member = 'member';
|
||||||
|
}
|
||||||
|
|
||||||
class Entities {
|
class Entities {
|
||||||
stakeholder = 'Dashboard';
|
stakeholder = 'Dashboard';
|
||||||
funder = 'Funder';
|
funder = 'Funder';
|
||||||
|
@ -37,6 +42,7 @@ class Entities {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StakeholderConfiguration {
|
export class StakeholderConfiguration {
|
||||||
|
public static ROLES: Roles = new Roles();
|
||||||
public static ENTITIES: Entities = new Entities();
|
public static ENTITIES: Entities = new Entities();
|
||||||
public static TYPES: Option[] = [
|
public static TYPES: Option[] = [
|
||||||
{value: 'funder', label: StakeholderConfiguration.ENTITIES.funder},
|
{value: 'funder', label: StakeholderConfiguration.ENTITIES.funder},
|
||||||
|
@ -60,6 +66,10 @@ export class StakeholderConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class StakeholderUtils {
|
export class StakeholderUtils {
|
||||||
|
get roles() {
|
||||||
|
return StakeholderConfiguration.ROLES;
|
||||||
|
}
|
||||||
|
|
||||||
get entities() {
|
get entities() {
|
||||||
return StakeholderConfiguration.ENTITIES;
|
return StakeholderConfiguration.ENTITIES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {EmailService} from "../utils/email/email.service";
|
||||||
import {Composer} from "../utils/email/composer";
|
import {Composer} from "../utils/email/composer";
|
||||||
import {ClearCacheService} from "../services/clear-cache.service";
|
import {ClearCacheService} from "../services/clear-cache.service";
|
||||||
import {BaseComponent} from "../sharedComponents/base/base.component";
|
import {BaseComponent} from "../sharedComponents/base/base.component";
|
||||||
|
import {StakeholderUtils} from "../monitor-admin/utils/indicator-utils";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'role-verification',
|
selector: 'role-verification',
|
||||||
|
@ -106,6 +107,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
public error: string = null;
|
public error: string = null;
|
||||||
public loading: boolean = false;
|
public loading: boolean = false;
|
||||||
public isMember: boolean = false;
|
public isMember: boolean = false;
|
||||||
|
public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
||||||
|
|
||||||
constructor(protected _route: ActivatedRoute,
|
constructor(protected _route: ActivatedRoute,
|
||||||
protected _router: Router,
|
protected _router: Router,
|
||||||
|
@ -179,7 +181,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
this.managerModal.okButtonText = 'Accept';
|
this.managerModal.okButtonText = 'Accept';
|
||||||
this.managerModal.stayOpen = true;
|
this.managerModal.stayOpen = true;
|
||||||
this.managerModal.cancelButtonText = 'Cancel';
|
this.managerModal.cancelButtonText = 'Cancel';
|
||||||
this.managerModal.alertTitle = 'Manager Invitation';
|
this.managerModal.alertTitle = this.stakeholderUtils.roles.manager + ' Invitation';
|
||||||
this.managerModal.open();
|
this.managerModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +197,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
|
||||||
this.memberModal.okButtonLeft = false;
|
this.memberModal.okButtonLeft = false;
|
||||||
this.memberModal.stayOpen = true;
|
this.memberModal.stayOpen = true;
|
||||||
this.memberModal.cancelButtonText = 'Cancel';
|
this.memberModal.cancelButtonText = 'Cancel';
|
||||||
this.memberModal.alertTitle = 'Member Invitation';
|
this.memberModal.alertTitle = this.stakeholderUtils.roles.member + ' Invitation';
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
this.memberModal.open();
|
this.memberModal.open();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {Email} from "./email";
|
||||||
import {Body} from "./body";
|
import {Body} from "./body";
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
import {User} from "../../login/utils/helper.class";
|
import {User} from "../../login/utils/helper.class";
|
||||||
|
import {StakeholderConfiguration} from "../../monitor-admin/utils/indicator-utils";
|
||||||
|
|
||||||
export class Composer {
|
export class Composer {
|
||||||
private static noteBodySize = "14px";
|
private static noteBodySize = "14px";
|
||||||
|
@ -335,13 +336,13 @@ export class Composer {
|
||||||
email.subject = 'National Open Access Monitor Ireland | ' + name;
|
email.subject = 'National Open Access Monitor Ireland | ' + name;
|
||||||
email.recipient = recipient;
|
email.recipient = recipient;
|
||||||
email.body = '<p>Dear user,</p>' +
|
email.body = '<p>Dear user,</p>' +
|
||||||
'<p>You have been invited to be a ' + role +' of the for the National Open Access Monitor, Ireland dashboard for the ' + name + '.</p>' +
|
'<p>You have been invited to be a ' + StakeholderConfiguration.ROLES[role] +' of the for the National Open Access Monitor, Ireland dashboard for the ' + name + '.</p>' +
|
||||||
'<p>Click <a href="((__link__))" target="_blank">this URL</a> and use the verification code below to accept the invitation.</p>' +
|
'<p>Click <a href="((__link__))" target="_blank">this URL</a> and use the verification code below to accept the invitation.</p>' +
|
||||||
'<p>The verification code is <b>((__code__))</b>.</p>' +
|
'<p>The verification code is <b>((__code__))</b>.</p>' +
|
||||||
'<p>At your first sign in you will be asked to accept and consent to the "OpenAIRE Personal Data Protection Policy and Consent Form" to be able to use the service.</p>' +
|
'<p>At your first sign in you will be asked to accept and consent to the "OpenAIRE Personal Data Protection Policy and Consent Form" to be able to use the service.</p>' +
|
||||||
(role === "manager"?
|
(role === "manager"?
|
||||||
'<p>As a manager of the National Open Access Monitor, Ireland, you will have access to the administration part of the dashboard, where you will be able to also invite other users to become managers.</p>':
|
'<p>As a ' + StakeholderConfiguration.ROLES[role] + ' of the National Open Access Monitor, Ireland, you will have access to the administration part of the dashboard, where you will be able to also invite other users to become ' + StakeholderConfiguration.ROLES['member'] + 's.</p>':
|
||||||
'<p>As a member of the OpenAIRE Monitor Dashboard, you will have access to the restricted access areas of the profile for the ' + name + '.') +
|
'<p>As a ' + StakeholderConfiguration.ROLES[role] + ' of the National Open Access Monitor, Ireland, you will have access to the sandbox of the profile for the ' + name + '.') +
|
||||||
'<p>Please contact us at <a href="mailto:' + properties.helpdeskEmail+'">' + properties.helpdeskEmail +
|
'<p>Please contact us at <a href="mailto:' + properties.helpdeskEmail+'">' + properties.helpdeskEmail +
|
||||||
'</a> if you have any questions or concerns.</p>' +
|
'</a> if you have any questions or concerns.</p>' +
|
||||||
'<p>Kind Regards<br>The OpenAIRE Team</p>' +
|
'<p>Kind Regards<br>The OpenAIRE Team</p>' +
|
||||||
|
|
Loading…
Reference in New Issue