more for inline linking in publication landing page

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43109 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-07-03 15:56:13 +00:00
parent 1a04444e54
commit 3ea5df83cb
6 changed files with 306 additions and 73 deletions

View File

@ -1,4 +1,4 @@
import {Component, Input} from '@angular/core';
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
import {JSONP_PROVIDERS} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
@ -12,28 +12,21 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
template: `
<div *ngIf="showComp == 'true'" class="panel-body well well-lg">
<div class="row" >
<claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" inline="true" [showComponent]="showComp" > </claim-contexts>
<div class="panel-body" >
<h6>Find Context:</h6>
<div *ngIf=" show == 'context' " class="row" >
<claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" > </claim-contexts>
<claim-selected [contexts]="contexts"
(contextsChange)="contextsChange($event)"
(showChange)="showChange($event)" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
</div>
<div *ngIf=" show == 'claim'" >
<claim-selected [contexts]="contexts" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
<claim-insert (showChange)="showChange($event)" inline="true" [contexts]="contexts" [publications]="publications" [datasets]="datasets" ></claim-insert>
</div>
<nav>
<ul class="pager">
<li *ngIf="show != 'context'" class="previous" (click)="prev()"><a ><span aria-hidden="true">&larr;</span> Previous</a></li>
<li class="next" *ngIf="show != 'claim'" (click)="next()" ><a >Next <span aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
<claim-insert (showChange)="showChange($event)" inline="true" [contexts]="contexts" [publications]="publications" [datasets]="datasets" showButton="false" ></claim-insert>
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
</div>
<!-- <h3>Find Context</h3>
<div *ngIf="show=='context'" >
@ -48,7 +41,7 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
<button (click)="claim()" class="btn btn-primary" style="float:right">Finish</button>
<button (click)="claim()" class="btn btn-primary btn-xs" style="float:right">Finish</button>
</div>
<div *ngIf="show=='claim'" >
@ -70,9 +63,14 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
contexts=[];
publications;
datasets;
show = "context";
private show = 'context';
private showComp:string = 'false';
private enableButton:boolean=true;
keyword: string = "";
@Output() contextAdded = new EventEmitter();
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
ngOnInit() {
}
@ -104,9 +102,158 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
showChange($event) {
this.show=$event.value;
if(this.show == "end"){
//TODO
this.contextAdded.emit({
value: this.contexts
});
this.contexts = [];
this.show = "context";
}
}
this.hideComponent();
}else if(this.show == "error"){
this.showComponent();
}
}
public toggle(){
if(this.showComp == 'false'){
this.showComponent();
}else{
this.hideComponent();
}
}
private showComponent(){
this.showComp='true';
this.enableButton = true;
}
private hideComponent(){
this.showComp='false';
}
private insert(){
this.claimInsert.publications = [];
this.claimInsert.publications.push(this.inlineEntity[0]);
this.publications = [];
this.publications.push(this.inlineEntity[0]);
console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate);
this.enableButton = false;
this.claimInsert.insert();
}
private cancel(){
this.contexts = [];
this.hideComponent();
}
}
// import {Component, Input} from '@angular/core';
// import {JSONP_PROVIDERS} from '@angular/http';
// import {Observable} from 'rxjs/Observable';
// import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
// import {ClaimContextComponent} from '../linking/claimContext/claimContext.component';
// import {ClaimSelectedComponent} from '../linking/selected/selected.component';
// import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
//
// @Component({
// selector: 'inline-claim-context',
// directives: [ROUTER_DIRECTIVES, ClaimContextComponent, ClaimSelectedComponent, ClaimInsertComponent],
// template: `
//
//
//
// <div class="panel-body" >
// <h6>Find Context:</h6>
// <div *ngIf=" show == 'context' " class="row" >
// <claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" > </claim-contexts>
// <claim-selected [contexts]="contexts"
// (contextsChange)="contextsChange($event)"
// (showChange)="showChange($event)" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
// </div>
// <div *ngIf=" show == 'claim'" >
// <claim-selected [contexts]="contexts" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
// <claim-insert (showChange)="showChange($event)" inline="true" [contexts]="contexts" [publications]="publications" [datasets]="datasets" ></claim-insert>
// </div>
// <nav>
// <ul class="pager">
// <li *ngIf="show != 'context'" class="previous" (click)="prev()"><a ><span aria-hidden="true">&larr;</span> Previous</a></li>
// <li class="next" *ngIf="show != 'claim'" (click)="next()" ><a >Next <span aria-hidden="true">&rarr;</span></a></li>
// </ul>
// </nav>
//
// </div>
//
// <!-- <h3>Find Context</h3>
//
// <div *ngIf="show=='context'" >
//
//
// <claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" > </claim-contexts>
//
// <h3>Link to</h3>
// <claim-selected [contexts]="contexts"
// (contextsChange)="contextsChange($event)"
// (showChange)="showChange($event)" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
//
//
//
// <button (click)="claim()" class="btn btn-primary" style="float:right">Finish</button>
//
// </div>
// <div *ngIf="show=='claim'" >
// <claim-insert showAccessRights="true" [contexts]="contexts" [publications]="publications" [datasets]="datasets" ></claim-insert>
// </div>-->
//
// `
//
// })
// export class InlineClaimContextComponent {
// constructor ( private _router: Router ) {
//
// }
//
// @Input() public inlineEntity:any;
// @Input() public inlineType:string;
//
//
// contexts=[];
// publications;
// datasets;
// show = "context";
// keyword: string = "";
//
// ngOnInit() {
//
// }
// next(){
// if(this.inlineType === 'dataset'){
// this.datasets = [];
// this.datasets.push(this.inlineEntity[0]);
// }else if(this.inlineType === 'publication'){
// this.publications = [];
// this.publications.push(this.inlineEntity[0]);
// console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate);
// }
// if( this.show == 'context'){
// this.show='claim';
// }
// }
// prev(){
// if(this.show == 'claim'){
// this.show = 'context';
// }
// }
//
//
// contextsChange($event) {
// this.contexts=$event.value;
// console.log($event.value);
// }
//
// showChange($event) {
// this.show=$event.value;
// if(this.show == "end"){
// this.contexts = [];
// this.show = "context";
// }
// }
//
// }

View File

@ -13,7 +13,6 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
<div *ngIf="showComp" class="panel-body well well-lg">
<h6>Search for Projects:</h6>
<div class="row" >
<claim-projects [selectedProjects]="projects" (projectsChange)="projectsChange($event)" inline="true" > </claim-projects>
@ -21,41 +20,41 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
(projectsChange)="projectsChange($event)"
(showChange)="showChange($event)" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
</div>
<claim-insert (showChange)="showChange($event)" inline="true" [projects]="projects" [publications]="publications" [datasets]="datasets" showButtton="false" ></claim-insert>
<button (click)="insert()" [class]="(enableButton)?'btn btn-primary':'btn btn-primary disabled'" style="float:right">Finish </button>
<button (click)="cancel()" [class]="(enableButton)?'btn ':'btn disabled'" style="float:left">Cancel </button>
<claim-insert (showChange)="showChange($event)" inline="true" [projects]="projects" [publications]="publications" [datasets]="datasets" showButton="false" ></claim-insert>
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
<!-- <div *ngIf=" show == 'claim'" >
<claim-selected [projects]="projects" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
<claim-insert (showChange)="showChange($event)" inline="true" [projects]="projects" [publications]="publications" [datasets]="datasets" showButtton="false" ></claim-insert>
<claim-insert (showChange)="showChange($event)" inline="true" [projects]="projects" [publications]="publications" [datasets]="datasets" showButton="false" ></claim-insert>
</div>
<nav>
<ul class="pager">
<li *ngIf="show != 'context'" class="previous" (click)="prev()"><a ><span aria-hidden="true">&larr;</span> Previous</a></li>
<li *ngIf="show != 'project'" class="previous" (click)="prev()"><a ><span aria-hidden="true">&larr;</span> Previous</a></li>
<li class="next" *ngIf="show != 'claim'" (click)="next()" ><a >Next <span aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
-->
</div>
<!-- <h3>Find Context</h3>
<!-- <h3>Find Project</h3>
<div *ngIf="show=='context'" >
<div *ngIf="show=='project'" >
<claim-projects [selectedList]="contexts" (contextsChange)="contextsChange($event)" > </claim-contexts>
<claim-projects [selectedList]="projects" (projectsChange)="projectsChange($event)" > </claim-projects>
<h3>Link to</h3>
<claim-selected [contexts]="contexts"
(contextsChange)="contextsChange($event)"
<claim-selected [projects]="projects"
(projectsChange)="projectsChange($event)"
(showChange)="showChange($event)" [inlineEntity]="inlineEntity" inline="true" [inlineType]="inlineType" > </claim-selected>
<button (click)="claim()" class="btn btn-primary" style="float:right">Finish</button>
<button (click)="claim()" class="btn btn-primary btn-xs" style="float:right">Finish</button>
</div>
<div *ngIf="show=='claim'" >
<claim-insert showAccessRights="true" [contexts]="contexts" [publications]="publications" [datasets]="datasets" ></claim-insert>
<claim-insert showAccessRights="true" [projects]="projects" [publications]="publications" [datasets]="datasets" ></claim-insert>
</div>-->
`
@ -93,13 +92,13 @@ import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component
this.publications.push(this.inlineEntity[0]);
console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate);
}
if( this.show == 'context'){
if( this.show == 'project'){
this.show='claim';
}
}
prev(){
if(this.show == 'claim'){
this.show = 'context';
this.show = 'project';
}
}

View File

@ -8,8 +8,9 @@ import {ContextsService} from '../../../services/contexts.service';
@Component({
selector: 'claim-contexts',
template: `
<div class="panel" >
<div class="input-group">
<div class="panel-body" >
<div class="input-group" *ngIf="inline === 'false'">
<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}}
@ -35,6 +36,64 @@ import {ContextsService} from '../../../services/contexts.service';
<input id="community" type="text" class="validate filter-input form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() >
</div>
<div class=" form-horizontal" *ngIf="inline === 'true' && showComponent=='true'">
<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">
<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" 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="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>-->
<div class="suggestions" *ngIf="filteredList.length > 0">
<ul class="list-group" >
<li class="list-group-item" *ngFor=" let item of filteredList">
@ -54,6 +113,9 @@ export class ClaimContextComponent {
this.getCommunities();
}
@Input() public inline= 'false' ; // for claimed started from landing pages
@Input() public showComponent= 'true' ; // for claimed started from landing pages
public query = '';
public filteredList = [];
@Input() public selectedList ;

View File

@ -8,16 +8,16 @@ import {Loading} from '../../../common/modal/loading.component';
@Component({
selector: 'claim-projects',
template: `
<div class="panel" >
<div class="panel-body" >
<!-- <select [(ngModel)]="selectedFunderId" (ngModelChange)="funderChanged()" >
<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>
<div [class]="(inline =='false')?'input-group':''">
<div [class]="(inline =='false')?'input-group-btn':''" >
<form *ngIf="(inline == 'false')">
<div class="input-group">
<div class="input-group-btn" >
<button type="button" class="btn btn-info dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{selectedFunderName}}
</button>
@ -28,10 +28,28 @@ import {Loading} from '../../../common/modal/loading.component';
</ul>
</div><!-- (keyup)=filter() *ngIf="selectedFunderId != '0'" -->
<input id="community" type="text" class="form-control" placeholder="Search for Projects" [(ngModel)]=query >
<span [class]="(inline =='false')?'input-group-btn':''" >
<button type="submit" (click)="filter()" class="btn btn-default">Search</button>
<span class="input-group-btn" >
<button type="submit" (click)="filter()" class="btn btn-default" >Search</button>
</span>
</div>
</form>
<form *ngIf="(inline == 'true')" class="form-horizontal">
<div class="">
<div class="form-group" >
<button type="button" class="btn btn-xs btn-info dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{selectedFunderName}}
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li (click)="funderChanged('0','Select funder:')"><a >Select funder:</a></li>
<li *ngFor="let funder of funders" (click)="funderChanged(funder.field.field[1]['@value_original'],funder.field.field[1]['@value'])" ><a >{{funder.field.field[1]['@value']}}</a></li>
</ul>
</div><!-- (keyup)=filter() *ngIf="selectedFunderId != '0'" -->
<div class="form-group"> <input id="community" type="text" class="form-control input-sm" placeholder="Search for Projects" [(ngModel)]=query ></div>
<div class="form-group" >
<button type="submit" (click)="filter()" class="btn btn-xs btn-default" >Search</button>
</div>
</div>
</form>
<div class="suggestions" *ngIf="filteredList.length > 0">
<ul class="list-group" >

View File

@ -34,7 +34,7 @@ export class ClaimInsertComponent {
@Input() public projects;
@Input() public publications;
@Input() public datasets;
@Input() public showButton:string = 'false';
@Input() public showButton:string = 'true';
@Input() show='claim';
@Input() inline='false';
@Output() showChange = new EventEmitter();

View File

@ -205,11 +205,11 @@ import { InlineClaimProjectComponent} from '../../claimPages/inlineClaimProject/
</a>
</dd>
</dl>
<a (click)="toggleClaimProject()">Add more Projects</a>
<button (click)="toggleClaimProject()" class = "btn btn-default btn-xs" >Add more Projects</button>
<inline-claim-project *ngIf="result " inline="true" inlineType ="publication" [inlineEntity]="result" (projectAdded)="projectAdded($event)" ></inline-claim-project>
</li>
<li class="list-group-item">
<a (click)=" claimInline=(claimInline=='context')?'none':'context'" >Add more Contexts</a>
<button (click)=" toggleClaimContext()" class = "btn btn-default btn-xs" >Add Contexts</button>
<inline-claim-context *ngIf="result " inline="true" inlineType ="publication" [inlineEntity]="result" ></inline-claim-context>
</li>
@ -234,9 +234,6 @@ export class PublicationComponent {
this.params = _routeParams;
}
ngOnInit() {
console.info('publication init');
// let result_ = {id: this.params.get("articleId"), type :"publication", source : "openaire", title:"lalalla",url: null, result: null, accessRights:"OPEN", embargoEndDate: null};
// this.result.push(result_);
this.getPublicationInfo();
}
@ -244,7 +241,6 @@ export class PublicationComponent {
publicationInfo: PublicationInfo;
params: RouteParams;
//AK - For the claims
private result ;
private claimInline:string = "none" ;
@ -253,12 +249,9 @@ export class PublicationComponent {
getPublicationInfo() {
console.info("inside getPublicationInfo of component");
this._publicationService.getPublicationInfo(this.params.get("articleId")).subscribe(
data => {
this.publicationInfo = data;
//AK - For the claims
this.result = []
let result_ ={id: this.params.get("articleId"), type :"publication", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''};
this.result.push(result_);
@ -266,8 +259,11 @@ export class PublicationComponent {
err => console.error(err)
);
}
/*
********* Methods for Inline Claim of project / publication *****
*/
toggleClaimProject(){
console.info("TOOGLE ");
this.inlineClaimProject.toggle();
}
projectAdded($event){
@ -279,20 +275,31 @@ export class PublicationComponent {
this.publicationInfo.fundedByProjects = new Map<string, string[]>();
}
var project =projects[i];
// this.publicationInfo.fundedByProjects.set(mydata.code, new Array<string>());
// this.publicationInfo.fundedByProjects.get(mydata.code)[0] = mydata.acronym;
// this.publicationInfo.fundedByProjects.get(mydata.code)[1] = mydata.title;
// var project= { funderId: this.selectedFunderId,funderName: this.selectedFunderName, projectId: item.field[0]['@value'], projectName: item.field[3]['@value'] , projectAcronym: item.field[1]['@value'] };
this.publicationInfo.fundedByProjects.set(project.projectId, new Array<string>());
this.publicationInfo.fundedByProjects.get(project.projectId)[0] = project.projectAcronym;
this.publicationInfo.fundedByProjects.get(project.projectId)[1] = project.projectName;
// this.publicationInfo.fundedByProjects.get(mydata.code)[2] = mydata['funding']['funder'].shortname;
// this.publicationInfo.fundedByProjects.get(mydata.code)[3] = mydata['funding']['funder'].name;
this.publicationInfo.fundedByProjects.get(project.projectId)[2] =project.selectedFunderId;
this.publicationInfo.fundedByProjects.get(project.projectId)[3] = project.selectedFunderName;
}
}
}
toggleClaimContext(){
this.inlineClaimContext.toggle();
}
contextAdded($event){
var contexts =$event.value;
if(contexts){
for(var i=0; i < contexts.length; i++){
// if(this.publicationInfo.fundedByProjects == undefined) {
// this.publicationInfo.fundedByProjects = new Map<string, string[]>();
// }
// var context =contexts[i];
// this.publicationInfo.fundedByProjects.set(project.projectId, new Array<string>());
// this.publicationInfo.fundedByProjects.get(project.projectId)[0] = project.projectAcronym;
// this.publicationInfo.fundedByProjects.get(project.projectId)[1] = project.projectName;
// this.publicationInfo.fundedByProjects.get(project.projectId)[2] =project.selectedFunderId;
// this.publicationInfo.fundedByProjects.get(project.projectId)[3] = project.selectedFunderName;
}
}
}