Revision 58567
Added by Argiro Kokogiannaki about 4 years ago
searchCommunities.component.ts | ||
---|---|---|
5 | 5 |
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; |
6 | 6 |
import {SearchPageComponent} from "../../openaireLibrary/searchPages/searchUtils/searchPage.component"; |
7 | 7 |
import {ActivatedRoute} from "@angular/router"; |
8 |
import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; |
|
8 |
import {AdvancedField, Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
|
9 | 9 |
import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields"; |
10 | 10 |
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service"; |
11 | 11 |
import {Session, User} from "../../openaireLibrary/login/utils/helper.class"; |
... | ... | |
15 | 15 |
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; |
16 | 16 |
import {UserManagementService} from "../../openaireLibrary/services/user-management.service"; |
17 | 17 |
import {Breadcrumb} from "../../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; |
18 |
import {NewSearchPageComponent} from "../../openaireLibrary/searchPages/searchUtils/newSearchPage.component"; |
|
18 | 19 |
|
19 | 20 |
@Component({ |
20 | 21 |
selector: 'search-communities', |
21 | 22 |
template: ` |
22 |
<search-page pageTitle="OpenAIRE-Connect | Search Communities" |
|
23 |
<new-search-page pageTitle="OpenAIRE-Connect | Search Communities"
|
|
23 | 24 |
[hasPrefix]=false [piwikSiteId]="piwikSiteId" |
24 | 25 |
searchFormClass="communitiesSearchForm" |
25 | 26 |
[formPlaceholderText]="'Search for Research Gateways…'" |
26 | 27 |
type="communities" entityType="community" [filters]="filters" |
27 | 28 |
[results]="results" [searchUtils]="searchUtils" |
28 |
[showResultCount]=true [baseUrl]="baseUrl"
|
|
29 |
[showResultCount]=true |
|
29 | 30 |
[disableForms]="disableForms" |
30 |
[lastIndex]=false [sort]=true |
|
31 |
[breadcrumbs]="breadcrumbs" |
|
32 |
[showType]="showType"> |
|
33 |
</search-page> |
|
31 |
[lastIndex]=false [sort]=true |
|
32 |
[simpleView]="true" |
|
33 |
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields" |
|
34 |
[simpleSearchLink]="searchLink" [entitiesSelection]="false" [showBreadcrumb]="true" |
|
35 |
> |
|
36 |
</new-search-page> |
|
37 |
<!-- [baseUrl]="baseUrl"--> |
|
38 |
<!-- [breadcrumbs]="breadcrumbs" |
|
39 |
[showType]="showType"--> |
|
34 | 40 |
` |
35 | 41 |
}) |
36 | 42 |
export class SearchCommunitiesComponent { |
... | ... | |
45 | 51 |
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); |
46 | 52 |
public disableForms: boolean = false; |
47 | 53 |
public baseUrl: string = null; |
54 |
public fieldIds: string[] = ["q"]; |
|
48 | 55 |
public refineFields: string[] = this.searchFields.COMMUNITIES_SEARCH_FIELDS; |
56 |
public fieldIdsMap = {["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", filterType: null}}; |
|
57 |
public selectedFields: AdvancedField[] = [new AdvancedField(this.fieldIds[0], "", this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type,"", "and")]; |
|
58 |
public searchLink; |
|
49 | 59 |
public showType = false; |
50 | 60 |
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'communities'}]; |
51 | 61 |
properties:EnvProperties; |
52 |
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
|
62 |
@ViewChild (NewSearchPageComponent) searchPage : NewSearchPageComponent ;
|
|
53 | 63 |
private user: User; |
54 | 64 |
|
55 | 65 |
constructor (private route: ActivatedRoute, |
... | ... | |
70 | 80 |
}); |
71 | 81 |
this.sub = this.route.queryParams.subscribe(params => { |
72 | 82 |
this.searchPage.resultsPerPage = 10; |
73 |
this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
|
83 |
this.searchUtils.keyword = (params['fv0']?params['fv0']:'');
|
|
74 | 84 |
this.searchUtils.page = (params['page'] === undefined) ? 1: + params['page']; |
75 | 85 |
this.searchUtils.sortBy = (params['sortBy'] === undefined)? '' : params['sortBy']; |
76 | 86 |
this.searchUtils.size = (params['size'] === undefined) ? this.searchPage.resultsPerPage: +params['size']; |
87 |
this.searchUtils.baseUrl = this.baseUrl; |
|
77 | 88 |
this.searchPage.searchUtils = this.searchUtils; |
78 | 89 |
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) { |
79 | 90 |
this.searchUtils.size = this.searchPage.resultsPerPage; |
... | ... | |
82 | 93 |
this.searchUtils.sortBy = ""; |
83 | 94 |
} |
84 | 95 |
this.searchPage.refineFields = this.refineFields; |
85 |
let queryParams = this.searchPage.getQueryParamsFromUrl(params); |
|
96 |
this.searchLink = this.properties.searchLinkToCommunities; |
|
97 |
this.selectedFields[0] = new AdvancedField(this.fieldIds[0], "", this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type,this.searchUtils.keyword, "and"); |
|
98 |
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields,[], this.fieldIdsMap,null,params, "community", null); |
|
99 |
|
|
100 |
let queryParams = params;//this.searchPage.getQueryParamsFromUrl(params); |
|
86 | 101 |
if(typeof document !== 'undefined') { |
87 | 102 |
this.userManagementService.getUserInfo().subscribe(user => { |
88 | 103 |
this.user = user; |
... | ... | |
108 | 123 |
* |
109 | 124 |
* @param params |
110 | 125 |
*/ |
111 |
private initCommunities(params: Map<string, string>) {
|
|
126 |
private initCommunities(params) { |
|
112 | 127 |
this.subResults = this._communitiesService.getCommunitiesState().subscribe( |
113 | 128 |
data => { |
114 | 129 |
if(!data){ |
... | ... | |
203 | 218 |
this.checkFilters(params); |
204 | 219 |
this.sort(); |
205 | 220 |
this.searchUtils.totalResults = this.results.length; |
206 |
this.searchPage.checkSelectedFilters(this.filters); |
|
207 |
this.searchPage.updateBaseUrlWithParameters(this.filters); |
|
221 |
// this.searchPage.checkSelectedFilters(this.filters); |
|
222 |
// this.searchPage.updateBaseUrlWithParameters(this.filters); |
|
223 |
// this.searchPage.buildPageURLParameters(this.filters, [], false); |
|
224 |
this.filters = this.searchPage.prepareFiltersToShow(this.filters,this.searchUtils.totalResults); |
|
225 |
|
|
208 | 226 |
this.results = this.results.slice((this.searchUtils.page-1)*this.searchUtils.size, (this.searchUtils.page*this.searchUtils.size)); |
209 | 227 |
this.searchUtils.status = this.errorCodes.DONE; |
210 | 228 |
if(this.searchUtils.totalResults == 0 ){ |
... | ... | |
286 | 304 |
* @param filterId |
287 | 305 |
* @param params |
288 | 306 |
*/ |
289 |
private applyFilter(filterId: string, params: Map<string, string>): CommunityInfo[] {
|
|
307 |
private applyFilter(filterId: string, params): CommunityInfo[] { |
|
290 | 308 |
let results:CommunityInfo[] = []; |
291 | 309 |
let values: string[] = []; |
292 |
if(params.get(filterId) != undefined) {
|
|
293 |
values = (StringUtils.URIDecode(params.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
|
|
310 |
if(params[filterId] != undefined) {
|
|
311 |
values = (StringUtils.URIDecode(params[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
|
|
294 | 312 |
} |
295 | 313 |
if(filterId == 'type') { |
296 | 314 |
for (let i = 0; i < this.results.length; i++) { |
Also available in: Unified diff
[Connect|Trunk]
Search communities: use newsearchpage component