Project

General

Profile

1
import {Component, Input, Output, EventEmitter} from '@angular/core';
2

    
3
@Component({
4
    selector: 'search-sorting',
5
    template: `        
6
      <span class="uk-width-2-3@m uk-width-1-1@s uk-float-right">
7
        <span class="uk-width-1-4"> Sort by:</span>
8
        <select *ngIf="entityType != 'community'" class="uk-select uk-width-3-4@m uk-width-auto" id="form-horizontal-select" name="select_results_per_page"
9
                [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()">
10
                <option value="">Relevance</option>
11
                <option value="resultdateofacceptance,descending">Date (most recent)</option>
12
                <option value="resultdateofacceptance,ascending">Date (least recent)</option>
13
        </select>
14
        <select *ngIf="entityType == 'community'" class="uk-select uk-width-3-4@m uk-width-auto" id="form-horizontal-select" name="select_results_per_page"
15
                  [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()">
16
                <option value="">Title</option>
17
                <option value="creationdate,descending">Creation Date (most recent)</option>
18
                <option value="creationdate,ascending">Creation Date (least recent)</option>
19
        </select>
20
      </span>
21
    `
22
})
23

    
24
export class SearchSortingComponent {
25

    
26
    @Input() sortBy: string = '';
27
    @Input() entityType: string = '';
28
    @Output() sortByChange  = new EventEmitter();
29

    
30

    
31
    constructor () {}
32

    
33
    ngOnInit() {}
34

    
35

    
36
    sortByChanged() {
37
      this.sortByChange.emit({
38
          value: this.sortBy
39
      });
40
    }
41
}
(40-40/45)