filterValuesNum">
+
+ + View more
-
-
+
+
+ = 99">* only the Top 100 values are shown
-
+
+
+ Sort by:
+
+
-
+
-
+
-
0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small">
+
-
+
+ - View less
+
-
-
filterValuesNum" (click)="open()"
- [class]="(isDisabled)?'uk-disabled uk-link-muted':''">View more
-
-
-
-
-
-
-
-
- {{filter.title}}
-
-
-
= 99" class="uk-alert uk-alert-primary uk-text-center uk-margin-right uk-margin-left uk-margin-small-top uk-margin-small-bottom ">Showing top {{filter.values.length}} values.
-
-
-
-
-
-
-
-
-
0 && (filter.values.length-filter.countSelectedValues ) > 0 " class="uk-grid-divider uk-margin-small">
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/searchPages/searchUtils/searchFilter.component.ts b/searchPages/searchUtils/searchFilter.component.ts
index 15e0ea95..183ecd4a 100644
--- a/searchPages/searchUtils/searchFilter.component.ts
+++ b/searchPages/searchUtils/searchFilter.component.ts
@@ -1,8 +1,5 @@
-import {Component, Input, Output, EventEmitter} from '@angular/core';
-import {Observable} from 'rxjs';
-
+import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
import { Filter, Value} from './searchHelperClasses.class';
-import {Open} from '../../utils/modal/open.component';
@Component({
selector: 'search-filter',
@@ -11,44 +8,36 @@ import {Open} from '../../utils/modal/open.component';
export class SearchFilterComponent {
- @Input() filter:Filter;
- @Input() showResultCount:boolean = true;
- @Input() isDisabled:boolean = false;
- @Input() addShowMore:boolean = true;
- @Input() showMoreInline: boolean = false;
- @Input() filterValuesNum: number = 5;
- public showAll:boolean = false;
- public _maxCharacters:number =28;
+ @Input() filter:Filter;
+ @Input() showResultCount:boolean = true;
+ @Input() isDisabled:boolean = false;
+ @Input() addShowMore:boolean = true;
+ @Input() showMoreInline: boolean = true;
+ @Input() filterValuesNum: number = 4;
+ public showAll:boolean = false;
+ public _maxCharacters:number =28;
- @Output() toggleModal = new EventEmitter();
+ @Output() toggleModal = new EventEmitter();
- @Output() modalChange = new EventEmitter();
- @Output() onFilterChange = new EventEmitter();
- keyword = "";
- sortBy = "num";
+ @Output() modalChange = new EventEmitter();
+ @Output() onFilterChange = new EventEmitter();
+ keyword = "";
+ sortBy = "num";
+ public isOpen:boolean=false;
- public isOpen:boolean=false;
-
- // filterModalChange() {
- // console.info("Modal Changed");
- // this.modalChange.emit({
- // value: true
- // });
- // //this.close();
- // }
-
- constructor () {
+ constructor () {
}
- ngOnInit() {
+ ngOnInit() {}
- }
public _formatTitle(title,length){
return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+((length >= 99)?length+"+":length)+")")
}
public _formatName(value){
- let maxLineLength = 24;
+ //let maxLineLength = 24;
+ let maxLineLength = 35;
+
//1 space after checkbox
//3 space before number + parenthesis
if(!this.showResultCount && value.name.length+1 > maxLineLength ){
@@ -59,15 +48,7 @@ export class SearchFilterComponent {
}
return value.name;
- //(((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name)
}
- // toggleShowAll(){
- // this.showAll = !this.showAll;
- // if(this.showAll == false) {
- // this.reorderFilterValues();
- // }
- // }
-
filterKeywords(value){
if(this.keyword.length > 0){
@@ -78,13 +59,10 @@ export class SearchFilterComponent {
return true;
}
filterChange(selected:boolean){
- //console.info("filter change: "+selected);
if(selected){
this.filter.countSelectedValues++;
- // this.reorderFilterValues();
}else{
this.filter.countSelectedValues--;
- // this.reorderFilterValues();
}
this.onFilterChange.emit({
value: this.filter
@@ -104,6 +82,15 @@ export class SearchFilterComponent {
value: this.filter
});
}
+ clearFilter() {
+ for (var i=0; i < this.filter.values.length; i++){
+ this.filter.values[i].selected = false;
+ }
+ this.filter.countSelectedValues = 0;
+ this.onFilterChange.emit({
+ value: this.filter
+ });
+ }
getSelectedValues(filter, sortBy:string = "num"):any{
var selected = [];
if(filter.countSelectedValues >0){
@@ -132,15 +119,11 @@ export class SearchFilterComponent {
}
getNotSelectedValues(filter, sortBy:string = "num"):any{
var notSselected = [];
- //if(filter.countSelectedValues >0){
- for (var i=0; i < filter.values.length; i++){
- if(!filter.values[i].selected){
- notSselected.push(filter.values[i]);
- }
+ for (var i=0; i < filter.values.length; i++){
+ if(!filter.values[i].selected){
+ notSselected.push(filter.values[i]);
}
- //}else {
- // notSselected = filter.values;
- //}
+ }
if(sortBy == "name"){
@@ -148,7 +131,6 @@ export class SearchFilterComponent {
if (n1.name > n2.name) {
return 1;
}
-
if (n1.name < n2.name) {
return -1;
}
@@ -158,67 +140,14 @@ export class SearchFilterComponent {
}
return notSselected;
}
- // reorderFilterValues() {
- // for(let value of this.filter.values) {
- // if(value.selected) {
- // let index: number = this.filter.values.indexOf(value);
- // let selectedValue:Value = this.filter.values[index];
- //
- // this.filter.values.splice(index, 1);
- // this.filter.values.splice(0, 0, selectedValue);
- // }
- // }
- // }
-// sliceSelected() {
-// let values: Value[] = [];
-//
-// for(let value of this.filter.values) {
-// if(value.selected) {
-// let index: number = this.filter.values.indexOf(value);
-// let selectedValue:Value = this.filter.values[index];
-//
-// this.filter.values.splice(index, 1);
-// this.filter.values.splice(0, 0, selectedValue);
-// }
-// }
-
- // toggle() {
- // this.toggleModal.emit({
- // value: this.filter
- // });
- // }
-
-
- open() {
- this.isOpen = true;
+ toggle() {
+ this.isOpen = !this.isOpen;
}
- close() {
- this.isOpen = false;
- }
-
- // filterChange2(selected:boolean){
- //
- // console.info("filter change2");
- // if(selected){
- // this.filter.countSelectedValues++;
- // // this.reorderFilterValues();
- // }else{
- // this.filter.countSelectedValues--;
- // // this.reorderFilterValues();
- // }
- // this.close();
- // }
getFilterName(value){
let name = value.name +" ("+ value.number.format()+")";
- console.log(name)
-
-
- //
- //
- // {{value.name}}
- //
({{value.number | number}})
+ console.log(name);
return name;
}
}
diff --git a/searchPages/searchUtils/searchHelperClasses.class.ts b/searchPages/searchUtils/searchHelperClasses.class.ts
index 14285210..c53b643a 100644
--- a/searchPages/searchUtils/searchHelperClasses.class.ts
+++ b/searchPages/searchUtils/searchHelperClasses.class.ts
@@ -7,7 +7,7 @@ export class Filter{
public values: Value[] = [];
public filterOperator: string ='or';
public valueIsExact: boolean = true; // for search table view, if value is contained or is equal with column entry
- public valueIsUnique: boolean = false;
+ public filterType: string = "checkbox";
// public uniqueValueIdSelected: string;
}
diff --git a/services/servicesUtils/refineResults.class.ts b/services/servicesUtils/refineResults.class.ts
index 129189f7..03389c23 100644
--- a/services/servicesUtils/refineResults.class.ts
+++ b/services/servicesUtils/refineResults.class.ts
@@ -18,9 +18,9 @@ export class RefineResultsUtils {
filter.title = searchFields.getFieldName(fields[j],entityType);
filter.filterId = fields[j];
filter.originalFilterId = fields[j];
- filter.valueIsUnique = searchFields.fieldHasUniqueValue(fields[j], entityType, usedBy);
+ filter.filterType = searchFields.getFieldFilterType(fields[j], entityType, usedBy);
filter.filterOperator = searchFields.getFieldOperator(fields[j]);
- //console.info("filter.title: "+filter.title+" filter.valueIsUnique: "+filter.valueIsUnique);
+ //console.info("filter.title: "+filter.title+" filter.filterType: "+filter.filterType);
let field = data[fields[j]];
if(field){
@@ -36,7 +36,8 @@ export class RefineResultsUtils {
}
- filters.push(filter);
+
+ filters.push(filter);
}
}
}
diff --git a/utils/properties/searchFields.ts b/utils/properties/searchFields.ts
index 9983e42d..b588b1d4 100644
--- a/utils/properties/searchFields.ts
+++ b/utils/properties/searchFields.ts
@@ -4,10 +4,14 @@ export class SearchFields {
//RESULTS
//Used for datasets and publications and software and orp
//In case Datasets or Software should display different fields, use seperate tables for fields
+ // "resultacceptanceyear",
+ public RESULT_RANGE_FIELDS = [
+ ["resultacceptanceyear", "resultacceptanceyear"]
+ ];
public RESULT_REFINE_FIELDS = [
"relfunder",
"relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id",
- "relproject","resultacceptanceyear",
+ "relproject",
"resultbestaccessright", "instancetypename", "resultlanguagename", "community","resulthostingdatasource","collectedfrom" ];
public RESULT_ADVANCED_FIELDS:string[] = ["q","resulttitle","resultauthor", "authorid","resultdescription","resultsubject","resultpublisher",
@@ -16,35 +20,38 @@ export class SearchFields {
"relfundinglevel0_id","relfundinglevel1_id","relfundinglevel2_id",
"resultlanguagename", "relorganizationid", "pid","relprojectid", "instancetypename"];
public RESULT_FIELDS: { [key:string]:FieldDetails}={
- ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", uniqueValue: false},
- ["resulttitle"]:{name:"Title", type:"keyword", param:"title", operator: "tt", equalityOperator: "=", uniqueValue: false},
- ["resultauthor"]:{name:"Author", type:"keyword", param:"author", operator: "at", equalityOperator: "=", uniqueValue: false},
- ["authorid"]:{name:"Author ORCID", type:"keyword", param:"orcid", operator: "oc", equalityOperator: " exact ", uniqueValue: false},
- ["resultsubject"]:{name:"Subject", type:"keyword", param:"subject", operator: "sb", equalityOperator: "=", uniqueValue: false},
- ["resultdescription"]:{name:"Description", type:"keyword", param:"description", operator: "ds", equalityOperator: "=", uniqueValue: false},
- ["resultpublisher"]:{name:"Publisher", type:"keyword", param:"publisher", operator: "pb", equalityOperator: "=", uniqueValue: false},
- ["pid"]:{name:"PID", type:"keyword", param:"pid", operator: "pd", equalityOperator: " = ", uniqueValue: false},
- ["resulthostingdatasourceid"]:{name:"Hosting Content Provider", type:"entity", param:"hostedBy", operator: "hs", equalityOperator: " exact ", uniqueValue: false},
- ["resulthostingdatasource"]:{name:"Content Provider", type:"refine", param:"hostedBy", operator: "hs", equalityOperator: " exact ", uniqueValue: false},
- ["instancetypename"]:{name:"Type", type:"vocabulary", param:"type", operator: "tp", equalityOperator: " exact ", uniqueValue: false},
- ["resultlanguagename"]:{name:"Language", type:"vocabulary", param:"lang", operator: "ln", equalityOperator: " exact ", uniqueValue: false},
- ["community"]:{name:"Community", type:"refine", param:"community", operator: "cm", equalityOperator: " exact ", uniqueValue: false},
- ["relproject"]:{name:"Project", type:"refine", param:"project", operator: "po", equalityOperator: " exact ", uniqueValue: false},
- ["relprojectid"]:{name:"Project", type:"entity", param:"project", operator: "po", equalityOperator: " exact ", uniqueValue: false},
- ["relfunder"]:{name:"Funder", type:"refine", param:"funder", operator: "fn", equalityOperator: " exact ", uniqueValue: false},
- ["relfundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", operator: "fn0", equalityOperator: " exact ", uniqueValue: false},
- ["relfundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", operator: "fn1", equalityOperator: " exact ", uniqueValue: false},
- ["relfundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", operator: "fn0", equalityOperator: " exact ", uniqueValue: false},
- ["resultacceptanceyear"]:{name:"Publication Date", type:"keyword", param:"year", operator: "ya", equalityOperator: " exact ", uniqueValue: false},
- ["resultdateofacceptance"]:{name:"Publication Date", type:"date", param:"date", operator: "dt", equalityOperator: " within ", uniqueValue: false},
- ["resultbestaccessright"]:{name:"Access Mode", type:"vocabulary", param:"access", operator: "ac", equalityOperator: " exact ", uniqueValue: false},
- ["collectedfrom"]:{name:"Collected From", type:"refine", param:"datasource", operator: "cl", equalityOperator: " exact ", uniqueValue: false},
- ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", uniqueValue: false},
- ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", uniqueValue: false}
+ ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", filterType: null},
+ ["resulttitle"]:{name:"Title", type:"keyword", param:"title", operator: "tt", equalityOperator: "=", filterType: null},
+ ["resultauthor"]:{name:"Author", type:"keyword", param:"author", operator: "at", equalityOperator: "=", filterType: null},
+ ["authorid"]:{name:"Author ORCID", type:"keyword", param:"orcid", operator: "oc", equalityOperator: " exact ", filterType: null},
+ ["resultsubject"]:{name:"Subject", type:"keyword", param:"subject", operator: "sb", equalityOperator: "=", filterType: null},
+ ["resultdescription"]:{name:"Description", type:"keyword", param:"description", operator: "ds", equalityOperator: "=", filterType: null},
+ ["resultpublisher"]:{name:"Publisher", type:"keyword", param:"publisher", operator: "pb", equalityOperator: "=", filterType: null},
+ ["pid"]:{name:"PID", type:"keyword", param:"pid", operator: "pd", equalityOperator: " = ", filterType: null},
+ ["resulthostingdatasourceid"]:{name:"Hosting Content Provider", type:"entity", param:"hostedBy", operator: "hs", equalityOperator: " exact ", filterType: null},
+ ["resulthostingdatasource"]:{name:"Content Provider", type:"refine", param:"hostedBy", operator: "hs", equalityOperator: " exact ", filterType: "checkbox"},
+ ["instancetypename"]:{name:"Type", type:"vocabulary", param:"type", operator: "tp", equalityOperator: " exact ", filterType: "checkbox"},
+ ["resultlanguagename"]:{name:"Language", type:"vocabulary", param:"lang", operator: "ln", equalityOperator: " exact ", filterType: "checkbox"},
+ ["community"]:{name:"Community", type:"refine", param:"community", operator: "cm", equalityOperator: " exact ", filterType: "checkbox"},
+ ["relproject"]:{name:"Project", type:"refine", param:"project", operator: "po", equalityOperator: " exact ", filterType: "checkbox"},
+ ["relprojectid"]:{name:"Project", type:"entity", param:"project", operator: "po", equalityOperator: " exact ", filterType: null},
+ ["relfunder"]:{name:"Funder", type:"refine", param:"funder", operator: "fn", equalityOperator: " exact ", filterType: "checkbox"},
+ ["relfundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", operator: "fn0", equalityOperator: " exact ", filterType: "checkbox"},
+ ["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},
+ ["resultacceptanceyear-range-resultacceptanceyear"]:{name:"Published between", 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"},
+ ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", filterType: null},
+ ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", filterType: null}
};
//PROJECT
-
+ public PROJECT_RANGE_FIELDS = [
+ ["projectendyear", "projectstartyear"]
+ ];
public PROJECT_REFINE_FIELDS:string[] = ["funder","fundinglevel0_id","fundinglevel1_id",
"fundinglevel2_id","projectstartyear","projectendyear","projectecsc39"];
public PROJECT_ADVANCED_FIELDS:string[] = ["q","projectacronym","projecttitle","projectkeywords",
@@ -52,23 +59,24 @@ export class SearchFields {
"projectstartdate","projectenddate","projectecsc39",
"projectcode_nt","relorganizationid", "collectedfromdatasourceid"];
public PROJECT_FIELDS: { [key:string]:FieldDetails}={
- ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", uniqueValue: false},
- ["projectacronym"]:{name:"Acronym", type:"keyword", param:"acronym", operator: "ar", equalityOperator: "=", uniqueValue: false},
- ["projecttitle"]:{name:"Title", type:"keyword", param:"title", operator: "tt", equalityOperator: "=", uniqueValue: false},
- ["projectkeywords"]:{name:"Keywords", type:"keyword", param:"keywords", operator: "ky", equalityOperator: "=", uniqueValue: false},
+ ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", filterType: null},
+ ["projectacronym"]:{name:"Acronym", type:"keyword", param:"acronym", operator: "ar", equalityOperator: "=", filterType: null},
+ ["projecttitle"]:{name:"Title", type:"keyword", param:"title", operator: "tt", equalityOperator: "=", filterType: null},
+ ["projectkeywords"]:{name:"Keywords", type:"keyword", param:"keywords", operator: "ky", equalityOperator: "=", filterType: null},
- ["funder"]:{name:"Funder", type:"refine", param:"funder", operator: "fn", equalityOperator: " exact ", uniqueValue: false},
- ["fundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", operator: "fn0", equalityOperator: " exact ", uniqueValue: false},
- ["fundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", operator: "fn1", equalityOperator: " exact ", uniqueValue: false},
- ["fundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", operator: "fn2", equalityOperator: " exact ", uniqueValue: false},
- ["projectstartyear"]:{name:"Start Year", type:"year", param:"startyear", operator: "sy", equalityOperator: " exact ", uniqueValue: false},
- ["projectendyear"]:{name:"End Year", type:"year", param:"endyear", operator: "ey", equalityOperator: " exact ", uniqueValue: false},
- ["projectstartdate"]:{name:"Start Date", type:"date", param:"startdate", operator: "sd", equalityOperator: " within ", uniqueValue: false},
- ["projectenddate"]:{name:"End Date", type:"date", param:"enddate", operator: "ed", equalityOperator: " within ", uniqueValue: false},
- ["projectecsc39"]:{name:"Special Clause 39", type:"boolean", param:"sc39", operator: "sc", equalityOperator: " exact ", uniqueValue: false},
- ["projectcode_nt"]:{name:"Project Code", type:"keyword", param:"code", operator: "cd", equalityOperator: " exact ", uniqueValue: false},
- ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", uniqueValue: false},
- ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", uniqueValue: false}
+ ["funder"]:{name:"Funder", type:"refine", param:"funder", operator: "fn", equalityOperator: " exact ", filterType: "checkbox"},
+ ["fundinglevel0_id"]:{name:"Funding Stream", type:"refine", param:"funderlv0", operator: "fn0", equalityOperator: " exact ", filterType: "checkbox"},
+ ["fundinglevel1_id"]:{name:"Funding Substream level 1", type:"refine", param:"funderlv1", operator: "fn1", equalityOperator: " exact ", filterType: "checkbox"},
+ ["fundinglevel2_id"]:{name:"Funding Substream level 2", type:"refine", param:"funderlv2", operator: "fn2", equalityOperator: " exact ", filterType: "checkbox"},
+ ["projectstartyear"]:{name:"Start Year", type:"year", param:"startyear", operator: "sy", equalityOperator: " <= ", filterType: "checkbox"},
+ ["projectendyear"]:{name:"End Year", type:"year", param:"endyear", operator: "ey", equalityOperator: " >= ", filterType: "checkbox"},
+ ["projectendyear-range-projectstartyear"]:{name:"Active years", type:"year", param:"year", operator: "ya", equalityOperator: " = ", filterType: "range"},
+ ["projectstartdate"]:{name:"Start Date", type:"date", param:"startdate", operator: "sd", equalityOperator: " within ", filterType: null},
+ ["projectenddate"]:{name:"End Date", type:"date", param:"enddate", operator: "ed", equalityOperator: " within ", filterType: null},
+ ["projectecsc39"]:{name:"Special Clause 39", type:"boolean", param:"sc39", operator: "sc", equalityOperator: " exact ", filterType: "radio"},
+ ["projectcode_nt"]:{name:"Project Code", type:"keyword", param:"code", operator: "cd", equalityOperator: " exact ", filterType: null},
+ ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", filterType: null},
+ ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", filterType: null}
};
@@ -81,20 +89,20 @@ export class SearchFields {
"datasourceodcontenttypes", "datasourcecompatibilityname","relorganizationid", "collectedfromdatasourceid"];
public DATASOURCE_FIELDS: { [key:string]:FieldDetails}={
- ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", uniqueValue: false},
- ["datasourceofficialname"]:{name:"English name", type:"keyword", param:"officialname", operator: "of", equalityOperator: "=", uniqueValue: false},
- ["datasourceenglishname"]:{name:"Title", type:"keyword", param:"engname", operator: "eg", equalityOperator: "=", uniqueValue: false},
- ["datasourceodsubjects"]:{name:"Subject", type:"keyword", param:"subjects", operator: "sb", equalityOperator: "=", uniqueValue: false},
- ["datasourcetypeuiid"]:{name:"Type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", uniqueValue: false},
- ["datasourcetypeuiname"]:{name:"Type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", uniqueValue: false},
- ["datasourcetypename"]:{name:"Type", type:"vocabulary", param:"type", operator: "tp", equalityOperator: " exact ", uniqueValue: false},
- ["datasourceodlanguages"]:{name:"Language", type:"vocabulary", param:"lang", operator: "ln", equalityOperator: " exact ", uniqueValue: false},
- ["datasourceodcontenttypes"]:{name:"Content", type:"refine", param:"content", operator: "cn", equalityOperator: " exact ", uniqueValue: false},
- ["datasourcecompatibilityid"]:{name:"Compatibility Level", type:"refine", param:"compatibility", operator: "cm", equalityOperator: " exact ", uniqueValue: false},
- ["datasourcecompatibilityname"]:{name:"Compatibility Level", type:"vocabulary", param:"compatibility", operator: "cm", equalityOperator: " exact ", uniqueValue: false},
- ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", uniqueValue: false},
- ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", uniqueValue: false},
- ["country"]:{name:"Country", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", uniqueValue: false}
+ ["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", filterType: null},
+ ["datasourceofficialname"]:{name:"English name", type:"keyword", param:"officialname", operator: "of", equalityOperator: "=", filterType: null},
+ ["datasourceenglishname"]:{name:"Title", type:"keyword", param:"engname", operator: "eg", equalityOperator: "=", filterType: null},
+ ["datasourceodsubjects"]:{name:"Subject", type:"keyword", param:"subjects", operator: "sb", equalityOperator: "=", filterType: null},
+ ["datasourcetypeuiid"]:{name:"Type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", filterType: null},
+ ["datasourcetypeuiname"]:{name:"Type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", filterType: "checkbox"},
+ ["datasourcetypename"]:{name:"Type", type:"vocabulary", param:"type", operator: "tp", equalityOperator: " exact ", filterType: null},
+ ["datasourceodlanguages"]:{name:"Language", type:"vocabulary", param:"lang", operator: "ln", equalityOperator: " exact ", filterType: "checkbox"},
+ ["datasourceodcontenttypes"]:{name:"Content", type:"refine", param:"content", operator: "cn", equalityOperator: " exact ", filterType: "checkbox"},
+ ["datasourcecompatibilityid"]:{name:"Compatibility Level", type:"refine", param:"compatibility", operator: "cm", equalityOperator: " exact ", filterType: null},
+ ["datasourcecompatibilityname"]:{name:"Compatibility Level", type:"vocabulary", param:"compatibility", operator: "cm", equalityOperator: " exact ", filterType: "checkbox"},
+ ["relorganizationid"]:{name:"Organization", type:"entity", param:"organization", operator: "og", equalityOperator: " exact ", filterType: null},
+ ["collectedfromdatasourceid"]:{name:"Collected from Content Provider", type:"entity", param:"collectedFrom", operator: "cl", equalityOperator: " exact ", filterType: null},
+ ["country"]:{name:"Country", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", filterType: "checkbox"}
};
public DEPOSIT_DATASOURCE_KEYWORD_FIELDS: { "name": string, "equalityOperator": string} []= [
@@ -109,11 +117,11 @@ export class SearchFields {
public DEPOSIT_DATASOURCE_REFINE_FIELDS:string[] = ["datasourcetypeuiname", "country", "datasourceodsubjects", "datasourceodcontenttypes", "datasourcecompatibilityname"];
public DEPOSIT_DATASOURCE_FIELDS: { [key:string]:FieldDetails}={
- ["datasourcetypeuiname"]:{name:"Repository type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", uniqueValue: true},
- ["country"]:{name:"Countries", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", uniqueValue: false},
- ["datasourceodsubjects"]:{name:"Subjects", type:"keyword", param:"subjects", operator: "sb", equalityOperator: "=", uniqueValue: false},
- ["datasourceodcontenttypes"]:{name:"Content type", type:"refine", param:"content", operator: "cn", equalityOperator: " exact ", uniqueValue: false},
- ["datasourcecompatibilityname"]:{name:"Compatibility Level", type:"vocabulary", param:"compatibility", operator: "cm", equalityOperator: " exact ", uniqueValue: true},
+ ["datasourcetypeuiname"]:{name:"Repository type", type:"refine", param:"type", operator: "tp", equalityOperator: " exact ", filterType: "radio"},
+ ["country"]:{name:"Countries", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", filterType: "checkbox"},
+ ["datasourceodsubjects"]:{name:"Subjects", type:"keyword", param:"subjects", operator: "sb", equalityOperator: "=", filterType: "checkbox"},
+ ["datasourceodcontenttypes"]:{name:"Content type", type:"refine", param:"content", operator: "cn", equalityOperator: " exact ", filterType: "checkbox"},
+ ["datasourcecompatibilityname"]:{name:"Compatibility Level", type:"vocabulary", param:"compatibility", operator: "cm", equalityOperator: " exact ", filterType: "checkbox"},
};
public COMPATIBLE_DATAPROVIDER_FIELDS:string[] = ["datasourcetypeuiid","datasourcecompatibilityname"];
@@ -126,10 +134,10 @@ export class SearchFields {
public ORGANIZATION_ADVANCED_FIELDS:string[] = ["q", "organizationlegalname","organizationlegalshortname","country"];
public ORGANIZATION_FIELDS: { [key:string]:FieldDetails}={
- ["q"]:{name:"All fields", type:"keyword", param:"q", operator:"op", equalityOperator: "=", uniqueValue: false},
- ["organizationlegalname"]:{name:"Legal Name", type:"keyword", param:"name", operator: "nm", equalityOperator: "=", uniqueValue: false},
- ["organizationlegalshortname"]:{name:"Legal Short Name", type:"keyword", param:"shortname", operator: "so", equalityOperator: "=", uniqueValue: false},
- ["country"]:{name:"Country", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", uniqueValue: false},
+ ["q"]:{name:"All fields", type:"keyword", param:"q", operator:"op", equalityOperator: "=", filterType: null},
+ ["organizationlegalname"]:{name:"Legal Name", type:"keyword", param:"name", operator: "nm", equalityOperator: "=", filterType: null},
+ ["organizationlegalshortname"]:{name:"Legal Short Name", type:"keyword", param:"shortname", operator: "so", equalityOperator: "=", filterType: null},
+ ["country"]:{name:"Country", type:"vocabulary", param:"country", operator: "cu", equalityOperator: "=", filterType: "checkbox"},
};
// public ORGANIZATION_INDEX:string[] = ["organizationcountryname"]//,"organizationeclegalbody"];
// public ADVANCED_SEARCH_ORGANIZATION_PARAM:string[] = ["q","contenttype","compatibility","country","type"];
@@ -173,24 +181,38 @@ export class SearchFields {
}
}
- fieldHasUniqueValue(fieldId:string,fieldType:string,usedBy:string="search"):boolean{
+ getFieldFilterType(fieldId:string, fieldType:string, usedBy:string="search"):string{
if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other"|| fieldType == "result"){
- return this.RESULT_FIELDS[fieldId].uniqueValue;
+ return this.RESULT_FIELDS[fieldId].filterType;
}else if(fieldType == "project"){
- return this.PROJECT_FIELDS[fieldId].uniqueValue;
+ return this.PROJECT_FIELDS[fieldId].filterType;
}else if(fieldType == "organization"){
- return this.ORGANIZATION_FIELDS[fieldId].uniqueValue;
+ return this.ORGANIZATION_FIELDS[fieldId].filterType;
}else if(fieldType == "datasource" || fieldType == "dataprovider"){
if(usedBy == "search") {
- return this.DATASOURCE_FIELDS[fieldId].uniqueValue;
+ return this.DATASOURCE_FIELDS[fieldId].filterType;
} else if(usedBy == "deposit") {
- return this.DEPOSIT_DATASOURCE_FIELDS[fieldId].uniqueValue;
+ return this.DEPOSIT_DATASOURCE_FIELDS[fieldId].filterType;
}
}else{
- return false;
+ return "checkbox";
}
}
+ getFieldParam(fieldId:string,fieldType:string):string{
+ if(fieldType == "publication" || fieldType == "dataset" || fieldType == "software" || fieldType == "other" || fieldType == "result"){
+ return this.RESULT_FIELDS[fieldId].param;
+ }else if(fieldType == "project"){
+ return this.PROJECT_FIELDS[fieldId].param;
+ }else if(fieldType == "organization"){
+ return this.ORGANIZATION_FIELDS[fieldId].param;
+ }else if(fieldType == "datasource" || fieldType == "dataprovider"){
+ return this.DATASOURCE_FIELDS[fieldId].param;
+ }else{
+ return "UNDEFINED";
+ }
+ }
+
/*
AND
Funder: relfunder, relfundinglevel0_id, relfundinglevel1_id, relfundinglevel2_id
@@ -220,7 +242,7 @@ RANGE
getFieldOperator(fieldId:string):string{
if(fieldId == "relfunder" || fieldId == "relfundinglevel0_id" || fieldId == "relfundinglevel1_id" || fieldId == "relfundinglevel2_id"
- || fieldId == "relproject" || fieldId == "community") {
+ || fieldId == "relproject" || fieldId == "community" || fieldId == "projectendyear-range-projectstartyear") {
return "and";
} else if(fieldId == "instancetypename" || fieldId == "datasourcetypeuiname"
|| fieldId == "resultlanguagename" || fieldId == "datasourceodlanguages"
@@ -237,5 +259,5 @@ export class FieldDetails{
param:string;
equalityOperator:string;
operator:string;
- uniqueValue: boolean = false;
+ filterType: string = "checkbox";
}
diff --git a/utils/rangeFilter/fromYearAfterToYear.directive.ts b/utils/rangeFilter/fromYearAfterToYear.directive.ts
new file mode 100644
index 00000000..d4980473
--- /dev/null
+++ b/utils/rangeFilter/fromYearAfterToYear.directive.ts
@@ -0,0 +1,19 @@
+import { Directive } from '@angular/core';
+import { AbstractControl, FormGroup, NG_VALIDATORS, ValidationErrors, Validator, ValidatorFn } from '@angular/forms';
+
+export const fromYearAfterToYearValidator: ValidatorFn = (control: FormGroup): ValidationErrors | null => {
+ const yearFrom = control.get('yearFrom');
+ const yearTo = control.get('yearTo');
+
+ return ((yearFrom && yearTo && (parseInt(yearFrom.value, 10) > parseInt(yearTo.value, 10))) ? { 'fromYearAfterToYear': true } : null);
+};
+
+@Directive({
+ selector: '[fromYearAfterToYear]',
+ providers: [{ provide: NG_VALIDATORS, useExisting: FromYearAfterToYearValidatorDirective, multi: true }]
+})
+export class FromYearAfterToYearValidatorDirective implements Validator {
+ validate(control: AbstractControl): ValidationErrors {
+ return fromYearAfterToYearValidator(control)
+ }
+}
diff --git a/utils/rangeFilter/inValidYear.directive.ts b/utils/rangeFilter/inValidYear.directive.ts
new file mode 100644
index 00000000..4b8dacf9
--- /dev/null
+++ b/utils/rangeFilter/inValidYear.directive.ts
@@ -0,0 +1,19 @@
+import { Directive, Input, OnChanges, SimpleChanges } from '@angular/core';
+import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, Validators } from '@angular/forms';
+import { Dates } from "../string-utils.class";
+
+export function inValidYearValidator(): ValidatorFn {
+ return (control: AbstractControl): {[key: string]: any} | null => {
+ return ((control.value && !Dates.isValidYear(control.value)) ? {'inValidYear': {value: control.value}} : null);
+ };
+}
+
+@Directive({
+ selector: '[inValidYear]',
+ providers: [{provide: NG_VALIDATORS, useExisting: InValidYearValidatorDirective, multi: true}]
+})
+export class InValidYearValidatorDirective implements Validator {
+ validate(control: AbstractControl): {[key: string]: any} | null {
+ return inValidYearValidator()(control);
+ }
+}
\ No newline at end of file
diff --git a/utils/rangeFilter/rangeFilter.component.html b/utils/rangeFilter/rangeFilter.component.html
new file mode 100644
index 00000000..dfcbed45
--- /dev/null
+++ b/utils/rangeFilter/rangeFilter.component.html
@@ -0,0 +1,44 @@
+
+
+
{{_formatTitle(filter.title)}}
+
+ Clear
+
+
+
+
\ No newline at end of file
diff --git a/utils/rangeFilter/rangeFilter.component.ts b/utils/rangeFilter/rangeFilter.component.ts
new file mode 100644
index 00000000..956b9afb
--- /dev/null
+++ b/utils/rangeFilter/rangeFilter.component.ts
@@ -0,0 +1,47 @@
+import {Component, Input, Output, EventEmitter} from '@angular/core';
+import { RangeFilter } from './rangeFilterHelperClasses.class';
+import { Dates } from "../string-utils.class";
+
+@Component({
+ selector: 'range-filter',
+ templateUrl: 'rangeFilter.component.html'
+})
+
+export class RangeFilterComponent {
+
+ @Input() filter:RangeFilter;
+ @Input() isDisabled:boolean = false;
+ public _maxCharacters:number =28;
+ public focusedInput: string = "";
+ public yearMin = Dates.yearMin;
+ public yearMax = Dates.yearMax;
+
+ @Output() onFilterChange = new EventEmitter();
+
+ constructor() {}
+
+ ngOnInit() {}
+
+ public _formatTitle(title){
+ return ((title.length > this._maxCharacters)?(title.substring(0,(this._maxCharacters - ('...').length))+"..."):title);
+ }
+
+ yearChanged(){
+ this.onFilterChange.emit({
+ value: this.filter
+ });
+ }
+
+ clearFilter() {
+ this.filter.selectedFromValue = null;
+ this.filter.selectedToValue = null;
+ this.onFilterChange.emit({
+ value: this.filter
+ });
+ }
+
+ getFilterName(value){
+ let name = value.name +" ("+ value.number.format()+")";
+ return name;
+ }
+}
diff --git a/utils/rangeFilter/rangeFilter.module.ts b/utils/rangeFilter/rangeFilter.module.ts
new file mode 100644
index 00000000..b4660919
--- /dev/null
+++ b/utils/rangeFilter/rangeFilter.module.ts
@@ -0,0 +1,23 @@
+import { NgModule} from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import { RouterModule } from '@angular/router';
+
+import {RangeFilterComponent} from './rangeFilter.component';
+import {InValidYearValidatorDirective} from "./inValidYear.directive";
+import {FromYearAfterToYearValidatorDirective} from "./fromYearAfterToYear.directive";
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule, RouterModule
+ ],
+ declarations: [
+ RangeFilterComponent, InValidYearValidatorDirective, FromYearAfterToYearValidatorDirective
+ ],
+ providers:[
+ ],
+ exports: [
+ RangeFilterComponent
+ ]
+})
+export class RangeFilterModule { }
\ No newline at end of file
diff --git a/utils/rangeFilter/rangeFilterHelperClasses.class.ts b/utils/rangeFilter/rangeFilterHelperClasses.class.ts
new file mode 100644
index 00000000..184a4b45
--- /dev/null
+++ b/utils/rangeFilter/rangeFilterHelperClasses.class.ts
@@ -0,0 +1,30 @@
+import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class";
+import {SearchFields} from "../properties/searchFields";
+
+export class RangeFilter{
+ public title: string; // eg Publication Date Range
+ public filterId: string; // type (name in url parameter)
+ public originalFilterIdFrom: string; // (in index)
+ public originalFilterIdTo: string; // (in index)
+ public selectedFromValue: string;
+ public selectedToValue: string;
+ public selectedFromAndToValues: string = "";
+
+ public static parse (fields:string[][], entityType:string,):RangeFilter[] {
+ var searchFields:SearchFields = new SearchFields();
+ var filters:RangeFilter[] = [];
+ if(fields){
+ for(let j=0; j
3000 )
+ if(year < this.yearMin || year > this.yearMax )
return false;
return true;
}