[Trunk | Library]:

In utils/tabs add folder 'contents' and 'search-tab.component', 'search-tab.module': common view for tabs with search results.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58809 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2020-05-31 11:26:45 +00:00
parent ad44991cd1
commit 1165a93c95
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,63 @@
import {Component, Input} from '@angular/core';
import {EnvProperties} from "../../properties/env-properties";
import {ErrorCodes} from "../../properties/errorCodes";
@Component({
selector: 'search-tab',
template: `
<errorMessages [status]="[fetch.searchUtils.status]" [type]="getEntityName(resultType, true, true)"
tab_error_class=true></errorMessages>
<div *ngIf="fetch.searchUtils.status == errorCodes.DONE">
<div class="tab-header">
<span *ngIf="resultType != 'organization' && resultType != 'dataprovider' && resultType != 'project'">Recent</span>
{{getEntityName(resultType, true, true)}}
</div>
<div class="uk-text-right">
<!-- {{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>
<search-result [properties]="properties"
[results]="fetch.results"
[status]="fetch.searchUtils.status"
[type]="resultType">
</search-result>
<div class="uk-text-right">
<!-- {{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;
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") {
return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
}
}
}

View File

@ -0,0 +1,22 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {ErrorMessagesModule} from "../../errorMessages.module";
import {SearchTabComponent} from "./search-tab.component";
import {SearchResultsModule} from "../../../searchPages/searchUtils/searchResults.module";
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
ErrorMessagesModule, SearchResultsModule
],
declarations: [
SearchTabComponent
],
providers:[],
exports: [
SearchTabComponent
]
})
export class SearchTabModule { }