|
|
|
@ -13,6 +13,8 @@ import {Session} from "../openaireLibrary/login/utils/helper.class";
|
|
|
|
|
import {EditStakeholderComponent} from "../general/edit-stakeholder/edit-stakeholder.component";
|
|
|
|
|
import {properties} from "../../environments/environment";
|
|
|
|
|
import {ActivatedRoute} from "@angular/router";
|
|
|
|
|
import {SearchInputComponent} from "../openaireLibrary/sharedComponents/search-input/search-input.component";
|
|
|
|
|
import {SearchUtilsClass} from '../openaireLibrary/searchPages/searchUtils/searchUtils.class';
|
|
|
|
|
|
|
|
|
|
type Tab = 'all' | 'templates'| 'profiles';
|
|
|
|
|
|
|
|
|
@ -34,6 +36,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|
|
|
|
public stakeholder: Stakeholder;
|
|
|
|
|
public index: number;
|
|
|
|
|
public user = null;
|
|
|
|
|
public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass();
|
|
|
|
|
/**
|
|
|
|
|
* Filtered Stakeholders
|
|
|
|
|
*/
|
|
|
|
@ -59,6 +62,12 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|
|
|
|
@ViewChild('editStakeholderComponent', { static: true }) editStakeholderComponent: EditStakeholderComponent;
|
|
|
|
|
|
|
|
|
|
tab: Tab = 'all';
|
|
|
|
|
|
|
|
|
|
// Search
|
|
|
|
|
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
|
|
|
|
|
filterForm: FormGroup;
|
|
|
|
|
private searchText: string = '';
|
|
|
|
|
public keyword: string = '';
|
|
|
|
|
|
|
|
|
|
constructor(private stakeholderService: StakeholderService,
|
|
|
|
|
private userManagementService: UserManagementService,
|
|
|
|
@ -68,6 +77,17 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
this.communitySearchUtils.keyword = "";
|
|
|
|
|
|
|
|
|
|
this.filterForm = this.fb.group({
|
|
|
|
|
keyword: [''],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
|
|
|
|
this.searchText = value.toLowerCase();
|
|
|
|
|
this.applyFilters();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
this.subscriptions.push(this.route.fragment.subscribe((fragment: Tab) => {
|
|
|
|
|
if (this.isTab(fragment)) {
|
|
|
|
|
this.tab = fragment;
|
|
|
|
@ -280,5 +300,19 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public applyFilters() {
|
|
|
|
|
this.displayDefaultStakeholders = this.defaultStakeholders.filter(stakeholder => stakeholder.alias.toLowerCase().includes(this.searchText) || stakeholder.name.toLowerCase().includes(this.searchText) || stakeholder.description?.toLowerCase().includes(this.searchText));
|
|
|
|
|
this.displayStakeholders = this.stakeholders.filter(stakeholder => stakeholder.alias.toLowerCase().includes(this.searchText) || stakeholder.name.toLowerCase().includes(this.searchText) || stakeholder.description?.toLowerCase().includes(this.searchText));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onSearchClose() {
|
|
|
|
|
this.communitySearchUtils.keyword = this.filterForm.get('keyword').value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public resetInput() {
|
|
|
|
|
this.communitySearchUtils.keyword = null;
|
|
|
|
|
this.searchInputComponent.reset()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|