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-1-4"> Sort by:</span>
7
      <mat-select *ngIf="(entityType != 'community' && entityType != 'funder' )" 
8
              class="uk-select uk-width-auto uk-text-bold matSelection" 
9
              id="form-horizontal-select" name="select_results_per_page"
10
              [disableOptionCentering]="true"
11
              panelClass="matSelectionPanel"
12
              [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()">
13
              <mat-option value="">Relevance</mat-option>
14
              <mat-option value="resultdateofacceptance,descending">Date (most recent)</mat-option>
15
              <mat-option value="resultdateofacceptance,ascending">Date (least recent)</mat-option>
16
      </mat-select>
17
      <mat-select *ngIf="(entityType == 'community' || entityType == 'funder')" 
18
              class="uk-select uk-width-auto uk-text-bold matSelection" 
19
              id="form-horizontal-select" name="select_results_per_page"
20
              [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
21
              [disableOptionCentering]="true"
22
              panelClass="matSelectionPanel">
23
              <mat-option value="">Title</mat-option>
24
              <mat-option value="creationdate,descending">Creation Date (most recent)</mat-option>
25
              <mat-option value="creationdate,ascending">Creation Date (least recent)</mat-option>
26
      </mat-select>
27
    `
28
})
29

    
30
export class SearchSortingComponent {
31

    
32
    @Input() sortBy: string = '';
33
    @Input() entityType: string = '';
34
    @Output() sortByChange  = new EventEmitter();
35

    
36

    
37
    constructor () {}
38

    
39
    ngOnInit() {}
40

    
41

    
42
    sortByChanged() {
43
      this.sortByChange.emit({
44
          value: this.sortBy
45
      });
46
    }
47
}
(48-48/54)