[Library | Trunk]: Roles users fix filter form on role change

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60734 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-03-28 11:15:33 +00:00
parent b9d46c5bd9
commit 1f643b347c
1 changed files with 22 additions and 17 deletions

View File

@ -69,16 +69,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
}
ngOnInit() {
this.filterForm = this.fb.group({
active: this.fb.control(''),
pending: this.fb.control('')
});
this.subs.push(this.filterForm.get('active').valueChanges.subscribe(value => {
this.filterActiveBySearch(value);
}));
this.subs.push(this.filterForm.get('pending').valueChanges.subscribe(value => {
this.filterPendingBySearch(value);
}));
this.initForm();
this.updateLists();
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
@ -86,8 +77,9 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
}
ngOnChanges(changes: SimpleChanges) {
if(changes.role) {
if (changes.role) {
this.unsubscribe();
this.initForm();
this.updateLists();
}
}
@ -104,11 +96,24 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
});
}
initForm() {
this.filterForm = this.fb.group({
active: this.fb.control(''),
pending: this.fb.control('')
});
this.subs.push(this.filterForm.get('active').valueChanges.subscribe(value => {
this.filterActiveBySearch(value);
}));
this.subs.push(this.filterForm.get('pending').valueChanges.subscribe(value => {
this.filterPendingBySearch(value);
}));
}
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') {
if (this.role === 'member') {
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager').subscribe(managers => {
this.managers = managers;
this.active = users;
@ -127,7 +132,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
}
}, error => {
this.active = [];
if(error.status === 404) {
if (error.status === 404) {
this.exists = false;
}
this.loadActive = false;
@ -232,7 +237,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
this.pending.push(this.invited.value);
this.filterPendingBySearch(this.filterForm.value.pending);
}
if(this.notificationFn) {
if (this.notificationFn) {
this.subs.push(this.notificationService.sendNotification(this.notificationFn(this.name, this.invited.value, this.role, invitation)).subscribe(notification => {
UIkit.notification('A notification has been <b>sent</b> successfully', {
status: 'success',