Search Pages: change Filter title on the left, in filters view more modal add keyword filter and sort functionalities, changes in the selected filters under the form

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52770 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-07-19 10:52:29 +00:00
parent eef4be71f2
commit 8bdec079b8
6 changed files with 150 additions and 109 deletions

View File

@ -44,8 +44,10 @@
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="minus" ratio="1"><rect height="3" width="18" y="9" x="1"></rect></svg></span>
</span>
</td>
<td *ngIf="i == selectedFields.length-1 " class=" "><span type="button" class="uk-icon-button" (click)="addField()">
<span><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="1"><rect x="9" y="1" width="3" height="17"></rect><rect x="1" y="9" width="17" height="3"></rect></svg></span>
<td *ngIf="i == selectedFields.length-1 " class=" "><span type="button" class="uk-icon-button icon-button-small" (click)="addField()">
<span class="uk-icon">
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
</span>
</span></td>
</tr>
</table>

View File

@ -6,7 +6,7 @@
{{pageTitle}}
</div>
<div>
<a *ngIf = "simpleSearchLink && simpleSearchLink.length > 0" routerLinkActive="router-link-active" [routerLink]=simpleSearchLink
<a *ngIf = "simpleSearchLink && simpleSearchLink.length > 0" routerLinkActive="router-link-active" [routerLink]=simpleSearchLink style="z-index:1;"
[class]="(disableForms)?'uk-float-right uk-disabled uk-link-muted uk-button uk-button-text uk-text-secondary uk-margin-right uk-margin-top':'uk-float-right uk-button uk-button-text uk-text-secondary uk-margin-right uk-margin-top'" >Simple search
<!--span class="uk-icon">
<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></svg>

View File

@ -1,42 +1,26 @@
<ul *ngIf= "filter.values.length >0" class="uk-list">
<li class="uk-open">
<h5 class="uk-margin-bottom-remove">{{_formatTitle(filter.title,filter.values.length)}}
<h5 class="uk-margin-bottom-remove sideInfoTitle">{{_formatTitle(filter.title,filter.values.length)}}
</h5>
<div aria-expanded="false">
<div class="searchFilterBoxValues ">
<div *ngFor = "let value of getSelectedValues(filter)" class = "uk-animation-fade filterItem">
<!--span *ngIf="!connectCommunityId || !(connectCommunityId && connectCommunityId == value.id)"-->
<div *ngFor = "let value of getSelectedValues(filter,'num')" class = "uk-animation-fade filterItem">
<span class="filterName"><div title = "{{value.name}}">
<input [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
{{_formatName(value)}} </div></span>
<span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number|number}})</span>
<!--/span-->
</div>
<!--div class="uk-grid-divider uk-margin-remove"></div-->
<hr *ngIf="getSelectedValues(filter).length > 0 && getNotSelectedValues(filter).length > 0 " class="uk-grid-divider uk-margin-remove">
<div *ngFor = "let value of getNotSelectedValues(filter).slice(0,(!addShowMore?getNotSelectedValues(filter).length:5-getSelectedValues(filter).length))" class = "uk-animation-fade filterItem">
<hr *ngIf="filter.countSelectedValues > 0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small">
<div *ngFor = "let value of getNotSelectedValues(filter,'num').slice(0,(!addShowMore?getNotSelectedValues(filter,'num').length:5-getSelectedValues(filter,'num').length))" class = "uk-animation-fade filterItem">
<!--span *ngIf="!connectCommunityId || !(connectCommunityId && connectCommunityId == value.id)"-->
<span class="filterName"><div title = "{{value.name}}"> <input [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="filterChange(value.selected)" />
{{_formatName(value)}} </div></span>
<span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number|number}})</span>
<!--/span-->
</div>
<!--a *ngIf="(getSelectedValues(filter).length + getNotSelectedValues(filter).length) > 5" (click)="toggle()" [class]="(isDisabled)?'uk-disabled uk-link-muted':''">Show More</a-->
<!--button *ngIf="(getSelectedValues(filter).length + getNotSelectedValues(filter).length) > 5"
class="uk-button uk-button-link" (click)="toggle()" [disabled]="isDisabled">
Show More
</button-->
<a *ngIf=" addShowMore && (getSelectedValues(filter).length + getNotSelectedValues(filter).length) > 5" (click)="open()" [class]="(isDisabled)?'uk-disabled uk-link-muted uk-button uk-button-text uk-text-secondary':'uk-button uk-button-text uk-text-secondary'">View more
<!--span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="triangle-right" ratio="1"><polygon points="8 5 13 10 8 15"></polygon></svg>
</span-->
<a *ngIf=" addShowMore && (filter.values.length) > 5" (click)="open()"
[class]="(isDisabled)?'uk-disabled uk-link-muted uk-button uk-button-text uk-text-secondary':'uk-button uk-button-text uk-text-secondary'">View more
</a>
@ -44,29 +28,37 @@
<div class="filtersModal uk-modal-dialog uk-small-1-2 uk-width-medium-1-3 uk-width-1-3 uk-padding-small uk-padding-remove-top uk-padding-remove-horizontal">
<button type="button" class="uk-modal-close-default" uk-close (click)="close()"></button>
<h5 class="uk-margin-remove uk-padding uk-padding-remove-bottom">
<h5 class="uk-margin-remove uk-padding uk-padding-remove-bottom uk-text-center">
{{filter.title}}
</h5>
<span *ngIf="filter.values.length >= 99" class="uk-article-meta uk-text-center">Showing top {{filter.values.length}} values. </span>
<div *ngIf="filter.values.length >= 99" class="uk-alert uk-alert-primary uk-text-center uk-margin-right uk-margin-left">Showing top {{filter.values.length}} values. </div>
<div class="uk-grid uk-margin-left uk-margin-right">
<input class="uk-input uk-margin-small-bottom uk-width-1-2 " name="filter-keyword" placeholder="Search for {{filter.title}}" type="text" [(ngModel)]="keyword">
<select [(ngModel)]="sortBy" class="uk-select uk-margin-small-bottom uk-width-1-2 uk-padding-remove" name="select_order" (ngModelChange)="sortByChanged = true;" >
<option value="num" >Sort by results number</option>
<option value="name" >Sort by name</option>
</select>
</div>
<div class="uk-modal-body uk-overflow-auto uk-height-medium uk-padding-remove
uk-margin-medium-left uk-margin-medium-right uk-margin-small-top uk-margin-bottom">
<div *ngFor = "let value of getSelectedValues(filter)" class = "uk-animation-fade filterItem">
<!--span *ngIf="!connectCommunityId || !(connectCommunityId && connectCommunityId == value.id)"==>
<ng-container *ngFor = "let value of getSelectedValues(filter, sortBy)">
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem">
<span class="filterName"><div title = "{{value.name}}">
<input [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" />
{{_formatName(value)}} </div></span>
<span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number}})</span>
<!--/span-->
</div>
<hr *ngIf="getSelectedValues(filter).length > 0 && getNotSelectedValues(filter).length > 0" class="uk-grid-divider uk-margin-remove">
<div *ngFor = "let value of getNotSelectedValues(filter)" class = "uk-animation-fade filterItem">
<!--span *ngIf="!connectCommunityId || !(connectCommunityId && connectCommunityId == value.id)"-->
<span class="filterName"><div title = "{{value.name}}"> <input [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" />
</div>
</ng-container>
<hr *ngIf="filter.countSelectedValues > 0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small">
<ng-container *ngFor = "let value of getNotSelectedValues(filter, sortBy)">
<div *ngIf="filterKeywords(value.name)" class = "uk-animation-fade filterItem">
<span class="filterName"><div title = "{{value.name}}">
<input [disabled]="isDisabled" [(ngModel)]="value.selected" type="checkbox" (ngModelChange)="close(); filterChange(value.selected)" />
{{_formatName(value)}} </div></span>
<span class="filterNumber" *ngIf = "showResultCount === true" > ({{value.number|number}})</span>
<!--/span-->
</div>
</div>
</ng-container>
</div>
</div>
</div>

View File

@ -22,17 +22,20 @@ export class SearchFilterComponent {
@Output() toggleModal = new EventEmitter();
@Output() modalChange = new EventEmitter();
@Output() onFilterChange = new EventEmitter();
keyword = "";
sortBy = "num";
public isOpen:boolean=false;
filterModalChange() {
console.info("Modal Changed");
this.modalChange.emit({
value: true
});
//this.close();
}
// filterModalChange() {
// console.info("Modal Changed");
// this.modalChange.emit({
// value: true
// });
// //this.close();
// }
constructor () {
}
@ -46,13 +49,22 @@ export class SearchFilterComponent {
private _formatName(value){
return value.name;//(((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name)
}
toggleShowAll(){
this.showAll = !this.showAll;
if(this.showAll == false) {
this.reorderFilterValues();
}
}
// toggleShowAll(){
// this.showAll = !this.showAll;
// if(this.showAll == false) {
// this.reorderFilterValues();
// }
// }
filterKeywords(value){
if(this.keyword.length > 0){
if(value.toLowerCase().indexOf(this.keyword.toLowerCase()) ==-1){
return false;
}
}
return true;
}
filterChange(selected:boolean){
console.info("filter change: "+selected);
if(selected){
@ -62,8 +74,11 @@ export class SearchFilterComponent {
this.filter.countSelectedValues--;
// this.reorderFilterValues();
}
this.onFilterChange.emit({
value: this.filter
});
}
getSelectedValues(filter):any{
getSelectedValues(filter, sortBy:string = "num"):any{
var selected = [];
if(filter.countSelectedValues >0){
for (var i=0; i < filter.values.length; i++){
@ -72,10 +87,24 @@ export class SearchFilterComponent {
}
}
}
if(sortBy == "name"){
selected.sort((n1,n2)=> {
if (n1.name > n2.name) {
return 1;
}
if (n1.name < n2.name) {
return -1;
}
return 0;
});
}
return selected;
}
getNotSelectedValues(filter):any{
getNotSelectedValues(filter, sortBy):any{
var notSselected = [];
if(filter.countSelectedValues >0){
for (var i=0; i < filter.values.length; i++){
@ -86,19 +115,34 @@ export class SearchFilterComponent {
}else {
notSselected = filter.values;
}
if(sortBy == "name"){
notSselected.sort((n1,n2)=> {
if (n1.name > n2.name) {
return 1;
}
if (n1.name < n2.name) {
return -1;
}
return 0;
});
}
return notSselected;
}
reorderFilterValues() {
for(let value of this.filter.values) {
if(value.selected) {
let index: number = this.filter.values.indexOf(value);
let selectedValue:Value = this.filter.values[index];
this.filter.values.splice(index, 1);
this.filter.values.splice(0, 0, selectedValue);
}
}
}
// reorderFilterValues() {
// for(let value of this.filter.values) {
// if(value.selected) {
// let index: number = this.filter.values.indexOf(value);
// let selectedValue:Value = this.filter.values[index];
//
// this.filter.values.splice(index, 1);
// this.filter.values.splice(0, 0, selectedValue);
// }
// }
// }
// sliceSelected() {
// let values: Value[] = [];
//
@ -113,11 +157,11 @@ export class SearchFilterComponent {
// }
toggle() {
this.toggleModal.emit({
value: this.filter
});
}
// toggle() {
// this.toggleModal.emit({
// value: this.filter
// });
// }
open() {
@ -128,17 +172,17 @@ export class SearchFilterComponent {
this.isOpen = false;
}
filterChange2(selected:boolean){
console.info("filter change2");
if(selected){
this.filter.countSelectedValues++;
// this.reorderFilterValues();
}else{
this.filter.countSelectedValues--;
// this.reorderFilterValues();
}
this.close();
}
// filterChange2(selected:boolean){
//
// console.info("filter change2");
// if(selected){
// this.filter.countSelectedValues++;
// // this.reorderFilterValues();
// }else{
// this.filter.countSelectedValues--;
// // this.reorderFilterValues();
// }
// this.close();
// }
}

View File

@ -4,38 +4,42 @@
<div class="">
<div [class]="'uk-background-norepeat uk-background-cover uk-section uk-flex uk-flex-middle uk- light '+searchFormClass" >
<div class="uk-width-1-1">
<div class="uk-width-1-1">
<search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)" [placeholderText]="formPlaceholderText"></search-form>
</div>
<div class="uk-width-1-1 ">
<!--link to advanced search -->
<a *ngIf = "advancedSearchLink && advancedSearchLink.length > 0" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-float-right uk-disabled uk-link-muted uk-light ':'uk-float-right uk-light'" [routerLink]=advancedSearchLink [queryParams]=advancedSearchParameters >More search options <span class="uk-icon">
<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></svg>
</span>
</a>
<div *ngIf="isFiltered()" class = "uk-container uk-width-1-2@m uk-width-1-2@s uk-align-center uk-text-center uk-text-small">
<span *ngIf = "searchUtils.keyword.length > 0">Keywords: <span [innerHtml]="searchUtils.keyword"></span><a (click) = "clearKeywords() " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable " aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
<div *ngIf="countFilters()>0" class = "uk-container uk-width-1-2@m uk-width-1-2@s uk-align-center uk-text-center uk-text-small whiteText uk-padding-small">
<a *ngIf="countFilters()>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' uk-button uk-button-default uk-margin-small-right'">
Clear All
</a>
<span *ngIf = "searchUtils.keyword.length > 0">Keywords: <span [innerHtml]="searchUtils.keyword"></span>
<a (click) = "clearKeywords() " title="Remove keywords" [class]="(disableForms)?'uk-icon-button icon-button-small uk-margin-small-right uk-disabled':'uk-icon-button icon-button-small uk-margin-small-right'"><span class=" clickable " aria-hidden="true"><span class="uk-icon ">
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
</span>
<span *ngFor="let filter of filters " >
<span *ngIf = "filter.countSelectedValues > 0"> {{filter.title}}:
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " ><span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name" title="value.name"></span><a (click) = "removeFilter(value, filter) " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable" aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
<span *ngIf = "filter.countSelectedValues > 0"> <span class="uk-text-bold">{{filter.title}}:</span>
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " ><span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name" [title]="value.name"></span>
<a [title]="'Remove '+value.name"(click) = "removeFilter(value, filter) " [class]="(disableForms)?'uk-icon-button icon-button-small uk-margin-small-right uk-disabled':'uk-icon-button icon-button-small uk-margin-small-right'"><span class=" clickable" aria-hidden="true"><span class="uk-icon">
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
<span *ngIf="!end">, </span>
<!--span *ngIf="!end" class=" uk-margin-small-right ">, </span-->
</span>
</span>
</span>
<a (click)="clearFilters()" [class]="(disableForms)?'uk-disabled uk-link-muted':''">
Clear All
</a>
</div>
<div *ngIf= "showUnknownFilters" class = " uk-text-center ">
<a (click) = "clearFilters() " >Try new Query</a>
</div>
<!--link to advanced search -->
<a *ngIf = "advancedSearchLink && advancedSearchLink.length > 0" routerLinkActive="router-link-active" [class]="((disableForms)?'uk-float-right uk-disabled uk-link-muted uk-light ':'uk-float-right uk-light') +' whiteText uk-padding-small uk-button-text'" [routerLink]=advancedSearchLink [queryParams]=advancedSearchParameters >
<span class="uk-padding-small">More search options</span>
</a>
</div>
</div>
@ -51,7 +55,7 @@
<div class="uk-offcanvas-bar">
<button class="uk-offcanvas-close" type="button" uk-close></button>
<div class="uk-text-large">Filter By:</div>
<search-filter *ngFor="let filter of filters " [addShowMore]=false [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (change)="filterChanged($event)" (toggleModal)="toggleModal($event)" [(connectCommunityId)]=connectCommunityId></search-filter>
<search-filter *ngFor="let filter of filters " [addShowMore]=false [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" [(connectCommunityId)]=connectCommunityId></search-filter>
</div>
</div>
@ -62,7 +66,7 @@
<div class="uk-grid uk-width-1-1">
<div *ngIf="showRefine" class="helper-left-right search-filters uk-visible@m">
<helper position="left" before="true"></helper>
<search-filter *ngFor="let filter of filters " [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (change)="filterChanged($event)" (toggleModal)="toggleModal($event)" [(connectCommunityId)]=connectCommunityId></search-filter>
<search-filter *ngFor="let filter of filters " [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" [(connectCommunityId)]=connectCommunityId></search-filter>
<helper position="left" before="false"></helper>
</div>
<helper *ngIf="!showRefine" class="helper-left-right uk-visible@m" position="left"></helper>

View File

@ -57,12 +57,12 @@ export class SearchPageComponent {
private queryParameters: Map<string, string> = new Map<string,string>();
private baseURLWithParameters:string = '';
private sub: any; piwiksub: any;
public countFilters= 0;
// public countFilters= 0;
public parameterNames:string[] =[];
public parameterValues:string[] =[];
public showUnknownFilters:boolean = false; // when a filter exists in query but has no results, so no filters returned from the query
//@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ;
public currentFilter: Filter;
// public currentFilter: Filter;
public csvLimit: number = 0;
public pagingLimit: number = 0;
public resultsPerPage: number = 0;
@ -111,10 +111,10 @@ export class SearchPageComponent {
this.piwiksub.unsubscribe();
}
}
toggleModal($event) {
this.currentFilter = $event.value;
//this.searchFilterModal.open();
}
// toggleModal($event) {
// this.currentFilter = $event.value;
// //this.searchFilterModal.open();
// }
updateDescription(description:string) {
this._meta.updateTag({content:description},"name='description'");
@ -444,23 +444,22 @@ export class SearchPageComponent {
return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs;
}
public isFiltered(){
var filtered=false;
public countFilters():number{
var filters=0;
this.showUnknownFilters = false;
for (let filter of this.filters){
if(filter.countSelectedValues > 0){
filtered = true;
break;
filters+=filter.countSelectedValues;
}
}
if(this.searchUtils.keyword.length > 0 ){
filtered = true;
filters++;
}
var errorCodes:ErrorCodes = new ErrorCodes();
if(this.queryParameters.keys() && this.searchUtils.totalResults == 0 && this.searchUtils.status !=errorCodes.LOADING ){
this.showUnknownFilters = true;
}
return filtered;
return filters;
}
private clearKeywords(){
if(this.searchUtils.keyword.length > 0 ){