1
|
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
|
4
|
// import {ClaimContextComponent} from '../linking/claimContext/claimContext.component';
|
5
|
// import {ClaimSelectedContextsComponent} from '../linking/selected/selectedContexts.component';
|
6
|
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
7
|
|
8
|
@Component({
|
9
|
selector: 'inline-claim-context',
|
10
|
template: `
|
11
|
|
12
|
|
13
|
<div *ngIf="showComp" class="panel-body well well-lg">
|
14
|
<div class="row" >
|
15
|
<claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" inline=true [showComponent]="showComp" > </claim-contexts>
|
16
|
|
17
|
<claim-selected-contexts [contexts]="contexts"
|
18
|
(showChange)="showChange($event)" inline=true [hideType]="inlineType" > </claim-selected-contexts>
|
19
|
</div>
|
20
|
<claim-insert (showChange)="showChange($event)" inline=true [contexts]="contexts" [publications]="publications" [datasets]="datasets" showButton=false ></claim-insert>
|
21
|
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
|
22
|
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
|
23
|
|
24
|
</div>
|
25
|
`
|
26
|
|
27
|
})
|
28
|
export class InlineClaimContextComponent {
|
29
|
constructor ( ) {
|
30
|
|
31
|
}
|
32
|
|
33
|
@Input() public inlineEntity:any;
|
34
|
@Input() public inlineType:string;
|
35
|
|
36
|
|
37
|
contexts=[];
|
38
|
publications;
|
39
|
datasets;
|
40
|
public show = 'context';
|
41
|
public showComp:boolean = false;
|
42
|
public enableButton:boolean=true;
|
43
|
public keyword: string = "";
|
44
|
|
45
|
@Output() contextAdded = new EventEmitter();
|
46
|
|
47
|
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
48
|
ngOnInit() {
|
49
|
|
50
|
}
|
51
|
showChange($event) {
|
52
|
this.show=$event.value;
|
53
|
if(this.show == "end"){
|
54
|
//TODO
|
55
|
this.contextAdded.emit({
|
56
|
value: this.contexts
|
57
|
});
|
58
|
this.contexts = [];
|
59
|
this.showComponent();
|
60
|
|
61
|
}else if(this.show == "error"){
|
62
|
this.showComponent();
|
63
|
}
|
64
|
}
|
65
|
public toggle(){
|
66
|
if(!this.showComp){
|
67
|
this.showComponent();
|
68
|
}else{
|
69
|
this.hideComponent();
|
70
|
}
|
71
|
}
|
72
|
private showComponent(){
|
73
|
this.showComp=true;
|
74
|
this.enableButton = true;
|
75
|
|
76
|
}
|
77
|
private hideComponent(){
|
78
|
this.showComp=false;
|
79
|
}
|
80
|
private insert(){
|
81
|
this.claimInsert.publications = [];
|
82
|
this.claimInsert.publications.push(this.inlineEntity);
|
83
|
this.publications = [];
|
84
|
this.publications.push(this.inlineEntity);
|
85
|
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);
|
86
|
this.enableButton = false;
|
87
|
if (!this.claimInsert.validateInsertions()){
|
88
|
this.enableButton = true;
|
89
|
}
|
90
|
|
91
|
|
92
|
}
|
93
|
private cancel(){
|
94
|
this.contexts = [];
|
95
|
|
96
|
this.hideComponent();
|
97
|
}
|
98
|
}
|