[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,25 +69,17 @@ export class RoleUsersComponent implements OnInit, OnDestroy, OnChanges {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.filterForm = this.fb.group({
|
||||
active: this.fb.control(''),
|
||||
pending: this.fb.control('')
|
||||
this.initForm();
|
||||
this.updateLists();
|
||||
this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
});
|
||||
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.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
});
|
||||
}
|
||||
|
||||
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',
|
||||
|
|
Loading…
Reference in New Issue