Project

General

Profile

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

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

    
8
        <!-- Contexts -->
9

    
10
            <div class="" >
11

    
12

    
13
              <div  *ngIf="contexts.length > 0 "  class="    ">
14
                  <!--h5 class=" uk-margin uk-h5 uk-text-primary">Selected Communities ({{contexts.length | number}}) </h5-->
15

    
16
                  <ul class="uk-list uk-list-divider">
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 icon-button-small ">
20
                        <span class="uk-icon">
21
                          <svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="0.8"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
22
                        </span>
23
                      </span>
24

    
25
                    </li>
26
                  </ul>
27
                </div>
28
                  <!--div  *ngIf="contexts.length == 0 "  class="uk-alert no-selected-message uk-text-center">You have not selected any communities</div-->
29
              </div>
30

    
31

    
32

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

    
48

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

    
58
  @Input() hideType;
59
  @Input() bulkMode:boolean = false;
60
  @Output() showChange = new EventEmitter();
61
  @Input()  localStoragePrefix:string = "";
62
  showsearch:boolean = false;
63

    
64
  todayDate = '';
65
  nextDate = '';
66

    
67
  removeContext(item:any){
68
    var index:number =this.contexts.indexOf(item);
69
     if (index > -1) {
70
        this.contexts.splice(index, 1);
71
        if(this.contexts != null){
72
          localStorage.setItem(this.localStoragePrefix + "contexts", JSON.stringify(this.contexts));
73
        }
74
      }
75

    
76
    }
77

    
78
}
(8-8/14)