Project

General

Profile

1
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {Location} from '@angular/common';
4
import { Filter, Value} from './searchHelperClasses.class';
5
import {SearchResult}     from '../../utils/entities/searchResult';
6
import {SearchFields} from '../../utils/properties/searchFields';
7
import {SearchUtilsClass} from './searchUtils.class';
8
import {DOI, StringUtils} from '../../utils/string-utils.class';
9
import {ModalLoading} from '../../utils/modal/loading.component';
10
import { Meta} from '../../../angular2-meta';
11
import{SearchFilterComponent} from './searchFilter.component';
12
import {SearchFilterModalComponent} from './searchFilterModal.component';
13
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
14

    
15

    
16
@Component({
17
    selector: 'search-page',
18
    template: `
19

    
20
    <div class="uk-margin-top">
21
      <div class="page-header">
22
          <h1>{{pageTitle}}</h1>
23
      </div>
24
      <div>
25
        <div *ngIf="showRefine"  >
26
          <div  class="uk-width-1-1  uk-margin uk-padding uk-panel  uk-background-muted">
27
              <search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)"></search-form>
28
              <div *ngIf="isFiltered()" class = " uk-text-center ">
29
                <span *ngIf = "searchUtils.keyword.length > 0">Keywords: <span>{{searchUtils.keyword}}<a (click) = "clearKeywords() " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable " aria-hidden="true"><span uk-icon="icon: close"></span></span></a></span>
30
                </span>
31
                <span *ngFor="let filter of filters " >
32
                  <span *ngIf = "filter.countSelectedValues > 0"> {{filter.title}}:
33
                    <span *ngFor="let value of getSelectedValues(filter); let i = index;  let end = last; " >{{value.name}}<a (click) = "removeFilter(value, filter) " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable" aria-hidden="true"><span uk-icon="icon: close"></span></span></a>
34
                     <span *ngIf="!end">, </span>
35
                    </span>
36
                  </span>
37
                </span>
38
                <!--span>
39
                 Clear All
40
                <a  (click)="clearFilters()"  class="uk-icon-button uk-text-right"><span uk-icon="icon: close"></span></a></span-->
41
                <a (click)="clearFilters()" [class]="(disableForms)?'uk-disabled uk-link-muted':''">
42
                 Clear All
43
                </a>
44
              </div>
45
              <a *ngIf = "advancedSearchLink && advancedSearchLink.length > 0" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-float-right uk-disabled uk-link-muted':'uk-float-right'" [routerLink]=advancedSearchLink >More search options <span uk-icon="icon: chevron-right"></span></a>
46
          </div>
47
          <div  class="uk-grid uk-width-1-1 uk-margin">
48
            <div class=" search-filters uk-width-1-4@l  uk-width-1-4@m  uk-width-1-1@s ">
49
               <search-filter  *ngFor="let filter of filters " [isDisabled]="disableForms" [filter]="filter"  [showResultCount]=showResultCount (change)="filterChanged($event)" (toggleModal)="toggleModal($event)"></search-filter>
50
            </div>
51

    
52
            <div class="uk-width-3-4@m  uk-width-3-4@l  uk-width-1-1@s uk-first-column" >
53
              <search-paging [type]="type" [(searchUtils)] = "searchUtils"  [(results)] = "results"  [(baseUrl)] = "baseUrl" [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues" ></search-paging>
54
              <search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" (downloadClick)="downloadClicked($event)"></search-download>
55
              <!--p class="uk-text-right" *ngIf="totalResults <= 10000">
56
                  <span class="clickable" (click)="downloadfile(downloadURLAPI+type+'?format=csv&page=0&size='+totalResults+csvParams,type+'-report-'+totalResults)">
57
                      <span aria-hidden="true" class="glyphicon glyphicon-download"></span>
58
                      <span uk-icon="icon: download"></span> Results (CSV)
59
                  </span>
60
              </p-->
61
              <p *ngIf="tableViewLink" class="uk-text-right">
62
                <a target="_blank" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-disabled uk-link-muted':''" [routerLink]=tableViewLink >Show results in table view</a>
63
              </p>
64

    
65
              <search-result    *ngIf="!tableView"
66
                                [results]="results"
67
                                [status]=searchUtils.status
68
                                [type]="entityType" [urlParam]="urlParam"
69
                                [showLoading]="true">
70
              </search-result>
71
              <!--table-view   *ngIf="tableView"
72
                            [results]="results"
73
                            [status]=searchUtils.status
74
                            [type]="entityType" [urlParam]="urlParam"
75
                            [showLoading]="true">
76
              </table-view-->
77
            </div>
78

    
79

    
80
          </div>
81
        </div>
82

    
83

    
84
        <div *ngIf="!showRefine" >
85
            <search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)"></search-form>
86
            <search-paging [type]="type" [(searchUtils)] = "searchUtils"  [(results)] = "results"   [(baseUrl)] = "baseUrl"  [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues"></search-paging>
87
            <search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" (downloadClick)="downloadClicked($event)"></search-download>
88
            <search-result  *ngIf="!tableView"
89
                            [results]="results"
90
                            [status]=searchUtils.status
91
                            [type]="entityType" [urlParam]="urlParam"
92
                            [showLoading]="true">
93
            </search-result>
94
            <!--table-view   *ngIf="tableView"
95
                          [results]="results"
96
                          [status]=searchUtils.status
97
                          [type]="entityType" [urlParam]="urlParam"
98
                          [showLoading]="true">
99
            </table-view-->
100
        </div>
101
      </div>
102
    </div>
103

    
104
    <!--modal-loading [message]= "'Loading results...'"></modal-loading-->
105

    
106
    <modal-search-filter [filter]="currentFilter" [showResultCount]=showResultCount (modalChange)="filterChanged($event)"></modal-search-filter>
107

    
108
    `
109
})
110
export class SearchPageComponent {
111
  @Input() pageTitle = "";
112
  @Input() results = [];
113
  @Input() filters = [];
114
  @Input() type:string = "";
115
  @Input() entityType: string = "";
116
  @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass();
117
  @Output() queryChange  = new EventEmitter();
118
  @Output() downloadClick = new EventEmitter();
119
  @Input() baseUrl:string = '';
120
  @Input() showResultCount:boolean = true;
121
  @Input() showRefine:boolean = true;
122
  @Input() refineFields = [];
123
  @Input() csvParams: string;
124
  @Input() csvPath: string;
125
  @Input() advancedSearchLink: string = "";
126
  @Input() tableViewLink: string;
127
  @Input() disableForms: boolean = false;
128
  @Input() tableView: boolean = false;
129

    
130
  @ViewChild (ModalLoading) loading : ModalLoading ;
131
  public fieldIdsMap;//:  { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string  }};
132
  private searchFieldsHelper:SearchFields = new SearchFields();
133
  private queryParameters: Map<string, string>  = new Map<string,string>();
134
  private baseURLWithParameters:string = '';
135
  private sub: any;
136
  public countFilters= 0;
137
  public urlParam: string;
138
  public parameterNames:string[] =[];
139
  public parameterValues:string[] =[];
140

    
141
  @ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ;
142
  public currentFilter: Filter;
143

    
144
  constructor (private location: Location , private _meta: Meta) {
145
   }
146

    
147
  ngOnInit() {
148
        this.updateBaseUrlWithParameters(this.filters);
149
        this.defineUrlParam();
150
        this.updateTitle(this.pageTitle);
151
        this.updateDescription("Openaire, search, repositories, open access, type, data provider, funder, project, " + this.type + "," +this.pageTitle);
152
        this.updateUrl(OpenaireProperties.getBaseLink()+location.pathname);
153
        // console.info(this.entityType + "   " + this.urlParam + this.type);
154
  }
155
  ngAfterViewChecked(){
156

    
157
  }
158

    
159
  toggleModal($event) {
160
    this.currentFilter = $event.value;
161
    this.searchFilterModal.open();
162
  }
163

    
164
  updateDescription(description:string){
165
    this._meta.updateMeta("description", description);
166
    this._meta.updateProperty("og:description", description);
167
  }
168
  updateTitle(title:string){
169
    var _suffix ="| OpenAIRE";
170
    var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix;
171
    this._meta.setTitle(_title );
172
    this._meta.updateProperty("og:title",_title);
173
  }
174
  updateUrl(url:string){
175
    this._meta.updateProperty("og:url", url);
176
  }
177
  private defineUrlParam() {
178
      if(this.entityType == "publication") {
179
          this.urlParam = "articleId";
180
      } else if(this.entityType == "dataset") {
181
          this.urlParam = "datasetId";
182
      } else if(this.entityType == "project") {
183
          this.urlParam = "projectId";
184
      } else if(this.entityType == "organization") {
185
          this.urlParam = "organizationId";
186
      } else if(this.entityType == "person") {
187
          this.urlParam = "personId";
188
      } else {
189
          this.urlParam = "datasourceId";
190
      }
191
  }
192

    
193
  public getQueryParametersFromUrl(params){
194
    // var parameters = "";
195
    var allFqs = "";
196

    
197
    for(var i=0; i< this.refineFields.length ; i++){
198
         var filterId =  this.refineFields[i];
199

    
200
          if(params[filterId] != undefined) {
201
            if(this.queryParameters == undefined){
202
              this.queryParameters = new Map<string,string>();
203
            }
204
             this.queryParameters[filterId]=StringUtils.URIDecode(params[filterId]);
205
             let values = (StringUtils.URIDecode(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
206
             var countvalues = 0;
207
             var fq = "";
208
             for(let value of values) {
209
               countvalues++;
210
               var paramId = this.fieldIdsMap[filterId].param;
211
              // parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or");
212
              fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " +value;// StringUtils.quote(value) ;
213
             }
214
             if(countvalues > 0){
215
               fq="&fq="+fq;
216
             }
217
             allFqs += fq;
218
          }
219

    
220

    
221
   }
222
   var keyword = params['keyword'];
223
   var doiQuery = "";
224
   var keywordQuery = "";
225
   if((keyword && keyword.length > 0)){
226
      if((this.type == 'publications' ||this.type == 'datasets')){
227
        var DOIs:string[] = DOI.getDOIsFromString(keyword);
228
       var doisParams = "";
229

    
230
       for(var i =0 ;i < DOIs.length; i++){
231
         doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
232
       }
233
       if(doisParams.length > 0){
234
         doiQuery += "&"+doisParams;
235
       }else {
236
        keywordQuery += "&q="+StringUtils.URIEncode(keyword);
237
       }
238
     }else{
239
        keywordQuery += "&q="+StringUtils.URIEncode(keyword);
240

    
241
     }
242
   }
243
   return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs;
244
 }
245
 public getIndexQueryParametersFromUrl(params){
246
  //  var parameters = "";
247
   var allFqs = "";
248

    
249
   for(var i=0; i< this.refineFields.length ; i++){
250
        var filterId =  this.refineFields[i];
251
        var fq = "";
252
         if(params[filterId] != undefined) {
253
           if(this.queryParameters == undefined){
254
             this.queryParameters = new Map<string,string>();
255
           }
256
            this.queryParameters[filterId]=decodeURIComponent(params[filterId]);
257
            let values = (decodeURIComponent(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
258
            var countvalues = 0
259
            for(let value of values) {
260
              countvalues++;
261
              // parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value;
262
              fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value);
263
            }
264
            // parameters+= " ) ";
265
            if(countvalues > 0){
266
              fq="&fq="+fq;
267
            }
268
            allFqs += fq;
269
        }
270

    
271
  }
272
  var keyword = params['keyword'];
273
  var doiQuery = "";
274
  var keywordQuery = "";
275
  if((keyword && keyword.length > 0)){
276
    if((this.type == 'publications' ||this.type == 'datasets')){
277
      var DOIs:string[] = DOI.getDOIsFromString(keyword);
278
      var doisParams = "";
279

    
280
      for(var i =0 ;i < DOIs.length; i++){
281
        doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
282
      }
283
      if(doisParams.length > 0){
284
        doiQuery += "&"+doisParams;
285
      }
286
    }else{
287
       keywordQuery += "and ("+StringUtils.quote(StringUtils.URIEncode(keyword)) +")";
288

    
289
    }
290
  }
291
  return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs;
292

    
293
}
294
 /*
295
 * Mark as check the new filters that are selected, when you get them from search
296
 */
297
  public checkSelectedFilters(filters:Filter[]){
298
    this.filters = filters;
299
       for(var i=0; i< filters.length ; i++){
300
            var filter:Filter = filters[i];
301
            filter.countSelectedValues = 0;
302
              if(this.queryParameters[filter.filterId] != undefined) {
303
                let values = (decodeURIComponent(this.queryParameters[filter.filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
304
                     for(let filterValue of filter.values) {
305
                       if(values.indexOf(StringUtils.quote(filterValue.id)) > -1) {
306
                            filterValue.selected = true;
307
                            filter.countSelectedValues++;
308
                         }else{
309
                           filterValue.selected = false;
310

    
311
                         }
312
                    }
313
            }else{
314
              for(let filterValue of filter.values) {
315
                 filterValue.selected = false;
316
              }
317
            }
318
        }
319

    
320
        return filters;
321
  }
322
  /*
323
  * Update the url with proper parameters. This is used as base url in Paging Component
324
  */
325
  public updateBaseUrlWithParameters(filters:Filter[]){
326
    this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(filters,false);
327
  }
328
  /*
329
  *
330
  */
331
  private createUrlParameters(filters:Filter[], includePage:boolean){
332
    var allLimits="";//location.search.slice(1);
333
    this.parameterNames.splice(0,this.parameterNames.length);
334
    this.parameterValues.splice(0,this.parameterValues.length);
335

    
336
    for (let filter of filters){
337
      var filterLimits="";
338
      if(filter.countSelectedValues > 0){
339
        for (let value of filter.values){
340
          if(value.selected == true){
341
            filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"';
342
           }
343
        }
344
        this.queryParameters[filter.filterId]=filterLimits;
345
        if(filterLimits.length > 0){
346
          this.parameterNames.push(filter.filterId);
347
          this.parameterValues.push(filterLimits);
348
        }
349
        allLimits+=(allLimits.length==0?"?":"&")+((filterLimits.length == 0 )?'':filter.filterId + '='+ filterLimits) ;
350
      }
351
    }
352
    if(this.searchUtils.keyword.length > 0 ){
353
       allLimits+=(allLimits.length==0?"?":"&")+'keyword=' + this.searchUtils.keyword;
354
      this.parameterNames.push("keyword");
355
      this.parameterValues.push(this.searchUtils.keyword);
356
     }
357
    if(this.searchUtils.page != 1 && includePage){
358
       allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page;
359
    }
360

    
361
    return allLimits;
362
  }
363
  /*
364
  *
365
  */
366
  private createSearchQueryParameters(filters:Filter[]){
367
    var allFqs = "";
368
    for (let filter of filters){
369
      if(filter.countSelectedValues > 0){
370
        var fq = "";
371
        var count_selected=0;
372
        for (let value of filter.values){
373
          if(value.selected == true){
374
              count_selected++;
375
              fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId +  " exact " + StringUtils.quote(StringUtils.URIEncode(value.id));
376
           }
377
        }
378
        fq="&fq="+fq;
379
        allFqs += fq;
380
      }
381
    }
382
    var doiQuery = "";
383
    var keywordQuery = "";
384
    if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){
385
      if((this.type == 'publications' ||this.type == 'datasets')){
386
        var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword);
387
        var doisParams = "";
388

    
389
        for(var i =0 ;i < DOIs.length; i++){
390
          doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
391
        }
392
        if(doisParams.length > 0){
393
          doiQuery += "&"+doisParams;
394
        }else{
395
          keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword);
396
        }
397
      }else{
398
           keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword);
399
      }
400
    }
401

    
402
    return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs;
403

    
404
  }
405
  private createIndexQueryParameters(filters:Filter[]){
406
    var allFqs = "";
407
    for (let filter of filters){
408
      if(filter.countSelectedValues > 0){
409
        var count_selected=0;
410
        var fq = "";
411
        for (let value of filter.values){
412
          if(value.selected == true){
413
              count_selected++;
414
               fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id));
415
           }
416
        }
417
        if(count_selected > 0){
418
          fq="&fq="+fq;
419
          allFqs += fq;
420
        }
421
      }
422
    }
423
    var doiQuery = "";
424
    var keywordQuery = "";
425
    if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){
426
      if((this.type == 'publications' ||this.type == 'datasets')){
427
        var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword);
428
        var doisParams = "";
429
        for(var i =0 ;i < DOIs.length; i++){
430
          doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
431
        }
432
        if(doisParams.length > 0){
433
          doiQuery += "&"+doisParams;
434
        }
435
      }else{
436
         keywordQuery += " and ("+StringUtils.quote(StringUtils.URIEncode(this.searchUtils.keyword)) +")"
437

    
438
      }
439
    }
440
    return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs;
441

    
442
  }
443
  private isFiltered(){
444
    var filtered=false;
445
    for (let filter of this.filters){
446
       if(filter.countSelectedValues > 0){
447
           filtered = true;
448
           break;
449
       }
450
     }
451
    if(this.searchUtils.keyword.length > 0 ){
452
      filtered = true;
453
    }
454
    return filtered;
455
  }
456
  private clearKeywords(){
457
    if(this.searchUtils.keyword.length > 0 ){
458
      this.searchUtils.keyword ='';
459
    }
460
    this.goTo(1);
461
  }
462
  private clearFilters(){
463
    for (var i =0 ; i <  this.filters.length; i++){
464
         for (var j=0; j <  this.filters[i].countSelectedValues; j++){
465
          if(this.filters[i].values[j].selected){
466
            this.filters[i].values[j].selected = false;
467
           }
468
        this.filters[i].countSelectedValues = 0;
469
      }
470
    }
471
    this.clearKeywords();
472

    
473
  }
474
  private removeFilter(value:Value,filter:Filter){
475
    filter.countSelectedValues--;
476
    if(value.selected == true){
477
      value.selected = false;
478
     }
479
    this.goTo(1);
480

    
481
  }
482
  goTo(page:number = 1){
483
    this.searchUtils.page = page;
484
    console.info("searchUtils.page goto = "+this.searchUtils.page);
485
    this.queryParameters = new Map<string,string>();
486
    var urlParameters = this.createUrlParameters(this.filters,true);
487
    console.info("urlParams : "+urlParameters);
488
    this.updateBaseUrlWithParameters(this.filters);
489
    var queryParameters = this.createSearchQueryParameters(this.filters);
490
    console.info("queryParams : "+queryParameters);
491
    var indexQuery = this.createIndexQueryParameters(this.filters);
492

    
493
    this.location.go(location.pathname,urlParameters);
494

    
495
    this.queryChange.emit({
496
        value: queryParameters,
497
        index:indexQuery
498

    
499
    });
500

    
501
  }
502
  filterChanged($event){
503
    console.info("filter Changed");
504
       this.goTo(1);
505
  }
506
  keywordChanged($event) {
507
       this.searchUtils.keyword = $event.value;
508
       this.goTo(1);
509
  }
510

    
511
	downloadClicked($event) {
512
		if($event.value == true) {
513
		    var queryParameters = this.createSearchQueryParameters(this.filters);
514

    
515
		    this.downloadClick.emit({
516
		        value: queryParameters
517
		    });
518
		}
519
	}
520

    
521
  /*
522
  * Get A sub-array of this.refineFields array, which contains the ids of the selected filters
523
  */
524
  public getSelectedFilters():string[] {
525
    var selected:string[] = [];
526
    for(var i=0; i <  this.filters.length; i++){
527
      var filter:Filter = this.filters[i];
528
      if(filter.countSelectedValues > 0){
529
          selected.push(filter.filterId);
530
      }
531
    }
532
    return selected;
533
  }
534
  /*
535
  * Get A sub-array of this.refineFields array, which contains the ids of the selected parameters
536
  */
537
  private getSelectedParameters():string[] {
538
    var selected:string[] = [];
539
    var params:string[] = Object.keys(this.queryParameters);
540
    for(var i=0; i <  params.length; i++){
541
       if(this.refineFields.indexOf(params[i]) > -1){
542
          selected.push(params[i]);
543
      }
544
    }
545
    return selected;
546
  }
547
  /*
548
  * Get A sub-array of this.refineFields array, which hides hidden fields (e.g Funding level 0,1,2,..), and contains those that depend on another fields (e.g  Funding level 0 if Funder is selected )
549
  */
550
  public getFields():string[] {
551
    var selected_filters:string[] = this.getSelectedFilters();
552
    if(selected_filters.length == 0){
553
      selected_filters = this.getSelectedParameters();
554
    }
555
    var fields:string[] = [];
556
    for(var i =0 ; i < this.refineFields.length;i++){
557
      var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]];
558

    
559
      //if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected
560
      if(this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 || (selected_filters.indexOf(dependentTo) != -1) ){
561
          fields.push(this.refineFields[i]);
562
       }
563
    }
564
    return fields;
565
  }
566
  /*
567
  * Get a query  string of all fields, that want to get from search (e.g. &fields=funderid&fields=projectstartyear&...))
568
  */
569
  public getRefineFieldsQuery():string{
570

    
571
    var fields:string[] = this.getFields();
572
    var fieldsStr = ""
573
    for(var i =0 ; i < fields.length  ;i++){
574
        fieldsStr+="&fields="+fields[i];
575
    }
576
    return "&refine=true"+fieldsStr;
577
  }
578

    
579
  // for loading
580
  public openLoading(){
581
    if(this.loading){
582
      this.loading.open();
583
    }
584
  }
585
  public closeLoading(){
586
    if(this.loading){
587
      this.loading.close();
588
    }
589
  }
590
  getSelectedValues(filter):any{
591
    var selected = [];
592
    if(filter.countSelectedValues >0){
593
      for (var i=0; i < filter.values.length; i++){
594
        if(filter.values[i].selected){
595
          selected.push(filter.values[i]);
596
        }
597
      }
598
    }
599
    return selected;
600

    
601
  }
602
}
(18-18/28)