2018-11-21 16:24:14 +01:00
|
|
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'search-sorting',
|
2019-04-05 19:21:23 +02:00
|
|
|
template: `
|
2018-11-21 16:24:14 +01:00
|
|
|
<span class="uk-width-2-3@m uk-width-1-1@s uk-float-right">
|
2018-12-07 10:35:20 +01:00
|
|
|
<span class="uk-width-1-4"> Sort by:</span>
|
2019-04-05 19:21:23 +02:00
|
|
|
<select *ngIf="entityType != 'community'" class="uk-select uk-width-3-4@m uk-width-auto" id="form-horizontal-select" name="select_results_per_page"
|
2018-11-21 16:24:14 +01:00
|
|
|
[(ngModel)]="sortBy" (ngModelChange)="sortByChanged()">
|
|
|
|
<option value="">Relevance</option>
|
2018-12-07 10:35:20 +01:00
|
|
|
<option value="resultdateofacceptance,descending">Date (most recent)</option>
|
|
|
|
<option value="resultdateofacceptance,ascending">Date (least recent)</option>
|
2018-11-21 16:24:14 +01:00
|
|
|
</select>
|
2019-04-05 19:21:23 +02:00
|
|
|
<select *ngIf="entityType == 'community'" class="uk-select uk-width-3-4@m uk-width-auto" id="form-horizontal-select" name="select_results_per_page"
|
|
|
|
[(ngModel)]="sortBy" (ngModelChange)="sortByChanged()">
|
|
|
|
<option value="">Title</option>
|
|
|
|
<option value="creationdate,descending">Creation Date (most recent)</option>
|
|
|
|
<option value="creationdate,ascending">Creation Date (least recent)</option>
|
|
|
|
</select>
|
2018-11-21 16:24:14 +01:00
|
|
|
</span>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchSortingComponent {
|
2019-04-05 19:21:23 +02:00
|
|
|
|
|
|
|
@Input() sortBy: string = '';
|
|
|
|
@Input() entityType: string = '';
|
2018-11-21 16:24:14 +01:00
|
|
|
@Output() sortByChange = new EventEmitter();
|
|
|
|
|
|
|
|
|
2019-04-05 19:21:23 +02:00
|
|
|
constructor () {}
|
2018-11-21 16:24:14 +01:00
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
|
|
|
|
|
|
sortByChanged() {
|
|
|
|
this.sortByChange.emit({
|
|
|
|
value: this.sortBy
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|