[Connect]: Search Communities search if there are ri communities show type filter.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@56846 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-08-05 10:31:12 +00:00
parent fb97379ab4
commit 6e16d55032
1 changed files with 28 additions and 22 deletions

View File

@ -20,12 +20,13 @@ import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class
<search-page pageTitle="OpenAIRE-Connect | Search Communities"
[hasPrefix]=false [piwikSiteId]="piwikSiteId"
searchFormClass="communitiesSearchForm"
formPlaceholderText="Search for Research Communities and Initiatives"
[formPlaceholderText]="'Search for Research Communities' + ((showType)?' and Initiatives':'')"
type="communities" entityType="community" [filters]="filters"
[results]="results" [searchUtils]="searchUtils"
[showResultCount]=true [baseUrl]="baseUrl"
[disableForms]="disableForms"
[lastIndex]=false [sort]=true>
[lastIndex]=false [sort]=true
[showType]="showType">
</search-page>
`
})
@ -42,6 +43,7 @@ export class SearchCommunitiesComponent {
public disableForms: boolean = false;
public baseUrl: string = null;
public refineFields: string[] = this.searchFields.COMMUNITIES_SEARCH_FIELDS;
public showType = false;
properties:EnvProperties;
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
@ -75,7 +77,6 @@ export class SearchCommunitiesComponent {
}
this.searchPage.refineFields = this.refineFields;
let queryParams = this.searchPage.getQueryParamsFromUrl(params);
this.filters = this.createFilters();
this.initCommunities(queryParams);
});
@ -105,9 +106,6 @@ export class SearchCommunitiesComponent {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = false;
this.totalResults[i].isSubscribed = false;
// For Test do not delete them.
//this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation."
//this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime()));
if(Session.isLoggedIn()) {
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
}
@ -147,6 +145,9 @@ export class SearchCommunitiesComponent {
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = this.totalResults;
if(this.filters.length === 0) {
this.filters = this.createFilters();
}
this.searchUtils.totalResults = 0;
this.applyParams(params);
}
@ -432,25 +433,30 @@ export class SearchCommunitiesComponent {
*
*/
private createFilters(): Filter[] {
let filter_names=["Type"];
let filter_ids=["type"];
let filter_names = [];
let filter_ids = [];
let searchFields = new SearchFields();
let filter_original_ids = searchFields.COMMUNITIES_SEARCH_FIELDS;
let value_names = [
[ "Research Communities", "Research Initiatives" ]
];
let value_original_ids=[
["community","ri"]
];
let value_names = [];
let value_original_ids=[];
this.showType = this.results.filter(community => community.type === 'ri').length > 0;
if(this.showType) {
filter_names.push("Type");
filter_ids.push("type");
value_names.push([ "Research Communities", "Research Initiatives" ]);
value_original_ids.push(["community","ri"]);
} else {
filter_original_ids = searchFields.COMMUNITIES_SEARCH_FIELDS.splice(0, 1);
}
if(Session.isLoggedIn()) {
filter_names[1] = "Status";
filter_ids[1] = "status";
value_names[1] = [ "Subscribed", "Non-subscribed"];
value_original_ids[1] = ["subscribed", "nonsubscribed"];
filter_names[2] = "Role";
filter_ids[2] = "role";
value_names[2] = [ "Manager" ];
value_original_ids[2] = ["manager"];
filter_names.push("Status");
filter_ids.push("status");
value_names.push([ "Subscribed", "Non-subscribed"]);
value_original_ids.push(["subscribed", "nonsubscribed"]);
filter_names.push("Role");
filter_ids.push("role");
value_names.push([ "Manager"]);
value_original_ids.push(["manager"]);
}
let filters: Filter[] = [];
for(let i =0 ; i < filter_names.length; i++){