[Explore|Trunk]

New Search:
	search all: add back entites selection
	advanced search: 
		css changes for date field
		change result date query to " within "
		use new URL parameters - keep order
		




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58173 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-03-04 12:42:52 +00:00
parent 2694761594
commit 803826efd3
10 changed files with 92 additions and 55 deletions

View File

@ -19,7 +19,7 @@
[simpleView]="true" [formPlaceholderText]="formPlaceholderText"
[selectedFields]="selectedFields"
[fieldIdsMap]="fieldIdsMap" [fieldIds]="fieldIds"
[fieldIdsMap]="fieldIdsMap" [fieldIds]="fieldIds" [entitiesSelection]="true"
>
</advanced-search-form>
</div>

View File

@ -32,7 +32,7 @@
<option *ngFor="let id of fieldIds" [value]="id">{{fieldIdsMap[id].name}} </option>
</select></td>
<td *ngIf="selectedField.type == 'keyword'">
<div class="uk-inline">
<div class="uk-inline uk-width-expand">
<a *ngIf="selectedField.value.length > 0" class="uk-form-icon uk-form-icon-flip"
(click)="selectedField.value = ''"
uk-icon="icon: close"></a>
@ -86,10 +86,10 @@
</span>
</td>
<td style="min-width: 75px;"><select *ngIf="i+1 <selectedFields.length"
[(ngModel)]="selectedField.operatorId"
[(ngModel)]="selectedFields[i+1].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>
<option *ngFor="let op of operators" (change)="fieldOperatorChanged(i+1, op.id, op.id)"
(click)="fieldOperatorChanged(i+1, op.id, op.id)" [value]="op.id">{{op.id}}</option>
</select>
<div *ngIf="i == selectedFields.length-1 " class=" uk-text-right" style="margin-top: 55px;">
<span class="uk-text-muted uk-text-uppercase uk-margin-small-right " > Add rule</span>

View File

@ -18,28 +18,28 @@ import {MatDatepickerInputEvent} from "@angular/material";
<div *ngIf="dateValue && dateValue.type=='range' ">
<table class=" uk-table uk-table-responsive" >
<tr>
<td class="uk-padding-remove-top">
<td class="uk-padding-remove">
<select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>
</select>
</td>
<td>
From
</td>
<td class="uk-padding-remove-top" style="width: 112px;">
<mat-form-field style="max-width: 112px;">
<input matInput [matDatepicker]="pickerFrom" placeholder="Choose a date"
<!-- <td>-->
<!-- From-->
<!-- </td>-->
<td class="uk-padding-remove-vertical" style="width: 112px;">
<mat-form-field style="max-width: 120px;">
<input matInput [matDatepicker]="pickerFrom" placeholder="Choose from date"
[formControl]="fromDate" (click)="pickerFrom.open()" (dateChange)="fromDateChanged($event)">
<mat-datepicker-toggle matSuffix [for]="pickerFrom"></mat-datepicker-toggle>
<mat-datepicker #pickerFrom></mat-datepicker>
</mat-form-field>
</td>
<td>
To
</td>
<td class="uk-padding-remove-top" style="width: 112px;">
<mat-form-field style="max-width: 112px;">
<input matInput [matDatepicker]="pickerTo" placeholder="Choose a date"
<!-- <td>-->
<!-- To -->
<!-- </td>-->
<td class="uk-padding-remove" style="width: 112px;">
<mat-form-field style="max-width: 120px;">
<input matInput [matDatepicker]="pickerTo" placeholder="Choose to date"
[formControl]="toDate" (click)="pickerTo.open()" (dateChange)="toDateChanged($event)">
<mat-datepicker-toggle matSuffix [for]="pickerTo"></mat-datepicker-toggle>
<mat-datepicker #pickerTo></mat-datepicker>

View File

@ -25,7 +25,6 @@ import {Router} from "@angular/router";
<span *ngIf="currentEntity=='organization'">Organizations</span>
</button>-->
<!---->
<span class="entitiesSelection portal-box uk-text-small " style="" >
<mat-select *ngIf="show && selectedEntity" [(value)]="selectedEntity"
(valueChange)="entityChanged()" [disableOptionCentering]="true" panelClass="entitiesSelectionPanel">

View File

@ -528,14 +528,60 @@ export class NewSearchPageComponent {
* Build advanced search Filters based on the URL parameters
* @param params
*/
createAdvancedSearchSelectedFiltersFromURLParameters(params) {
for (var i = 0; i < this.fieldIds.length; i++) {
createAdvancedSearchSelectedFiltersFromNewURLParameters(params) {
for (let i = 0; i < Object.keys(params).length; i++) {
if(params["f"+i] && params["fv"+i] ) {
let fieldId = params["f" + i].split(",")[0];
let operator = (params["f" + i].split(",").length >1 )?params["f" + i].split(",")[1]:"and";
let fieldparam = (this.fieldIdsMap[fieldId]) ? this.fieldIdsMap[fieldId].param : "";
if (!this.fieldIdsMap[fieldId]) {
console.error("Field: " + fieldId + " not found in fieldIds map");
continue;
}
let value: string = StringUtils.URIDecode(params["fv"+i]);
if (this.fieldIdsMap[fieldId].type == "date") {
let validDates: boolean = true;
let dateField: AdvancedField = new AdvancedField(fieldId, fieldparam, this.fieldIdsMap[fieldId].name, this.fieldIdsMap[fieldId].type, value, operator);
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,value, operator));
}
}
}
}
/**
* Build advanced search Filters based on the URL parameters
* @param params
*/
createAdvancedSearchSelectedFiltersFromURLParameters(params) {
this.createAdvancedSearchSelectedFiltersFromNewURLParameters(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");
continue;
}
var operatorId = this.getOperatorParameter(fieldparam);
@ -569,7 +615,7 @@ export class NewSearchPageComponent {
}
} 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, values[j], operators[j]));
}
}
}
@ -600,6 +646,7 @@ export class NewSearchPageComponent {
}
} else {
if (this.selectedFields[i].id == "q") {
console.log(this.selectedFields[i].value)
var op = "";
var doisParams = "";
if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) {
@ -636,8 +683,8 @@ export class NewSearchPageComponent {
if (this.customFilter) {
params += (countParams == 0 ? "" : " and ") + this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId));
}
// console.log("ParameterS:")
// console.log(params)
console.log("ParameterS:")
console.log(params)
return params;
}
@ -911,33 +958,22 @@ export class NewSearchPageComponent {
buildPageURLParameters(filters:Filter[], rangeFilters: RangeFilter[], includePage: boolean) {
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);
//default operator is and
this.parameterNames.push("f"+i);
this.parameterValues.push(this.selectedFields[i].id + (this.selectedFields[i].operatorId!='and'?(","+this.selectedFields[i].operatorId):''));
this.parameterNames.push("fv"+i);
if (this.selectedFields[i].type == "date") {
}
}
for (var i = 0; i < this.fieldIds.length; i++) {
if (fields[this.fieldIds[i]]) {
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 (this.selectedFields[i].dateValue.type == "range") {
this.parameterValues.push(StringUtils.URIEncode("range" + Dates.getDateToString(this.selectedFields[i].dateValue.from) + ":" + Dates.getDateToString(this.selectedFields[i].dateValue.to)));
} else {
this.parameterValues.push(StringUtils.URIEncode(this.selectedFields[i].dateValue.type));
}
} else {
console.log(this.selectedFields[i].value +" " + StringUtils.URIEncode(this.selectedFields[i].value))
this.parameterValues.push(StringUtils.URIEncode(this.selectedFields[i].value));
}
}
if (includePage && this.searchUtils.page != 1) {

View File

@ -18,9 +18,9 @@ import {ConfigurationService} from "../../utils/configuration/configuration.serv
<span class="uk-text-muted">Include: </span>
<span>
<span *ngIf="showPublications" class="uk-margin-small-left"> <input type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications </span>
<span *ngIf="showDatasets" class="uk-margin-small-left"> <input type="checkbox" formControlName="dataset" (change)="changed()"> Research Data </span>
<span *ngIf="showDatasets" class="uk-margin-small-left"> <input type="checkbox" formControlName="dataset" (change)="changed()"> Research data </span>
<span *ngIf="showSoftware" class="uk-margin-small-left"> <input type="checkbox" formControlName="software" (change)="changed()"> Software </span>
<span *ngIf="showOrp" class="uk-margin-small-left"> <input type="checkbox" formControlName="other" (change)="changed()"> Other Research outcomes </span>
<span *ngIf="showOrp" class="uk-margin-small-left"> <input type="checkbox" formControlName="other" (change)="changed()"> Other research outcomes </span>
</span>
</div>
</form>

View File

@ -77,6 +77,8 @@ export class RefineFieldResultsService {
suffix="datasources/";
}else if(entityType == "person"){
suffix="people/";
}else if(entityType == "result"){
suffix="publications/";
}
return suffix;
}

View File

@ -390,7 +390,7 @@ export class SearchResearchResultsService {
if(doisParams.length > 0){
url += "&"+doisParams;
}else{
url += "&q=" + StringUtils.URIEncode(params);
url += "&query=" + StringUtils.URIEncode(params);
}
}

View File

@ -259,7 +259,7 @@ export class EntitiesAutocompleteComponent {
this.showInput = true;
if(this.selectedValue && this.selectedValue.length > 0 ){
console.log(this.selectedValue+" "+this.entityType )
this.sub = this._search.fetchByType(this.selectedValue,this.entityType, this.properties).subscribe(
data => {
this.selected.push( data[0]);

View File

@ -40,7 +40,7 @@ export class SearchFields {
["relfundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", operator: "fn1", equalityOperator: " exact ", filterType: "checkbox"},
["relfundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", operator: "fn0", equalityOperator: " exact ", filterType: "checkbox"},
["resultacceptanceyear"]:{name:"Publication Date", type:"keyword", param:"year", operator: "ya", equalityOperator: " = ", filterType: null},
["resultdateofacceptance"]:{name:"Publication Date", type:"date", param:"date", operator: "dt", equalityOperator: " exact ", filterType: null},
["resultdateofacceptance"]:{name:"Publication Date", type:"date", param:"date", operator: "dt", equalityOperator: " within ", filterType: null},
["resultacceptanceyear-range-resultacceptanceyear"]:{name:"Year range", type:"keyword", param:"year", operator: "ya", equalityOperator: " within ", filterType: "range"},
["resultbestaccessright"]:{name:"Access Mode", type:"vocabulary", param:"access", operator: "ac", equalityOperator: " exact ", filterType: "radio"},
["collectedfrom"]:{name:"Collected From", type:"refine", param:"datasource", operator: "cl", equalityOperator: " exact ", filterType: "checkbox"},