1 |
50169
|
argiro.kok
|
import {Component, Input} from '@angular/core';
|
2 |
|
|
import {ActivatedRoute} from '@angular/router';
|
3 |
|
|
|
4 |
|
|
import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
5 |
|
|
import { SearchProjectsService } from '../../services/searchProjects.service';
|
6 |
|
|
|
7 |
50761
|
argiro.kok
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
8 |
50169
|
argiro.kok
|
import {StringUtils} from '../../utils/string-utils.class';
|
9 |
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
10 |
50586
|
argiro.kok
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
11 |
50169
|
argiro.kok
|
|
12 |
|
|
@Component({
|
13 |
|
|
selector: 'searchingProjectsTab',
|
14 |
|
|
template: `
|
15 |
52401
|
konstantin
|
<errorMessages [status]="[fetchProjects.searchUtils.status]" [type]="'projects'" tab_error_class=true></errorMessages>
|
16 |
50169
|
argiro.kok
|
|
17 |
52424
|
konstantin
|
<div *ngIf="fetchProjects.searchUtils.status == errorCodes.DONE">
|
18 |
50169
|
argiro.kok
|
<div class = "uk-text-right" *ngIf = "fetchProjects.searchUtils.totalResultsNoFilters > 10">
|
19 |
52676
|
argiro.kok
|
<a [queryParams]="routerHelper.createQueryParams(['organization', 'og'], [organizationId, 'and'])"
|
20 |
50169
|
argiro.kok
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchProjects" class="uk-button uk-button-text">
|
21 |
52096
|
konstantin
|
View all {{fetchProjects.searchUtils.totalResultsNoFilters | number}} results
|
22 |
50169
|
argiro.kok
|
</a>
|
23 |
|
|
</div>
|
24 |
|
|
<div class= "searchPaging uk-panel uk-margin-top">
|
25 |
|
|
<div class="uk-clearfix">
|
26 |
|
|
<div class="uk-float-right" *ngIf="fetchProjects.results && fetchProjects.searchUtils.totalResults > fetchProjects.searchUtils.size">
|
27 |
|
|
<paging-no-load [currentPage]="page" [totalResults]="fetchProjects.searchUtils.totalResults" [term]="keyword" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
|
28 |
|
|
</div>
|
29 |
|
|
</div>
|
30 |
|
|
<ul *ngIf = "fetchProjects.funders.length > 1" class="uk-list uk-list-divider uk-margin-remove">
|
31 |
|
|
<li *ngFor="let filter of fetchProjects.filters " >
|
32 |
|
|
<!--div class="text-bold">Filter by {{filter.title}}:</div-->
|
33 |
|
|
<span *ngFor = "let value of filter.values" class = "uk-animation-fade">
|
34 |
|
|
<input [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
|
35 |
52096
|
konstantin
|
<span title = "{{value.name}}"> {{value.name}}</span><span *ngIf = "showResultCount === true" > ({{value.number | number}})</span>
|
36 |
50169
|
argiro.kok
|
</span>
|
37 |
|
|
</li>
|
38 |
|
|
|
39 |
52096
|
konstantin
|
<li *ngIf = "fetchProjects.searchUtils.totalResults !=fetchProjects.searchUtils.totalResultsNoFilters "> Filtered {{fetchProjects.searchUtils.totalResults | number}} results of {{fetchProjects.searchUtils.totalResultsNoFilters | number}} total results</li>
|
40 |
50169
|
argiro.kok
|
<li></li>
|
41 |
|
|
</ul>
|
42 |
|
|
|
43 |
|
|
<tab-result [(results)]="fetchProjects.results" [(status)]= "fetchProjects.searchUtils.status"
|
44 |
|
|
type="project" urlParam="projectId" [showLoading] = true [showOrganizations] = false>
|
45 |
|
|
</tab-result>
|
46 |
|
|
</div>
|
47 |
|
|
</div>
|
48 |
|
|
`
|
49 |
|
|
})
|
50 |
|
|
|
51 |
|
|
export class SearchingProjectsTabComponent {
|
52 |
|
|
@Input() fetchProjects : FetchProjects;
|
53 |
|
|
@Input() organizationId:string = "";
|
54 |
50586
|
argiro.kok
|
@Input() properties:EnvProperties;
|
55 |
50169
|
argiro.kok
|
public page :number = 1;
|
56 |
|
|
public size :number = 10;
|
57 |
|
|
public linkToSearchProjects: string;
|
58 |
|
|
|
59 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
60 |
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
61 |
|
|
|
62 |
|
|
private filterQuery:string = "";
|
63 |
|
|
|
64 |
|
|
constructor (private route: ActivatedRoute,
|
65 |
|
|
private _searchProjectsService: SearchProjectsService) {
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
ngOnInit() {
|
70 |
|
|
|
71 |
|
|
if(this.organizationId) {
|
72 |
55570
|
argiro.kok
|
this.linkToSearchProjects = this.properties.searchLinkToAdvancedProjects;//+"?organization="+this.organizationId+"or=and";;
|
73 |
50169
|
argiro.kok
|
if(this.fetchProjects.searchUtils.totalResults > 0) {
|
74 |
|
|
this.search(false,"");
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
private search(refine:boolean, filterQuery:string){
|
81 |
|
|
var refineFields:string [] = ["funder"];
|
82 |
50586
|
argiro.kok
|
this.fetchProjects.getResultsForOrganizations(this.organizationId, filterQuery, this.page, this.size,(refine)?refineFields:[], this.properties);
|
83 |
50169
|
argiro.kok
|
}
|
84 |
|
|
|
85 |
|
|
public pageChange($event) {
|
86 |
|
|
this.page=$event.value;
|
87 |
|
|
this.search(false, this.filterQuery);
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
public filterChange($event) {
|
91 |
|
|
this.updateFilters();
|
92 |
|
|
//this.search(true, this.filterQuery);
|
93 |
|
|
this.search(false, this.filterQuery);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
private updateFilters (){
|
97 |
|
|
this.filterQuery = "";
|
98 |
|
|
for (let filter of this.fetchProjects.filters){
|
99 |
|
|
var filterLimits="";
|
100 |
|
|
for (let value of filter.values){
|
101 |
|
|
if(value.selected == true){
|
102 |
|
|
//filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"';
|
103 |
|
|
filterLimits+=((filterLimits.length == 0)?'':' or ')+filter.filterId+' exact ';
|
104 |
|
|
filterLimits+='"'+ StringUtils.URIEncode(value.id)+'"';
|
105 |
|
|
}
|
106 |
|
|
}
|
107 |
|
|
if(filterLimits.length > 0){
|
108 |
|
|
//this.filterQuery+=' and '+filter.filterId + ' exact '+ filterLimits + ' ';
|
109 |
|
|
this.filterQuery+=' and ( ' + filterLimits + ' ) ';
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
}
|
113 |
54775
|
konstantin
|
//console.log("Filter Changed"+this.filterQuery);
|
114 |
50169
|
argiro.kok
|
|
115 |
|
|
}
|
116 |
|
|
}
|