Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
import {ActivatedRoute, Router} from '@angular/router';
4
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
5
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
6
import {SearchPublicationsService} from '../../services/searchPublications.service';
7
import {SearchDatasetsService} from '../../services/searchDatasets.service';
8
import { Meta} from '../../../angular2-meta';
9
declare var UIkit:any;
10

    
11
@Component({
12
    selector: 'linking-generic',
13
    templateUrl: 'linkingGeneric.component.html'
14

    
15
})
16
export class LinkingGenericComponent {
17

    
18
  @Input() bulkMode: boolean = false;
19
  sourceType:string;
20
  targetType:string;
21
  step:number = 1;
22
  contexts=[];
23
  projects=[];
24
   results = [];
25
  show = "project";
26
  date='8-6-2016';
27
  keyword: string = "";
28
  linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
29
  /* url Parameters for inline linking */
30
  id:string = null; //entity id
31
  type:string = null; // entity type (publication or research data)
32
  linkTo:string = null; // entity type (project or context or result)
33

    
34
  entityTypes=["dataset", "publication", "project","context"];
35
  inlineResult:ClaimResult =null;
36
  sub:any =null;
37
  constructor ( private _router: Router,  private route: ActivatedRoute, private entitySearch:EntitiesSearchService,
38
    private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService, private _meta: Meta) {
39
      this._meta.setTitle("OpenAIRE | Linking");
40
  }
41
  ngOnInit() {
42
      if( typeof localStorage !== 'undefined') {
43
        if(localStorage.getItem("projects")){
44
          this.projects  = JSON.parse(localStorage.getItem("projects"));
45

    
46
        }
47
        if(localStorage.getItem("contexts")){
48
          this.contexts  = JSON.parse(localStorage.getItem("contexts"));
49
        }
50
        if(localStorage.getItem("results")){
51
          this.results  = JSON.parse(localStorage.getItem("results"));
52

    
53
        }
54
        localStorage.removeItem("projects");
55
        localStorage.removeItem("contexts");
56
        localStorage.removeItem("results");
57
    }
58
  }
59

    
60
  next(){
61

    
62
    if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
63
        this.show='claim';
64

    
65
    }
66
  }
67
  prev(){
68
  if(this.show == 'claim'){
69
      this.show='result';
70
    }
71
  }
72

    
73

    
74
  resultsChange($event) {
75
    this.results=$event.value;
76
  }
77

    
78
  projectsChange($event) {
79
    this.projects=$event.value;
80
  }
81

    
82
  linkTypeChange($event) {
83

    
84
    this.linkType =$event.value;
85
    this.show="result";
86
    if(this.bulkMode){
87
      this.show="claim";
88
    }
89
  }
90

    
91
  showChange($event) {
92
    this.show=$event.value;
93
    this.showChangedType($event.value);
94
  }
95

    
96
  showChangedType(type:string) {
97
    this.show=type;
98
     if(this.show == 'project' || this.show == 'context' || this.show == 'software'){
99
        this.linkType = this.show;
100
    }
101
  }
102

    
103
  canProceedToMetadata(){
104
    if(this.results.length == 0){
105

    
106
      UIkit.notification({
107
          message : 'No research results selected!<br>Please select research results to link with projects and/ or ommunities.',
108
          status  : 'warning',
109
          timeout : 1000,
110
          pos     : 'top-center'
111
      });
112
    }else{
113
      this.show = 'claim';
114
      this.step = 3;
115
    }
116
  }
117
}
(6-6/7)