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
            <div class="uk-placeholder" >
11

    
12
             <!--div  class="uk-width-1-2    ">
13

    
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><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="1"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg></span></button></div>
15
                <claim-contexts-search-form *ngIf=" showsearch "    [selectedList]="contexts" [projects]="projects" [results]="results" [inlineEntity]="inlineEntity" > </claim-contexts-search-form>
16
              </div-->
17
              <div  *ngIf="contexts.length > 0 "  class="    ">
18
                  <h3 > Selected Communities ({{contexts.length}}) </h3>
19
                  <ul class="uk-list uk-list-divider">
20
                    <li class="list-group-item" *ngFor="let context of contexts" >
21
                      <span *ngIf="context.community != context.concept.label">{{context.community }} > {{context.category}} ></span><span> {{context.concept.label}} </span>
22
                      <span (click)="removeContext(context)" aria-hidden="true" class="uk-icon-button"><span class="uk-icon">
23
                        <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><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>
24
                        </span></span>
25

    
26
                    </li>
27
                  </ul>
28
                </div>
29
                  <div  *ngIf="contexts.length == 0 "  class="uk-text-center">There are no selected communities</div>
30
              </div>
31

    
32

    
33

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

    
49

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

    
60
  @Input() hideType;
61
  @Input() bulkMode:boolean = false;
62
  @Output() showChange = new EventEmitter();
63

    
64
  showsearch:boolean = false;
65

    
66
  todayDate = '';
67
  nextDate = '';
68

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

    
78

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

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

    
90
}
(1-1/6)