Project

General

Profile

1
import {Component, Input,Output, EventEmitter} from '@angular/core';
2
import {ClaimResult,ClaimProject, ClaimContext} from '../../../utils/entities/claimEntities.class';
3

    
4
@Component({
5
    selector: 'claim-selected',
6
    template: `
7

    
8
      <div   [class]="(showAccessRights== 'true' )?'row':''" >
9

    
10
        <div   [class]="(showAccessRights== 'true' )?'col-sm-6':''" >
11
        <!-- Contexts -->
12
          <div   *ngIf=" !(inline  && hideType == 'context') && contexts"  class="concepts" >
13
          <ul class="uk-list">
14
            <li class="list-group-item list-group-item-success">Selected Concepts  ({{(contexts.length)}})
15
               <span *ngIf=" !inline"  title="Add More Concepts" (click)="showType('context')" aria-hidden="true"    style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span>
16
            </li>
17
            <li class="list-group-item" *ngFor="let context of contexts" >
18
              <span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
19
              <span (click)="removeContext(context)" aria-hidden="true" class="btn  "><i class="uk-icon-remove"></i></span>
20

    
21
            </li>
22
            <li  *ngIf="contexts.length == 0 " class="list-group-item">There are no contexts</li>
23
          </ul>
24
          </div>
25

    
26
        </div>
27
        <div   [class]="(showAccessRights== 'true' )?'col-sm-6':''" >
28
          <!-- Projects -->
29
          <div   *ngIf=" !(inline  && hideType == 'project') && projects "  class="projects" >
30
                <ul class="uk-list">
31
                <li class="list-group-item list-group-item-info">Selected Projects  ({{(projects.length)}})
32
                   <span  *ngIf=" !inline " title="Add More Projects" (click)="showType('project')" aria-hidden="true"  style="float:right;cursor: pointer;"> <i class="uk-icon-plus"></i></span>
33
                </li>
34
                  <li class="list-group-item" *ngFor="let project of projects">
35

    
36
                    <span >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} <!--[{{project.startDate}} - {{project.endDate}}]--></span>
37
                    <span  (click)="removeProject(project)" aria-hidden="true" class="btn  "><i class="uk-icon-remove"></i></span>
38
                  </li>
39
                  <li *ngIf="projects.length == 0 " class="list-group-item">There are no projects</li>
40
                </ul>
41
          </div>
42

    
43
        </div>
44
      </div>
45
      <!-- Results -->
46

    
47
        <div *ngIf=" !(inline && (hideType == 'publication' || hideType == 'dataset' )) && (datasets || publications)"  class="publications" >
48
          <ul class="uk-list">
49
            <li class="list-group-item panel-footer "> Research Results ({{(datasets.length+publications.length)}})
50
               <span *ngIf=" !inline  && linkToResults "  title="Add More Research Results" (click)="showType('result')" aria-hidden="true"   style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span>
51
            </li>
52
            <li *ngIf="publications && datasets && publications.length == 0 && datasets.length == 0"  class="list-group-item">There are no Research Results </li>
53
            <li  *ngIf="(publications &&  publications.length > 0) ||(datasets &&  datasets.length > 0 ) "  class="list-group-item  list-group-item-warning ">{{publications. length }} Selected Publications:
54
               <span  *ngIf=" !inline && linkToResults " title="Add More Publications" (click)="showType('publication')" aria-hidden="true"    style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span>
55
            </li>
56
            <li  *ngFor="let pub of publications" class="list-group-item">
57
              <span *ngIf="showAccessRights == 'true'" (click)="removePublication(pub)" aria-hidden="true" class="btn "><i class="uk-icon-remove"></i></span>
58
              <span >
59
                <a *ngIf="pub.url" target="_blank" href="{{pub.url}}" >{{pub.title}}</a>
60
                <span *ngIf="!pub.url" >{{pub.title}}</span><span *ngIf="pub.date" >({{pub.date.substring(0,4)}})</span>
61
              </span>
62
              <span *ngIf="showAccessRights== 'true'  && pub.source != 'openaire' " class="dropdown">
63
                   <button class="uk-button dropdown-toggle" type="button" id="{{'dropdown'+pub.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
64
                   {{pub.accessRights}}
65
                    </button>
66
                   <ul class="dropdown-menu" [attr.aria-labelledby]="'dropdown'+pub.id">
67
                      <li *ngFor="let type of accessTypes" ><a  (click)="pub.accessRights = type " >{{type}} </a></li>
68
                   </ul>
69
                   <input *ngIf="pub.accessRights== 'EMBARGO'" type="date" id="{{'date'+pub.id}}" name="" [min]="todayDate" (keyup)="dateChanged($event, pub)" [value]="pub.embargoEndDate">
70
              </span>
71
              <span *ngIf="showAccessRights== 'true'  && pub.source == 'openaire' " >
72
                   <button class="uk-button disabled " type="button" >
73
                   {{pub.accessRights}}
74
                    </button>
75
              </span>
76
             <span *ngIf="showAccessRights != 'true'" (click)="removePublication(pub)" aria-hidden="true" class="btn "><i class="uk-icon-remove"></i></span>
77
            </li>
78
            <li *ngIf="publications.length > 0 || datasets.length > 0" class="list-group-item  list-group-item-warning "> {{datasets.length}} Selected Research Data:
79
              <span  *ngIf=" !inline  && linkToResults " title="Add More  Research Data" (click)="showType('dataset')" aria-hidden="true" style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span>
80
            </li>
81
            <li  *ngFor="let dataset of datasets" class="list-group-item">
82
              <span *ngIf="showAccessRights == 'true'" (click)="removeDataset(dataset)" aria-hidden="true" class="btn "><i class="uk-icon-remove"></i></span>
83
              <span >
84
              <a *ngIf="dataset.url" target="_blank" href="{{dataset.url}}" >{{dataset.title}}</a>
85
              <span *ngIf="!dataset.url" >{{dataset.title}}</span>
86
              <span *ngIf="dataset.date" >({{dataset.date.substring(0,4)}})</span>
87
              </span>
88
              <span  *ngIf="showAccessRights== 'true' && dataset.source != 'openaire'"  class="dropdown">
89
                   <button class="uk-button dropdown-toggle" type="button" id="{{'dropdown'+dataset.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
90
                   {{dataset.accessRights}}
91
                    </button>
92
                   <ul class="dropdown-menu" [attr.aria-labelledby]="'dropdown'+dataset.id">
93
                      <li *ngFor="let type of accessTypes" ><a  (click)="dataset.accessRights = type " >{{type}} </a></li>
94
                   </ul>
95
                   <input *ngIf="dataset.accessRights== 'EMBARGO'" type="date" id="{{'date'+dataset.id}}" name="" [min]="todayDate" (keyup)="dateChanged($event,dataset)" [value]="dataset.embargoEndDate">
96
              </span>
97
              <span *ngIf="showAccessRights== 'true'  && dataset.source == 'openaire' "  >
98
                   <button class="uk-button disabled " type="button" >
99
                   {{dataset.accessRights}}
100
                    </button>
101
              </span>
102
              <span *ngIf="showAccessRights != 'true'" (click)="removeDataset(dataset)" aria-hidden="true" class="btn "><i class="uk-icon-remove"></i></span>
103
            </li>
104

    
105
          </ul>
106
          </div>
107
          <!-- Bulk Mode Results  (publicationsChange)="publicationsChanged($event)" -->
108
          <div *ngIf="bulkMode">
109
            <bulk-claim *ngIf=" bulkMode " [(publications)]="publications" (publicationsChange)="publicationsChanged($event)" > </bulk-claim>
110
          </div>
111
          `
112

    
113

    
114
})
115
export class ClaimSelectedComponent {
116
   ngOnInit() {
117
     console.info("Show accessRights selection? :"+this.showAccessRights);
118
     var myDate = new Date();
119
     this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
120
     this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
121
     //2015-05-01
122
}
123

    
124

    
125
  @Input() contexts: ClaimContext[];
126
  @Input() projects: ClaimProject[];
127
  @Input() publications: ClaimResult[];
128
  @Input() datasets: ClaimResult[];
129
  @Input() showAccessRights:boolean = false;
130
  @Input() show='home';
131
  @Input() inline:boolean = false;
132
  @Input() hideType;
133
  @Input() bulkMode:boolean = false;
134
  @Input() linkToResults:boolean = true;
135
  @Output() projectsChange = new EventEmitter();
136
  @Output()publicationsChange = new EventEmitter();
137
  @Output() datasetsChange = new EventEmitter();
138
  @Output() contextsChange = new EventEmitter();
139

    
140
  @Output() showChange = new EventEmitter();
141

    
142
  todayDate = '';
143
  nextDate = '';
144
  removeContext(item:any){
145
    var index:number =this.contexts.indexOf(item);
146
     if (index > -1) {
147
        this.contexts.splice(index, 1);
148
    }
149
    this.contextsChange.emit({
150
      value: this.contexts
151
    });
152
  }
153
  removePublication(item:any){
154
    var index:number =this.publications.indexOf(item);
155
     if (index > -1) {
156
        this.publications.splice(index, 1);
157
    }
158
    this.publicationsChange.emit({
159
      value: this.publications
160
    });
161
  }
162
  removeDataset(item:any){
163
    var index:number =this.datasets.indexOf(item);
164
     if (index > -1) {
165
        this.datasets.splice(index, 1);
166
    }
167
    this.datasetsChange.emit({
168
      value: this.datasets
169
    });
170
  }
171
  removeProject(item:any){
172
    var index:number =this.projects.indexOf(item);
173
     if (index > -1) {
174
        this.projects.splice(index, 1);
175
    }
176
    this.projectsChange.emit({
177
      value: this.projects
178
    });
179
  }
180
  showType(type){
181
   if(type != this.show){
182
     this.show = type;
183
     this.showChange.emit({
184
       value: this.show
185
     });
186
   }
187
  }
188
  accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"];
189

    
190
  dateChanged (event:any, item:any) {
191
      item.embargoEndDate = event.target.value ;
192
    }
193
    publicationsChanged($event) {
194
      this.publications=$event.value;
195
      this.publicationsChange.emit({
196
        value: this.publications
197
      });
198
    }
199
}
200

    
201

    
202

    
203
// @Component({
204
//     selector: 'add-more',
205
//     template: ``
206
// })
207
// export class Addmore {
208
//     @Input() type = 'publication';
209
// }
(1-1/6)