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

50 lines
2.0 KiB
TypeScript
Raw Normal View History

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() {
[Trunk | Library]: 1. searchUtils.class.ts: In SearchUtilsClass added field "refineStatus:number = 1;" for refine queries. 2. searchResultsPerPage.component.ts & searchSorting.component.ts: [Bug fix] In EventEmitter (value change), emit raw value, not object with field "value". 3. searchDataProviders.component.ts & searchOrganizations.component.ts & searchProjects.component.ts & searchResearchResults.component.ts: a. Add subscriptions in array to unsubscribe in ngOnDestroy. b. Get properties from environment (no service needed). c. Separate queries for refine and results. d. Do not call refine query when page, results per page, sortBy change (there is still a bug here). e. For refine query, added field "disableRefineForms" default set to false - passed in <new-search-page>. 4. newSearchPage.component.html: a. Disable forms when "disableForms" or "disableRefineForms" is true. b. Do not show filters, until results query returns, but show results while refine is loading. c. Deleted old, unused code. 5. newSearchPage.component.ts: a. Added fields "@Input() disableRefineForms: boolean = false;", "@Input() sortedByChanged: string = "";", "@Input() resultsPerPageChanged: number;" b. When results per page or sortBy change, do not upadate immediately searchUtils values - do not query for refine when these change (there is still a bug here). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59155 d315682c-612b-4755-9ff5-7f18f6832af3
2020-07-21 15:48:55 +02:00
this.sortByChange.emit(this.sortBy);
}
}