add claim entities classes for linking, add an initial draft for generic autocomplete component

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43933 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-10-04 13:56:04 +00:00
parent 69ba6571bc
commit 9eb6f1c7da
19 changed files with 388 additions and 252 deletions

View File

@ -44,6 +44,7 @@
"angular2-universal": "~2.0.11",
"angular2-universal-polyfills": "~2.0.11",
"body-parser": "^1.15.2",
"bootstrap": "^4.0.0-alpha.4",
"express": "^4.14.0",
"methods": "~1.1.2",
"ng2-webstorage": "^1.2.2",

View File

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
// require('bootstrap');
import 'rxjs/Rx';
//import {LocalStorageService} from "angular2-localstorage/LocalStorageEmitter";
@ -11,9 +12,8 @@ import 'rxjs/Rx';
@Component({
selector: 'app',
template: `
<div>
<div>
<navbar></navbar>
<main>
<router-outlet></router-outlet>
</main>

View File

@ -1,136 +1,159 @@
import {Component, Input,Output, ElementRef, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ContextsService} from '../../services/contexts.service';
import {ClaimContext} from '../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-contexts',
template: `
<div class="panel-body" >
<div class="panel-body" *ngIf="!inline">
<div class="input-group" *ngIf="!inline">
<div class=" input-group-btn">
<button class="btn btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="input-group" >
<div class=" input-group-btn">
<button class="btn btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCommunityLabel}}
</button>
<ul class="dropdown-menu" aria-labelledby="communityDropDown">
<li (click)="communityChanged('0','Community:')"><a >Community:</a></li>
<li *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" ><a >{{communities.label}}</a></li>
</ul>
</div>
<div class="input-group-btn ">
<button class="btn btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCategoryLabel}}
</button>
<ul class="dropdown-menu" aria-labelledby="categoryDropDown">
<li (click)="categoryChanged('0','Category:')"><a >Category:</a></li>
<li *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" ><a >{{category.label}}</a></li>
</ul>
</div>
<!--input id="community" type="text" class="validate filter-input form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() -->
</div>
<autocomplete [(keyword)] = query [(filtered)] =filteredList [(selected)] =selectedList [showSelected]=false placeHolderMessage = "Search for contexts" title = "Contexts:" (keywordChange)="filter(query)" type="context"></autocomplete>
</div>
<div class="panel-body" *ngIf=" inline && showComponent ">
<div class=" form-horizontal">
<div class=" form-group ">
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCommunityLabel}}
</button>
<ul class="dropdown-menu" aria-labelledby="communityDropDown">
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="communityDropDown">
<li (click)="communityChanged('0','Community:')"><a >Community:</a></li>
<li *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" ><a >{{communities.label}}</a></li>
</ul>
</div>
<div class="input-group-btn ">
<button class="btn btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="form-group ">
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCategoryLabel}}
</button>
<ul class="dropdown-menu" aria-labelledby="categoryDropDown">
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="categoryDropDown">
<li (click)="categoryChanged('0','Category:')"><a >Category:</a></li>
<li *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" ><a >{{category.label}}</a></li>
</ul>
</div>
<input id="community" type="text" class="validate filter-input form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() >
<!--div class="form-group">
<input id="community" type="text" class="validate filter-input input-sm form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() >
</div-->
</div>
<autocomplete [(keyword)] = query [(filtered)] =filteredList [(selected)] =selectedList [showSelected]=false placeHolderMessage = "Search for contexts" title = "Contexts:" (keywordChange)="filter($event)" type="context"></autocomplete>
</div>
<div class=" form-horizontal" *ngIf=" inline && showComponent ">
<div class=" form-group ">
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCommunityLabel}}
</button>
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="communityDropDown">
<li (click)="communityChanged('0','Community:')"><a >Community:</a></li>
<li *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" ><a >{{communities.label}}</a></li>
</ul>
</div>
<div class="form-group ">
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{selectedCategoryLabel}}
</button>
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="categoryDropDown">
<li (click)="categoryChanged('0','Category:')"><a >Category:</a></li>
<li *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" ><a >{{category.label}}</a></li>
</ul>
</div>
<div class="form-group">
<input id="community" type="text" class="validate filter-input input-sm form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() >
</div>
</div>
<div class="suggestions" *ngIf="filteredList.length > 0">
<!--div class="suggestions" *ngIf="filteredList.length > 0">
<ul class="list-group" >
<li class="list-group-item" *ngFor=" let item of filteredList">
<a (click)="select(item)">{{item.label}}</a>
</li>
</ul>
</div>
</div>
</div-->
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div>
`
})
export class ClaimContextComponent {
ngOnInit() {
this.getCommunities();
}
@Input() public inline:boolean = false ; // for claimed started from landing pages
@Input() public showComponent:boolean = true ; // for claimed started from landing pages
@Input() public selectedList = [];
@Input() public selectedCommunityId:string = "0";
@Input() public selectedCategoryId:string ="0";
@Output() cselectedCommunityChange = new EventEmitter();
@Output() selectedCategoryChange = new EventEmitter();
public query = '';
public filteredList = [];
@Input() public selectedList ;
public elementRef;
// @Output() contextsChange = new EventEmitter();
public communities:string[];
@Input() public selectedCommunityId:string = "0";
selectedCommunityLabel:string = "Community:";
@Output() cselectedCommunityChange = new EventEmitter();
private selectedCommunityLabel:string = "Community:";
public categories:string[];
@Input() public selectedCategoryId:string ="0";
selectedCategoryLabel:string ="Category:";
@Output() selectedCategoryChange = new EventEmitter();
private selectedCategoryLabel:string ="Category:";
public concepts:string[];
public warningMessage = "";
public infoMessage = "";
ngOnInit() {
this.getCommunities();
}
constructor(private _contextService: ContextsService,myElement: ElementRef) {
this.elementRef = myElement;
}
filter() {
this.warningMessage = "";
this.infoMessage = "";
if(this.selectedCommunityId == "0"){
this.warningMessage = "Please select Community";
}else if (this.query !== ""){
this.warningMessage = "";
this.infoMessage = "";
if(this.selectedCategoryId == "0"){
this.warningMessage = "Specify category for more concepts";
}
this.filteredList = this.concepts.filter(function(el){
return el.label.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
}.bind(this));
if(this.filteredList.length == 0 ){
this.infoMessage = "No results found";
}
}else{
this.filteredList = [];
// filter() {
// this.warningMessage = "";
// this.infoMessage = "";
// if(this.selectedCommunityId == "0"){
// this.warningMessage = "Please select Community";
// }else if (this.query !== ""){
// this.warningMessage = "";
// this.infoMessage = "";
// if(this.selectedCategoryId == "0"){
// this.warningMessage = "Specify category for more concepts";
// }
// this.filteredList = this.concepts.filter(function(el){
// return el.label.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
// }.bind(this));
// if(this.filteredList.length == 0 ){
// this.infoMessage = "No results found";
// }
// }else{
// this.filteredList = [];
// }
//
// }
filter($event) {
var query = $event.value;
this.query = $event.value;
this.filteredList = this.concepts.filter(function(el){
return el.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
}.bind(this));
var list = [ ];
for (var _i = 0; _i < this.filteredList.length; _i++) {
let item = this.filteredList[_i];
var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item };
list.push(context);
}
this.filteredList = list;
}
select(item){
this.query = "";
this.filteredList = [];
var context= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item };
var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item };
var found:boolean = false;
this.warningMessage = "";
for (var _i = 0; _i < this.selectedList.length; _i++) {
@ -142,48 +165,26 @@ select(item){
}
if (!found) {
this.selectedList.push(context);
// this.contextsChange.emit({
// value: this.selectedList
// });
}
// var index:number =this.selectedList.indexOf(context);
// if (index == -1) {
// this.selectedList.push(context);
// this.contextsChange.emit({
// value: this.selectedList
// });
// }
}
}
// remove(item){
// var index:number =this.selectedList.indexOf(item);
// if (index > -1) {
// this.selectedList.splice(index, 1);
// handleClick(event){
// var clickedComponent = event.target;
// var inside = false;
// do {
// if (clickedComponent === this.elementRef.nativeElement) {
// inside = true;
// }
// clickedComponent = clickedComponent.parentNode;
// } while (clickedComponent);
// if(!inside){
// this.filteredList = [];
// }
// this.contextsChange.emit({
// value: this.selectedList
// });
// }
handleClick(event){
var clickedComponent = event.target;
var inside = false;
do {
if (clickedComponent === this.elementRef.nativeElement) {
inside = true;
}
clickedComponent = clickedComponent.parentNode;
} while (clickedComponent);
if(!inside){
this.filteredList = [];
}
}
getCommunities () {
this._contextService.getCommunities().subscribe(
data => {
this.communities = data.communities;
// var concept= ["{id: this.communities['id'], label: this.communities['label'] }"];
// this.filteredList.push(concept);
// this.concepts.push(concept);
},
err => console.error(err)
);
@ -197,7 +198,9 @@ getCommunities () {
this.concepts = [];
this.filteredList = [];
if (this.query !== ""){
this.filter();
var event = {value: ""};
event.value = this.query;
this.filter(event);
}
},
@ -211,8 +214,10 @@ getCommunities () {
data => {
this.concepts = data.concept;
if (this.query !== ""){
this.filter();
}
var event = {value: ""};
event.value = this.query;
this.filter(event);
}
},
err => console.error(err)
);
@ -220,21 +225,21 @@ getCommunities () {
this.concepts=[];
}
}
communityChanged(communityId:string, communityLabel:string){
this.warningMessage = "";
this.infoMessage = "";
this.selectedCommunityId= communityId;
this.selectedCommunityLabel= communityLabel;
this.getCategories();
}
categoryChanged(categoryId:string, categoryLabel:string){
this.warningMessage = "";
this.infoMessage = "";
this.selectedCategoryId = categoryId;
this.selectedCategoryLabel = categoryLabel;
this.getConcepts();
}
communityChanged(communityId:string, communityLabel:string){
this.warningMessage = "";
this.infoMessage = "";
this.selectedCommunityId= communityId;
this.selectedCommunityLabel= communityLabel;
this.getCategories();
}
categoryChanged(categoryId:string, categoryLabel:string){
this.warningMessage = "";
this.infoMessage = "";
this.selectedCategoryId = categoryId;
this.selectedCategoryLabel = categoryLabel;
this.getConcepts();
}
}

View File

@ -1,6 +1,7 @@
import { Component, Input, Output, EventEmitter} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { SearchDataciteService } from '../../services/searchDatacite.service';
import {ClaimResult} from '../../utils/entities/claimEntities.class';
@Component({
@ -112,7 +113,7 @@ export class ClaimDatasetComponent {
}
add(item, itemId,itemType,itemSource,itemTitle, itemUrl, date){
var result ;
var result: ClaimResult ;
if(itemSource == 'datacite'){
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
}else if (itemSource == 'openaire'){

View File

@ -4,10 +4,12 @@ import {OpenaireProjectsService} from '../../services/openaireProjects.service';
import {ProjectService} from '../../services/project.service';
import {ModalLoading} from '../../utils/modal/loading.component';
import { Subject } from 'rxjs/Subject';
import {ClaimProject} from '../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-projects',
// styleUrls: ['/autoComplete.component.css'],
template: `
<div class="panel-body" >
@ -15,10 +17,9 @@ import { Subject } from 'rxjs/Subject';
<option [ngValue]="'0'">Funder:</option>
<option *ngFor="let funder of funders" [ngValue]="funder.field.field[1]['@value_original']">{{funder.field.field[1]['@value']}}</option>
</select> -->
<form *ngIf=" !inline ">
<div class="input-group">
<div class="input-group-btn" >
<form><!-- *ngIf=" !inline "-->
<div><!-- class="input-group"-->
<div> <!-- class="input-group-btn" -->
<button type="button" class="btn btn-info dropdown-toggle" id="dropdownFunder" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{selectedFunderName}}
</button>
@ -28,10 +29,36 @@ import { Subject } from 'rxjs/Subject';
</ul>
</div>
<input id="community" type="text" class="form-control" placeholder="Search for Projects" [(ngModel)]=query name="query" (keyup)="search()" >
<!--input id="community" type="text" class="form-control" placeholder="Search for Projects" [(ngModel)]=query name="query" (keyup)="search()"-->
<!--autocomplete -->
<div class="bs-docs-grid">
<div class = "row-fluid form-inline auto-complete-box panel panel-default">
<div class="panel-heading">Projects</div>
<div class="panel-body">
<span *ngIf = "showSelected">
<span class="row-fluid show-grid auto-complete-choice" *ngFor="let item of selected" >
<span >{{showItem(item)}} </span>
<span (click)="remove(item)" aria-hidden="true" class=" remove glyphicon glyphicon-remove"></span>
</span>
</span>
<input name="searchkeyword" type="text" class="auto-complete-input validate filter-input input-sm form-control " placeholder="Search for Projects" [(ngModel)]=query (keyup)=search() >
<div class="suggestions" ><!--*ngIf="filtered.length > 0"-->
<ul class="list-group" >
<li class="list-group-item" *ngFor=" let item of filtered | async">
<a (click)="select(item)">{{showItem(item)}}</a>
</li>
</ul>
</div>
<div *ngIf="warningMessage.length > 0" class="alert alert-warning row-fluid " role="alert">{{warningMessage}}</div>
<div *ngIf="filtered.length == 0 && keyword.length >=3 " class="alert alert-info row-fluid " role="alert">No results Found</div>
</div>
</div>
</div>
<!--autocomplete -->
</div>
</form>
<form *ngIf=" inline " class="form-horizontal">
<!--form *ngIf=" inline " class="form-horizontal">
<div class="">
<div class="form-group" >
<button type="button" class="btn btn-xs btn-info dropdown-toggle" id="dropdownFunder" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
@ -52,7 +79,7 @@ import { Subject } from 'rxjs/Subject';
<a (click)="select(item)"> {{(item.field[1]['@value'])?item.field[1]['@value']+" - ":""}} {{item.field[3]['@value']}}</a>
</li>
</ul>
</div>
</div-->
</div>
@ -70,7 +97,6 @@ export class ClaimProjectsComponent {
@Input() public inline: boolean = false ; // for claimed started from landing pages
public query = '';
// public filteredList = [];
@Input() public selectedProjects=[] ;
public elementRef;
@ -84,50 +110,73 @@ export class ClaimProjectsComponent {
public infoMessage = "";
private searchTermStream = new Subject<string>();
search() {
console.info("term changed!!!");
this.searchTermStream.next(this.query); }
filteredList: Observable<{}> = this.searchTermStream
.debounceTime(300).
distinctUntilChanged()
filtered: Observable<{}> = this.searchTermStream
.debounceTime(300).distinctUntilChanged()
.switchMap((term: string) => this._projectService.searchForProjectsObs(term, this.selectedFunderId));
private tries:number = 0 ;
private keywordlimit = 3;
constructor(private _service: ProjectService,private _projectService: OpenaireProjectsService,myElement: ElementRef) {
constructor(private _service: ProjectService, private _projectService: OpenaireProjectsService,myElement: ElementRef) {
this.elementRef = myElement;
}
filter() {
console.info("Search projects");
if (this.selectedFunderId == '0' ){
this.warningMessage = "Please select a funder first";
this.infoMessage = "";
}else if ( this.query == "" || this.query.length < 3){
this.warningMessage = "Please type a keyword, containing at least 3 characters"
this.infoMessage = "";
}else{
this.warningMessage = "";
this.infoMessage = "";
this.loading.open();
this._projectService.searchForProjects(this.query, this.selectedFunderId).subscribe(
data => {
this.filteredList =(data == null)?[]:data;
this.infoMessage = (data == null)?"No Results found":"";
this.loading.close();
},
err => {
console.error(err);
this.loading.close();
this.warningMessage = "An error occured";
}
);
search() {
console.info("heeere "+this.query );
this.infoMessage = "";
// this.filtered = [];
if(this.query == ""){
this.tries = 0;
this.warningMessage = "";
} else if(this.query && this.query.length < this.keywordlimit){
this.tries++;
if(this.tries == this.keywordlimit -1 ){
this.warningMessage = "Type at least " + this.keywordlimit + " characters";
this.tries = 0;
}
}else{
console.info("doo the search "+this.query );
this.tries = 0;
this.warningMessage = "";
this.searchTermStream.next(this.query);
}
}
// filter() {
// console.info("Search projects");
// if (this.selectedFunderId == '0' ){
// this.warningMessage = "Please select a funder first";
// this.infoMessage = "";
// }else if ( this.query == "" || this.query.length < 3){
// this.warningMessage = "Please type a keyword, containing at least 3 characters"
// this.infoMessage = "";
// }else{
// this.warningMessage = "";
// this.infoMessage = "";
// this.loading.open();
// this._projectService.searchForProjects(this.query, this.selectedFunderId).subscribe(
// data => {
// this.filteredList =(data == null)?[]:data;
// this.infoMessage = (data == null)?"No Results found":"";
// this.loading.close();
// },
// err => {
// console.error(err);
// this.loading.close();
// this.warningMessage = "An error occured";
//
// }
// );
// }
// }
select(item){
this.query = "";
var project= { funderId: this.selectedFunderId,funderName: this.selectedFunderName, projectId: item.field[0]['@value'], projectName: item.field[3]['@value'] , projectAcronym: item.field[1]['@value'], startDate: null, endDate: null };
this.searchTermStream.next(this.query); //clear
var project: ClaimProject = { funderId: this.selectedFunderId,funderName: this.selectedFunderName, projectId: item.field[0]['@value'], projectName: item.field[3]['@value'] , projectAcronym: item.field[1]['@value'], startDate: null, endDate: null };
this._service.getProjectDates(project.projectId).subscribe(
data => {
project.startDate = data.startDate;
@ -152,6 +201,9 @@ select(item){
}
}
showItem(item):string{
return ((item.field[1]['@value'])?item.field[1]['@value']+" - ":"" ) + item.field[3]['@value'];
}
remove(item){
var index:number =this.selectedProjects.indexOf(item);
if (index > -1) {

View File

@ -3,6 +3,7 @@ import {Observable} from 'rxjs/Observable';
import { ActivatedRoute } from '@angular/router';
import {SearchCrossrefService} from '../../services/searchCrossref.service';
import {SearchOrcidService} from '../../services/searchOrcid.service';
import {ClaimResult} from '../../utils/entities/claimEntities.class';
@Component({
@ -227,7 +228,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
private add(item, id, itemSource, itemType, itemUrl, itemTitle, date){
var result ;
var result: ClaimResult ;
if(itemSource == 'crossref'){
date = (date == null) ? null : date.substring(0,10);
result = {id: id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date};

View File

@ -37,9 +37,9 @@ import {LinkingGenericComponent} from './linking/linkingGeneric.component';
import {InlineClaimContextComponent} from './inlineClaims/inlineClaimContext.component';
import {InlineClaimProjectComponent} from './inlineClaims/inlineClaimProject.component';
import {InlineClaimResultComponent} from './inlineClaims/inlineClaimResult.component';
import {ClaimEntityFormatter} from '../utils/claimEntityFormatter.component';
import { Claim } from '../utils/entities/claim';
import {ClaimEntityFormatter} from '../utils/claimEntityFormatter.component';
import { Claim } from '../utils/entities/claim';
//helpers
@NgModule({

View File

@ -55,9 +55,9 @@ import { Router } from '@angular/router';
</div>
</div>
<div *ngIf=" show == 'claim' " >
<claim-selected [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show]="show"
<!--claim-selected [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show]="show"
(showChange)="showChange($event)" (publicationsChange)="publicationsChange($event)" [showAccessRights]="'true'" [bulkMode]="bulkMode"
[linkToResults]="(bulkMode)?false:true" > </claim-selected>
[linkToResults]="(bulkMode)?false:true" > </claim-selected-->
<claim-selected-contexts [contexts]="contexts" [show]="show"
(showChange)="showChange($event)" > </claim-selected-contexts>

View File

@ -1,4 +1,5 @@
import {Component, Input,Output, EventEmitter} from '@angular/core';
import {ClaimResult,ClaimProject, ClaimContext} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected',
@ -121,10 +122,10 @@ export class ClaimSelectedComponent {
}
@Input() contexts;
@Input() projects;
@Input() publications;
@Input() datasets;
@Input() contexts: ClaimContext[];
@Input() projects: ClaimProject[];
@Input() publications: ClaimResult[];
@Input() datasets: ClaimResult[];
@Input() showAccessRights:boolean = false;
@Input() show='home';
@Input() inline:boolean = false;

View File

@ -1,5 +1,5 @@
import {Component, Input,Output, EventEmitter} from '@angular/core';
import {ClaimContext} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected-contexts',
template: `
@ -31,7 +31,7 @@ export class ClaimSelectedContextsComponent {
}
@Input() contexts;
@Input() contexts:ClaimContext[];
@Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
@Input() show='home';
@Input() inline:boolean = false;

View File

@ -1,6 +1,6 @@
import {Component, Input,Output, EventEmitter,ViewChild} from '@angular/core';
import {AlertModal} from '../../../utils/modal/alert';
import {ClaimResult} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected-datasets',
template: `
@ -51,7 +51,7 @@ export class ClaimSelectedDatasetsComponent {
@Input() datasets;
@Input() datasets: ClaimResult[];
@Input() showAccessRights:boolean = false;
@Input() inline:boolean = false;
@Input() hideType;

View File

@ -1,4 +1,5 @@
import {Component, Input,Output, EventEmitter} from '@angular/core';
import {ClaimProject} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected-projects',
@ -33,7 +34,7 @@ ngOnInit() {
}
@Input() projects;
@Input() projects: ClaimProject[];
@Input() show='home';
@Input() inline:boolean = false;
@Input() hideType;

View File

@ -1,5 +1,6 @@
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
import {AlertModal} from '../../../utils/modal/alert';
import {ClaimResult} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected-publications',
@ -48,7 +49,7 @@ export class ClaimSelectedPublicationsComponent {
//2015-05-01
}
@Input() publications;
@Input() publications: ClaimResult[];
@Input() showAccessRights:boolean = false;
@Input() inline:boolean = false;
@Input() hideType;

View File

@ -1,4 +1,5 @@
import {Component, Input,Output, EventEmitter} from '@angular/core';
import {ClaimResult} from '../../../utils/entities/claimEntities.class';
@Component({
selector: 'claim-selected-results',
@ -47,8 +48,8 @@ export class ClaimSelectedResultsComponent {
@Input() publications;
@Input() datasets;
@Input() publications:ClaimResult[];
@Input() datasets:ClaimResult[];
@Input() showAccessRights:boolean = false;
@Input() show='home';
@Input() inline:boolean = false;

View File

@ -6,7 +6,7 @@ import {Component, ElementRef} from '@angular/core';
template: `
<!--i-frame url="https://google.com" width="30%" height="250"></i-frame-->
<div style ="width:30%; height:250px;" >
<autocomplete [(filtered)] =filtered [(selected)] =selected placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)"></autocomplete>
<autocomplete [(filtered)] =filtered [(selected)] =selected [showSelected]=false placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)" ></autocomplete>
<div>
Selected::
<span class="row-fluid show-grid auto-complete-choice" *ngFor="let item of selected" >

View File

@ -0,0 +1,25 @@
.auto-complete-box{
}
.auto-complete-choice .remove {
cursor: pointer;
}
.auto-complete-choice{
background: grey none repeat scroll 0 0;
border-color: grey;
border-radius: 5px;
border-style: solid;
color: white;
margin: 3px;
padding: 1px;
}
.auto-complete-input {
border-radius:0;
border-color: white;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0) inset;
}
.form-control. auto-complete-input {
box-shadow: 0 1px 1px rgba(0, 0, 0, 0) inset;
}
.auto-complete-box .suggestions.list-group-item {
padding: 5px 10px;
}

View File

@ -1,46 +1,28 @@
import {Component, ElementRef, Input, Output, EventEmitter} from '@angular/core';
import {Value} from '../searchPages/searchUtils/searchHelperClasses.class';
import {ClaimResult, ClaimContext, ClaimProject} from './entities/claimEntities.class';
//Usage example
//<autocomplete [(filtered)] =filtered [(selected)] =selected placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)"></autocomplete>
@Component({
selector: 'autocomplete',
styles: [`
.auto-complete-box{ }
.auto-complete-choice .remove {
cursor: pointer;
}
.auto-complete-choice{
background: grey none repeat scroll 0 0;
border-color: grey;
border-radius: 5px;
border-style: solid;
color: white;
margin: 3px;
padding: 1px;
}
.auto-complete-input { border-radius:0; border-color: white; box-shadow: 0 1px 1px rgba(0, 0, 0, 0) inset; }
.form-control. auto-complete-input {box-shadow: 0 1px 1px rgba(0, 0, 0, 0) inset;}
.auto-complete-box .suggestions.list-group-item {
padding: 5px 10px;
}
`],
styleUrls: ['autoComplete.component.css'],
template: `
<div class="bs-docs-grid">
<div class = "row-fluid form-inline auto-complete-box panel panel-default">
<div class="panel-heading">{{title}}</div>
<div class="panel-body">
<span class="row-fluid show-grid auto-complete-choice" *ngFor="let item of selected" >
<span >{{item.label}} </span>
<span (click)="remove(item)" aria-hidden="true" class=" remove glyphicon glyphicon-remove"></span>
</span>
<span *ngIf = "showSelected">
<span class="row-fluid show-grid auto-complete-choice" *ngFor="let item of selected" >
<span >{{showItem(item)}} </span>
<span (click)="remove(item)" aria-hidden="true" class=" remove glyphicon glyphicon-remove"></span>
</span>
</span>
<input type="text" class="auto-complete-input validate filter-input input-sm form-control " [placeholder]=placeHolderMessage [(ngModel)]=keyword (keyup)=filter() >
<div class="suggestions" *ngIf="filtered.length > 0">
<ul class="list-group" >
<li class="list-group-item" *ngFor=" let item of filtered">
<a (click)="select(item)">{{item.label}}</a>
<a (click)="select(item)">{{showItem(item)}}</a>
</li>
</ul>
</div>
@ -56,18 +38,22 @@ export class AutocompleteComponent {
@Input() placeHolderMessage = "Search for entries";
@Input() title = "Autocomplete";
@Output() keywordChange = new EventEmitter(); // when changed a method for filtering will be called
@Output() addNew = new EventEmitter(); // when changed a method for filtering will be called
@Input() public filtered = []; // the entries resulted after filtering function
@Input() public selected = []; // the entries selected from user
@Input() public keywordlimit = 3; // the minimum length of keyword
@Input() public showSelected = true; // the minimum length of keyword
public keyword = '';
@Input() public keyword = '';
@Input() public type = 'search' //search, result, context, project
private warningMessage = "";
private infoMessage = "";
private tries = 0;
constructor () {
console.info('project constructor');
constructor () {
console.info("Type"+this.type);
}
filter() {
this.infoMessage = "";
@ -84,54 +70,83 @@ export class AutocompleteComponent {
}else{
this.tries = 0;
this.warningMessage = "";
// this.filtered = this.concepts.filter(function(el){
// return el.label.toLowerCase().indexOf(this.keyword.toLowerCase()) > -1;
// }.bind(this));
this.keywordChange.emit({
value: this.keyword
});
// this.filtered = this.countries.filter(function(el){
// return el.toLowerCase().indexOf(this.keyword.toLowerCase()) > -1;
// }.bind(this));
// if(this.filtered.length == 0 ){
// this.infoMessage = "No results found";
// }
}
}
remove(item:any){
var index:number =this.selected.indexOf(item);
var index:number =this.checkIfExists(item,this.selected);
if (index > -1) {
this.selected.splice(index, 1);
}
}
select(item:any){
var index:number =this.selected.indexOf(item);
if (index > -1) {
// this.warningMessage = "Already selected";
this.keyword = "";
this.filtered.splice(0, this.filtered.length);
}else{
this.selected.push(item);
this.keyword = "";
this.filtered.splice(0, this.filtered.length);
var index:number =this.checkIfExists(item,this.selected);
if (index > -1) {
this.keyword = "";
this.filtered.splice(0, this.filtered.length);
return;
}
else{
this.selected.push(item);
this.keyword = "";
this.filtered.splice(0, this.filtered.length);
}
}
private checkIfExists(item:any,list):number{
console.log("type "+this.type);
if(this.type == "search"){
console.log("Value");
}else if(this.type == "context"){
console.log("context");
for (var _i = 0; _i < list.length; _i++) {
let itemInList = list[_i];
console.log("itemiL "+itemInList.concept.id);
console.log("item "+item.concept.id);
if(item.concept.id == itemInList.concept.id){
return _i;
}
}
}else if(this.type == "project"){
console.log("project");
}else {
console.log("no----");
}
return -1;
}
showItem(item:any):string{
if (item.name){ //search
return item.name;
}else if( item.concept && item.concept.label){ //context
return item.concept.label;
}else if (item.label){ //simple
return item.label;
}
}
// handleClick(event){
// var clickedComponent = event.target;
// var inside = false;
// do {
// if (clickedComponent === this.elementRef.nativeElement) {
// inside = true;
// }
// clickedComponent = clickedComponent.parentNode;
// } while (clickedComponent);
// if(!inside){
// this.filteredList = [];
// }
// }
// handleClick(event){
// var clickedComponent = event.target;
// var inside = false;
// do {
// if (clickedComponent === this.elementRef.nativeElement) {
// inside = true;
// }
// clickedComponent = clickedComponent.parentNode;
// } while (clickedComponent);
// if(!inside){
// this.filtered = [];
// }
// }
}

View File

@ -0,0 +1,30 @@
//Classes used in linking / inlinelinking when selecting an entity
export class ClaimResult{
public id: string;
public type: string;
public source: string;
public title: string;
public url: string;
public result: any;
public accessRights: string = "OPEN";
public embargoEndDate: string;
public date: string;
}
export class ClaimProject{
public funderId: string;
public funderName: string;
public projectId: string;
public projectName: string;
public projectAcronym: string;
public startDate: string;
public endDate: string;
}
export class ClaimContext{
public community: string;
public category: string;
public concept:any;
}

View File

@ -13,6 +13,8 @@ import {PublicationInfo} from './publicationInfo';
import {SearchResult} from './searchResult';
import { DataProviderInfo } from './dataProviderInfo';
import {ClaimResult, ClaimProject, ClaimContext} from './claimEntities.class';
@NgModule({
imports: [ CommonModule, FormsModule ],
declarations: [