[Library|Trunk]

- Filters issue with quick filter: revert to previous code, value should be url encoded
- Custom Filter: always Show the value of the custom filter
- update message for link in explore portal
- Search pages - add indexUpdateDate, update link to index info




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59971 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-11-26 14:33:37 +00:00
parent c94f78dfee
commit 8d4198caca
3 changed files with 58 additions and 25 deletions

View File

@ -1,9 +1,10 @@
<ng-template #selected_filters_pills> <ng-template #selected_filters_pills>
<div class="uk-grid uk-grid-small uk-text-small" uk-grid> <div class="uk-grid uk-grid-small uk-text-small" uk-grid>
<ng-container *ngIf="customFilterEnabled && customFilter && refineFields.indexOf(customFilter.queryFieldName) == <ng-container *ngIf="customFilter && ((customFilterEnabled &&
-1 "> refineFields.indexOf(customFilter.queryFieldName) ==
-1) ||customFilter.isHiddenFilter)">
<span class="uk-grid-margin"> <span class="uk-grid-margin">
<span class="selectedFilterLabel uk-disabled "> <span class="selectedFilterLabel customFilterLabel">
<span class="">{{customFilter.valueName}}</span> <span class="">{{customFilter.valueName}}</span>
</span> </span>
</span> </span>
@ -55,8 +56,10 @@
</ng-container> </ng-container>
<ng-container *ngFor="let filter of filters "> <ng-container *ngFor="let filter of filters ">
<ng-container *ngIf="filter.countSelectedValues > 0"> <ng-container *ngIf="filter.countSelectedValues > 0">
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " <ng-container *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; ">
[title]="'Remove '+value.name" (click)="removeFilter(value, filter) " <span *ngIf="!customFilter || (customFilter.isHiddenFilter && customFilter.valueId != value.id)"
[title]="'Remove '+value.name"
(click)="removeFilter(value, filter) "
[class]="((disableForms || disableRefineForms) ? 'uk-disabled' : 'clickable') + ' uk-grid-margin'"> [class]="((disableForms || disableRefineForms) ? 'uk-disabled' : 'clickable') + ' uk-grid-margin'">
<!-- if no grid on the div above, remove it and move class 'selectedFilterLabel' on top span --> <!-- if no grid on the div above, remove it and move class 'selectedFilterLabel' on top span -->
<span class="selectedFilterLabel "> <span class="selectedFilterLabel ">
@ -78,6 +81,7 @@
</span> </span>
</ng-container> </ng-container>
</ng-container> </ng-container>
</ng-container>
</div> </div>
</ng-template> </ng-template>
<ng-template #filters_column> <ng-template #filters_column>
@ -95,7 +99,7 @@
</a> </a>
</div> </div>
<div *ngIf="selectedRangeFilters+selectedFilters + selectedTypesNum > 0 || (customFilter && customFilter.selected <div *ngIf="selectedRangeFilters+selectedFilters + selectedTypesNum > 0 || (customFilter && customFilter.selected
== true)" == true || customFilter.isHiddenFilter)"
class="uk-margin-small-top uk-margin-medium-bottom"> class="uk-margin-small-top uk-margin-medium-bottom">
<ng-container *ngTemplateOutlet="selected_filters_pills; context: {}"></ng-container> <ng-container *ngTemplateOutlet="selected_filters_pills; context: {}"></ng-container>
</div> </div>
@ -291,10 +295,15 @@
Do you want to see results only for {{customFilter.valueName}}? <a Do you want to see results only for {{customFilter.valueName}}? <a
(click)="addCustomFilter();">Click here</a>. (click)="addCustomFilter();">Click here</a>.
</div> </div>
<div *ngIf="openaireLink && (searchUtils.totalResults > 0 || !loadPaging )"><a <div *ngIf="openaireLink && (searchUtils.totalResults > 0 || !loadPaging )" class="uk-alert uk-text-center ">
class="uk-margin-top uk-button uk-button-text" <span *ngIf="customFilter">The following results are related to <span class="portal-color"
>{{customFilter.valueName}}</span>.</span>
Are you interested to view more results? Visit
<a
class="uk-margin-top uk-link"
[href]="openaireLink+this.routerHelper.createQueryParamsString(this.parameterNames, this.parameterValues)" [href]="openaireLink+this.routerHelper.createQueryParamsString(this.parameterNames, this.parameterValues)"
target="_blank">Results in OpenAIRE</a></div> target="_blank"> OpenAIRE - Explore</a>.
</div>
<div class="uk-align-center uk-margin-remove-bottom"> <div class="uk-align-center uk-margin-remove-bottom">
<div <div
*ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)" *ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)"
@ -384,12 +393,28 @@
[isDisabled]="disableForms || disableRefineForms"> [isDisabled]="disableForms || disableRefineForms">
</search-paging> </search-paging>
</div> </div>
<div *ngIf=" searchUtils.status !==
<a *ngIf="properties.showLastIndexInformationLink && lastIndex && searchUtils.status !== errorCodes.LOADING" errorCodes.LOADING" class="uk-margin-small-top uk-grid uk-child-width-1-2">
class="last_index_info uk-button-text uk-button" <!-- Last Index Info-->
<div class="">
<img src="assets/common-assets/graph.svg" style="opacity: 0.4">
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by <a href="https://graph.openaire.eu" class="graph-color">OpenAIRE Research Graph</a></span>
</div>
<div class="uk-text-right">
<span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
<a *ngIf="properties.showLastIndexInformationLink && lastIndex"
class="uk-link"
[href]="properties.lastIndexInformationLink" target="_blank"> [href]="properties.lastIndexInformationLink" target="_blank">
Last index information
</a> Last update
</a><span *ngIf="!(properties.showLastIndexInformationLink && lastIndex) ">
Last update
</span>
of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
</span>
</div>
</div>
</div> </div>
<!-- </ng-template>--> <!-- </ng-template>-->
<!-- <div class="uk-visible@m uk-margin-top uk-width-1-5">--> <!-- <div class="uk-visible@m uk-margin-top uk-width-1-5">-->

View File

@ -23,6 +23,7 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {AlertModal} from "../../utils/modal/alert"; import {AlertModal} from "../../utils/modal/alert";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {IndexInfoService} from "../../utils/indexInfo.service";
declare var UIkit: any; declare var UIkit: any;
@ -123,6 +124,7 @@ export class NewSearchPageComponent {
@ViewChild('removeCustomFilter') removeCustomFilter: AlertModal; @ViewChild('removeCustomFilter') removeCustomFilter: AlertModal;
currentValueToRemove; currentValueToRemove;
currentFilterToRemove; currentFilterToRemove;
public indexUpdateDate: Date;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private location: Location, private location: Location,
private _meta: Meta, private _meta: Meta,
@ -131,7 +133,7 @@ export class NewSearchPageComponent {
private router: Router, private router: Router,
private seoService: SEOService, private seoService: SEOService,
private helper: HelperService, private helper: HelperService,
private cdr:ChangeDetectorRef) { private cdr:ChangeDetectorRef, private indexInfoService: IndexInfoService) {
} }
ngOnInit() { ngOnInit() {
@ -179,6 +181,13 @@ export class NewSearchPageComponent {
this.breadcrumbs.push({name: "Advanced Search", route: null}); this.breadcrumbs.push({name: "Advanced Search", route: null});
} }
//console.log(this.filters) //console.log(this.filters)
if (typeof document !== 'undefined') {
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate);
}
}));
}
} }
private getPageContents() { private getPageContents() {
@ -1297,7 +1306,7 @@ public static createRangeFilterQuery(rangeField,selectedFromValue, selectedToVal
if (filter.countSelectedValues > 0) { if (filter.countSelectedValues > 0) {
for (let value of filter.values) { for (let value of filter.values) {
if (value.selected == true) { if (value.selected == true) {
filterLimits += ((filterLimits.length == 0) ? '' : ',') + '"' + (value.id) + '"'; filterLimits += ((filterLimits.length == 0) ? '' : ',') + '"' + StringUtils.URIEncode(value.id) + '"';
} }
} }
if (filterLimits.length > 0) { if (filterLimits.length > 0) {

View File

@ -244,8 +244,12 @@ export class SearchFilterComponent implements OnInit, OnChanges{
} }
getParams(filter:Filter, value:Value){ getParams(filter:Filter, value:Value){
let params = Object.assign({}, this.queryParams); let params = Object.assign({}, this.queryParams);
let isValueSelected = true; let qf=false;
if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)==-1) { if(this.quickFilter && this.quickFilter.filterId == filter.filterId && this.quickFilter.selected && value.id == this.quickFilter.value){
params['qf']="false";
qf=true;
}
if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)==-1 && !qf) {
//has other values of this filter --> add this value //has other values of this filter --> add this value
params[filter.filterId] = params[filter.filterId] + ',' + '"' + encodeURIComponent(value.id) + '"'; params[filter.filterId] = params[filter.filterId] + ',' + '"' + encodeURIComponent(value.id) + '"';
}else if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)!=-1) { }else if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)!=-1) {
@ -257,15 +261,10 @@ export class SearchFilterComponent implements OnInit, OnChanges{
if(values.length == 0){ if(values.length == 0){
delete params[filter.filterId]; delete params[filter.filterId];
} }
isValueSelected = false; } else if(!qf){
} else{
//has no filter, no value --> add the value //has no filter, no value --> add the value
params[filter.filterId] = '"' + encodeURIComponent(value.id) + '"' ; params[filter.filterId] = '"' + encodeURIComponent(value.id) + '"' ;
} }
//if it is the Quick filter set the if selected or not
if(this.quickFilter && this.quickFilter.filterId == filter.filterId && value.id == this.quickFilter.value){
params['qf']=isValueSelected;
}
delete params['page']; delete params['page'];
return params; return params;
} }