Project

General

Profile

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

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

    
8
        <!-- Contexts -->
9

    
10
          <ul     class="uk-accordion" uk-accordion="{showfirst:true}">
11
          <li class="uk-open">
12
            <h3 class="uk-accordion-title"> {{title}} ({{(contexts.length)}})</h3>
13
            <div class="uk-accordion-content" ><!--(contextSelected)="contextSelected($event)"-->
14
            <div class="uk-clearfix"><button *ngIf=" !showsearch "  (click)="showsearch = true;" class="uk-button uk-button-default uk-animation uk-float-right">Add more <span uk-icon="icon: plus"></span></button></div>
15
            <claim-contexts-search-form *ngIf=" showsearch "    [selectedList]="contexts" [projects]="projects" [results]="results" [inlineEntity]="inlineEntity" > </claim-contexts-search-form>
16
              <ul class="uk-list uk-list-line">
17
                <li class="list-group-item" *ngFor="let context of contexts" >
18
                  <span *ngIf="context.community != context.concept.label">{{context.community }} > {{context.category}} ></span><span> {{context.concept.label}} </span>
19
                  <span (click)="removeContext(context)" aria-hidden="true" class="uk-icon-button"><span uk-icon="icon: close"></span></span>
20

    
21
                </li>
22
              </ul>
23
              <div  *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities</div>
24
          </div>
25
        </li>
26
        </ul>
27

    
28

    
29
        `
30
})
31
export class ClaimSelectedContextsComponent {
32
   ngOnInit() {
33
     var myDate = new Date();
34
     this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
35
     this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
36
     //2015-05-01
37
    //  if(this.linkType == "context"){
38
       this.showsearch = true
39
    //  }else{
40
    //    this.showsearch = false;
41
    //  }
42
}
43

    
44

    
45
  @Input() contexts:ClaimContext[];
46
  //The following need to be kept in case we have to save the current state
47
  @Input() public projects;
48
  @Input() public results;
49
  @Input() public inlineEntity;
50
  @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
51
  @Input() show='home';
52
  @Input() title='Communities';
53
  @Input() linkType:string = "project";
54

    
55
  @Input() hideType;
56
  @Input() bulkMode:boolean = false;
57
  @Output() showChange = new EventEmitter();
58

    
59
  showsearch:boolean = false;
60

    
61
  todayDate = '';
62
  nextDate = '';
63

    
64
  showType(type){
65
     if(type != this.show){
66
       this.show = type;
67
       this.showChange.emit({
68
         value: this.show
69
       });
70
     }
71
    }
72

    
73

    
74
  removeContext(item:any){
75
    var index:number =this.contexts.indexOf(item);
76
     if (index > -1) {
77
        this.contexts.splice(index, 1);
78
      }
79

    
80
    }
81
  contextSelected($event) {
82
    // this.showsearch = false;
83
  }
84

    
85
}
(1-1/6)