1
|
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
4
|
// import {ClaimResultComponent} from '../linking/claimResult/claimResult.component';
|
5
|
// import {ClaimSelectedResultsComponent} from '../linking/selected/selectedResults.component';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'inline-claim-result',
|
9
|
template: `
|
10
|
|
11
|
|
12
|
<div *ngIf="showComp" class="panel-body well well-lg">
|
13
|
<div class="row" >
|
14
|
<claim-result [selectedDatasets]="datasets" [selectedPublications]="publications" (datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)" inline=true > </claim-result>
|
15
|
|
16
|
<!-- ClaimSelectedResultsComponent -->
|
17
|
<claim-selected-results [publications]="publications" [datasets]="datasets"
|
18
|
(datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)"
|
19
|
(showChange)="showChange($event)" inline=true [hideType]="hideType" [showAccessRights]=true > </claim-selected-results>
|
20
|
</div>
|
21
|
<claim-insert (showChange)="showChange($event)" inline=true [publications]="publications" [datasets]="datasets" showButton=false [inlineEntity]="inlineEntity" ></claim-insert>
|
22
|
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
|
23
|
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
|
24
|
</div>
|
25
|
|
26
|
|
27
|
|
28
|
`
|
29
|
|
30
|
})
|
31
|
export class InlineClaimResultComponent {
|
32
|
constructor () {
|
33
|
|
34
|
}
|
35
|
// This is the component from the landing page
|
36
|
@Input() public inlineEntity:any;
|
37
|
@Input() public inlineType:string;
|
38
|
private hideType:string;
|
39
|
|
40
|
|
41
|
|
42
|
publications = [];
|
43
|
datasets = [];
|
44
|
private show = 'project';
|
45
|
private showComp:boolean = false;
|
46
|
private enableButton:boolean=true;
|
47
|
keyword: string = "";
|
48
|
|
49
|
@Output() datasetAdded = new EventEmitter();
|
50
|
@Output() publicationAdded = new EventEmitter();
|
51
|
|
52
|
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
53
|
ngOnInit() {
|
54
|
console.info("Inline entity:"+this.inlineEntity.id);
|
55
|
this.hideType = this.inlineType;
|
56
|
if(this.inlineType == 'dataset' || this.inlineType == 'publication' ){
|
57
|
this.hideType = "";
|
58
|
}
|
59
|
}
|
60
|
|
61
|
datasetsChange($event) {
|
62
|
this.datasets=$event.value;
|
63
|
console.log($event.value);
|
64
|
}
|
65
|
publicationsChange($event) {
|
66
|
this.publications=$event.value;
|
67
|
console.log($event.value);
|
68
|
}
|
69
|
showChange($event) {
|
70
|
this.show=$event.value;
|
71
|
if(this.show == "end"){
|
72
|
this.datasetAdded.emit({
|
73
|
value: this.datasets
|
74
|
});
|
75
|
this.publicationAdded.emit({
|
76
|
value: this.publications
|
77
|
});
|
78
|
this.datasets = [];
|
79
|
this.publications = [];
|
80
|
this.showComponent();
|
81
|
}else if(this.show == "error"){
|
82
|
this.showComponent();
|
83
|
}
|
84
|
}
|
85
|
public toggle(){
|
86
|
if(!this.showComp){
|
87
|
this.showComponent();
|
88
|
}else{
|
89
|
this.hideComponent();
|
90
|
}
|
91
|
}
|
92
|
private showComponent(){
|
93
|
this.showComp=true;
|
94
|
this.enableButton = true;
|
95
|
|
96
|
}
|
97
|
private hideComponent(){
|
98
|
this.showComp=false;
|
99
|
}
|
100
|
private insert(){
|
101
|
if(this.inlineType === 'project'){ //TODO check if neccessary
|
102
|
this.claimInsert.projects = [];
|
103
|
this.claimInsert.projects.push(this.inlineEntity);
|
104
|
}
|
105
|
|
106
|
this.enableButton = false;
|
107
|
if (!this.claimInsert.validateInsertions()){
|
108
|
this.enableButton = true;
|
109
|
}
|
110
|
|
111
|
}
|
112
|
private cancel(){
|
113
|
this.datasets = [];
|
114
|
this.publications = [];
|
115
|
this.hideComponent();
|
116
|
}
|
117
|
}
|