diff --git a/portal-2/package.json b/portal-2/package.json index bdc97268..81ae0ea2 100644 --- a/portal-2/package.json +++ b/portal-2/package.json @@ -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", diff --git a/portal-2/src/app/app.ts b/portal-2/src/app/app.ts index 60b1a3cb..b5ab8e11 100644 --- a/portal-2/src/app/app.ts +++ b/portal-2/src/app/app.ts @@ -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: ` -
+
-
diff --git a/portal-2/src/app/claimPages/claim-utils/claimContext.component.ts b/portal-2/src/app/claimPages/claim-utils/claimContext.component.ts index 099ed71e..b335df90 100644 --- a/portal-2/src/app/claimPages/claim-utils/claimContext.component.ts +++ b/portal-2/src/app/claimPages/claim-utils/claimContext.component.ts @@ -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: ` -
+
-
-
- + +
+
+ + +
+ + + + +
+ +
+
+
+
+ -
-
- -
- - + +
+
-
-
- - -
-
- - -
-
- -
-
-
+ + ` }) 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(); + + } } diff --git a/portal-2/src/app/claimPages/claim-utils/claimDataset.component.ts b/portal-2/src/app/claimPages/claim-utils/claimDataset.component.ts index 5e06eada..07c539d5 100644 --- a/portal-2/src/app/claimPages/claim-utils/claimDataset.component.ts +++ b/portal-2/src/app/claimPages/claim-utils/claimDataset.component.ts @@ -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'){ diff --git a/portal-2/src/app/claimPages/claim-utils/claimProject.component.ts b/portal-2/src/app/claimPages/claim-utils/claimProject.component.ts index d1153420..0e330c08 100644 --- a/portal-2/src/app/claimPages/claim-utils/claimProject.component.ts +++ b/portal-2/src/app/claimPages/claim-utils/claimProject.component.ts @@ -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: `
@@ -15,10 +17,9 @@ import { Subject } from 'rxjs/Subject'; --> - -
-
-
+ +
+
@@ -28,10 +29,36 @@ import { Subject } from 'rxjs/Subject';
- + + +
+
+
Projects
+
+ + + {{showItem(item)}} + + + + +
+ +
+ + +
+
+
+ +
-
+
@@ -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(); -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) { diff --git a/portal-2/src/app/claimPages/claim-utils/claimPublication.component.ts b/portal-2/src/app/claimPages/claim-utils/claimPublication.component.ts index 74c3dac0..9adc0298 100644 --- a/portal-2/src/app/claimPages/claim-utils/claimPublication.component.ts +++ b/portal-2/src/app/claimPages/claim-utils/claimPublication.component.ts @@ -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}; diff --git a/portal-2/src/app/claimPages/claim.module.ts b/portal-2/src/app/claimPages/claim.module.ts index 46c116b9..b787708b 100644 --- a/portal-2/src/app/claimPages/claim.module.ts +++ b/portal-2/src/app/claimPages/claim.module.ts @@ -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({ diff --git a/portal-2/src/app/claimPages/linking/linkingGeneric.component.ts b/portal-2/src/app/claimPages/linking/linkingGeneric.component.ts index 54386e33..bf419da7 100644 --- a/portal-2/src/app/claimPages/linking/linkingGeneric.component.ts +++ b/portal-2/src/app/claimPages/linking/linkingGeneric.component.ts @@ -55,9 +55,9 @@ import { Router } from '@angular/router';
- + [linkToResults]="(bulkMode)?false:true" > diff --git a/portal-2/src/app/claimPages/linking/selected/selected.component.ts b/portal-2/src/app/claimPages/linking/selected/selected.component.ts index 66e09d87..3917e35d 100644 --- a/portal-2/src/app/claimPages/linking/selected/selected.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selected.component.ts @@ -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; diff --git a/portal-2/src/app/claimPages/linking/selected/selectedContexts.component.ts b/portal-2/src/app/claimPages/linking/selected/selectedContexts.component.ts index f9fb1af8..6ebbb1d2 100644 --- a/portal-2/src/app/claimPages/linking/selected/selectedContexts.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selectedContexts.component.ts @@ -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; diff --git a/portal-2/src/app/claimPages/linking/selected/selectedDatasets.component.ts b/portal-2/src/app/claimPages/linking/selected/selectedDatasets.component.ts index ea4a19a7..3628677e 100644 --- a/portal-2/src/app/claimPages/linking/selected/selectedDatasets.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selectedDatasets.component.ts @@ -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; diff --git a/portal-2/src/app/claimPages/linking/selected/selectedProjects.component.ts b/portal-2/src/app/claimPages/linking/selected/selectedProjects.component.ts index 91c45bcf..57f761ae 100644 --- a/portal-2/src/app/claimPages/linking/selected/selectedProjects.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selectedProjects.component.ts @@ -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; diff --git a/portal-2/src/app/claimPages/linking/selected/selectedPublications.component.ts b/portal-2/src/app/claimPages/linking/selected/selectedPublications.component.ts index 210f5ccf..40ce24b6 100644 --- a/portal-2/src/app/claimPages/linking/selected/selectedPublications.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selectedPublications.component.ts @@ -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; diff --git a/portal-2/src/app/claimPages/linking/selected/selectedResults.component.ts b/portal-2/src/app/claimPages/linking/selected/selectedResults.component.ts index 14db9103..2d5af1bc 100644 --- a/portal-2/src/app/claimPages/linking/selected/selectedResults.component.ts +++ b/portal-2/src/app/claimPages/linking/selected/selectedResults.component.ts @@ -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; diff --git a/portal-2/src/app/test/test.component.ts b/portal-2/src/app/test/test.component.ts index e3f06da9..c830d042 100644 --- a/portal-2/src/app/test/test.component.ts +++ b/portal-2/src/app/test/test.component.ts @@ -6,7 +6,7 @@ import {Component, ElementRef} from '@angular/core'; template: `
- +
Selected:: diff --git a/portal-2/src/app/utils/autoComplete.component.css b/portal-2/src/app/utils/autoComplete.component.css new file mode 100644 index 00000000..690cbed7 --- /dev/null +++ b/portal-2/src/app/utils/autoComplete.component.css @@ -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; +} diff --git a/portal-2/src/app/utils/autoComplete.component.ts b/portal-2/src/app/utils/autoComplete.component.ts index 43872092..71a646b9 100644 --- a/portal-2/src/app/utils/autoComplete.component.ts +++ b/portal-2/src/app/utils/autoComplete.component.ts @@ -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 // @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: `
{{title}}
- - - {{item.label}} - - - + + + {{showItem(item)}} + + + @@ -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 = []; - // } - // } } diff --git a/portal-2/src/app/utils/entities/claimEntities.class.ts b/portal-2/src/app/utils/entities/claimEntities.class.ts new file mode 100644 index 00000000..8af32621 --- /dev/null +++ b/portal-2/src/app/utils/entities/claimEntities.class.ts @@ -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; + +} diff --git a/portal-2/src/app/utils/entities/entities.module.ts b/portal-2/src/app/utils/entities/entities.module.ts index 9aec3f78..6e7f37bf 100644 --- a/portal-2/src/app/utils/entities/entities.module.ts +++ b/portal-2/src/app/utils/entities/entities.module.ts @@ -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: [