Blame view

controllets/select-fields-controllet/select-fields-controllet.html 4.65 KB
89558a41   Renato De Donato   datatype, provide...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  <link rel="import" href="../../bower_components/polymer/polymer.html" />
  
  <link rel="import" href="../../bower_components/paper-material/paper-material.html" />
  <link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
  <link rel="import" href="../../bower_components/paper-item/paper-item.html">
  
  <dom-module id="select-fields-controllet">
  
      <style is="custom-style">
  
          #select_fields_controllet_container {
              height: 100%;
              width: 100%;
          }
  
          #select_fields_controllet_container * {
              font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
              font-size: 16px;
              line-height: 24px;
          }
  
          #select_fields_controllet_container #header {
              background: #B6B6B6;
              height: 24px;
              padding: 12px;
              text-align: center;
              font-weight: 700;
              cursor: pointer;
          }
  
256ece27   Renato De Donato   new controllet
31
32
33
34
          #select_fields_controllet_container #header:hover {
              color: #2196F3;
          }
  
89558a41   Renato De Donato   datatype, provide...
35
36
37
38
39
40
41
42
43
44
45
46
47
          #select_fields_controllet_container #menu_container {
              position: relative;
              height: calc(100% - 48px);
              width: 100%;
          }
  
          paper-menu {
              padding: 0px;
          }
  
          paper-item {
              cursor: pointer;
              color: #000000;
34789a0e   Renato De Donato   jsdatachecker ln,...
48
              background: #FFFFFF;
89558a41   Renato De Donato   datatype, provide...
49
              margin: 4px;
34789a0e   Renato De Donato   jsdatachecker ln,...
50
51
52
53
54
55
              padding: 0 12px;
              /*background: rgba(0, 0, 0, 0.12);*/
              border-radius: 2px;
              border: 1px solid #B6B6B6;
  
              /*background: #E0E0E0;*/
256ece27   Renato De Donato   new controllet
56
57
58
59
60
61
62
          }
  
          paper-item span {
              width: 100%;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
89558a41   Renato De Donato   datatype, provide...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
          }
  
          paper-item.iron-selected {
              background: #2196F3;
              color: #FFFFFF;
          }
  
          paper-item:focus:before {
              opacity: 0 !important;
              background: white;
          }
  
          paper-item:focus:after {
              opacity: 0 !important;
              background: white;
          }
  
          paper-item:hover:not(.iron-selected) {
34789a0e   Renato De Donato   jsdatachecker ln,...
81
82
83
84
85
              background-color: #BBDEFB;
          }
  
          #menu, #menu_container {
              background-color: #E0E0E0;
89558a41   Renato De Donato   datatype, provide...
86
87
88
89
90
91
92
93
94
95
96
97
          }
  
      </style>
  
      <template>
  
          <paper-material id="select_fields_controllet_container" elevation="5">
  
              <div id="header" on-click="_invertSelection"><span id="fields"></span></div>
              <div id="menu_container">
                  <paper-menu id="menu" multi>
                      <template is="dom-repeat" items="{{fields}}">
256ece27   Renato De Donato   new controllet
98
                          <paper-item title="{{item}}"><span>{{item}}</span></paper-item>
89558a41   Renato De Donato   datatype, provide...
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
                      </template>
                  </paper-menu>
              </div>
  
          </paper-material>
  
      </template>
  
      <script>
          Polymer({
  
              is : 'select-fields-controllet',
  
              properties : {
  
                  fields : {
                      type  : Array,
                      value : []
256ece27   Renato De Donato   new controllet
117
                  }
89558a41   Renato De Donato   datatype, provide...
118
  
89558a41   Renato De Donato   datatype, provide...
119
120
121
122
123
124
125
126
127
128
129
130
              },
  
              listeners: {
                  'iron-activate': '_fireSelectedFields'
              },
  
              ready : function() {
                  $(this.$.menu_container).perfectScrollbar();
              },
  
              attached : function() {
                  this._translate();
89558a41   Renato De Donato   datatype, provide...
131
132
133
              },
  
              setFields : function(fields) {
256ece27   Renato De Donato   new controllet
134
135
136
137
                  var index = fields.indexOf("_id");
                  if(index > -1)
                      fields.splice(index, 1);//providers_utility _copy
                  this.fields = fields.sort();
89558a41   Renato De Donato   datatype, provide...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
              },
  
              setSelectFields : function(selectFields) {
                  for(var i=0; i<selectFields.length; i++)
                      this.$.menu.select(selectFields[i]);
                  this._fireSelectedFields();
              },
  
              reset: function() {
                  this.$.menu.selectedValues = [];
                  this.setFields([]);
              },
  
              _translate : function() {
                  this.$.fields.innerHTML = ln["fields_" + ln["localization"]];
              },
  
89558a41   Renato De Donato   datatype, provide...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
              _fireSelectedFields : function() {
                  this.debounce('_fireSelectedFields', function () {
                      this.fire('select-fields-controllet_selected-fields', {selectedFields: this.$.menu.selectedValues});
                  }, 300);
              },
  
              _invertSelection : function() {
  //                for(var i=this.fields.length-1; i>=0; i--)
                  for(var i=0; i<this.fields.length; i++)
                      this.$.menu.select(i);
  
                  $(this.$.menu_container).animate({ scrollTop: 0}, 0);
  
                  this._fireSelectedFields();
              }
  
          });
  
      </script>
  
  </dom-module>