Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {SearchResult}     from '../../utils/entities/searchResult';
3
import {ErrorCodes} from '../../utils/properties/errorCodes';
4
import {RouterHelper} from '../../utils/routerHelper.class';
5
import{EnvProperties} from '../../utils/properties/env-properties';
6
@Component({
7
    selector: 'search-result',
8
    templateUrl:'searchResult.component.html'
9
})
10

    
11
export class SearchResultComponent {
12
    @Input() results: SearchResult[];
13
    @Input() status: number;
14
    @Input() type: string;
15
    @Input() showLoading: boolean = false;
16
    @Input() showSubjects: boolean = false;
17
    @Input() showOrganizations: boolean = true;
18
    @Input() custom_class: string = "search-results";
19
    @Input() properties:EnvProperties;
20

    
21

    
22
    public urlParam: string;
23
    public linkToAdvancedSearchPage: string;
24
    public errorCodes:ErrorCodes = new ErrorCodes();
25
    public routerHelper:RouterHelper = new RouterHelper();
26
    public errorMessage: string = "No results found";
27
    constructor () {}
28

    
29
    ngOnInit() {
30

    
31
          if(this.type == "publication") {
32
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
33
            this.urlParam = "articleId";
34
          } else if(this.type == "dataset") {
35
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
36
            this.urlParam = "datasetId";
37
          } else if(this.type == "software") {
38
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
39
            this.urlParam = "softwareId";
40
          } else if(this.type == "other") {
41
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps;
42
            this.urlParam = "orpId";
43
          } else if(this.type == "project") {
44
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
45
            this.urlParam = "projectId";
46
          } else if(this.type == "organization") {
47
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
48
            this.urlParam = "organizationId";
49
          } else if(this.type == "dataprovider") {
50
            this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
51
            this.urlParam = "datasourceId";
52
          }
53

    
54

    
55
    }
56

    
57
    public  quote(params: string):string {
58
      return '"'+params+'"';
59
    }
60
}
(31-31/36)