Project

General

Profile

1 61381 k.triantaf
import {Component, Input, Output, EventEmitter} from '@angular/core';
2
3
@Component({
4
    selector: 'search-sorting',
5
    template: `
6
      <div>
7
        <mat-form-field class="matSelectionFormField">
8
          <mat-label>Sort by:</mat-label>
9
          <mat-select  *ngIf="(entityType != 'community' && entityType != 'stakeholder' )"
10
                       [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
11
                       [disableOptionCentering]="true"
12
                       panelClass="matSelectionPanel"
13
                       class="uk-text-bold matSelection">
14
            <mat-option value="" [disabled]="isDisabled">Relevance</mat-option>
15
            <mat-option value="resultdateofacceptance,descending" [disabled]="isDisabled">Date (most recent)</mat-option>
16
            <mat-option value="resultdateofacceptance,ascending" [disabled]="isDisabled">Date (least recent)</mat-option>
17
          </mat-select>
18
19
          <mat-select *ngIf="(entityType == 'community' || entityType == 'stakeholder')"
20
            class="uk-text-bold matSelection"
21
            id="form-horizontal-select" name="select_results_per_page"
22
            [(ngModel)]="sortBy" (ngModelChange)="sortByChanged()"
23
            [disableOptionCentering]="true"
24
            panelClass="matSelectionPanel">
25
            <mat-option value="" [disabled]="isDisabled">Title</mat-option>
26
            <mat-option value="creationdate,descending" [disabled]="isDisabled">Creation Date (most recent)</mat-option>
27
            <mat-option value="creationdate,ascending" [disabled]="isDisabled">Creation Date (least recent)</mat-option>
28
          </mat-select>
29
        </mat-form-field>
30
      </div>
31
    `
32
})
33
34
export class SearchSortingComponent {
35
    @Input() isDisabled: boolean = false;
36
    @Input() sortBy: string = '';
37
    @Input() entityType: string = '';
38
    @Output() sortByChange  = new EventEmitter();
39
40
41
    constructor () {}
42
43
    ngOnInit() {}
44
45
46
    sortByChanged() {
47
      this.sortByChange.emit(this.sortBy);
48
    }
49
}