1
|
import {Component, Input} from '@angular/core';
|
2
|
import {EnvProperties} from "../../properties/env-properties";
|
3
|
import {ErrorCodes} from "../../properties/errorCodes";
|
4
|
|
5
|
@Component({
|
6
|
selector: 'search-tab',
|
7
|
template: `
|
8
|
<errorMessages [status]="[fetch.searchUtils.status]" [type]="getEntityName(resultType, true, true)"
|
9
|
tab_error_class=true></errorMessages>
|
10
|
|
11
|
<div *ngIf="fetch.searchUtils.status == errorCodes.DONE">
|
12
|
<div class="tab-header">
|
13
|
<span *ngIf="resultType != 'organization' && resultType != 'dataprovider' && resultType != 'project'">Recent</span>
|
14
|
{{getEntityName(resultType, true, true)}}
|
15
|
</div>
|
16
|
<div class="uk-text-right">
|
17
|
<!-- {{getEntityName(resultType, true, true)}}-->
|
18
|
<a class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">
|
19
|
View all
|
20
|
<span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>
|
21
|
</a>
|
22
|
</div>
|
23
|
|
24
|
<search-result [properties]="properties"
|
25
|
[results]="fetch.results"
|
26
|
[status]="fetch.searchUtils.status"
|
27
|
[type]="resultType" [showImpactFactors]="showImpactFactors" >
|
28
|
</search-result>
|
29
|
|
30
|
<div class="uk-text-right">
|
31
|
<!-- {{getEntityName(resultType, true, true)}}-->
|
32
|
<a class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">
|
33
|
View all
|
34
|
<span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>
|
35
|
</a>
|
36
|
</div>
|
37
|
</div>
|
38
|
`
|
39
|
})
|
40
|
|
41
|
export class SearchTabComponent {
|
42
|
@Input() public fetch;
|
43
|
@Input() public resultType: string;
|
44
|
@Input() public params: any;
|
45
|
@Input() public searchNumber: number = 5;
|
46
|
@Input() public searchLinkToAdvancedPage: string;
|
47
|
@Input() properties: EnvProperties;
|
48
|
@Input() showImpactFactors;
|
49
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
50
|
|
51
|
public getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
52
|
if (entityType == "publication") {
|
53
|
return "publication" + (plural ? "s" : "");
|
54
|
} else if (entityType == "dataset") {
|
55
|
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
56
|
} else if (entityType == "software") {
|
57
|
return "software";
|
58
|
} else if (entityType == "other") {
|
59
|
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
60
|
} else if (entityType == "result") {
|
61
|
return ((full ? "research outcome" : "result") + (plural ? "s" : ""));
|
62
|
} else if (entityType == "project") {
|
63
|
return "project" + (plural ? "s" : "");
|
64
|
} else if (entityType == "dataprovider") {
|
65
|
return ((full ? "content provider" : "dataprovider") + (plural ? "s" : ""));
|
66
|
}
|
67
|
}
|
68
|
}
|