openaire-library/searchPages/searchUtils/searchSorting.component.ts

52 lines
1.8 KiB
TypeScript

import {Component, Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'search-sorting',
template: `
<div>
<mat-form-field class="matSelectionFormField">
<mat-label>Sort by:</mat-label>
<mat-select *ngIf="(entityType != 'community' && entityType != 'funder' )"
[(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
[disableOptionCentering]="true"
panelClass="matSelectionPanel"
class="uk-text-bold matSelection">
<mat-option value="">Relevance</mat-option>
<mat-option value="resultdateofacceptance,descending">Date (most recent)</mat-option>
<mat-option value="resultdateofacceptance,ascending">Date (least recent)</mat-option>
</mat-select>
<mat-select *ngIf="(entityType == 'community' || entityType == 'funder')"
class="uk-text-bold matSelection"
id="form-horizontal-select" name="select_results_per_page"
[(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
[disableOptionCentering]="true"
panelClass="matSelectionPanel">
<mat-option value="">Title</mat-option>
<mat-option value="creationdate,descending">Creation Date (most recent)</mat-option>
<mat-option value="creationdate,ascending">Creation Date (least recent)</mat-option>
</mat-select>
</mat-form-field>
</div>
`
})
export class SearchSortingComponent {
@Input() sortBy: string = '';
@Input() entityType: string = '';
@Output() sortByChange = new EventEmitter();
constructor () {}
ngOnInit() {}
sortByChanged() {
this.sortByChange.emit({
value: this.sortBy
});
}
}