[Library|Trunk]
Create new search page with unified simple and advanced search pages - use advanced search form - add fields/ code in advance form to support simple view - add links for research result search pages in properties - searchResearchResults.service: add refine fields in advanced search git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58045 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
95122e54a7
commit
07bdf020ba
|
@ -0,0 +1,264 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AdvancedField} from './searchUtils/searchHelperClasses.class';
|
||||
import {SearchResearchResultsService} from '../services/searchResearchResults.service';
|
||||
import {ErrorCodes} from '../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../utils/errorMessages.component';
|
||||
import {SearchFields} from '../utils/properties/searchFields';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils/searchUtils.class';
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {NewSearchPageComponent} from "./searchUtils/newSearchPage.component";
|
||||
import {DOI} from "../utils/string-utils.class";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'search-research-results',
|
||||
template: `
|
||||
<new-search-page
|
||||
pageTitle="{{(simpleView?'':'Advanced ')}} Search for {{ getEntityName(resultType, true, true) | titlecase }}"
|
||||
[entityType]="resultType"
|
||||
[type]="getEntityName(resultType, true, true)"
|
||||
[(results)]="results"
|
||||
[(searchUtils)]="searchUtils"
|
||||
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
|
||||
[csvParams]="csvParams" [csvPath]="getEntityName(resultType, true, false)"
|
||||
[simpleSearchLink]="simpleSearchLink" [advancedSearchLink]="advancedSearchLink"
|
||||
[disableForms]="disableForms"
|
||||
[loadPaging]="loadPaging"
|
||||
[oldTotalResults]="oldTotalResults"
|
||||
[(openaireLink)]=openaireLink
|
||||
[piwikSiteId]=piwikSiteId [hasPrefix]="hasPrefix"
|
||||
searchFormClass="publicationsSearchForm"
|
||||
[(sort)]=sort
|
||||
[(filters)]="filters"
|
||||
[simpleView]="simpleView" formPlaceholderText="Search by title, author, doi, abstract content..."
|
||||
>
|
||||
</new-search-page>
|
||||
|
||||
<!--
|
||||
Field missing from simple search!
|
||||
formPlaceholderText = "Search for {{ getEntityName(resultType, true, true) | titlecase }}"
|
||||
|
||||
[(filters)] = "filters"
|
||||
[(baseUrl)] = baseUrl
|
||||
[advancedSearchLink]="advancedSearchLink"
|
||||
[(advancedSearchParameters)]=advancedSearchParameters-->
|
||||
`
|
||||
})
|
||||
|
||||
export class SearchResearchResultsComponent {
|
||||
@Input() resultType: string = "publication";
|
||||
|
||||
simpleSearchLink: string = "";
|
||||
advancedSearchLink: string = "";
|
||||
|
||||
private errorCodes: ErrorCodes;
|
||||
private errorMessages: ErrorMessagesComponent;
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
public results = [];
|
||||
public filters = [];
|
||||
|
||||
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
|
||||
public searchFields: SearchFields = new SearchFields();
|
||||
|
||||
public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS;
|
||||
public fieldIdsMap = this.searchFields.RESULT_FIELDS;
|
||||
public selectedFields: AdvancedField[] = [];
|
||||
public resourcesQuery = "((oaftype exact result) and (resulttypeid exact " + this.resultType + "))";
|
||||
public csvParams: string;
|
||||
public disableForms: boolean = false;
|
||||
public loadPaging: boolean = true;
|
||||
public oldTotalResults: number = 0;
|
||||
@Input() openaireLink: string;
|
||||
@Input() customFilter: SearchCustomFilter = null;
|
||||
public pagingLimit: number = 0;
|
||||
public isPiwikEnabled;
|
||||
public sort: boolean = true;
|
||||
properties: EnvProperties;
|
||||
public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS;
|
||||
@ViewChild(NewSearchPageComponent) searchPage: NewSearchPageComponent;
|
||||
@Input() simpleView: boolean = true;
|
||||
|
||||
constructor(private route: ActivatedRoute, private _searchResearchResultsService: SearchResearchResultsService) {
|
||||
this.results = [];
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
|
||||
// this.searchLink = "/search/research-results";
|
||||
// this.searchUtils.baseUrl = this.searchLink;
|
||||
this.simpleSearchLink = this.properties.searchLinkToResults;
|
||||
this.advancedSearchLink = this.properties.searchLinkToAdvancedResults;
|
||||
this.searchUtils.baseUrl = (this.simpleView)?this.simpleSearchLink:this.advancedSearchLink;
|
||||
// } else if(this.resultType == "dataset") {
|
||||
// this.simpleSearchLink = this.properties.searchLinkToDatasets;
|
||||
// this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedDatasets;
|
||||
// } else if(this.resultType == "software") {
|
||||
// this.simpleSearchLink = this.properties.searchLinkToSoftware;
|
||||
// this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedSoftware;
|
||||
// } else if(this.resultType == "other") {
|
||||
// this.simpleSearchLink = this.properties.searchLinkToOrps;
|
||||
// this.searchUtils.baseUrl = this.properties.searchLinkToAdvancedOrps;
|
||||
// }
|
||||
});
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
var firstLoad = true;
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
if (params['page'] && this.searchUtils.page != params['page']) {
|
||||
this.loadPaging = false;
|
||||
this.oldTotalResults = this.searchUtils.totalResults;
|
||||
}
|
||||
var refine = true;
|
||||
if (this.searchUtils.page != ((params['page'] === undefined) ? 1 : +params['page']) && this.filters && !firstLoad) {
|
||||
refine = false;
|
||||
|
||||
}
|
||||
firstLoad = false;
|
||||
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
||||
this.searchUtils.page = (page <= 0) ? 1 : page;
|
||||
|
||||
this.searchUtils.size = (params['size'] === undefined) ? 10 : +params['size'];
|
||||
if (this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.sortBy = (params['sortBy']) ? params['sortBy'] : '';
|
||||
if (this.searchUtils.sortBy && this.searchUtils.sortBy != "resultdateofacceptance,descending" && this.searchUtils.sortBy != "resultdateofacceptance,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
||||
this.searchPage.fieldIds = this.fieldIds;
|
||||
this.selectedFields = [];
|
||||
this.searchPage.selectedFields = this.selectedFields;
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
||||
this.searchPage.customFilter = this.customFilter;
|
||||
this.searchPage.createAdvancedSearchSelectedFiltersFromURLParameters(params);
|
||||
this._getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, this.searchUtils.sortBy, refine, this.searchPage.getSearchAPIQueryForRefineFields(params));
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
|
||||
sub: any;
|
||||
|
||||
/*public getResults(parameters:string, page: number, size: number, sortBy: string, refine:boolean ) {
|
||||
if (page > this.pagingLimit) {
|
||||
size = 0;
|
||||
}
|
||||
if (page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
if (parameters != null && parameters != '') {
|
||||
this.csvParams = "&fq=(" + this.resourcesQuery + " and (" + parameters + "))";
|
||||
} else {
|
||||
this.csvParams = "&fq=" + this.resourcesQuery;
|
||||
}
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
|
||||
this._getResults(parameters, page, size, sortBy, refine);
|
||||
}
|
||||
}*/
|
||||
|
||||
public _getResults(parameters: string, page: number, size: number, sortBy: string, refine: boolean, refineFieldsFilterQuery = null) {
|
||||
if (page > this.pagingLimit) {
|
||||
size = 0;
|
||||
}
|
||||
if (page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
||||
// TODO update the following method to get more than one types
|
||||
if (parameters != null && parameters != '') {
|
||||
this.csvParams = "&fq=(" + this.resourcesQuery + " and (" + parameters + "))";
|
||||
} else {
|
||||
this.csvParams = "&fq=" + this.resourcesQuery;
|
||||
}
|
||||
this.csvParams += (refineFieldsFilterQuery?refineFieldsFilterQuery:'');
|
||||
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.results = [];
|
||||
this.searchUtils.totalResults = 0;
|
||||
// TODO update the following method to get more than one types
|
||||
this._searchResearchResultsService.advancedSearch(this.resultType, parameters, page, size, sortBy, this.properties, (refine) ? this.searchPage.getRefineFieldsQuery() : null, this.searchPage.getFields(), refineFieldsFilterQuery).subscribe(
|
||||
data => {
|
||||
this.searchUtils.totalResults = data[0];
|
||||
this.results = data[1];
|
||||
if (refine) {
|
||||
this.filters = data[2];
|
||||
console.info(this.filters);
|
||||
}
|
||||
this.searchPage.checkSelectedFilters(this.filters);
|
||||
// this.searchPage.updateBaseUrlWithParameters(this.filters);
|
||||
|
||||
this.searchPage.updateBaseUrlWithParameters();
|
||||
this.searchUtils.status = this.errorCodes.DONE;
|
||||
if (this.searchUtils.totalResults == 0) {
|
||||
this.searchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
this.disableForms = false;
|
||||
|
||||
if (this.searchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
|
||||
if (!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if (totalPages < page) {
|
||||
this.searchUtils.totalResults = 0;
|
||||
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
this.handleError("Error getting " + this.getEntityName(this.resultType, true, true), err);
|
||||
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
||||
|
||||
//TODO check erros (service not available, bad request)
|
||||
// if( ){
|
||||
// this.searchUtils.status = ErrorCodes.ERROR;
|
||||
// }
|
||||
//var errorCodes:ErrorCodes = new ErrorCodes();
|
||||
//this.searchUtils.status = errorCodes.NOT_AVAILABLE;
|
||||
/*if(err.status == '404') {
|
||||
this.searchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.searchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}*/
|
||||
|
||||
//this.searchPage.closeLoading();
|
||||
this.disableForms = false;
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error(this.getEntityName(this.resultType, true, true) + " advanced Search Page: " + message, error);
|
||||
}
|
||||
|
||||
public getEntityName(entityType: string, plural: boolean, full: boolean): string {
|
||||
if (entityType == "publication") {
|
||||
return "publication" + (plural ? "s" : "");
|
||||
} else if (entityType == "dataset") {
|
||||
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
|
||||
} else if (entityType == "software") {
|
||||
return "software";
|
||||
} else if (entityType == "other") {
|
||||
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import {SearchResearchResultsServiceModule} from '../services/searchResearchResultsService.module';
|
||||
import {FreeGuard} from '../login/freeGuard.guard';
|
||||
import {IsRouteEnabled} from '../error/isRouteEnabled.guard';
|
||||
import {SearchResearchResultsComponent} from "./searchResearchResults.component";
|
||||
import {NewSearchPageModule} from "./searchUtils/newSearchPage.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule,
|
||||
SearchResearchResultsServiceModule,
|
||||
NewSearchPageModule
|
||||
|
||||
],
|
||||
declarations: [
|
||||
SearchResearchResultsComponent
|
||||
],
|
||||
providers:[FreeGuard, IsRouteEnabled],
|
||||
exports: [
|
||||
SearchResearchResultsComponent
|
||||
]
|
||||
})
|
||||
export class SearchResearchResultsModule { }
|
|
@ -1,81 +1,125 @@
|
|||
|
||||
<form [class]="(isDisabled )?'uk-disabled advancedSearchForm uk-tile uk-margin-small-top uk-padding-small':'advancedSearchForm uk-tile uk-margin-small-top uk-padding-small'">
|
||||
<div class="uk-article-title custom-article-title uk-text-center">
|
||||
{{pageTitle}}
|
||||
</div>
|
||||
<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 portal-link uk-margin-right ':'uk-float-right portal-link uk-margin-right '" >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>
|
||||
</span-->
|
||||
<form [class]="(isDisabled )?'uk-disabled advancedSearchForm uk-tile uk-margin-small-top uk-padding-small':'advancedSearchForm uk-tile uk-margin-small-top uk-padding-small'">
|
||||
<div *ngIf="!simpleView">
|
||||
<div class="uk-article-title custom-article-title uk-text-center">
|
||||
{{pageTitle}}
|
||||
</div>
|
||||
<a *ngIf="simpleSearchLink && simpleSearchLink.length > 0" routerLinkActive="router-link-active"
|
||||
[routerLink]=simpleSearchLink style="z-index:1;"
|
||||
[class]="(isDisabled)?'uk-float-right uk-disabled uk-link-muted portal-link uk-margin-right ':'uk-float-right portal-link uk-margin-right '">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>
|
||||
</span-->
|
||||
</a>
|
||||
<table class=" uk-table uk-table-responsive uk-table-small" >
|
||||
<tr *ngFor="let selectedField of selectedFields; let i = index" class="-row ">
|
||||
<td *ngIf ="i==0 " class="">Search for:</td>
|
||||
<table class=" uk-table uk-table-responsive uk-table-small">
|
||||
<tr *ngFor="let selectedField of selectedFields; let i = index" class="-row ">
|
||||
<td *ngIf="i==0 " class="">Search for:</td>
|
||||
|
||||
<td *ngIf = "i != 0" class=""><select [(ngModel)]="selectedField.operatorId" name="selectOp_{{i}}" >
|
||||
<option *ngFor="let op of operators" (change)="fieldOperatorChanged(i, op.id, op.id)" (click)="fieldOperatorChanged(i, op.id, op.id)" [value]="op.id">{{op.id}}</option>
|
||||
</select></td>
|
||||
<td ><select [(ngModel)]="selectedField.id" name="selectField_{{i}}" (ngModelChange)="fieldIdsChanged(i,selectedField.id)" ><!--(click)="fieldIdsChanged(i)" -->
|
||||
<option *ngFor="let id of fieldIds" [value]="id" >{{fieldIdsMap[id].name}} </option>
|
||||
</select> </td>
|
||||
<td *ngIf = "selectedField.type == 'keyword'" ><input type="text" class="form-control" placeholder="Type keywords..."
|
||||
[(ngModel)]="selectedField.value" name="value[{{i}}]"></td>
|
||||
<td *ngIf = "selectedField.type == 'date'" >
|
||||
<date-filter [(dateValue)]=selectedField.dateValue [(validDateFrom)]=validDateFrom [(validDateTo)]=validDateTo></date-filter>
|
||||
</td>
|
||||
<td *ngIf = " selectedField.id && selectedField.type == 'vocabulary'" >
|
||||
<static-autocomplete [(properties)]=properties *ngIf = " selectedField.id" [(vocabularyId)] = selectedField.param [fieldId]=selectedField.id
|
||||
[(list)] = this.fieldList[selectedField.id] [entityName] = "entityType" [selectedValue]=selectedField.value [showSelected]=true
|
||||
[placeHolderMessage] = "'Search for '+selectedField.name" [title] = "selectedField.name" [multipleSelections]=false
|
||||
(selectedValueChanged)="valueChanged($event,i)" (listUpdated) = "listUpdated($event,selectedField.id)"></static-autocomplete>
|
||||
</td>
|
||||
<td *ngIf = " selectedField.id && selectedField.type == 'refine'" class="uk-width-1-3">
|
||||
<static-autocomplete [(properties)]=properties [(list)] = this.fieldList[selectedField.id] [fieldId]=selectedField.id [entityName] = "entityType" [fieldName] = [selectedField.id] [selectedValue]=selectedField.value [showSelected]=true [placeHolderMessage] = "'Search for '+selectedField.name" [title] = "selectedField.name" [multipleSelections]=false (selectedValueChanged)="valueChanged($event,i)" (listUpdated) = "listUpdated($event,selectedField.id)"></static-autocomplete></td>
|
||||
<td *ngIf = "selectedField.type == 'entity'" ><entities-autocomplete [(properties)]=properties [fieldId]=selectedField.id [entityType]=selectedField.param [selectedValue]=selectedField.value [showSelected]=true
|
||||
[placeHolderMessage] = "'Search for '+selectedField.name" [title] = "selectedField.name" [multipleSelections]=false
|
||||
(selectedValueChanged)="valueChanged($event,i)" (listUpdated) = "listUpdated($event,selectedField.id)" >
|
||||
</entities-autocomplete></td>
|
||||
<td *ngIf="i != 0" class=""><select [(ngModel)]="selectedField.operatorId" name="selectOp_{{i}}">
|
||||
<option *ngFor="let op of operators" (change)="fieldOperatorChanged(i, op.id, op.id)"
|
||||
(click)="fieldOperatorChanged(i, op.id, op.id)" [value]="op.id">{{op.id}}</option>
|
||||
</select></td>
|
||||
<td><select [(ngModel)]="selectedField.id" name="selectField_{{i}}"
|
||||
(ngModelChange)="fieldIdsChanged(i,selectedField.id)"><!--(click)="fieldIdsChanged(i)" -->
|
||||
<option *ngFor="let id of fieldIds" [value]="id">{{fieldIdsMap[id].name}} </option>
|
||||
</select></td>
|
||||
<td *ngIf="selectedField.type == 'keyword'"><input type="text" class="form-control"
|
||||
placeholder="Type keywords..."
|
||||
[(ngModel)]="selectedField.value" name="value[{{i}}]"></td>
|
||||
<td *ngIf="selectedField.type == 'date'">
|
||||
<date-filter [(dateValue)]=selectedField.dateValue [(validDateFrom)]=validDateFrom
|
||||
[(validDateTo)]=validDateTo></date-filter>
|
||||
</td>
|
||||
<td *ngIf=" selectedField.id && selectedField.type == 'vocabulary'">
|
||||
<static-autocomplete [(properties)]=properties *ngIf=" selectedField.id" [(vocabularyId)]=selectedField.param
|
||||
[fieldId]=selectedField.id
|
||||
[(list)]=this.fieldList[selectedField.id] [entityName]="entityType"
|
||||
[selectedValue]=selectedField.value [showSelected]=true
|
||||
[placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name"
|
||||
[multipleSelections]=false
|
||||
(selectedValueChanged)="valueChanged($event,i)"
|
||||
(listUpdated)="listUpdated($event,selectedField.id)"></static-autocomplete>
|
||||
</td>
|
||||
<td *ngIf=" selectedField.id && selectedField.type == 'refine'" class="uk-width-1-3">
|
||||
<static-autocomplete [(properties)]=properties [(list)]=this.fieldList[selectedField.id]
|
||||
[fieldId]=selectedField.id [entityName]="entityType" [fieldName]=[selectedField.id]
|
||||
[selectedValue]=selectedField.value [showSelected]=true
|
||||
[placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name"
|
||||
[multipleSelections]=false (selectedValueChanged)="valueChanged($event,i)"
|
||||
(listUpdated)="listUpdated($event,selectedField.id)"></static-autocomplete>
|
||||
</td>
|
||||
<td *ngIf="selectedField.type == 'entity'">
|
||||
<entities-autocomplete [(properties)]=properties [fieldId]=selectedField.id [entityType]=selectedField.param
|
||||
[selectedValue]=selectedField.value [showSelected]=true
|
||||
[placeHolderMessage]="'Search for '+selectedField.name" [title]="selectedField.name"
|
||||
[multipleSelections]=false
|
||||
(selectedValueChanged)="valueChanged($event,i)"
|
||||
(listUpdated)="listUpdated($event,selectedField.id)">
|
||||
</entities-autocomplete>
|
||||
</td>
|
||||
|
||||
<td *ngIf = "selectedField.type == 'boolean'" class="input-group" >
|
||||
<td *ngIf="selectedField.type == 'boolean'" class="input-group">
|
||||
<span class="input-group-addon">
|
||||
<input type="radio" [(ngModel)]="selectedField.value" [name]=selectedField.param value="true">Yes<br>
|
||||
<input type="radio" [(ngModel)]="selectedField.value" [name]=selectedField.param
|
||||
value="true">Yes<br>
|
||||
</span>
|
||||
<span class="input-group-addon">
|
||||
<input type="radio" [(ngModel)]="selectedField.value" [name]=selectedField.param value="false">No<br>
|
||||
<span class="input-group-addon">
|
||||
<input type="radio" [(ngModel)]="selectedField.value" [name]=selectedField.param
|
||||
value="false">No<br>
|
||||
</span>
|
||||
</td>
|
||||
<td class=" " >
|
||||
<span *ngIf="selectedFields.length > 1" type="button" class="uk-icon-button icon-button-small" (click)="removeField(i)">
|
||||
<span class=""><svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="minus" ratio="0.8"><rect height="1" width="18" y="9" x="1"></rect></svg></span>
|
||||
</td>
|
||||
<td class=" ">
|
||||
<span type="button" class="uk-icon-button icon-button-small"
|
||||
(click)="removeField(i)">
|
||||
<span class=""><svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
|
||||
icon="minus" ratio="0.8"><rect height="1" width="18" y="9"
|
||||
x="1"></rect></svg></span>
|
||||
</span>
|
||||
<span *ngIf="selectedFields.length == 1" type="button" class="uk-icon-button icon-button-small" disabled>
|
||||
<span class="uk-icon">
|
||||
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="minus" ratio="0.8"><rect height="1" width="18" y="9" x="1"></rect></svg>
|
||||
</span>
|
||||
</span>
|
||||
<span *ngIf="i == selectedFields.length-1 " type="button" class="uk-icon-button icon-button-small" (click)="addField()">
|
||||
<!-- <span *ngIf="selectedFields.length == 1" type="button" class="uk-icon-button icon-button-small" disabled>-->
|
||||
<!-- <span class="uk-icon">-->
|
||||
<!-- <svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="minus"-->
|
||||
<!-- ratio="0.8"><rect height="1" width="18" y="9" x="1"></rect></svg>-->
|
||||
<!-- </span>-->
|
||||
<!-- </span>-->
|
||||
<span *ngIf="i == selectedFields.length-1 " 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>
|
||||
<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>
|
||||
<div class=" uk-text-center">
|
||||
<div *ngIf="!validDateFrom && validDateTo" class="uk-text-danger">
|
||||
Please check your <u>from</u> date
|
||||
</div>
|
||||
<div *ngIf="!validDateTo && validDateFrom" class="uk-text-danger">
|
||||
Please check your <u>to</u> date
|
||||
</div>
|
||||
<div *ngIf="!validDateFrom && !validDateTo" class="uk-text-danger">
|
||||
Please check your dates
|
||||
</div>
|
||||
</tr>
|
||||
</table>
|
||||
<div class=" uk-text-center">
|
||||
<div *ngIf="!validDateFrom && validDateTo" class="uk-text-danger">
|
||||
Please check your <u>from</u> date
|
||||
</div>
|
||||
<div *ngIf="!validDateTo && validDateFrom" class="uk-text-danger">
|
||||
Please check your <u>to</u> date
|
||||
</div>
|
||||
<div *ngIf="!validDateFrom && !validDateTo" class="uk-text-danger">
|
||||
Please check your dates
|
||||
</div>
|
||||
|
||||
<button (click)="queryChanged()" type="submit"
|
||||
class=" uk-button uk-padding uk-padding-remove-top uk-padding-remove-bottom ">
|
||||
<span class="uk-icon" ><svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1.5"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg></span>
|
||||
</button>
|
||||
</div>
|
||||
<button (click)="queryChanged()" type="submit"
|
||||
class=" uk-button uk-padding uk-padding-remove-top uk-padding-remove-bottom ">
|
||||
<span class="uk-icon"><svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
|
||||
icon="search" ratio="1.5"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9"
|
||||
cy="9" r="7"></circle><path fill="none"
|
||||
stroke="#000"
|
||||
stroke-width="1.1"
|
||||
d="M14,14 L18,18 L14,14 Z"></path></svg></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="simpleView">
|
||||
<a routerLinkActive="router-link-active"
|
||||
[routerLink]="advancedSearchLink" style="z-index:1;" [queryParams]="advancedSearchLinkParameters"
|
||||
[class]="(isDisabled)?'uk-float-right uk-disabled uk-link-muted portal-link uk-margin-right ':'uk-float-right portal-link uk-margin-right '">Advanced search
|
||||
</a>
|
||||
<search-form [isDisabled]="isDisabled" [(keyword)]="selectedFields[0].value"
|
||||
(keywordChange)="simpleKeywordChanged($event)"
|
||||
[placeholderText]="formPlaceholderText"></search-form>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</form>
|
||||
|
|
|
@ -17,6 +17,10 @@ export class AdvancedSearchFormComponent {
|
|||
@Input() selectedFields:AdvancedField[];
|
||||
@Input() isDisabled: boolean = false;
|
||||
@Input() simpleSearchLink;
|
||||
@Input() advancedSearchLink;
|
||||
@Input() advancedSearchLinkParameters;
|
||||
@Input() simpleView:boolean = false;
|
||||
@Input() formPlaceholderText = "Type Keywords...";
|
||||
@Input() pageTitle;
|
||||
@Output() queryChange = new EventEmitter();
|
||||
|
||||
|
@ -44,7 +48,10 @@ properties:EnvProperties;
|
|||
this.newFieldId = this.fieldIds[0];
|
||||
this.newFieldName = this.fieldIdsMap[this.newFieldId].name;
|
||||
}
|
||||
|
||||
simpleKeywordChanged($event){
|
||||
this.selectedFields[0].value = $event.value;
|
||||
this.queryChanged();
|
||||
}
|
||||
queryChanged() {
|
||||
this.validDateFrom = true;
|
||||
this.validDateTo = true;
|
||||
|
@ -68,9 +75,7 @@ properties:EnvProperties;
|
|||
//console.info("emit");
|
||||
|
||||
this.queryChange.emit({
|
||||
// selectedFields: this.selectedFields,
|
||||
// selectedQuantifiers: this.selectedQuantifiers,
|
||||
// keywords: this.keywords
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +92,11 @@ properties:EnvProperties;
|
|||
}
|
||||
|
||||
removeField(index: number) {
|
||||
if(this.selectedFields.length == 1){
|
||||
this.selectedFields[index] = new AdvancedField(this.newFieldId,this.fieldIdsMap[this.newFieldId].param, this.fieldIdsMap[this.newFieldId].name, this.fieldIdsMap[this.newFieldId].type, "", "and");
|
||||
}else{
|
||||
this.selectedFields.splice(index, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fieldOperatorChanged(index: number, operatorId: string, operatorName: string) {
|
||||
|
|
|
@ -7,11 +7,12 @@ import{AdvancedSearchFormComponent} from './advancedSearchForm.component';
|
|||
import {EntitiesAutocompleteModule} from '../../utils/entitiesAutoComplete/entitiesAutoComplete.module';
|
||||
import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module';
|
||||
import {DateFilterModule} from './dateFilter.module';
|
||||
import{SearchFormModule} from './searchForm.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, RouterModule, EntitiesAutocompleteModule, StaticAutocompleteModule, DateFilterModule
|
||||
CommonModule, FormsModule, RouterModule, EntitiesAutocompleteModule, StaticAutocompleteModule, DateFilterModule, SearchFormModule
|
||||
],
|
||||
declarations: [
|
||||
AdvancedSearchFormComponent,
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
|
||||
<div class="image-front-topbar uk-section-default uk-position-relative" uk-scrollspy="{"target":"[uk-scrollspy-class]","cls":"uk-animation-fade","delay":false}" tm-header-transparent="light">
|
||||
<div style="box-sizing: border-box; " [class]="' uk-background-norepeat uk-background-cover uk-background-bottom-center uk-section uk-padding-remove-bottom uk-flex uk-flex-middle uk-background-fixed advancedSearchFormBackground '+searchFormClass">
|
||||
<div class="uk-position-cover" style="/*background-color: rgba(255, 255, 255, 0.37);*/"></div>
|
||||
<div class="uk-width-1-1">
|
||||
<div class="uk-position-relative">
|
||||
<div class="uk-container uk-margin-large-top">
|
||||
<advanced-search-form
|
||||
[entityType] = "entityType"
|
||||
[(fieldIds)]="fieldIds"
|
||||
[(fieldIdsMap)]="fieldIdsMap"
|
||||
[(selectedFields)]="selectedFields"
|
||||
(queryChange)="queryChanged($event)"
|
||||
[isDisabled]="disableForms"
|
||||
[simpleSearchLink]="simpleSearchLink"
|
||||
[advancedSearchLink]="advancedSearchLink"
|
||||
[advancedSearchLinkParameters]
|
||||
="this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)"
|
||||
[pageTitle]=pageTitle [simpleView]="simpleView" [formPlaceholderText]="formPlaceholderText"
|
||||
>
|
||||
</advanced-search-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<schema2jsonld *ngIf="url" [URL]="url" type="search" [name]=pageTitle [searchAction]=false></schema2jsonld>
|
||||
|
||||
|
||||
|
||||
<div id="tm-main" class=" tm-middle">
|
||||
<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="uk-container">
|
||||
<div>
|
||||
|
||||
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper>
|
||||
<div [class]="(showRefine)? 'uk-width-4-5@m uk-width-4-5@l uk-width-1-1@s' :'uk-width-1-1'">
|
||||
<div *ngIf="showRefine" class="uk-offcanvas-content uk-hidden@m">
|
||||
|
||||
<a href="#offcanvas-usage" uk-toggle><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"><rect x="6" y="4" width="12" height="1"></rect><rect x="6" y="9" width="12" height="1"></rect><rect x="6" y="14" width="12" height="1"></rect><rect x="2" y="4" width="2" height="1"></rect><rect x="2" y="9" width="2" height="1"></rect><rect x="2" y="14" width="2" height="1"></rect></svg></a>
|
||||
|
||||
<div id="offcanvas-usage" uk-offcanvas>
|
||||
<div class="uk-offcanvas-bar">
|
||||
<button class="uk-offcanvas-close" type="button" uk-close></button>
|
||||
<div class="uk-width-1-1 uk-margin-small-bottom uk-margin-top">
|
||||
|
||||
<span *ngIf="tableViewLink || mapUrl" class="uk-width-expand">
|
||||
<span *ngIf="tableViewLink">
|
||||
<a uk-tooltip="title: Table view" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-disabled uk-link-muted':''" [routerLink]=tableViewLink >
|
||||
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"><rect x="2" y="2" width="3" height="3"></rect><rect x="8" y="2" width="3" height="3"></rect><rect x="14" y="2" width="3" height="3"></rect><rect x="2" y="8" width="3" height="3"></rect><rect x="8" y="8" width="3" height="3"></rect><rect x="14" y="8" width="3" height="3"></rect><rect x="2" y="14" width="3" height="3"></rect><rect x="8" y="14" width="3" height="3"></rect><rect x="14" y="14" width="3" height="3"></rect></svg></span>
|
||||
</a>
|
||||
<span uk-tooltip="title: List view" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="table" ratio="1"><rect x="1" y="3" width="18" height="1"></rect><rect x="1" y="7" width="18" height="1"></rect><rect x="1" y="11" width="18" height="1"></rect><rect x="1" y="15" width="18" height="1"></rect></svg></span>
|
||||
</span>
|
||||
<search-dataprovider-map *ngIf= "!showUnknownFilters" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [mapUrl]="mapUrl" [mapTooltipType]="mapTooltipType"></search-dataprovider-map>
|
||||
</span>
|
||||
<search-download *ngIf= "!showUnknownFilters && searchUtils.totalResults > 0 && ( entityType !=
|
||||
'community' && entityType != 'funder') && usedBy == 'search'"
|
||||
class="uk-width-1-2" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults">
|
||||
</search-download>
|
||||
|
||||
<div *ngIf="countFilters()>0" class="uk-margin-small-bottom">
|
||||
<div class="uk-grid uk-margin-bottom uk-margin-top">
|
||||
<span class="uk-text-bold uk-text-large">Filters</span>
|
||||
<a *ngIf="countFilters()>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'">
|
||||
Clear All
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<span *ngIf = "searchUtils.keyword.length > 0"><span class="uk-text-bold">Keywords:</span>
|
||||
<a (click) = "clearKeywords() " title="Remove keywords" [class]="((disableForms)?' uk-disabled':' ')+' uk-margin-small-right portal-color '"><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.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
||||
</span></span></a>
|
||||
<span [innerHtml]="searchUtils.keyword"></span>
|
||||
|
||||
</span>
|
||||
<div *ngFor="let filter of filters " >
|
||||
<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; " >
|
||||
<a [title]="'Remove '+value.name"(click) = "removeFilter(value, filter) " [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><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.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
||||
</span></span></a>
|
||||
<span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name" [title]="value.name"></span><span *ngIf="!end" class=" ">, </span>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="uk-margin-small-bottom uk-margin-small-top uk-grid">
|
||||
<a *ngIf= "showUnknownFilters" class = " portal-link" (click) = "clearFilters() " >Try new Query</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div *ngIf="filters.length === 0 && searchUtils.keyword.length === 0 && results.length > 0" class="uk-margin-top">
|
||||
<span class="uk-text-meta">No filters available</span>
|
||||
</div>
|
||||
<div class="uk-text-large">Filter By:</div>
|
||||
<search-filter *ngFor="let filter of filters " [addShowMore]=false [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-1-1 uk-grid helper-grid uk-padding-large uk-padding-remove-top" >
|
||||
<div *ngIf="showRefine" class="uk-margin-top uk-width-1-4@m search-filters uk-visible@m">
|
||||
<!-- top: #container-1; bottom: #true; -->
|
||||
<!-- <div id="container-1" style="z-index: -1;" uk-sticky="top: #container-1; offset: 120; "> -->
|
||||
<span *ngIf="tableViewLink || mapUrl" class="uk-width-expand">
|
||||
<span *ngIf="tableViewLink">
|
||||
<a uk-tooltip="title: Table view" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-disabled uk-link-muted':''" [routerLink]=tableViewLink >
|
||||
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"><rect x="2" y="2" width="3" height="3"></rect><rect x="8" y="2" width="3" height="3"></rect><rect x="14" y="2" width="3" height="3"></rect><rect x="2" y="8" width="3" height="3"></rect><rect x="8" y="8" width="3" height="3"></rect><rect x="14" y="8" width="3" height="3"></rect><rect x="2" y="14" width="3" height="3"></rect><rect x="8" y="14" width="3" height="3"></rect><rect x="14" y="14" width="3" height="3"></rect></svg></span>
|
||||
</a>
|
||||
<span uk-tooltip="title: List view" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="table" ratio="1"><rect x="1" y="3" width="18" height="1"></rect><rect x="1" y="7" width="18" height="1"></rect><rect x="1" y="11" width="18" height="1"></rect><rect x="1" y="15" width="18" height="1"></rect></svg></span>
|
||||
</span>
|
||||
<search-dataprovider-map *ngIf= "!showUnknownFilters" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [mapUrl]="mapUrl" [mapTooltipType]="mapTooltipType"></search-dataprovider-map>
|
||||
</span>
|
||||
<search-download *ngIf= "!showUnknownFilters && searchUtils.totalResults > 0 && ( entityType !=
|
||||
'community' && entityType != 'funder') && usedBy == 'search'"
|
||||
class="uk-width-1-2" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults">
|
||||
</search-download>
|
||||
|
||||
<div class="uk-width-1-1 uk-margin-small-bottom ">
|
||||
<div class="uk-grid uk-margin-bottom uk-margin-top">
|
||||
<span class="uk-text-bold uk-text-large">Filters</span>
|
||||
<a *ngIf="countFilters()>1" (click)="clearFilters()" [class]="((disableForms)?'uk-disabled uk-link-muted':'')+' portal-link ' + 'uk-width-1-2'">
|
||||
Clear All
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div *ngIf="countFilters()>0" class="uk-margin-small-bottom">
|
||||
|
||||
<span *ngIf = "searchUtils.keyword.length > 0"><span class="uk-text-bold">Keywords:</span>
|
||||
<a (click) = "clearKeywords() " title="Remove keywords" [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><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.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
||||
</span></span></a>
|
||||
<span [innerHtml]="searchUtils.keyword"></span>
|
||||
|
||||
</span>
|
||||
<div *ngFor="let filter of filters " >
|
||||
<span *ngIf = "filter.countSelectedValues > 0"> <span class="uk-text-bold">{{filter.title}}:</span>
|
||||
<label *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; "
|
||||
[title]="'Remove '+value.name" (click) = "removeFilter(value, filter) ">
|
||||
<a [class]="((disableForms)?' uk-disabled':' ')+' portal-color '"><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.6" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.6" d="M16,4 L4,16"></path></svg>
|
||||
</span></span>
|
||||
</a>
|
||||
<span [innerHtml]="(value.name.length > 25)?value.name.substring(0,25)+'...':value.name"></span><span *ngIf="!end" class=" ">, </span>
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-margin-small-bottom uk-margin-small-top uk-grid">
|
||||
<a *ngIf= "showUnknownFilters" class = " portal-link" (click) = "clearFilters() " >Try new Query</a>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="filters.length === 0 && searchUtils.keyword.length === 0 && results.length > 0" class="uk-margin-top">
|
||||
<span class="uk-text-meta">No filters available</span>
|
||||
</div>
|
||||
<search-filter *ngFor="let filter of filters " [filterValuesNum]="filterValuesNum" [showMoreInline]="showMoreFilterValuesInline" [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (onFilterChange)="filterChanged($event)" ></search-filter>
|
||||
</div>
|
||||
<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 class="uk-align-center uk-margin-remove-bottom">
|
||||
<div *ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)"
|
||||
class="uk-grid uk-margin-top uk-margin-bottom">
|
||||
<search-results-per-page class="uk-width-1-2@m uk-width-1-1" [(size)]="searchUtils.size" (sizeChange)="sizeChanged($event)"></search-results-per-page>
|
||||
<search-sorting class="uk-width-1-2@m uk-width-1-1" *ngIf="sort" [(sortBy)]="searchUtils.sortBy" (sortByChange)="sortByChanged($event)"></search-sorting>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<div *ngIf="(searchUtils.page <= pagingLimit)" class="">
|
||||
<search-result [results]="results"
|
||||
[status]=searchUtils.status
|
||||
[type]="entityType"
|
||||
[showLoading]="true" [(properties)]=properties>
|
||||
</search-result>
|
||||
</div>
|
||||
|
||||
<div [class]="searchUtils.page > pagingLimit ? 'search-results' : ''" *ngIf="(searchUtils.page >= pagingLimit) && (searchUtils.totalResults > searchUtils.size*pagingLimit)">
|
||||
<p class="uk-alert-warning" uk-alert>For more results please try a new, more specific query</p>
|
||||
</div>
|
||||
|
||||
<div class="uk-align-center uk-margin-remove-bottom">
|
||||
<div *ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)"
|
||||
class="uk-grid uk-margin-top uk-margin-bottom">
|
||||
<search-results-per-page class="uk-width-1-2@m uk-width-1-1" [(size)]="searchUtils.size" (sizeChange)="sizeChanged($event)"></search-results-per-page>
|
||||
<search-sorting class="uk-width-1-2@m uk-width-1-1" *ngIf="sort" [(sortBy)]="searchUtils.sortBy" (sortByChange)="sortByChanged($event)"></search-sorting>
|
||||
</div>
|
||||
<search-paging [type]="type" [loadPaging]="loadPaging" [oldTotalResults]="oldTotalResults" [(searchUtils)] = "searchUtils" [(results)] = "results" [(baseUrl)] = "searchUtils.baseUrl" [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues" ></search-paging>
|
||||
</div>
|
||||
|
||||
<a *ngIf="properties.showLastIndexInformationLink" class="last_index_info uk-button-text"
|
||||
[href]="properties.lastIndexInformationLink" target="_blank">
|
||||
Last index information
|
||||
</a>
|
||||
</div>
|
||||
<!-- <div class="uk-visible@m uk-margin-top uk-width-1-5">-->
|
||||
<!-- <search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" ></search-download>-->
|
||||
<!-- </div>-->
|
||||
<!-- <helper *ngIf="searchUtils.totalResults > csvLimit" class="uk-margin-top helper-left-right uk-visible@m" position="right"></helper> -->
|
||||
</div>
|
||||
|
||||
<helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0" [texts]="pageContents['bottom']"></helper>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,699 @@
|
|||
import {Component, Input, ViewChild} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
|
||||
import {AdvancedField, Filter, Value} from './searchHelperClasses.class';
|
||||
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class';
|
||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||
import {Dates, DOI, StringUtils} from '../../utils/string-utils.class';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||
|
||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {SEOService} from '../../sharedComponents/SEO/SEO.service';
|
||||
import {HelperService} from "../../utils/helper/helper.service";
|
||||
import {SearchFields} from "../../utils/properties/searchFields";
|
||||
|
||||
@Component({
|
||||
selector: 'new-search-page',
|
||||
templateUrl: 'newSearchPage.component.html'
|
||||
})
|
||||
export class NewSearchPageComponent {
|
||||
@Input() piwikSiteId = null;
|
||||
@Input() hasPrefix: boolean = true;
|
||||
@Input() pageTitle = "";
|
||||
@Input() results = [];
|
||||
@Input() type;
|
||||
@Input() entityType;
|
||||
@Input() searchUtils: SearchUtilsClass = new SearchUtilsClass();
|
||||
@Input() fieldIds: string[];
|
||||
@Input() fieldIdsMap;//:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ;
|
||||
@Input() selectedFields: AdvancedField[];
|
||||
@ViewChild(ModalLoading) loading: ModalLoading;
|
||||
@Input() csvParams: string;
|
||||
@Input() csvPath: string;
|
||||
@Input() simpleSearchLink: string = "";
|
||||
@Input() advancedSearchLink: string = "";
|
||||
@Input() disableForms: boolean = false;
|
||||
@Input() loadPaging: boolean = true;
|
||||
@Input() oldTotalResults: number = 0;
|
||||
@Input() openaireLink: string;
|
||||
@Input() customFilter: SearchCustomFilter = null;
|
||||
@Input() sort: boolean = false;
|
||||
@Input() searchFormClass: string = "searchForm";
|
||||
//From simple:
|
||||
@Input() refineFields = [];
|
||||
@Input() filters = [];
|
||||
private queryParameters: Map<string, string> = new Map<string, string>();
|
||||
private searchFieldsHelper: SearchFields = new SearchFields();
|
||||
@Input() newQueryButton: boolean = true;
|
||||
public showUnknownFilters: boolean = false; // when a filter exists in query but has no results, so no filters returned from the query
|
||||
@Input() showRefine: boolean = true;
|
||||
@Input() tableViewLink: string;
|
||||
@Input() mapUrl: string = "";
|
||||
@Input() usedBy: string = "search";
|
||||
@Input() showResultCount: boolean = true;
|
||||
@Input() showMoreFilterValuesInline: boolean = false;
|
||||
@Input() filterValuesNum: number = 5;
|
||||
@Input() keywordFields = [];
|
||||
@Input() simpleView: boolean = true;
|
||||
@Input() formPlaceholderText = "Type Keywords...";
|
||||
|
||||
piwiksub: any;
|
||||
public parameterNames: string[] = [];
|
||||
public parameterValues: string[] = [];
|
||||
|
||||
public baseURLWithParameters: string = '';
|
||||
|
||||
public csvLimit: number = 0;
|
||||
public pagingLimit: number = 0;
|
||||
public resultsPerPage: number = 0;
|
||||
isPiwikEnabled = false;
|
||||
properties: EnvProperties;
|
||||
public pageContents = null;
|
||||
public divContents = null;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
public errorCodes: ErrorCodes = new ErrorCodes();
|
||||
|
||||
url = null;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private location: Location,
|
||||
private _meta: Meta,
|
||||
private _title: Title,
|
||||
private _piwikService: PiwikService,
|
||||
private router: Router,
|
||||
private seoService: SEOService,
|
||||
private helper: HelperService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
//this.getDivContents();
|
||||
this.getPageContents();
|
||||
this.pagingLimit = data.envSpecific.pagingLimit;
|
||||
this.resultsPerPage = data.envSpecific.resultsPerPage;
|
||||
this.csvLimit = data.envSpecific.csvLimit;
|
||||
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
||||
if (typeof window !== 'undefined') {
|
||||
this.updateUrl(data.envSpecific.baseLink + location.pathname);
|
||||
this.url = data.envSpecific.baseLink + location.pathname
|
||||
}
|
||||
if (typeof document !== 'undefined' && this.isPiwikEnabled) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
|
||||
}
|
||||
});
|
||||
|
||||
var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.pageTitle;
|
||||
|
||||
this.updateTitle(this.pageTitle);
|
||||
this.updateDescription(description);
|
||||
|
||||
this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl;
|
||||
|
||||
this.updateBaseUrlWithParameters();
|
||||
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() {
|
||||
if (this.piwiksub) {
|
||||
this.piwiksub.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
updateDescription(description: string) {
|
||||
this._meta.updateTag({content: description}, "name='description'");
|
||||
this._meta.updateTag({content: description}, "property='og:description'");
|
||||
}
|
||||
|
||||
updateTitle(title: string) {
|
||||
var _prefix = "";
|
||||
if (this.hasPrefix) {
|
||||
_prefix = "OpenAIRE | ";
|
||||
}
|
||||
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
|
||||
this._title.setTitle(_title);
|
||||
this._meta.updateTag({content: _title}, "property='og:title'");
|
||||
}
|
||||
|
||||
updateUrl(url: string) {
|
||||
this._meta.updateTag({content: url}, "property='og:url'");
|
||||
}
|
||||
|
||||
|
||||
clearFilters() {
|
||||
for (var i = 0; i < this.filters.length; i++) {
|
||||
for (var j = 0; j < this.filters[i].countSelectedValues; j++) {
|
||||
if (this.filters[i].values[j].selected) {
|
||||
this.filters[i].values[j].selected = false;
|
||||
}
|
||||
this.filters[i].countSelectedValues = 0;
|
||||
}
|
||||
}
|
||||
this.goTo(1);
|
||||
// this.clearKeywords();
|
||||
}
|
||||
|
||||
goTo(page: number = 1) {
|
||||
this.searchUtils.page = page;
|
||||
this.buildPageURLParameters(true);
|
||||
this.router.navigate([this.searchUtils.baseUrl], {queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)});
|
||||
/* Code For Piwik*/
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
//console.log("In PreviousRouteRecorder : "+this.router.url );
|
||||
localStorage.setItem('previousRoute', this.router.url);
|
||||
}
|
||||
if (this.isPiwikEnabled && (typeof document !== 'undefined')) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
|
||||
}
|
||||
/* End Piwik Code */
|
||||
}
|
||||
|
||||
queryChanged($event) {
|
||||
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
pageChanged($event) {
|
||||
this.searchUtils.page = +$event.value;
|
||||
this.goTo(this.searchUtils.page);
|
||||
}
|
||||
|
||||
sizeChanged($event) {
|
||||
this.searchUtils.size = $event.value;
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
sortByChanged($event) {
|
||||
this.searchUtils.sortBy = $event.value;
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the url with proper parameters. This is used as base url in Paging Component
|
||||
*/
|
||||
public updateBaseUrlWithParameters() {
|
||||
this.baseURLWithParameters = this.searchUtils.baseUrl + this.buildPageURLParameters(false);
|
||||
}
|
||||
|
||||
getOperatorParameter(parameter: string): string {
|
||||
for (let id of this.fieldIds) {
|
||||
if (this.fieldIdsMap[id]["param"] == parameter) {
|
||||
return this.fieldIdsMap[id]["operator"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get A sub-array of this.refineFields array, which contains the ids of the selected filters
|
||||
*/
|
||||
public getSelectedFilters(): string[] {
|
||||
var selected: string[] = [];
|
||||
for (var i = 0; i < this.filters.length; i++) {
|
||||
var filter: Filter = this.filters[i];
|
||||
if (filter.countSelectedValues > 0) {
|
||||
selected.push(filter.filterId);
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get A sub-array of this.refineFields array, which contains the ids of the selected parameters
|
||||
*/
|
||||
private getSelectedParameters(): string[] {
|
||||
var selected: string[] = [];
|
||||
var params: string[] = Object.keys(this.queryParameters);
|
||||
|
||||
for (var i = 0; i < this.refineFields.length; i++) {
|
||||
if (this.queryParameters.get(this.refineFields[i]) != undefined) {
|
||||
selected.push(this.refineFields[i]);
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get A sub-array of this.refineFields array, which hides hidden fields (e.g Funding level 0,1,2,..), and contains those that depend on another fields (e.g Funding level 0 if Funder is selected )
|
||||
*/
|
||||
public getFields(): string[] {
|
||||
var selected_filters: string[] = this.getSelectedFilters();
|
||||
if (selected_filters.length == 0) {
|
||||
selected_filters = this.getSelectedParameters();
|
||||
}
|
||||
var fields: string[] = [];
|
||||
for (var i = 0; i < this.refineFields.length; i++) {
|
||||
var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]];
|
||||
|
||||
//if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected
|
||||
if (this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 || (selected_filters.indexOf(dependentTo) != -1) || (selected_filters.indexOf(this.refineFields[i]) != -1)) {
|
||||
fields.push(this.refineFields[i]);
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a query string of all fields, that want to get from search (e.g. &fields=funderid&fields=projectstartyear&...))
|
||||
*/
|
||||
public getRefineFieldsQuery(): string {
|
||||
|
||||
var fields: string[] = this.getFields();
|
||||
var fieldsStr = ""
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
fieldsStr += "&fields=" + fields[i];
|
||||
}
|
||||
return "&refine=true" + fieldsStr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Mark as check the new filters that are selected, when you get them from search
|
||||
*/
|
||||
public checkSelectedFilters(filters: Filter[]) {
|
||||
this.filters = filters;
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
var filter: Filter = filters[i];
|
||||
filter.countSelectedValues = 0;
|
||||
if (this.queryParameters.get(filter.filterId) != undefined) {
|
||||
let values = (decodeURIComponent(this.queryParameters.get(filter.filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
for (let filterValue of filter.values) {
|
||||
if (values.indexOf(StringUtils.quote(filterValue.id)) > -1) {
|
||||
filterValue.selected = true;
|
||||
filter.countSelectedValues++;
|
||||
} else {
|
||||
filterValue.selected = false;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let filterValue of filter.values) {
|
||||
filterValue.selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.filterFilterValues(this.filters);
|
||||
return filters;
|
||||
}
|
||||
|
||||
/*
|
||||
* For Funder filters - if funder selected
|
||||
*/
|
||||
public filterFilterValues(filters: Filter[]) {
|
||||
var funders = [];
|
||||
var funder_prefix = [];
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
|
||||
var filter: Filter = filters[i];
|
||||
// console.log(filter.filterId);
|
||||
if (filter.filterId.indexOf("funder") != -1 && this.queryParameters.get(filter.filterId) != undefined) {
|
||||
let funders = (decodeURIComponent(this.queryParameters.get(filter.filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
for (let funder of funders) {
|
||||
funder_prefix.push(StringUtils.unquote(funder).split("____")[0]);
|
||||
}
|
||||
// console.log(funder_prefix );
|
||||
} else if (filter.filterId.indexOf("funding") != -1) {
|
||||
// console.log(" funding: "+filter.filterId );
|
||||
var filteredValues = []
|
||||
for (let filterValue of filter.values) {
|
||||
var value_prefix = filterValue.id.split("____")[0];
|
||||
// console.log("Value prefix: "+value_prefix );
|
||||
if (funder_prefix.indexOf(value_prefix) != -1) {
|
||||
// console.log("here" + value_prefix);
|
||||
filteredValues.push(filterValue);
|
||||
}
|
||||
|
||||
}
|
||||
if (filteredValues.length > 0) {
|
||||
filter.values = filteredValues;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
public countFilters(): number {
|
||||
var filters = 0;
|
||||
this.showUnknownFilters = false;
|
||||
for (let filter of this.filters) {
|
||||
if (filter.countSelectedValues > 0) {
|
||||
filters += filter.countSelectedValues;
|
||||
}
|
||||
}
|
||||
if (this.searchUtils.keyword.length > 0) {
|
||||
filters++;
|
||||
}
|
||||
var errorCodes: ErrorCodes = new ErrorCodes();
|
||||
if (this.queryParameters.keys() && this.searchUtils.totalResults == 0 && this.searchUtils.status != errorCodes.LOADING) {
|
||||
if (this.newQueryButton) {
|
||||
this.showUnknownFilters = true;
|
||||
}
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
private clearKeywords() {
|
||||
if (this.searchUtils.keyword.length > 0) {
|
||||
this.searchUtils.keyword = '';
|
||||
}
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
private removeFilter(value: Value, filter: Filter) {
|
||||
filter.countSelectedValues--;
|
||||
if (value.selected == true) {
|
||||
value.selected = false;
|
||||
}
|
||||
this.goTo(1);
|
||||
|
||||
}
|
||||
|
||||
getSelectedValues(filter): any {
|
||||
var selected = [];
|
||||
if (filter.countSelectedValues > 0) {
|
||||
for (var i = 0; i < filter.values.length; i++) {
|
||||
if (filter.values[i].selected) {
|
||||
selected.push(filter.values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
|
||||
}
|
||||
|
||||
filterChanged($event) {
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
// for loading
|
||||
public openLoading() {
|
||||
this.loading.open();
|
||||
}
|
||||
|
||||
public closeLoading() {
|
||||
this.loading.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build advanced search Filters based on the URL parameters
|
||||
* @param params
|
||||
*/
|
||||
createAdvancedSearchSelectedFiltersFromURLParameters(params) {
|
||||
for (var i = 0; i < this.fieldIds.length; i++) {
|
||||
|
||||
var fieldId = this.fieldIds[i];
|
||||
var fieldparam = (this.fieldIdsMap[fieldId]) ? this.fieldIdsMap[fieldId].param : "";
|
||||
if (!this.fieldIdsMap[fieldId]) {
|
||||
|
||||
console.error("Field: " + fieldId + " not found in fieldIds map");
|
||||
}
|
||||
|
||||
var operatorId = this.getOperatorParameter(fieldparam);
|
||||
if (params[fieldparam] != undefined && params[operatorId] != undefined) {
|
||||
var values: string [] = StringUtils.URIDecode(params[fieldparam]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
var operators: string [] = (StringUtils.URIDecode(params[operatorId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
if (values.length == operators.length) {
|
||||
for (var j = 0; j < values.length; j++) {
|
||||
if (this.fieldIdsMap[fieldId].type == "date") {
|
||||
var value: string = StringUtils.unquote(values[j]);
|
||||
var validDates: boolean = true;
|
||||
var dateField: AdvancedField = new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, value, operators[j]);
|
||||
if (value.indexOf("range") != -1) {
|
||||
dateField.dateValue.type = "range";
|
||||
if (value.length < 26) {
|
||||
validDates = false;
|
||||
} else {
|
||||
if (!Dates.isValidDate(value.substring(5, 15)) || !Dates.isValidDate(value.substring(16, 26))) {
|
||||
validDates = false;
|
||||
} else {
|
||||
dateField.dateValue.from = Dates.getDateFromString(value.substring(5, 15));
|
||||
dateField.dateValue.to = Dates.getDateFromString(value.substring(16, 26));
|
||||
}
|
||||
}
|
||||
// "rangeYYYY-MM-DD:YYYY-MM-DD"
|
||||
} else {
|
||||
dateField.dateValue.setDatesByType(value);
|
||||
}
|
||||
if (validDates) {
|
||||
this.selectedFields.push(dateField);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.selectedFields.push(new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, StringUtils.unquote(values[j]), operators[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params['keyword'] && params['keyword'].length > 0) {
|
||||
this.selectedFields.push(new AdvancedField(this.fieldIds[0], this.fieldIdsMap[this.fieldIds[0]].param, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, params['keyword'], "and"));
|
||||
}
|
||||
if (this.selectedFields.length == 0) {
|
||||
this.selectedFields.push(new AdvancedField(this.fieldIds[0], this.fieldIdsMap[this.fieldIds[0]].param, this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type, "", "and"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Search API query based on the selected fields of the advanced form
|
||||
*/
|
||||
getSearchAPIQueryForAdvancedSearhFields() {
|
||||
|
||||
var params = "";
|
||||
var countParams = 0;
|
||||
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")) {
|
||||
//console.log("createQueryParameters::"+this.selectedFields[i].type);
|
||||
if (this.selectedFields[i].type == "date") {
|
||||
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)) + " "
|
||||
+ StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.to)) + '"' + " ";
|
||||
}
|
||||
} else {
|
||||
if (this.selectedFields[i].id == "q") {
|
||||
var op = "";
|
||||
var doisParams = "";
|
||||
if ((this.type == 'publications' || this.type == 'research data' || this.type == 'software' || this.type == 'other research products')) { //
|
||||
var DOIs: string[] = DOI.getDOIsFromString(this.selectedFields[i].value);
|
||||
for (var i = 0; i < DOIs.length; i++) {
|
||||
doisParams += (doisParams.length > 0 ? " or " : "") + 'pid="' + DOIs[i] + '"';
|
||||
}
|
||||
}
|
||||
if (doisParams.length > 0) {
|
||||
params += doisParams;
|
||||
} else {
|
||||
//Remove quotes from keyword search
|
||||
// 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) + " ";
|
||||
}
|
||||
// params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
|
||||
} else if (countParams == 0 && this.selectedFields[i].operatorId == "not") {
|
||||
params += " " + this.selectedFields[i].id + " <> " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " ";
|
||||
} else {
|
||||
params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " ") + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator + '"' + encodeURIComponent(this.selectedFields[i].value) + '"' + " ";
|
||||
|
||||
}
|
||||
}
|
||||
countParams++;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.customFilter) {
|
||||
params += (countParams == 0 ? "" : " and ") + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId));
|
||||
}
|
||||
console.log(params);
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Search API query based on the filters of refine fields
|
||||
* @param URLparams
|
||||
*/
|
||||
getSearchAPIQueryForRefineFields(URLparams) {
|
||||
|
||||
var allFqs = "";
|
||||
|
||||
this.queryParameters = new Map<string, string>();
|
||||
for (var i = 0; i < this.refineFields.length; i++) {
|
||||
var filterId = this.refineFields[i];
|
||||
|
||||
if (URLparams[filterId] != undefined) {
|
||||
this.queryParameters.set(filterId, StringUtils.URIDecode(URLparams[filterId]));
|
||||
let values = (StringUtils.URIDecode(this.queryParameters.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
var countvalues = 0;
|
||||
var fq = "";
|
||||
let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId);
|
||||
console.info(filterId, filterOp);
|
||||
for (let value of values) {
|
||||
countvalues++;
|
||||
var paramId = this.fieldIdsMap[filterId].param;
|
||||
// parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or");
|
||||
fq += (fq.length > 0 ? " " + filterOp + " " : "") + filterId + " exact " + (value);
|
||||
}
|
||||
if (countvalues > 0) {
|
||||
fq = "&fq=" + StringUtils.URIEncode(fq);
|
||||
}
|
||||
allFqs += fq;
|
||||
}
|
||||
}
|
||||
if (this.customFilter) {
|
||||
allFqs += "&fq=" + StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId)));
|
||||
}
|
||||
|
||||
// var keyword = URLparams['keyword'];
|
||||
// var doiQuery = "";
|
||||
// var keywordQuery = "";
|
||||
// if((keyword && keyword.length > 0)){
|
||||
// if((this.type == 'publications' ||this.type == 'research data' || this.type == 'software' || this.type == 'other research products')){
|
||||
// var DOIs:string[] = DOI.getDOIsFromString(keyword);
|
||||
// var doisParams = "";
|
||||
//
|
||||
// for(var i =0 ;i < DOIs.length; i++){
|
||||
// doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"';
|
||||
// }
|
||||
// if(doisParams.length > 0){
|
||||
// doiQuery += "&"+doisParams;
|
||||
// }else {
|
||||
// keywordQuery += "&q="+StringUtils.URIEncode(keyword);
|
||||
// }
|
||||
// }else{
|
||||
// if(this.usedBy == "deposit") {
|
||||
// if(this.keywordFields.length > 0) {
|
||||
// keywordQuery = "&fq=";
|
||||
// }
|
||||
//
|
||||
// for(let i=0; i< this.keywordFields.length ; i++) {
|
||||
// if(i > 0) {
|
||||
// keywordQuery += " or ";
|
||||
// }
|
||||
// let field = this.keywordFields[i];
|
||||
// //keywordQuery += field.name+field.equalityOperator+StringUtils.URIEncode(keyword);
|
||||
// keywordQuery += field.name+field.equalityOperator+StringUtils.quote(StringUtils.URIEncode(keyword));
|
||||
// }
|
||||
// } else {
|
||||
// keywordQuery += "&q=" + StringUtils.URIEncode(keyword);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//TODO add DOI?
|
||||
return allFqs;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
buildPageURLParameters(includePage: boolean) {
|
||||
var params = "";
|
||||
this.parameterNames.splice(0, this.parameterNames.length);
|
||||
this.parameterValues.splice(0, this.parameterValues.length);
|
||||
var fields: { [key: string]: { values: string[], operators: string[] } } = {};
|
||||
for (var i = 0; i < this.selectedFields.length; i++) {
|
||||
if (this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value.length > 0 || this.selectedFields[i].type == "date")) {
|
||||
if (!fields[this.selectedFields[i].id]) {
|
||||
fields[this.selectedFields[i].id] = {values: [], operators: []};
|
||||
fields[this.selectedFields[i].id].values = [];
|
||||
fields[this.selectedFields[i].id].operators = [];
|
||||
}
|
||||
if (this.selectedFields[i].type == "date") {
|
||||
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))));
|
||||
} else {
|
||||
fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].dateValue.type)));
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < this.fieldIds.length; i++) {
|
||||
if (fields[this.fieldIds[i]]) {
|
||||
|
||||
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.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].param);
|
||||
this.parameterValues.push(fields[this.fieldIds[i]].values.join());
|
||||
this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].operator);
|
||||
this.parameterValues.push(fields[this.fieldIds[i]].operators.join());
|
||||
}
|
||||
}
|
||||
if (includePage && this.searchUtils.page != 1) {
|
||||
params += "&page=" + this.searchUtils.page;
|
||||
}
|
||||
|
||||
if (this.searchUtils.size != 10) {
|
||||
params += ((params.length == 0) ? '' : '&') + 'size=' + this.searchUtils.size;
|
||||
this.parameterNames.push("size");
|
||||
this.parameterValues.push("" + this.searchUtils.size);
|
||||
}
|
||||
|
||||
if (this.sort && this.searchUtils.sortBy) {
|
||||
params += ((params.length == 0) ? '' : '&') + 'sortBy=' + this.searchUtils.sortBy;
|
||||
this.parameterNames.push("sortBy");
|
||||
this.parameterValues.push(this.searchUtils.sortBy);
|
||||
}
|
||||
var allLimits = "";//location.search.slice(1);
|
||||
for (let filter of this.filters) {
|
||||
var filterLimits = "";
|
||||
if (filter.countSelectedValues > 0) {
|
||||
for (let value of filter.values) {
|
||||
if (value.selected == true) {
|
||||
filterLimits += ((filterLimits.length == 0) ? '' : ',') + '"' + (value.id) + '"';
|
||||
}
|
||||
}
|
||||
this.queryParameters.set(filter.filterId, filterLimits);
|
||||
if (filterLimits.length > 0) {
|
||||
this.parameterNames.push(filter.filterId);
|
||||
this.parameterValues.push(filterLimits);
|
||||
}
|
||||
allLimits += (allLimits.length == 0 ? "?" : "&") + ((filterLimits.length == 0) ? '' : filter.filterId + '=' + filterLimits);
|
||||
}
|
||||
}
|
||||
if (this.searchUtils.keyword.length > 0) {
|
||||
allLimits += (allLimits.length == 0 ? "?" : "&") + 'keyword=' + this.searchUtils.keyword;
|
||||
this.parameterNames.push("keyword");
|
||||
this.parameterValues.push(this.searchUtils.keyword);
|
||||
//this.parameterValues.push(StringUtils.quote(this.searchUtils.keyword));
|
||||
}
|
||||
if (this.searchUtils.page != 1 && includePage) {
|
||||
allLimits += ((allLimits.length == 0) ? '?' : '&') + 'page=' + this.searchUtils.page;
|
||||
}
|
||||
if (this.searchUtils.size != this.resultsPerPage) {
|
||||
allLimits += ((allLimits.length == 0) ? '?' : '&') + 'size=' + this.searchUtils.size;
|
||||
this.parameterNames.push("size");
|
||||
this.parameterValues.push("" + this.searchUtils.size);
|
||||
}
|
||||
if (this.sort && this.searchUtils.sortBy) {
|
||||
allLimits += ((allLimits.length == 0) ? '?' : '&') + 'sortBy=' + this.searchUtils.sortBy;
|
||||
this.parameterNames.push("sortBy");
|
||||
this.parameterValues.push(this.searchUtils.sortBy);
|
||||
}
|
||||
|
||||
|
||||
return params + allLimits;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import{NewSearchPageComponent} from './newSearchPage.component';
|
||||
import{SearchFormModule} from './searchForm.module';
|
||||
import {SearchFilterModule} from './searchFilter.module';
|
||||
import{LoadingModalModule} from '../../utils/modal/loadingModal.module';
|
||||
import {ReportsServiceModule} from '../../services/reportsService.module';
|
||||
import{SearchPagingModule} from './searchPaging.module';
|
||||
import {SearchResultsPerPageModule} from './searchResultsPerPage.module';
|
||||
import {SearchSortingModule} from './searchSorting.module';
|
||||
import {SearchDownloadModule} from './searchDownload.module';
|
||||
import {ModalModule} from '../../utils/modal/modal.module';
|
||||
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module';
|
||||
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard';
|
||||
import {HelperModule} from '../../utils/helper/helper.module';
|
||||
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
|
||||
import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module';
|
||||
import { SearchDataproviderMapModule } from './searchDataproviderMap.module';
|
||||
import {CommunitySearchResultsModule} from "./communitySearchResults.module";
|
||||
import {SearchResultsModule} from "./searchResults.module";
|
||||
import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module";
|
||||
import {AdvancedSearchFormModule} from "./advancedSearchForm.module";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule, FormsModule, RouterModule, SearchFormModule, SearchResultsModule, CommunitySearchResultsModule,
|
||||
LoadingModalModule, ReportsServiceModule, SearchDataproviderMapModule,
|
||||
SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, SearchFilterModule,
|
||||
PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule,
|
||||
SearchResultsInDepositModule, AdvancedSearchFormModule
|
||||
],
|
||||
declarations: [
|
||||
NewSearchPageComponent
|
||||
],
|
||||
|
||||
providers:[
|
||||
PreviousRouteRecorder
|
||||
],
|
||||
exports: [
|
||||
NewSearchPageComponent
|
||||
]
|
||||
})
|
||||
export class NewSearchPageModule { }
|
|
@ -79,7 +79,7 @@ export class SearchResearchResultsService {
|
|||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
|
||||
advancedSearch (resultType:string, params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
|
||||
advancedSearch (resultType:string, params: string, page: number, size: number, sortBy: string, properties:EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null ):any {
|
||||
let url = properties.searchResourcesAPIURL;
|
||||
var basicQuery = "(oaftype exact result) and (resulttypeid exact "+this.getEntityName(resultType,false) + ") ";
|
||||
url += "?query=";
|
||||
|
@ -88,17 +88,22 @@ export class SearchResearchResultsService {
|
|||
}else{
|
||||
url +=" ( "+basicQuery+ " ) ";
|
||||
}
|
||||
|
||||
if(refineParams!= null && refineParams != '' ) {
|
||||
url += refineParams;
|
||||
}
|
||||
if(sortBy) {
|
||||
let sortOptions = sortBy.split(",");
|
||||
url += "sortBy "+sortOptions[0]+"/sort."+sortOptions[1]+" ";
|
||||
}
|
||||
if(refineQuery) {
|
||||
url += "&" + refineQuery;
|
||||
}
|
||||
|
||||
url += "&page="+(page-1)+"&size="+size;
|
||||
url += "&format=json";
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
||||
}
|
||||
|
||||
searchResultForEntity (resultType:string, params: string, page: number, size: number, properties:EnvProperties):any {
|
||||
|
|
|
@ -11,7 +11,7 @@ export class RefineResultsUtils {
|
|||
|
||||
var searchFields:SearchFields = new SearchFields();
|
||||
var filters:Filter[] = [];
|
||||
if(data){
|
||||
if(data && fields){
|
||||
for(let j=0; j<fields.length; j++) {
|
||||
|
||||
var filter:Filter = new Filter();
|
||||
|
|
|
@ -117,6 +117,7 @@ export class EnvProperties {
|
|||
searchLinkToEntityRegistriesDataProvidersTable;
|
||||
searchLinkToJournals;
|
||||
searchLinkToJournalsTable;
|
||||
searchLinkToResults;
|
||||
|
||||
//Advanced Search for pages
|
||||
searchLinkToAdvancedPublications;
|
||||
|
@ -126,6 +127,7 @@ export class EnvProperties {
|
|||
searchLinkToAdvancedOrps;
|
||||
searchLinkToAdvancedDataProviders;
|
||||
searchLinkToAdvancedOrganizations;
|
||||
searchLinkToAdvancedResults;
|
||||
|
||||
|
||||
lastIndexInformationLink;
|
||||
|
|
Loading…
Reference in New Issue