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

50 lines
2.0 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 != 'stakeholder' )"
[(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
[disableOptionCentering]="true"
panelClass="matSelectionPanel"
class="uk-text-bold matSelection">
<mat-option value="" [disabled]="isDisabled">Relevance</mat-option>
<mat-option value="resultdateofacceptance,descending" [disabled]="isDisabled">Date (most recent)</mat-option>
<mat-option value="resultdateofacceptance,ascending" [disabled]="isDisabled">Date (least recent)</mat-option>
</mat-select>
<mat-select *ngIf="(entityType == 'community' || entityType == 'stakeholder')"
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="" [disabled]="isDisabled">Title</mat-option>
<mat-option value="creationdate,descending" [disabled]="isDisabled">Creation Date (most recent)</mat-option>
<mat-option value="creationdate,ascending" [disabled]="isDisabled">Creation Date (least recent)</mat-option>
</mat-select>
</mat-form-field>
</div>
`
})
export class SearchSortingComponent {
@Input() isDisabled: boolean = false;
@Input() sortBy: string = '';
@Input() entityType: string = '';
@Output() sortByChange = new EventEmitter();
constructor () {}
ngOnInit() {}
sortByChanged() {
this.sortByChange.emit(this.sortBy);
}
}