[Trunk | Library]:
1. searchProjects.component.ts: Initialize range filters only on first load (bug fix for flickering range filtes on page/query change). 2. searchResearchResults.component.ts: Initialize range filters only on first load (bug fix for flickering range filtes on page/query change) | set "loadPaging" to true when params change. 3. searchDownload.component.ts: Added input field "isDisabled" and disable button when it is true (bug fix for missing or flickering button). 4. rangeFilter.component.html: Disable inputs and buttons when "isDisabled" is true. 5. newSearchPage.component.html: Update input parameters for <search-download>. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58351 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
cad0fe9061
commit
fe4178cdca
|
@ -122,7 +122,7 @@ export class SearchProjectsComponent {
|
|||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, "project");
|
||||
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
|
||||
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad), firstLoad);
|
||||
firstLoad = false;
|
||||
});
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export class SearchProjectsComponent {
|
|||
this.sub.unsubscribe();
|
||||
}
|
||||
sub: any;
|
||||
public getResults(parameters:string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null){
|
||||
public getResults(parameters:string, page: number, size: number, refine: boolean, refineFieldsFilterQuery = null, firstLoad: boolean = true){
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
|
@ -165,7 +165,9 @@ export class SearchProjectsComponent {
|
|||
}else{
|
||||
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
||||
}
|
||||
if(firstLoad) {
|
||||
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
||||
}
|
||||
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
|
|
|
@ -109,6 +109,7 @@ export class SearchResearchResultsComponent {
|
|||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var firstLoad = true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.loadPaging = true;
|
||||
if (params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
|
@ -131,7 +132,7 @@ export class SearchResearchResultsComponent {
|
|||
}
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, this.rangeFields, this.fieldIdsMap,this.customFilter,params, this.resultType, this.quickFilter);
|
||||
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
|
||||
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRangeFields(params)+this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad), firstLoad);
|
||||
firstLoad = false;
|
||||
});
|
||||
}
|
||||
|
@ -142,7 +143,7 @@ export class SearchResearchResultsComponent {
|
|||
|
||||
sub: any;
|
||||
|
||||
public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) {
|
||||
public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null, firstLoad: boolean = true) {
|
||||
if (page > this.pagingLimit) {
|
||||
size = 0;
|
||||
}
|
||||
|
@ -170,7 +171,9 @@ export class SearchResearchResultsComponent {
|
|||
} else {
|
||||
this.searchPage.buildPageURLParameters(this.filters, this.rangeFilters, false);
|
||||
}
|
||||
if(firstLoad) {
|
||||
this.rangeFilters = this.searchPage.prepareRangeFiltersToShow();
|
||||
}
|
||||
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if (this.searchUtils.totalResults == 0) {
|
||||
|
|
|
@ -352,9 +352,9 @@
|
|||
</div>
|
||||
<!-- uk-flex uk-flex-middle-->
|
||||
<div class="uk-width-auto@m uk-margin-small-bottom">
|
||||
<search-download *ngIf= "!showUnknownFilters && searchUtils.totalResults > 0
|
||||
&& ( entityType !='community' && entityType != 'funder') && usedBy == 'search'"
|
||||
[loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils"
|
||||
<!-- !showUnknownFilters && (searchUtils.totalResults > 0 || !loadPaging)-->
|
||||
<search-download *ngIf= "( entityType !='community' && entityType != 'funder') && usedBy == 'search'"
|
||||
[isDisabled]="disableForms"
|
||||
[type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults">
|
||||
</search-download>
|
||||
|
||||
|
@ -372,7 +372,11 @@
|
|||
<search-paging [type]="type" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [(results)] = "results" [(baseUrl)] = "searchUtils.baseUrl" [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues" ></search-paging>
|
||||
</div>
|
||||
|
||||
<search-download class="uk-width-1-1@s uk-hidden@m" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" ></search-download>
|
||||
<search-download *ngIf= "( entityType !='community' && entityType != 'funder') && usedBy == 'search'"
|
||||
class="uk-width-1-1@s uk-hidden@m"
|
||||
[isDisabled]="disableForms"
|
||||
[type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults">
|
||||
</search-download>
|
||||
|
||||
<div *ngIf="(searchUtils.page <= pagingLimit)" class="uk-margin-large-bottom">
|
||||
<search-result *ngIf="usedBy == 'search'" [results]="results"
|
||||
|
|
|
@ -14,7 +14,7 @@ import 'rxjs';
|
|||
template: `
|
||||
<a [attr.uk-tooltip]="'title: Download'
|
||||
+ ((totalResults > csvLimit)?' the first 2000 ':' ')
|
||||
+ 'results'" class="uk-link-text" *ngIf="totalResults > 0">
|
||||
+ 'results'" [class]="isDisabled ? 'uk-disabled uk-link-muted' : 'uk-link-text'">
|
||||
<!-- type: {{type}}-->
|
||||
<span class="clickable" (click)="downloadfile(downloadURLAPI+'?format=csv'+csvParams,type+'-report-'+((totalResults > csvLimit)?'2000 ':totalResults))">
|
||||
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
|
||||
|
@ -34,9 +34,7 @@ import 'rxjs';
|
|||
})
|
||||
|
||||
export class SearchDownloadComponent {
|
||||
@Input() searchUtils;
|
||||
@Input() oldTotalResults:number = 0;
|
||||
@Input() loadPaging: boolean = true;
|
||||
@Input() isDisabled: boolean = false;
|
||||
@Input() totalResults:number = 0;
|
||||
@Input() csvParams: string;
|
||||
@Input() type: string;
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
<form class="uk-inline uk-text-small form-group uk-margin-remove-bottom" #rangeForm="ngForm" fromYearAfterToYear>
|
||||
<input class=" uk-input form-control uk-width-1-3" (focus)="focusedInput = 'from'" (blur)="focusedInput = ''"
|
||||
[(ngModel)]="filter.selectedFromValue" name="yearFrom" #yearFrom="ngModel" inValidYear
|
||||
placeholder="e.g. 1931"/>
|
||||
placeholder="e.g. 1931" [disabled]="isDisabled"/>
|
||||
<input class=" uk-input form-control uk-width-1-3 uk-margin-left" (focus)="focusedInput = 'to'" (blur)="focusedInput = ''"
|
||||
[(ngModel)]="filter.selectedToValue" name="yearTo" #yearTo="ngModel" inValidYear
|
||||
placeholder="e.g. 2020"/>
|
||||
placeholder="e.g. 2020" [disabled]="isDisabled"/>
|
||||
<button type="submit" (click)="yearChanged()"
|
||||
[ngStyle]="{'cursor': (rangeForm.valid && (yearFrom.dirty || yearTo.dirty)) ? 'pointer' : 'default'}"
|
||||
class="uk-icon uk-icon-button uk-margin-small-left uk-text-right uk-button-default"
|
||||
[disabled]="rangeForm.invalid || (!yearFrom.dirty && !yearTo.dirty)">
|
||||
[disabled]="isDisabled || rangeForm.invalid || (!yearFrom.dirty && !yearTo.dirty)">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
|
||||
icon="chevron-right" ratio="1">
|
||||
<polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline>
|
||||
|
@ -43,16 +43,15 @@
|
|||
<!-- padding: 0 25px;-->
|
||||
<button [class]="'uk-button uk-button-default uk-button-small uk-text-small'
|
||||
+ ((stringToNum(filter.selectedFromValue) == currentYear && stringToNum(filter.selectedToValue) == currentYear) ? ' uk-text-bold' : '')"
|
||||
(click)="yearChanged(0)">This year
|
||||
(click)="yearChanged(0)" [disabled]="isDisabled">This year
|
||||
</button>
|
||||
<button [class]="'uk-button uk-button-default uk-button-small uk-text-small'
|
||||
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-4) ? ' uk-text-bold' : '')"
|
||||
(click)="yearChanged(4)">Last 5 years
|
||||
(click)="yearChanged(4)" [disabled]="isDisabled">Last 5 years
|
||||
</button>
|
||||
<button [class]="'uk-button uk-button-default uk-button-small uk-text-small'
|
||||
+ ((stringToNum(filter.selectedToValue) == currentYear && stringToNum(filter.selectedFromValue) == currentYear-9) ? ' uk-text-bold' : '')"
|
||||
|
||||
(click)="yearChanged(9)">Last 10 years
|
||||
(click)="yearChanged(9)" [disabled]="isDisabled">Last 10 years
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue