[Trunk|Library]: Add help texts top and bottom on advanced search.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56649 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-07-22 11:05:39 +00:00
parent 11cf47ac5a
commit 46ca524ce5
4 changed files with 221 additions and 207 deletions

View File

@ -36,7 +36,7 @@ export class AdvancedSearchDatasetsComponent {
private errorCodes: ErrorCodes; private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
properties:EnvProperties; properties:EnvProperties;
@Input() piwikSiteId = null; @Input() piwikSiteId = null;
@Input() customFilter:SearchCustomFilter= null; @Input() customFilter:SearchCustomFilter= null;
public results =[]; public results =[];

View File

@ -29,15 +29,11 @@
<div id="tm-main" class=" tm-middle"> <div id="tm-main" class=" tm-middle">
<div uk-grid uk-grid> <div uk-grid uk-grid>
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first "> <div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
<div class="uk-container "> <div class="uk-container">
<div> <div>
<div class="uk-width-1-1"> <helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper>
<helper position="top"></helper>
</div>
<div class="uk-width-1-1 uk-grid helper-grid uk-padding-large uk-padding-remove-top" > <div class="uk-width-1-1 uk-grid helper-grid uk-padding-large uk-padding-remove-top" >
<helper class="uk-margin-top helper-left-right uk-visible@m" position="left"></helper>
<div class="uk-width-expand@m uk-with-1-1@s"> <div class="uk-width-expand@m uk-with-1-1@s">
<div *ngIf="openaireLink"> <a class="uk-margin-top uk-button uk-button-text" [href]=openaireLink target="_blank" >Results in OpenAIRE</a></div> <div *ngIf="openaireLink"> <a class="uk-margin-top uk-button uk-button-text" [href]=openaireLink target="_blank" >Results in OpenAIRE</a></div>
<div class="uk-align-center uk-margin-remove-bottom"> <div class="uk-align-center uk-margin-remove-bottom">
@ -76,24 +72,16 @@
[href]="properties.lastIndexInformationLink" target="_blank"> [href]="properties.lastIndexInformationLink" target="_blank">
Last index information Last index information
</a> </a>
<helper class="uk-hidden@m" position="left" styleName="uk-width-1-1@s"></helper>
<helper class="uk-hidden@m" position="right" styleName="uk-width-1-1@s"></helper>
</div> </div>
<div class="uk-visible@m uk-margin-top helper-left-right"> <div class="uk-visible@m uk-margin-top uk-width-1-5">
<helper position="right" before="true"></helper>
<search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" ></search-download> <search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" ></search-download>
<helper position="right" before="false"></helper>
</div> </div>
<!-- <helper *ngIf="searchUtils.totalResults > csvLimit" class="uk-margin-top helper-left-right uk-visible@m" position="right"></helper> --> <!-- <helper *ngIf="searchUtils.totalResults > csvLimit" class="uk-margin-top helper-left-right uk-visible@m" position="right"></helper> -->
</div> </div>
<div class="uk-width-1-1"> <helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0" [texts]="pageContents['bottom']"></helper>
<helper position="bottom"></helper>
</div> </div>
</div> </div>
</div> </div>
<!--modal-loading [message]= "'Loading results...'"></modal-loading-->
</div>
</div> </div>
</div> </div>

View File

@ -1,23 +1,19 @@
import {Component, Input, ViewChild} from '@angular/core'; import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {Output, EventEmitter} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import {Observable} from 'rxjs'; import {AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {Filter, Value, AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchResult} from '../../utils/entities/searchResult';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class'; import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class';
import {ModalLoading} from '../../utils/modal/loading.component'; import {ModalLoading} from '../../utils/modal/loading.component';
import {StringUtils, Dates} from '../../utils/string-utils.class'; import {Dates, StringUtils} from '../../utils/string-utils.class';
import {ErrorCodes} from '../../utils/properties/errorCodes'; import {ErrorCodes} from '../../utils/properties/errorCodes';
import {RouterHelper} from '../../utils/routerHelper.class'; import {RouterHelper} from '../../utils/routerHelper.class';
import {PiwikService} from '../../utils/piwik/piwik.service'; import {PiwikService} from '../../utils/piwik/piwik.service';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import { SEOService } from '../../sharedComponents/SEO/SEO.service'; import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperService} from "../../utils/helper/helper.service";
@Component({ @Component({
selector: 'advanced-search-page', selector: 'advanced-search-page',
@ -29,66 +25,72 @@ export class AdvancedSearchPageComponent {
@Input() results = []; @Input() results = [];
@Input() type; @Input() type;
@Input() entityType; @Input() entityType;
@Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); @Input() searchUtils: SearchUtilsClass = new SearchUtilsClass();
@Input() fieldIds: string[]; @Input() fieldIds: string[];
@Input() fieldIdsMap;//:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ; @Input() fieldIdsMap;//:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ;
@Input() selectedFields:AdvancedField[]; @Input() selectedFields: AdvancedField[];
@Input() simpleSearchUrl: string; @Input() simpleSearchUrl: string;
@ViewChild (ModalLoading) loading : ModalLoading ; @ViewChild(ModalLoading) loading: ModalLoading;
@Input() csvParams: string; @Input() csvParams: string;
@Input() csvPath: string; @Input() csvPath: string;
@Input() simpleSearchLink: string = ""; @Input() simpleSearchLink: string = "";
@Input() disableForms:boolean = false; @Input() disableForms: boolean = false;
@Input() loadPaging: boolean = true; @Input() loadPaging: boolean = true;
@Input() oldTotalResults: number = 0; @Input() oldTotalResults: number = 0;
@Input() openaireLink: string; @Input() openaireLink: string;
@Input() customFilter:SearchCustomFilter= null; @Input() customFilter: SearchCustomFilter = null;
@Input() sort: boolean = false; @Input() sort: boolean = false;
@Input() searchFormClass: string = "searchForm"; @Input() searchFormClass: string = "searchForm";
piwiksub: any; piwiksub: any;
public parameterNames:string[] =[]; public parameterNames: string[] = [];
public parameterValues:string[] =[]; public parameterValues: string[] = [];
public baseURLWithParameters:string = ''; public baseURLWithParameters: string = '';
public csvLimit: number = 0; public csvLimit: number = 0;
public pagingLimit: number = 0; public pagingLimit: number = 0;
public resultsPerPage: number = 0; public resultsPerPage: number = 0;
isPiwikEnabled = false; isPiwikEnabled = false;
properties:EnvProperties; properties: EnvProperties;
public routerHelper:RouterHelper = new RouterHelper(); public pageContents = null;
public errorCodes:ErrorCodes = new ErrorCodes(); public divContents = null;
public routerHelper: RouterHelper = new RouterHelper();
public errorCodes: ErrorCodes = new ErrorCodes();
url = null; url = null;
@Output() queryChange = new EventEmitter(); @Output() queryChange = new EventEmitter();
constructor (private route: ActivatedRoute,
constructor(private route: ActivatedRoute,
private location: Location, private location: Location,
private _meta: Meta, private _meta: Meta,
private _title: Title, private _title: Title,
private _piwikService:PiwikService, private _piwikService: PiwikService,
private router: Router, private router: Router,
private seoService: SEOService) { private seoService: SEOService,
private helper: HelperService) {
} }
ngOnInit() { ngOnInit() {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
//this.getDivContents();
this.getPageContents();
this.pagingLimit = data.envSpecific.pagingLimit; this.pagingLimit = data.envSpecific.pagingLimit;
this.resultsPerPage =data.envSpecific.resultsPerPage; this.resultsPerPage = data.envSpecific.resultsPerPage;
this.csvLimit = data.envSpecific.csvLimit; this.csvLimit = data.envSpecific.csvLimit;
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack; this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
if(typeof window !== 'undefined') { if (typeof window !== 'undefined') {
this.updateUrl(data.envSpecific.baseLink+location.pathname); this.updateUrl(data.envSpecific.baseLink + location.pathname);
this.url = data.envSpecific.baseLink+location.pathname this.url = data.envSpecific.baseLink + location.pathname
} }
if(typeof document !== 'undefined' && this.isPiwikEnabled){ if (typeof document !== 'undefined' && this.isPiwikEnabled) {
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
} }
}); });
var title = "Advanced search "+this.pageTitle; var title = "Advanced search " + this.pageTitle;
var description = "Openaire, search, repositories, open access, type, content provider, funder, project, "+ this.pageTitle; var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.pageTitle;
this.updateTitle(title); this.updateTitle(title);
this.updateDescription(description); this.updateDescription(description);
@ -96,156 +98,173 @@ export class AdvancedSearchPageComponent {
this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl;
this.updateBaseUrlWithParameters(); this.updateBaseUrlWithParameters();
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this.router.url,false); this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.router.url, false);
} }
private getPageContents() {
this.helper.getPageHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => {
this.pageContents = contents;
})
}
private getDivContents() {
this.helper.getDivHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => {
this.divContents = contents;
})
}
ngOnDestroy() { ngOnDestroy() {
if(this.piwiksub){ if (this.piwiksub) {
this.piwiksub.unsubscribe(); this.piwiksub.unsubscribe();
} }
} }
updateDescription(description:string) {
this._meta.updateTag({content:description},"name='description'"); updateDescription(description: string) {
this._meta.updateTag({content:description},"property='og:description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
} }
updateTitle(title:string) {
var _prefix ="OpenAIRE | "; updateTitle(title: string) {
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); var _prefix = "OpenAIRE | ";
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title); this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
} }
updateUrl(url:string) {
this._meta.updateTag({content:url},"property='og:url'"); updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
} }
public getSelectedFiltersFromUrl(params) { public getSelectedFiltersFromUrl(params) {
for(var i=0; i< this.fieldIds.length ; i++){ for (var i = 0; i < this.fieldIds.length; i++) {
var fieldId = this.fieldIds[i]; var fieldId = this.fieldIds[i];
var fieldparam = (this.fieldIdsMap[fieldId])?this.fieldIdsMap[fieldId].param:""; var fieldparam = (this.fieldIdsMap[fieldId]) ? this.fieldIdsMap[fieldId].param : "";
if(!this.fieldIdsMap[fieldId]){ if (!this.fieldIdsMap[fieldId]) {
console.error("Field: "+fieldId +" not found in fieldIds map"); console.error("Field: " + fieldId + " not found in fieldIds map");
} }
var operatorId = this.getOperatorParameter(fieldparam); var operatorId = this.getOperatorParameter(fieldparam);
if(params[fieldparam] != undefined && params[operatorId] != undefined) { if (params[fieldparam] != undefined && params[operatorId] != undefined) {
var values:string [] = StringUtils.URIDecode(params[fieldparam]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); var values: string [] = StringUtils.URIDecode(params[fieldparam]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
var operators:string [] = (StringUtils.URIDecode(params[operatorId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); var operators: string [] = (StringUtils.URIDecode(params[operatorId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
if(values.length == operators.length){ if (values.length == operators.length) {
for(var j=0; j< values.length ; j++){ for (var j = 0; j < values.length; j++) {
if(this.fieldIdsMap[fieldId].type == "date"){ if (this.fieldIdsMap[fieldId].type == "date") {
var value:string =StringUtils.unquote(values[j]); var value: string = StringUtils.unquote(values[j]);
var validDates:boolean = true; var validDates: boolean = true;
var dateField:AdvancedField = new AdvancedField(fieldId,fieldparam,this.fieldIdsMap[fieldId].name,this.fieldIdsMap[fieldId].type,value,operators[j]) ; var dateField: AdvancedField = new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, value, operators[j]);
if(value.indexOf("range") != -1){ if (value.indexOf("range") != -1) {
dateField.dateValue.type="range"; dateField.dateValue.type = "range";
if(value.length < 26 ){ if (value.length < 26) {
validDates =false; validDates = false;
}else{ } else {
if(!Dates.isValidDate(value.substring(5,15)) || !Dates.isValidDate(value.substring(16,26))){ if (!Dates.isValidDate(value.substring(5, 15)) || !Dates.isValidDate(value.substring(16, 26))) {
validDates =false; validDates = false;
}else { } else {
dateField.dateValue.from = Dates.getDateFromString(value.substring(5,15)); dateField.dateValue.from = Dates.getDateFromString(value.substring(5, 15));
dateField.dateValue.to = Dates.getDateFromString(value.substring(16,26)); dateField.dateValue.to = Dates.getDateFromString(value.substring(16, 26));
} }
} }
// "rangeYYYY-MM-DD:YYYY-MM-DD" // "rangeYYYY-MM-DD:YYYY-MM-DD"
}else{ } else {
dateField.dateValue.setDatesByType(value); dateField.dateValue.setDatesByType(value);
} }
if(validDates){ if (validDates) {
this.selectedFields.push(dateField); this.selectedFields.push(dateField);
} }
} } else {
else{ this.selectedFields.push(new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, StringUtils.unquote(values[j]), operators[j]));
this.selectedFields.push(new AdvancedField(fieldId,fieldparam,this.fieldIdsMap[fieldId].name,this.fieldIdsMap[fieldId].type,StringUtils.unquote(values[j]),operators[j]) );
} }
} }
} }
} }
} }
if(this.selectedFields.length == 0){ if (this.selectedFields.length == 0) {
this.selectedFields.push(new AdvancedField(this.fieldIds[0],fieldparam,this.fieldIdsMap[this.fieldIds[0]].name,this.fieldIdsMap[this.fieldIds[0]].type,"","and")); this.selectedFields.push(new AdvancedField(this.fieldIds[0], fieldparam, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, "", "and"));
} }
} }
private createUrlParameters(includePage:boolean){
var params=""; private createUrlParameters(includePage: boolean) {
this.parameterNames.splice(0,this.parameterNames.length); var params = "";
this.parameterValues.splice(0,this.parameterValues.length); this.parameterNames.splice(0, this.parameterNames.length);
var fields: { [key:string]:{ values:string[], operators:string[] }}={}; this.parameterValues.splice(0, this.parameterValues.length);
for(var i = 0; i< this.selectedFields.length; i++){ var fields: { [key: string]: { values: string[], operators: string[] } } = {};
if(this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value.length > 0 || this.selectedFields[i].type == "date" )){ for (var i = 0; i < this.selectedFields.length; i++) {
if(!fields[this.selectedFields[i].id]){ if (this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value.length > 0 || this.selectedFields[i].type == "date")) {
fields[this.selectedFields[i].id] = {values:[], operators:[]}; if (!fields[this.selectedFields[i].id]) {
fields[this.selectedFields[i].id].values =[]; fields[this.selectedFields[i].id] = {values: [], operators: []};
fields[this.selectedFields[i].id].operators =[]; fields[this.selectedFields[i].id].values = [];
fields[this.selectedFields[i].id].operators = [];
} }
if(this.selectedFields[i].type == "date"){ if (this.selectedFields[i].type == "date") {
if(this.selectedFields[i].dateValue.type == "range"){ if (this.selectedFields[i].dateValue.type == "range") {
fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode("range"+Dates.getDateToString(this.selectedFields[i].dateValue.from)+":"+Dates.getDateToString(this.selectedFields[i].dateValue.to)))); fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode("range" + Dates.getDateToString(this.selectedFields[i].dateValue.from) + ":" + Dates.getDateToString(this.selectedFields[i].dateValue.to))));
}else{ } else {
fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].dateValue.type))); fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].dateValue.type)));
} }
}else{ } else {
fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].value))); fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].value)));
} }
fields[this.selectedFields[i].id].operators.push(this.selectedFields[i].operatorId); fields[this.selectedFields[i].id].operators.push(this.selectedFields[i].operatorId);
} }
} }
for(var i = 0; i< this.fieldIds.length; i++){ for (var i = 0; i < this.fieldIds.length; i++) {
if(fields[this.fieldIds[i]]){ if (fields[this.fieldIds[i]]) {
params+="&"+this.fieldIdsMap[this.fieldIds[i]].param+"="+fields[this.fieldIds[i]].values.join()+ params += "&" + this.fieldIdsMap[this.fieldIds[i]].param + "=" + fields[this.fieldIds[i]].values.join() +
"&"+ this.fieldIdsMap[this.fieldIds[i]].operator+"="+fields[this.fieldIds[i]].operators.join() "&" + this.fieldIdsMap[this.fieldIds[i]].operator + "=" + fields[this.fieldIds[i]].operators.join()
this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].param); this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].param);
this.parameterValues.push(fields[this.fieldIds[i]].values.join()); this.parameterValues.push(fields[this.fieldIds[i]].values.join());
this.parameterNames.push( this.fieldIdsMap[this.fieldIds[i]].operator); this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].operator);
this.parameterValues.push(fields[this.fieldIds[i]].operators.join()); this.parameterValues.push(fields[this.fieldIds[i]].operators.join());
} }
} }
if(includePage && this.searchUtils.page != 1){ if (includePage && this.searchUtils.page != 1) {
params += "&page="+this.searchUtils.page; params += "&page=" + this.searchUtils.page;
} }
if(this.searchUtils.size != 10) { if (this.searchUtils.size != 10) {
params+=((params.length == 0)?'':'&') + 'size=' + this.searchUtils.size; params += ((params.length == 0) ? '' : '&') + 'size=' + this.searchUtils.size;
this.parameterNames.push("size"); this.parameterNames.push("size");
this.parameterValues.push(""+this.searchUtils.size); this.parameterValues.push("" + this.searchUtils.size);
} }
if(this.sort && this.searchUtils.sortBy) { if (this.sort && this.searchUtils.sortBy) {
params+=((params.length == 0)?'':'&') + 'sortBy=' + this.searchUtils.sortBy; params += ((params.length == 0) ? '' : '&') + 'sortBy=' + this.searchUtils.sortBy;
this.parameterNames.push("sortBy"); this.parameterNames.push("sortBy");
this.parameterValues.push(this.searchUtils.sortBy); this.parameterValues.push(this.searchUtils.sortBy);
} }
return '?'+params; return '?' + params;
} }
public createQueryParameters(){
var params=""; public createQueryParameters() {
var params = "";
var countParams = 0; var countParams = 0;
for(var i = 0; i< this.selectedFields.length; i++){ for (var i = 0; i < this.selectedFields.length; i++) {
if(this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value != "" ||this.selectedFields[i].type == "date")){ if (this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value != "" || this.selectedFields[i].type == "date")) {
//console.log("createQueryParameters::"+this.selectedFields[i].type); //console.log("createQueryParameters::"+this.selectedFields[i].type);
if(this.selectedFields[i].type == "date"){ if (this.selectedFields[i].type == "date") {
if(this.selectedFields[i].dateValue.type != "any"){ if (this.selectedFields[i].dateValue.type != "any") {
params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator+ '"' + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.from)) + " " params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.from)) + " "
+ StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.to)) + '"' + " "; + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.to)) + '"' + " ";
} }
}else{ } else {
if(this.selectedFields[i].id == "q"){ if (this.selectedFields[i].id == "q") {
var op = ""; var op = "";
// if() // if()
params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " "; params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
}else if(countParams == 0 && this.selectedFields[i].operatorId == "not"){ } else if (countParams == 0 && this.selectedFields[i].operatorId == "not") {
params += " "+ this.selectedFields[i].id + " <> "+'"' + StringUtils.URIEncode(this.selectedFields[i].value) +'"' + " "; params += " " + this.selectedFields[i].id + " <> " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
}else{ } else {
params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " " ) + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator+'"' + encodeURIComponent(this.selectedFields[i].value) +'"' + " "; params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " ") + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + encodeURIComponent(this.selectedFields[i].value) + '"' + " ";
} }
} }
@ -253,21 +272,22 @@ export class AdvancedSearchPageComponent {
} }
} }
if(this.customFilter){ if (this.customFilter) {
params+= (countParams == 0 ? "" : " and " ) + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )); params += (countParams == 0 ? "" : " and ") + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId));
} }
return params; return params;
} }
clearFilters(){
clearFilters() {
} }
goTo(page:number = 1){ goTo(page: number = 1) {
this.searchUtils.page = page; this.searchUtils.page = page;
var urlParameters = this.createUrlParameters(true); var urlParameters = this.createUrlParameters(true);
var queryParameters = this.createQueryParameters(); var queryParameters = this.createQueryParameters();
//this.location.go(location.pathname,urlParameters); //this.location.go(location.pathname,urlParameters);
this.router.navigate( [this.searchUtils.baseUrl], { queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues) } ); this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)});
this.queryChange.emit({ this.queryChange.emit({
value: queryParameters value: queryParameters
@ -277,7 +297,7 @@ export class AdvancedSearchPageComponent {
//console.log("In PreviousRouteRecorder : "+this.router.url ); //console.log("In PreviousRouteRecorder : "+this.router.url );
localStorage.setItem('previousRoute', this.router.url); localStorage.setItem('previousRoute', this.router.url);
} }
if(this.isPiwikEnabled && (typeof document !== 'undefined')){ if (this.isPiwikEnabled && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
} }
/* End Piwik Code */ /* End Piwik Code */
@ -287,14 +307,17 @@ export class AdvancedSearchPageComponent {
this.goTo(1); this.goTo(1);
} }
pageChanged($event) { pageChanged($event) {
this.searchUtils.page = +$event.value; this.searchUtils.page = +$event.value;
this.goTo(this.searchUtils.page); this.goTo(this.searchUtils.page);
} }
sizeChanged($event) { sizeChanged($event) {
this.searchUtils.size = $event.value; this.searchUtils.size = $event.value;
this.goTo(1); this.goTo(1);
} }
sortByChanged($event) { sortByChanged($event) {
this.searchUtils.sortBy = $event.value; this.searchUtils.sortBy = $event.value;
this.goTo(1); this.goTo(1);
@ -303,21 +326,24 @@ export class AdvancedSearchPageComponent {
/* /*
* Update the url with proper parameters. This is used as base url in Paging Component * Update the url with proper parameters. This is used as base url in Paging Component
*/ */
public updateBaseUrlWithParameters(){ public updateBaseUrlWithParameters() {
this.baseURLWithParameters = this.searchUtils.baseUrl + this.createUrlParameters(false); this.baseURLWithParameters = this.searchUtils.baseUrl + this.createUrlParameters(false);
} }
getOperatorParameter(parameter:string):string{
getOperatorParameter(parameter: string): string {
for (let id of this.fieldIds) { for (let id of this.fieldIds) {
if(this.fieldIdsMap[id]["param"] == parameter){ if (this.fieldIdsMap[id]["param"] == parameter) {
return this.fieldIdsMap[id]["operator"]; return this.fieldIdsMap[id]["operator"];
} }
} }
} }
// for loading // for loading
public openLoading(){ public openLoading() {
this.loading.open(); this.loading.open();
} }
public closeLoading(){
public closeLoading() {
this.loading.close(); this.loading.close();
} }
} }

View File

@ -120,14 +120,14 @@ export class SearchPageComponent {
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this.router.url,false); this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this.router.url,false);
} }
public getPageContents() { private getPageContents() {
this.helper.getPageHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => { this.helper.getPageHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
}) })
} }
public getDivContents() { private getDivContents() {
this.helper.getDivHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => { this.helper.getDivHelpContents(this.router.url, this.properties, (this.customFilter)?this.customFilter.valueId:null).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
}) })