Compare commits

...

2 Commits

2 changed files with 15 additions and 12 deletions

View File

@ -44,7 +44,9 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
@Input() @Input()
public id: string; public id: string;
@Input() @Input()
public type: string; set type(type: string) {
this._type = Role.mapType(type);
}
@Input() @Input()
public name: string; public name: string;
@Input() @Input()
@ -90,6 +92,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
@ViewChild('deletePendingModal') deletePendingModal: AlertModal; @ViewChild('deletePendingModal') deletePendingModal: AlertModal;
@ViewChild('createRoleModal') createRoleModal: AlertModal; @ViewChild('createRoleModal') createRoleModal: AlertModal;
public stakeholderUtils: StakeholderUtils = new StakeholderUtils(); public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
private _type: string;
constructor(private userRegistryService: UserRegistryService, constructor(private userRegistryService: UserRegistryService,
private userManagementService: UserManagementService, private userManagementService: UserManagementService,
@ -143,7 +146,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
updateLists() { updateLists() {
this.loadActive = true; this.loadActive = true;
this.loadPending = true; this.loadPending = true;
this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role, true).subscribe(users => { this.subs.push(this.userRegistryService.getActive(this._type, this.id, this.role, true).subscribe(users => {
this.active = users; this.active = users;
this.filterActiveBySearch(this.filterForm.value.active); this.filterActiveBySearch(this.filterForm.value.active);
this.loadActive = false; this.loadActive = false;
@ -156,7 +159,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
} }
this.loadActive = false; this.loadActive = false;
})); }));
this.subs.push(this.userRegistryService.getPending(this.type, this.id, this.role, true).subscribe(users => { this.subs.push(this.userRegistryService.getPending(this._type, this.id, this.role, true).subscribe(users => {
this.pending = users; this.pending = users;
this.filterPendingBySearch(this.filterForm.value.pending); this.filterPendingBySearch(this.filterForm.value.pending);
this.loadPending = false; this.loadPending = false;
@ -208,8 +211,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.createRoleModal.okButtonLeft = false; this.createRoleModal.okButtonLeft = false;
this.createRoleModal.okButtonText = 'Create'; this.createRoleModal.okButtonText = 'Create';
this.roleFb = this.fb.group({ this.roleFb = this.fb.group({
name: this.fb.control(Role.roleName(this.type, this.id), Validators.required), name: this.fb.control(Role.roleName(this._type, this.id), Validators.required),
description: this.fb.control(Role.roleName(this.type, this.id), Validators.required) description: this.fb.control(Role.roleName(this._type, this.id), Validators.required)
}); });
setTimeout(() => { setTimeout(() => {
this.roleFb.get('name').disable(); this.roleFb.get('name').disable();
@ -220,7 +223,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
deleteActive() { deleteActive() {
this.loadActive = true; this.loadActive = true;
this.subs.push(this.userRegistryService.remove(this.type, this.id, this.selectedUser, this.role).subscribe(() => { this.subs.push(this.userRegistryService.remove(this._type, this.id, this.selectedUser, this.role).subscribe(() => {
this.active = this.active.filter(user => user.email != this.selectedUser); this.active = this.active.filter(user => user.email != this.selectedUser);
if (this.currentActivePage.length === 0) { if (this.currentActivePage.length === 0) {
this.activePage = 1; this.activePage = 1;
@ -238,7 +241,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
deletePending() { deletePending() {
this.loadPending = true; this.loadPending = true;
this.subs.push(this.userRegistryService.cancelInvitation(this.type, this.id, this.selectedUser, this.role).subscribe(() => { this.subs.push(this.userRegistryService.cancelInvitation(this._type, this.id, this.selectedUser, this.role).subscribe(() => {
this.pending = this.pending.filter(user => user != this.selectedUser); this.pending = this.pending.filter(user => user != this.selectedUser);
this.filterPendingBySearch(this.filterForm.value.pending); this.filterPendingBySearch(this.filterForm.value.pending);
if (this.currentPendingPage.length === 0) { if (this.currentPendingPage.length === 0) {
@ -265,7 +268,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
let current = null; let current = null;
let invitations = (<Array<any>>this.emailsForm.value).map(email => { let invitations = (<Array<any>>this.emailsForm.value).map(email => {
current = email; current = email;
return this.userRegistryService.invite(this.type, this.id, { return this.userRegistryService.invite(this._type, this.id, {
link: this.link, link: this.link,
email: this.emailComposer(this.name, email, this.role) email: this.emailComposer(this.name, email, this.role)
}, this.role).pipe(catchError(error => { }, this.role).pipe(catchError(error => {
@ -308,7 +311,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
createGroup() { createGroup() {
this.loadActive = true; this.loadActive = true;
this.loadPending = true; this.loadPending = true;
this.userRegistryService.createRole(this.type, this.id).subscribe(() => { this.userRegistryService.createRole(this._type, this.id).subscribe(() => {
NotificationHandler.rise('Group has been <b> successfully created</b>'); NotificationHandler.rise('Group has been <b> successfully created</b>');
this.updateLists(); this.updateLists();
}, error => { }, error => {
@ -336,11 +339,11 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
} }
public get isManager(): boolean { public get isManager(): boolean {
return this.isCurator || !!Session.isManager(this.type, this.id, this.user); return this.isCurator || !!Session.isManager(this._type, this.id, this.user);
} }
public get isCurator(): boolean { public get isCurator(): boolean {
return this.isPortalAdmin || !!Session.isCurator(this.type, this.user); return this.isPortalAdmin || !!Session.isCurator(this._type, this.user);
} }
public get isPortalAdmin(): boolean { public get isPortalAdmin(): boolean {

View File

@ -73,7 +73,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit,
public id: string; public id: string;
@Input() @Input()
set type(type: string) { set type(type: string) {
this._type = Role.GROUP + type; this._type = Role.GROUP + Role.mapType(type);
} }
@Input() @Input()
public name: string; public name: string;