explore-services/portal/src/app/claimPages/linking/selected/selected.component.ts

213 lines
10 KiB
TypeScript

import {Component, Input,Output, EventEmitter} from '@angular/core';
import {PublicationTitleFormatter} from '../../../common/publicationTitleFormatter.component';
@Component({
selector: 'claim-selected',
template: `
<div [class]="(showAccessRights== 'true' )?'row':''" >
<!-- <div *ngIf=" inline == 'true'">
<div *ngIf=" inlineType == 'publication' " class="publication" >
<a *ngIf="inlineEntity[0].url" target="_blank" href="{{inlineEntity[0].url}}" >{{inlineEntity[0].title}}</a>
<span *ngIf="!inlineEntity[0].url" >{{inlineEntity[0].title}}</span>
</div>
<div *ngIf=" inlineType == 'dataset' " class="dataset" >
<a *ngIf="inlineEntity[0].url" target="_blank" href="{{inlineEntity[0].url}}" >{{inlineEntity[0].title}}</a>
<span *ngIf="!inlineEntity[0].url" >{{inlineEntity[0].title}}</span>
</div>
<div *ngIf=" inlineType == 'project' " class="project" >
<a *ngIf="inlineEntity[0].url" target="_blank" href="{{inlineEntity[0].url}}" >{{inlineEntity[0].title}}</a>
<span *ngIf="!inlineEntity[0].url" >{{inlineEntity[0].title}}</span>
<span >{{inlineEntity[0].funderName}} | {{(inlineEntity[0].projectAcronym)?inlineEntity[0].projectAcronym: inlineEntity[0].projectName}}</span>
</div>
<div>Link to </div>
</div> -->
<div [class]="(showAccessRights== 'true' )?'col-sm-6':''" >
<div *ngIf=" !(inline == 'true' && inlineType == 'context') && contexts" class="concepts" >
<ul class="list-group">
<li class="list-group-item list-group-item-success">Selected Concepts ({{(contexts.length)}})
<span *ngIf=" inline == 'false'" title="Add More Concepts" (click)="showType('context')" aria-hidden="true" class="glyphicon glyphicon-plus " style="float:right;cursor: pointer;"></span>
</li>
<li class="list-group-item" *ngFor="let context of contexts" >
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
<span (click)="removeContext(context)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
</li>
<li *ngIf="contexts.length == 0 " class="list-group-item">There are no contexts</li>
</ul>
</div>
</div>
<div [class]="(showAccessRights== 'true' )?'col-sm-6':''" >
<div *ngIf=" !(inline == 'true' && inlineType == 'project') && projects " class="projects" >
<ul class="list-group">
<li class="list-group-item list-group-item-info">Selected Projects ({{(projects.length)}})
<span *ngIf=" inline == 'false'" title="Add More Projects" (click)="showType('project')" aria-hidden="true" class="glyphicon glyphicon-plus " style="float:right;cursor: pointer;"></span>
</li>
<li class="list-group-item" *ngFor="let project of projects">
<span >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}}</span>
<span (click)="removeProject(project)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
</li>
<li *ngIf="projects.length == 0 " class="list-group-item">There are no projects</li>
</ul>
</div>
</div>
</div>
<div *ngIf=" !(inline == 'true' && (inlineType == 'publication' || inlineType == 'dataset' )) && (datasets || publications)" class="publications" >
<ul class="list-group">
<li class="list-group-item panel-footer "> Research Results ({{(datasets.length+publications.length)}})
<span *ngIf=" inline == 'false'" title="Add More Research Results" (click)="showType('result')" aria-hidden="true" class="glyphicon glyphicon-plus " style="float:right;cursor: pointer;"></span>
</li>
<li *ngIf="publications && datasets && publications.length == 0 && datasets.length == 0" class="list-group-item">There are no Research Results </li>
<li *ngIf="(publications && publications.length > 0) ||(datasets && datasets.length > 0 ) " class="list-group-item list-group-item-warning ">{{publications. length }} Selected Publications:
<span *ngIf=" inline == 'false'" title="Add More Publications" (click)="showType('publication')" aria-hidden="true" class="glyphicon glyphicon-plus " style="float:right;cursor: pointer;"></span>
</li>
<li *ngFor="let pub of publications" class="list-group-item">
<span *ngIf="showAccessRights == 'true'" (click)="removePublication(pub)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
<span >
<a *ngIf="pub.url" target="_blank" href="{{pub.url}}" >{{pub.title}}</a>
<span *ngIf="!pub.url" >{{pub.title}}</span>
</span>
<span *ngIf="showAccessRights== 'true' && pub.source != 'openaire' " class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="{{'dropdown'+pub.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{pub.accessRights}}
</button>
<ul class="dropdown-menu" [attr.aria-labelledby]="'dropdown'+pub.id">
<li *ngFor="let type of accessTypes" ><a (click)="pub.accessRights = type " >{{type}} </a></li>
</ul>
<input *ngIf="pub.accessRights== 'EMBARGO'" type="date" id="{{'date'+pub.id}}" name="" [min]="todayDate" (keyup)="dateChanged($event, pub)" [value]="pub.embargoEndDate">
</span>
<span *ngIf="showAccessRights== 'true' && pub.source == 'openaire' " >
<button class="btn btn-default disabled " type="button" >
{{pub.accessRights}}
</button>
</span>
<span *ngIf="showAccessRights != 'true'" (click)="removePublication(pub)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
</li>
<li *ngIf="publications.length > 0 || datasets.length > 0" class="list-group-item list-group-item-warning "> {{datasets.length}} Selected Research Data:
<span *ngIf=" inline == 'false'" title="Add More Research Data" (click)="showType('dataset')" aria-hidden="true" class="glyphicon glyphicon-plus " style="float:right;cursor: pointer;"></span>
</li>
<li *ngFor="let dataset of datasets" class="list-group-item">
<span *ngIf="showAccessRights == 'true'" (click)="removeDataset(dataset)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
<span >
<a *ngIf="dataset.url" target="_blank" href="{{dataset.url}}" >{{dataset.title}}</a>
<span *ngIf="!dataset.url" >{{dataset.title}}</span>
</span>
<span *ngIf="showAccessRights== 'true' && dataset.source != 'openaire'" class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="{{'dropdown'+dataset.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{dataset.accessRights}}
</button>
<ul class="dropdown-menu" [attr.aria-labelledby]="'dropdown'+dataset.id">
<li *ngFor="let type of accessTypes" ><a (click)="dataset.accessRights = type " >{{type}} </a></li>
</ul>
<input *ngIf="dataset.accessRights== 'EMBARGO'" type="date" id="{{'date'+dataset.id}}" name="" [min]="todayDate" (keyup)="dateChanged($event,dataset)" [value]="dataset.embargoEndDate">
</span>
<span *ngIf="showAccessRights== 'true' && dataset.source == 'openaire' " >
<button class="btn btn-default disabled " type="button" >
{{dataset.accessRights}}
</button>
</span>
<span *ngIf="showAccessRights != 'true'" (click)="removeDataset(dataset)" aria-hidden="true" class="btn glyphicon glyphicon-remove"></span>
</li>
</ul>
</div>
`,
directives: [ PublicationTitleFormatter]
})
export class ClaimSelectedComponent {
ngOnInit() {
console.info("Show accessRights selection? :"+this.showAccessRights);
var myDate = new Date();
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
//2015-05-01
}
@Input() contexts;
@Input() projects;
@Input() publications;
@Input() datasets;
@Input() showAccessRights=false;
@Input() show='home';
@Input() inline='false';
@Input() inlineEntity;
@Input() inlineType;
@Output() projectsChange = new EventEmitter();
@Output()publicationsChange = new EventEmitter();
@Output() datasetsChange = new EventEmitter();
@Output() contextsChange = new EventEmitter();
@Output() showChange = new EventEmitter();
todayDate = '';
nextDate = '';
removeContext(item:any){
var index:number =this.contexts.indexOf(item);
if (index > -1) {
this.contexts.splice(index, 1);
}
this.contextsChange.emit({
value: this.contexts
});
}
removePublication(item:any){
var index:number =this.publications.indexOf(item);
if (index > -1) {
this.publications.splice(index, 1);
}
this.publicationsChange.emit({
value: this.publications
});
}
removeDataset(item:any){
var index:number =this.datasets.indexOf(item);
if (index > -1) {
this.datasets.splice(index, 1);
}
this.datasetsChange.emit({
value: this.datasets
});
}
removeProject(item:any){
var index:number =this.projects.indexOf(item);
if (index > -1) {
this.projects.splice(index, 1);
}
this.projectsChange.emit({
value: this.projects
});
}
showType(type){
if(type != this.show){
this.show = type;
this.showChange.emit({
value: this.show
});
}
}
accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"];
dateChanged (event:any, item:any) {
item.embargoEndDate = event.target.value ;
}
}
@Component({
selector: 'add-more',
template: ``
})
export class Addmore {
@Input() type = 'publication';
}