Project

General

Profile

1
import {Component, Input,Output, EventEmitter} from '@angular/core';
2
import {ClaimContext} from '../../claim-utils/claimEntities.class';
3
@Component({
4
    selector: 'claim-selected-contexts',
5
    template: `
6

    
7
        <!-- Contexts -->
8

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

    
19
                </li>
20
              </ul>
21
              <div  *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities</div>
22
          </div>
23
        </div>
24
        <!--div *ngIf="this.linkType != 'context'"   class="uk-accordion" data-uk-accordion="{showfirst:false}">
25
          <h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i>{{title}}  ({{(contexts.length)}})</h3>
26
          <div class="uk-accordion-content" >
27
          <div class="uk-clearfix"><button *ngIf=" !showsearch "  (click)="showsearch = true;" class="uk-button uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
28
          <claim-contexts-search-form *ngIf=" showsearch "    [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
29
            <ul class="uk-list uk-list-line">
30
              <li class="list-group-item" *ngFor="let context of contexts" >
31
                <span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
32
                <span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
33

    
34
              </li>
35
            </ul>
36
            <div  *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities.</div>
37
        </div>
38
      </div-->
39

    
40

    
41
        `
42
})
43
export class ClaimSelectedContextsComponent {
44
   ngOnInit() {
45
     var myDate = new Date();
46
     this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
47
     this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
48
     //2015-05-01
49
    //  if(this.linkType == "context"){
50
       this.showsearch = true
51
    //  }else{
52
    //    this.showsearch = false;
53
    //  }
54
}
55

    
56

    
57
  @Input() contexts:ClaimContext[];
58
  @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
59
  @Input() show='home';
60
  @Input() title='Communities';
61
  @Input() linkType:string = "project";
62

    
63
  @Input() hideType;
64
  @Input() bulkMode:boolean = false;
65
  @Output() showChange = new EventEmitter();
66
  showsearch:boolean = false;
67

    
68
  todayDate = '';
69
  nextDate = '';
70

    
71
  showType(type){
72
     if(type != this.show){
73
       this.show = type;
74
       this.showChange.emit({
75
         value: this.show
76
       });
77
     }
78
    }
79

    
80

    
81
  removeContext(item:any){
82
    var index:number =this.contexts.indexOf(item);
83
     if (index > -1) {
84
        this.contexts.splice(index, 1);
85
      }
86

    
87
    }
88
  contextSelected($event) {
89
    // this.showsearch = false;
90
  }
91

    
92
}
(1-1/6)