2020-05-31 13:26:45 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {EnvProperties} from "../../properties/env-properties";
|
|
|
|
import {ErrorCodes} from "../../properties/errorCodes";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'search-tab',
|
|
|
|
template: `
|
2021-03-10 14:24:19 +01:00
|
|
|
<errorMessages *ngIf="resultType" [status]="[fetch.searchUtils.status]" [type]="getEntityName(resultType, true, true)"
|
2020-05-31 13:26:45 +02:00
|
|
|
tab_error_class=true></errorMessages>
|
2021-12-01 15:39:39 +01:00
|
|
|
<a *ngIf="fetch.searchUtils.status == errorCodes.LOADING" class="uk-invisible"
|
|
|
|
[queryParams]="params" [routerLink]="searchLinkToAdvancedPage"></a>
|
|
|
|
|
2020-05-31 13:26:45 +02:00
|
|
|
<div *ngIf="fetch.searchUtils.status == errorCodes.DONE">
|
|
|
|
<div class="tab-header">
|
2021-03-10 14:24:19 +01:00
|
|
|
<span *ngIf="!customTitle && resultType"><span *ngIf="resultType != 'organization' && resultType != 'dataprovider' && resultType != 'project'">Recent</span>
|
2020-05-31 13:26:45 +02:00
|
|
|
{{getEntityName(resultType, true, true)}}
|
2021-03-10 11:41:38 +01:00
|
|
|
</span>
|
|
|
|
<span *ngIf="customTitle">{{customTitle}}</span>
|
2020-05-31 13:26:45 +02:00
|
|
|
</div>
|
2021-03-10 11:41:38 +01:00
|
|
|
<div *ngIf="searchLinkToAdvancedPage" class="uk-text-right">
|
2020-05-31 13:26:45 +02:00
|
|
|
<!-- {{getEntityName(resultType, true, true)}}-->
|
|
|
|
<a class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">
|
|
|
|
View all
|
|
|
|
<span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
2021-05-19 11:36:09 +02:00
|
|
|
<ng-content></ng-content>
|
|
|
|
|
2020-05-31 13:26:45 +02:00
|
|
|
<search-result [properties]="properties"
|
|
|
|
[results]="fetch.results"
|
|
|
|
[status]="fetch.searchUtils.status"
|
2021-04-02 11:17:00 +02:00
|
|
|
[type]="resultType" [showImpactFactors]="showImpactFactors" [showEnermaps]="showEnermaps">
|
2020-05-31 13:26:45 +02:00
|
|
|
</search-result>
|
|
|
|
|
2021-03-10 11:41:38 +01:00
|
|
|
<div *ngIf="searchLinkToAdvancedPage" class="uk-text-right">
|
2020-05-31 13:26:45 +02:00
|
|
|
<!-- {{getEntityName(resultType, true, true)}}-->
|
|
|
|
<a class="el-content uk-button uk-button-text" [queryParams]="params" [routerLink]="searchLinkToAdvancedPage">
|
|
|
|
View all
|
|
|
|
<span *ngIf="fetch.searchUtils.totalResults <= searchNumber">in search page</span>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchTabComponent {
|
|
|
|
@Input() public fetch;
|
|
|
|
@Input() public resultType: string;
|
|
|
|
@Input() public params: any;
|
|
|
|
@Input() public searchNumber: number = 5;
|
|
|
|
@Input() public searchLinkToAdvancedPage: string;
|
|
|
|
@Input() properties: EnvProperties;
|
2020-06-02 10:40:56 +02:00
|
|
|
@Input() showImpactFactors;
|
2021-03-10 11:41:38 +01:00
|
|
|
@Input() customTitle;
|
2021-04-02 11:17:00 +02:00
|
|
|
@Input() showEnermaps: boolean;
|
2021-03-10 11:41:38 +01:00
|
|
|
|
2020-05-31 13:26:45 +02:00
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
public getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
|
|
|
if (entityType == "publication") {
|
|
|
|
return "publication" + (plural ? "s" : "");
|
|
|
|
} else if (entityType == "dataset") {
|
|
|
|
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
|
|
|
} else if (entityType == "software") {
|
|
|
|
return "software";
|
|
|
|
} else if (entityType == "other") {
|
|
|
|
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
|
|
|
} else if (entityType == "result") {
|
2020-06-10 13:05:59 +02:00
|
|
|
return ((full ? "research outcome" : "result") + (plural ? "s" : ""));
|
|
|
|
} else if (entityType == "project") {
|
|
|
|
return "project" + (plural ? "s" : "");
|
|
|
|
} else if (entityType == "dataprovider") {
|
|
|
|
return ((full ? "content provider" : "dataprovider") + (plural ? "s" : ""));
|
2020-05-31 13:26:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|