108 lines
3.2 KiB
TypeScript
108 lines
3.2 KiB
TypeScript
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
|
|
|
@Component({
|
|
selector: 'inline-claim-project',
|
|
template: `
|
|
|
|
|
|
<div *ngIf="showComp" class="panel-body well well-lg">
|
|
<div class="row" >
|
|
<claim-projects [selectedProjects]="projects" (projectsChange)="projectsChange($event)" inline=true > </claim-projects>
|
|
|
|
<claim-selected-projects [projects]="projects"
|
|
(showChange)="showChange($event)" inline=true [hideType]="inlineType" > </claim-selected-projects>
|
|
</div>
|
|
<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>
|
|
|
|
|
|
|
|
`
|
|
|
|
})
|
|
export class InlineClaimProjectComponent {
|
|
constructor () {
|
|
|
|
}
|
|
|
|
@Input() public inlineEntity:any;
|
|
@Input() public inlineType:string;
|
|
|
|
|
|
projects=[];
|
|
publications;
|
|
datasets;
|
|
private show = 'project';
|
|
private showComp:boolean = false;
|
|
private enableButton:boolean=true;
|
|
keyword: string = "";
|
|
|
|
@Output() projectAdded = new EventEmitter();
|
|
|
|
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
|
ngOnInit() {
|
|
|
|
}
|
|
|
|
showChange($event) {
|
|
this.show=$event.value;
|
|
if(this.show == "end"){
|
|
//TODO
|
|
this.projectAdded.emit({
|
|
value: this.projects
|
|
});
|
|
this.projects = [];
|
|
this.showComponent();
|
|
}else if(this.show == "error"){
|
|
this.showComponent();
|
|
}
|
|
}
|
|
public toggle(){
|
|
console.info("TOOGLE pr ");
|
|
if(!this.showComp){
|
|
console.info("TOOGLE show ");
|
|
this.showComponent();
|
|
}else{
|
|
console.info("TOOGLE hide ");
|
|
this.hideComponent();
|
|
}
|
|
}
|
|
private showComponent(){
|
|
this.showComp=true;
|
|
this.enableButton = true;
|
|
|
|
}
|
|
private hideComponent(){
|
|
this.showComp=false;
|
|
}
|
|
private insert(){
|
|
if(this.inlineType === 'dataset'){
|
|
this.datasets = [];
|
|
this.datasets.push(this.inlineEntity);
|
|
this.claimInsert.datasets = [];
|
|
this.claimInsert.datasets.push(this.inlineEntity);
|
|
}else if(this.inlineType === 'publication'){
|
|
this.claimInsert.publications = [];
|
|
this.claimInsert.publications.push(this.inlineEntity);
|
|
this.publications = [];
|
|
this.publications.push(this.inlineEntity);
|
|
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;
|
|
if (!this.claimInsert.validateInsertions()){
|
|
this.enableButton = true;
|
|
}
|
|
|
|
|
|
}
|
|
private cancel(){
|
|
this.projects = [];
|
|
|
|
this.hideComponent();
|
|
}
|
|
}
|