autocomplete component for searching organizations| use it in advnced search of dataproviders and projects

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44759 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-12-01 11:19:38 +00:00
parent 7ac9b343fc
commit b7a2efed9b
5 changed files with 28 additions and 15 deletions

View File

@ -157,7 +157,7 @@ export class SearchPageComponent {
} }
var keyword = params['keyword']; var keyword = params['keyword'];
var doiQuery =(keyword.length > 0 && keyword.split(" ").length ==1 )?'or ((pidclassid exact doi) and (pid exact "'+ keyword+'"))':""; var doiQuery =(keyword && keyword.length > 0 && keyword.split(" ").length ==1 )?'or ((pidclassid exact doi) and (pid exact "'+ keyword+'"))':"";
var keywordQuery =(doiQuery.length > 0 )? "((" + this.quote(keyword) + ")" + doiQuery + ")":this.quote(keyword); var keywordQuery =(doiQuery.length > 0 )? "((" + this.quote(keyword) + ")" + doiQuery + ")":this.quote(keyword);
// parameters += (keyword && keyword.length > 0?' and '+(this.type == 'publication' ||this.type == 'dataset' ?keywordQuery:keyword)+' ':''); // parameters += (keyword && keyword.length > 0?' and '+(this.type == 'publication' ||this.type == 'dataset' ?keywordQuery:keyword)+' ':'');
// allFqs += ; // allFqs += ;

View File

@ -22,7 +22,7 @@ export class ISVocabulariesService {
return this.getDatasetTypesJsonFile(); return this.getDatasetTypesJsonFile();
}else if( field == "access" && (entity == "publication" || entity == "dataset")){ }else if( field == "access" && (entity == "publication" || entity == "dataset")){
return this.getAccessModeJsonFile(); return this.getAccessModeJsonFile();
} else if( field == "type" && (entity == "dataprovider")){ } else if( (field == "datasourcetype") && (entity == "dataprovider")){
return this.getDataProviderTypesJsonFile(); return this.getDataProviderTypesJsonFile();
} else if( field == "compatibility" && (entity == "dataprovider")){ } else if( field == "compatibility" && (entity == "dataprovider")){
return this.getDataProviderCompatibilityJsonFile(); return this.getDataProviderCompatibilityJsonFile();

View File

@ -69,7 +69,7 @@ private fetch (link,id,oafEntityType,type){
let url = link+"/"+id; let url = link+"/"+id;
return this.http.get(url) return this.http.get(url)
.map(request => <any> request.json()) .map(request => <any> request.json())
.do(res => console.info(res)) // .do(res => console.info(res))
.map(request => <any> this.parse(request,oafEntityType,type)); .map(request => <any> this.parse(request,oafEntityType,type));
@ -111,6 +111,12 @@ private fetch (link,id,oafEntityType,type){
} else { } else {
value.label = resData["fullname"]; value.label = resData["fullname"];
} }
}else if(resData["legalname"]){
if(Array.isArray(resData["legalname"])) {
value.label = resData["legalname"][0];
} else {
value.label = resData["legalname"];
}
} }
value.id = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; value.id = length > 1 ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
if(type=="project"){ if(type=="project"){

View File

@ -23,8 +23,9 @@ import {EntitiesSearchService} from '../services/entitySearch.service';
</div> </div>
<input *ngIf = "showInput" type="text" class="auto-complete-input validate filter-input input-sm form-control " [placeholder]=placeHolderMessage [(ngModel)]=keyword (keyup)=search() > <input *ngIf = "showInput" type="text" class="auto-complete-input validate filter-input input-sm form-control " [placeholder]=placeHolderMessage [(ngModel)]=keyword (keyup)=search() >
<div *ngIf = "keyword != null && keyword.length > 0 " class="suggestions" > <div *ngIf = "keyword != null && keyword.length > 0 " class="suggestions" >
<div *ngIf="showLoading" class="alert alert-info row-fluid " role="alert"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span></div>
<ul class="list-group" > <ul class="list-group" >
<li class="list-group-item" > <li *ngIf = "filtered.length > 0 " class="list-group-item" >
Select: Select:
</li> </li>
<li class="list-group-item" *ngFor=" let item of filtered | async"> <li class="list-group-item" *ngFor=" let item of filtered | async">
@ -62,7 +63,7 @@ export class EntitiesAutocompleteComponent {
private showInput = true; private showInput = true;
private sub; private sub;
private done = false; private done = false;
private showLoading:boolean = false;
private searchTermStream = new Subject<string>(); private searchTermStream = new Subject<string>();
filtered: Observable<{}> ; filtered: Observable<{}> ;
@ -83,8 +84,11 @@ export class EntitiesAutocompleteComponent {
this.filtered = this.searchTermStream this.filtered = this.searchTermStream
.debounceTime(300).distinctUntilChanged() .debounceTime(300).distinctUntilChanged()
.switchMap((term: string) => .switchMap((term: string) => {
this._search.searchByType(term, this.entityType)); var results = this._search.searchByType(term, this.entityType);
this.showLoading = false;
return results;
});
this.getSelectedNameFromGivenId(); this.getSelectedNameFromGivenId();
} }
@ -111,7 +115,7 @@ export class EntitiesAutocompleteComponent {
this.tries = 0; this.tries = 0;
this.warningMessage = ""; this.warningMessage = "";
this.searchTermStream.next(this.keyword); this.searchTermStream.next(this.keyword);
this.showLoading = true;
} }
} }

View File

@ -36,10 +36,10 @@ export class SearchFields {
public PROJECT_INDEX:string[] = ["funderid","fundinglevel0_id","fundinglevel1_id","fundinglevel2_id","projectstartyear","projectendyear","projectecsc39"]; public PROJECT_INDEX:string[] = ["funderid","fundinglevel0_id","fundinglevel1_id","fundinglevel2_id","projectstartyear","projectendyear","projectecsc39"];
public ADVANCED_PROJECTS_PARAM:string[] = ["q", "acronym","title","keywords", "funder", "funderlv0", public ADVANCED_PROJECTS_PARAM:string[] = ["q", "acronym","title","keywords", "funder", "funderlv0",
"funderlv1","funderlv2","startyear","endyear","sc39","code"]; "funderlv1","funderlv2","startyear","endyear","sc39","code","organization"];
public PROJECT_INDEX_PARAM_MAP:{ [key:string]:string } = { public PROJECT_INDEX_PARAM_MAP:{ [key:string]:string } = {
[ "funderid"]:"funder", ["fundinglevel0_id"]:"funderlv0",["fundinglevel1_id"]:"funderlv1",["fundinglevel2_id"]:"funderlv2", [ "funderid"]:"funder", ["fundinglevel0_id"]:"funderlv0",["fundinglevel1_id"]:"funderlv1",["fundinglevel2_id"]:"funderlv2",
["projectstartyear"]:"startyear",["projectendyear"]:"endyear",["projectecsc39"]:"sc39"}; ["projectstartyear"]:"startyear",["projectendyear"]:"endyear",["projectecsc39"]:"sc39",["relorganizationid"]:"organization"};
public PROJECT_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ public PROJECT_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={
["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="}, ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator: "="},
@ -53,17 +53,19 @@ export class SearchFields {
["startyear"]:{name:"Start Year",operator:"sa", type:"keyword", indexField:"projectstartyear", equalityOperator: " exact "}, ["startyear"]:{name:"Start Year",operator:"sa", type:"keyword", indexField:"projectstartyear", equalityOperator: " exact "},
["endyear"]: {name:"End Year",operator:"ed", type:"keyword", indexField:"projectendyear", equalityOperator: " exact "}, ["endyear"]: {name:"End Year",operator:"ed", type:"keyword", indexField:"projectendyear", equalityOperator: " exact "},
["sc39"]: {name:"Special Clause 39",operator:"sc", type:"boolean", indexField:"projectecsc39", equalityOperator: " exact "}, ["sc39"]: {name:"Special Clause 39",operator:"sc", type:"boolean", indexField:"projectecsc39", equalityOperator: " exact "},
["code"]: {name:"Project Code",operator:"cd", type:"keyword", indexField:"projectcode", equalityOperator: " exact "} ["code"]: {name:"Project Code",operator:"cd", type:"keyword", indexField:"projectcode", equalityOperator: " exact "},
["organization"]: {name:"Organization",operator:"og", type:"entity", indexField:"relorganizationid", equalityOperator: " exact "}
}; };
//DATAPROVIDERS //DATAPROVIDERS
public DATAPROVIDER_INDEX:string[] = ["datasourcetypeuiid", "datasourceodlanguages", "datasourceodcontenttypes", public DATAPROVIDER_INDEX:string[] = ["datasourcetypeuiid", "datasourceodlanguages", "datasourceodcontenttypes",
"datasourcecompatibilityid"];; "datasourcecompatibilityid"];;
public ADVANCED_DATAPROVIDER_PARAM:string[] = ["q", "officialname", public ADVANCED_DATAPROVIDER_PARAM:string[] = ["q", "officialname",
"engname","subjects", "type","lang","contenttype", "compatibility"]; "engname","subjects", "datasourcetype","lang","contenttype", "compatibility","organization"];
public DATAPROVIDER_INDEX_PARAM_MAP:{ [key:string]:string } = { public DATAPROVIDER_INDEX_PARAM_MAP:{ [key:string]:string } = {
[ "datasourcetypeuiid"]:"type", [ "datasourcetypeid"]:"datasourcetype", ["datasourceodlanguages"]:"lang",["datasourceodcontenttypes"]:"contenttype", [ "datasourcetypeuiid"]:"type", [ "datasourcetypeid"]:"datasourcetype", ["datasourceodlanguages"]:"lang",["datasourceodcontenttypes"]:"contenttype",
["datasourcecompatibilityid"]:"compatibility"}; ["datasourcecompatibilityid"]:"compatibility",["relorganizationid"]:"organization"};
public DATAPROVIDER_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={ public DATAPROVIDER_FIELDS_MAP: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ={
["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator:"="}, ["q"]:{name:"All fields",operator:"op", type:"keyword", indexField:null, equalityOperator:"="},
@ -75,6 +77,7 @@ export class SearchFields {
["lang"]:{name:"Language",operator:"ln", type:"vocabulary", indexField:"datasourceodlanguages", equalityOperator: " exact "}, ["lang"]:{name:"Language",operator:"ln", type:"vocabulary", indexField:"datasourceodlanguages", equalityOperator: " exact "},
["contenttype"]:{name:"Content Type",operator:"cn", type:"refine", indexField:"datasourceodcontenttypes", equalityOperator: " exact "}, ["contenttype"]:{name:"Content Type",operator:"cn", type:"refine", indexField:"datasourceodcontenttypes", equalityOperator: " exact "},
["compatibility"]:{name:"Compatibility Level",operator:"cm", type:"vocabulary", indexField:"datasourcecompatibilityid", equalityOperator: " exact "}, ["compatibility"]:{name:"Compatibility Level",operator:"cm", type:"vocabulary", indexField:"datasourcecompatibilityid", equalityOperator: " exact "},
["organization"]: {name:"Organization",operator:"og", type:"entity", indexField:"relorganizationid", equalityOperator: " exact "}
}; };
public COMPATIBLE_DATAPROVIDER_FIELDS:string[] = ["type","compatibility"]; public COMPATIBLE_DATAPROVIDER_FIELDS:string[] = ["type","compatibility"];