|
|
|
@ -38,9 +38,8 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
@Input()
|
|
|
|
|
public inviteDisableMessage: string;
|
|
|
|
|
public user: User = null;
|
|
|
|
|
public active: any[];
|
|
|
|
|
public active: any[] = [];
|
|
|
|
|
public showActive: any[] = [];
|
|
|
|
|
public managers: any[];
|
|
|
|
|
public pending: any[];
|
|
|
|
|
public showPending: any[] = [];
|
|
|
|
|
public showCurrent: boolean = true;
|
|
|
|
@ -114,24 +113,11 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
updateLists() {
|
|
|
|
|
this.loadActive = true;
|
|
|
|
|
this.loadPending = true;
|
|
|
|
|
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, this.role).subscribe(users => {
|
|
|
|
|
if (this.role === 'member') {
|
|
|
|
|
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager').subscribe(managers => {
|
|
|
|
|
this.managers = managers;
|
|
|
|
|
this.active = users;
|
|
|
|
|
this.active.forEach(user => {
|
|
|
|
|
user['isManager'] = this.managers.find(manager => manager.email === user.email);
|
|
|
|
|
});
|
|
|
|
|
this.filterActiveBySearch(this.filterForm.value.active);
|
|
|
|
|
this.loadActive = false;
|
|
|
|
|
this.exists = true;
|
|
|
|
|
}))
|
|
|
|
|
} else {
|
|
|
|
|
this.active = users;
|
|
|
|
|
this.filterActiveBySearch(this.filterForm.value.active);
|
|
|
|
|
this.loadActive = false;
|
|
|
|
|
this.exists = true;
|
|
|
|
|
}
|
|
|
|
|
this.subs.push(this.userRegistryService.getActive(this.type, this.id, this.role).subscribe(users => {
|
|
|
|
|
this.active = users;
|
|
|
|
|
this.filterActiveBySearch(this.filterForm.value.active);
|
|
|
|
|
this.loadActive = false;
|
|
|
|
|
this.exists = true;
|
|
|
|
|
}, error => {
|
|
|
|
|
this.active = [];
|
|
|
|
|
this.showActive = [];
|
|
|
|
@ -191,11 +177,12 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
this.createRoleModal.okButtonLeft = false;
|
|
|
|
|
this.createRoleModal.okButtonText = 'Create';
|
|
|
|
|
this.roleFb = this.fb.group({
|
|
|
|
|
name: this.fb.control(Role.mapType(this.type, (this.role === 'manager')) + '.' + this.id, Validators.required),
|
|
|
|
|
description: this.fb.control('', Validators.required)
|
|
|
|
|
name: this.fb.control(Role.mapType(this.type) + '.' + this.id, Validators.required),
|
|
|
|
|
description: this.fb.control(Role.mapType(this.type) + ' ' + this.id, Validators.required)
|
|
|
|
|
});
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.roleFb.get('name').disable();
|
|
|
|
|
this.roleFb.get('description').disable();
|
|
|
|
|
}, 0);
|
|
|
|
|
this.createRoleModal.open();
|
|
|
|
|
}
|
|
|
|
@ -204,7 +191,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
this.loadActive = true;
|
|
|
|
|
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);
|
|
|
|
|
if(this.currentActivePage.length === 0) {
|
|
|
|
|
if (this.currentActivePage.length === 0) {
|
|
|
|
|
this.activePage = 1;
|
|
|
|
|
}
|
|
|
|
|
this.filterActiveBySearch(this.filterForm.value.active);
|
|
|
|
@ -230,7 +217,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
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.filterPendingBySearch(this.filterForm.value.pending);
|
|
|
|
|
if(this.currentPendingPage.length === 0) {
|
|
|
|
|
if (this.currentPendingPage.length === 0) {
|
|
|
|
|
this.pendingPage = 1;
|
|
|
|
|
}
|
|
|
|
|
UIkit.notification(StringUtils.capitalize(this.role) + ' invitation to ' + this.selectedUser + ' has been <b>canceled</b>', {
|
|
|
|
@ -260,7 +247,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
this.subs.push(this.userRegistryService.invite(this.type, this.id, details, this.role).subscribe(invitation => {
|
|
|
|
|
if (!this.pending.includes(this.invited.value)) {
|
|
|
|
|
this.pending.push(this.invited.value);
|
|
|
|
|
this.pendingPage = Math.ceil(this.pending.length/this.pageSize);
|
|
|
|
|
this.pendingPage = Math.ceil(this.pending.length / this.pageSize);
|
|
|
|
|
this.filterPendingBySearch(this.filterForm.value.pending);
|
|
|
|
|
}
|
|
|
|
|
if (this.notificationFn) {
|
|
|
|
@ -298,7 +285,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|
|
|
|
this.loadActive = true;
|
|
|
|
|
this.loadPending = true;
|
|
|
|
|
this.roleFb.get('name').enable();
|
|
|
|
|
this.userRegistryService.createRole(this.type, this.id, this.roleFb.value).subscribe(() => {
|
|
|
|
|
this.userRegistryService.createRole(this.type, this.id).subscribe(() => {
|
|
|
|
|
UIkit.notification('Group has been <b> successfully created</b>', {
|
|
|
|
|
status: 'success',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|