[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:
parent
b9d46c5bd9
commit
1f643b347c
|
@ -69,16 +69,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.filterForm = this.fb.group({
|
this.initForm();
|
||||||
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.updateLists();
|
this.updateLists();
|
||||||
this.userManagementService.getUserInfo().subscribe(user => {
|
this.userManagementService.getUserInfo().subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
@ -86,8 +77,9 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if(changes.role) {
|
if (changes.role) {
|
||||||
this.unsubscribe();
|
this.unsubscribe();
|
||||||
|
this.initForm();
|
||||||
this.updateLists();
|
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() {
|
updateLists() {
|
||||||
this.loadActive = true;
|
this.loadActive = true;
|
||||||
this.loadPending = true;
|
this.loadPending = true;
|
||||||
this.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, this.role).subscribe(users => {
|
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.subs.push(this.userRegistryService.getActiveEmail(this.type, this.id, 'manager').subscribe(managers => {
|
||||||
this.managers = managers;
|
this.managers = managers;
|
||||||
this.active = users;
|
this.active = users;
|
||||||
|
@ -127,7 +132,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
this.active = [];
|
this.active = [];
|
||||||
if(error.status === 404) {
|
if (error.status === 404) {
|
||||||
this.exists = false;
|
this.exists = false;
|
||||||
}
|
}
|
||||||
this.loadActive = false;
|
this.loadActive = false;
|
||||||
|
@ -232,7 +237,7 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
this.pending.push(this.invited.value);
|
this.pending.push(this.invited.value);
|
||||||
this.filterPendingBySearch(this.filterForm.value.pending);
|
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 => {
|
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', {
|
UIkit.notification('A notification has been <b>sent</b> successfully', {
|
||||||
status: 'success',
|
status: 'success',
|
||||||
|
|
Loading…
Reference in New Issue