0af843be
Renato De Donato
filters + alasql
|
1
2
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
|
89558a41
Renato De Donato
datatype, provide...
|
3
4
|
<link rel="import" href="../../bower_components/paper-material/paper-material.html" />
|
0af843be
Renato De Donato
filters + alasql
|
5
6
7
8
9
10
11
12
|
<link rel="import" href="../../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-icon-button/paper-icon-button.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
|
89558a41
Renato De Donato
datatype, provide...
|
13
14
|
<link rel="import" href="../../bower_components/paper-button/paper-button.html">
|
0af843be
Renato De Donato
filters + alasql
|
15
16
17
18
19
20
|
<dom-module id="filters-controllet">
<template>
<style is="custom-style">
|
0af843be
Renato De Donato
filters + alasql
|
21
|
#filters_container {
|
89558a41
Renato De Donato
datatype, provide...
|
22
|
height: 48px;
|
0af843be
Renato De Donato
filters + alasql
|
23
|
width: 100%;
|
89558a41
Renato De Donato
datatype, provide...
|
24
|
}
|
0af843be
Renato De Donato
filters + alasql
|
25
|
|
89558a41
Renato De Donato
datatype, provide...
|
26
|
#filters_container * {
|
0af843be
Renato De Donato
filters + alasql
|
27
28
|
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
|
89558a41
Renato De Donato
datatype, provide...
|
29
|
line-height: 24px;
|
0af843be
Renato De Donato
filters + alasql
|
30
31
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
32
|
#filters_container #header {
|
0af843be
Renato De Donato
filters + alasql
|
33
34
35
36
37
|
height: 32px;
padding-top: 16px;
text-align: center;
font-weight: 700;
|
89558a41
Renato De Donato
datatype, provide...
|
38
|
background: #FFFFFF;
|
0af843be
Renato De Donato
filters + alasql
|
39
40
41
42
|
color: #00BCD4;
cursor: pointer;
}
|
89558a41
Renato De Donato
datatype, provide...
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#filters_container #header.hide{
color: #00BCD4;
background: #FFFFFF;
}
/*#filters_container #header.hide:hover{*/
/*}*/
#filters_container #header.show{
color: #000000;
background: #B6B6B6;
}
#filters_container #panel {
display: none;
position: relative;
height: calc(100% - 48px);
background: #FFFFFF;
}
|
0af843be
Renato De Donato
filters + alasql
|
63
|
paper-dropdown-menu {
|
89558a41
Renato De Donato
datatype, provide...
|
64
|
width: 100%;
|
0af843be
Renato De Donato
filters + alasql
|
65
66
67
|
--paper-input-container-focus-color: #2196F3;
}
|
89558a41
Renato De Donato
datatype, provide...
|
68
69
70
71
72
73
74
75
76
77
|
:host {
--paper-dropdown-menu-icon: {
color: #2196F3;
};
}
paper-item {
min-width: 128px;
}
|
0af843be
Renato De Donato
filters + alasql
|
78
79
80
81
82
|
paper-item.iron-selected {
background-color: #2196F3;
color: #FFFFFF;
}
|
89558a41
Renato De Donato
datatype, provide...
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
paper-input {
width: 100%;
--paper-input-container-focus-color: #2196F3;
}
paper-button {
margin: 0px;
height: 44px;
color: #FFFFFF;
background: #2196F3;
font-weight: 700;
}
paper-button:hover {
box-shadow: 0px 8px 12px #888;
-webkit-box-shadow: 0px 8px 12px #888;
-moz-box-shadow: 0px 8px 12px #888;
}
|
0af843be
Renato De Donato
filters + alasql
|
102
|
paper-icon-button {
|
89558a41
Renato De Donato
datatype, provide...
|
103
104
105
106
|
padding: 4px;
}
paper-icon-button.add {
|
0af843be
Renato De Donato
filters + alasql
|
107
108
|
color: #2196F3;
--paper-icon-button-ink-color: #2196F3;
|
0af843be
Renato De Donato
filters + alasql
|
109
110
111
112
113
|
}
paper-icon-button.cancel {
color: #F44336;
--paper-icon-button-ink-color: #F44336;
|
0af843be
Renato De Donato
filters + alasql
|
114
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
115
116
117
118
119
|
#filters_container .row {
display: flex;
height: 60px;
width: 100%;
|
0af843be
Renato De Donato
filters + alasql
|
120
121
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
#filters_container .ddl_container {
display: flex;
height: 60px;
width: 25%;
padding: 0px 8px;
}
#filters_container .add_container {
height: 40px;
width: 40px;
padding: 10px 0px;
}
#filters_container .andOr_container {
|
0af843be
Renato De Donato
filters + alasql
|
136
|
display: inline-block;
|
89558a41
Renato De Donato
datatype, provide...
|
137
138
139
140
|
height: 44px;
width: calc(100% - 40px);
padding: 8px 0px;
text-align: right;
|
0af843be
Renato De Donato
filters + alasql
|
141
142
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
143
144
|
#filters_container .row2 {
display: flex;
|
0af843be
Renato De Donato
filters + alasql
|
145
|
height: 48px;
|
89558a41
Renato De Donato
datatype, provide...
|
146
|
width: 100%;
|
0af843be
Renato De Donato
filters + alasql
|
147
148
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
149
150
151
152
153
154
155
156
157
|
#filters_container .row2 .highlighted {
color: #2196F3;
font-weight: 700;
}
#filters_container .filter {
height: 24px;
width: calc(75% - 16px);
padding: 12px 8px;
|
0af843be
Renato De Donato
filters + alasql
|
158
159
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
160
161
162
163
164
|
#filters_container .remove_container {
height: 40px;
width: 40px;
padding: 4px 8px;
|
0af843be
Renato De Donato
filters + alasql
|
165
166
167
168
|
}
</style>
|
89558a41
Renato De Donato
datatype, provide...
|
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
<paper-material id="filters_container" elevation="5">
<div id="header" class="hide" on-click="_showFiltersPanel"><span id="filters"><span id="addFilters"></span></span></div>
<div id="panel">
<div class="row">
<div class="ddl_container">
<paper-dropdown-menu id="filter_field" label="Field">
<paper-menu id="filter_field_menu" class="dropdown-content">
<template is="dom-repeat" items={{fields}}>
<paper-item id={{index}}>{{_fieldName(item)}}</paper-item>
</template>
</paper-menu>
</paper-dropdown-menu>
</div>
<div class="ddl_container">
<paper-dropdown-menu id="filter_operation" label="Operation">
<paper-menu id="filter_operation_menu" class="dropdown-content">
<template is="dom-repeat" items={{operations}}>
<paper-item id={{index}}>{{_getOperationlName(item)}}</paper-item>
</template>
</paper-menu>
</paper-dropdown-menu>
</div>
<div class="ddl_container">
<paper-input id="filter_value" label="Value" class="base_input" maxlength="32" auto-validate pattern="^[.:,;+-_ a-zA-Z0-9]*" error-message="Invalid value!"></paper-input>
</div>
<div class="ddl_container">
<div class="add_container">
|
0af843be
Renato De Donato
filters + alasql
|
199
|
<paper-icon-button on-click="_addFilter" icon="add-circle" class="add"></paper-icon-button>
|
89558a41
Renato De Donato
datatype, provide...
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
</div>
<div class="andOr_container">
<paper-button raised on-click="_changeLogicalOperator"><span id="andOr">{{logicalOperator}}</span></paper-button>
</div>
</div>
</div>
<template is="dom-repeat" items={{filters}}>
<template is="dom-if" if="{{index}}"><!--excludes logicalOperator-->
<div class="row2">
<div class="filter">
{{item.field}} <span class="highlighted">{{item.operation}}</span> "{{item.value}}" <span class="highlighted">{{_getLogicalOperator(index)}}</span>
</div>
<div class="remove_container">
<paper-icon-button on-click="_deleteFilter" icon="cancel" class="cancel"></paper-icon-button>
</div>
</div>
|
0af843be
Renato De Donato
filters + alasql
|
217
|
</template>
|
89558a41
Renato De Donato
datatype, provide...
|
218
|
</template>
|
0af843be
Renato De Donato
filters + alasql
|
219
220
221
|
</div>
|
89558a41
Renato De Donato
datatype, provide...
|
222
|
</paper-material>
|
0af843be
Renato De Donato
filters + alasql
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
</template>
<script>
Polymer({
is : 'filters-controllet',
properties : {
fields : {
type : Array,
value : []
},
operations : {
type : Array,
|
7464051f
Renato De Donato
not contains
|
241
|
value : ["=", "!=", ">", ">=", "<", "<=", "contains", "not contains", "start", "ends"]
|
0af843be
Renato De Donato
filters + alasql
|
242
243
244
245
|
},
filters : {
type : Array,
|
89558a41
Renato De Donato
datatype, provide...
|
246
|
value : [{logicalOperator: "AND"}]
|
0af843be
Renato De Donato
filters + alasql
|
247
248
249
250
251
252
253
254
255
256
|
},
show : {
type : Boolean,
value : false
}
},
ready : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
257
258
|
$(this.$.panel).perfectScrollbar();
// this._showFiltersPanel();
|
0af843be
Renato De Donato
filters + alasql
|
259
260
|
},
|
e94f9513
Renato De Donato
filter ln
|
261
|
attached : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
262
263
|
this.logicalOperator = this.filters[0].logicalOperator;
|
e94f9513
Renato De Donato
filter ln
|
264
265
266
|
this._translate();
},
|
0af843be
Renato De Donato
filters + alasql
|
267
|
setFields : function(fields) {
|
89558a41
Renato De Donato
datatype, provide...
|
268
269
270
271
272
273
274
275
276
|
// this.fields = this._copy(fields);
this.fields = fields.slice();
this.fields = fields;
},
setFilters : function(filters) {
this.filters = filters.slice();
this.logicalOperator = this.filters[0].logicalOperator;
this._fire();
|
0af843be
Renato De Donato
filters + alasql
|
277
278
279
280
281
282
|
},
getFilters : function() {
return this.filters;
},
|
89558a41
Renato De Donato
datatype, provide...
|
283
284
285
286
287
|
reset : function() {
this.fields = [];
this.filters = [{logicalOperator: "AND"}];
},
|
e94f9513
Renato De Donato
filter ln
|
288
|
_translate : function() {
|
79627d7e
Renato De Donato
controllet ln
|
289
|
this.$.addFilters.innerHTML = ln["expertAddFilters_" + ln["localization"]];
|
e94f9513
Renato De Donato
filter ln
|
290
291
292
293
294
|
this.$.filter_field.setAttribute("label", ln["filterField_" + ln["localization"]]);
this.$.filter_operation.setAttribute("label", ln["filterOperation_" + ln["localization"]]);
this.$.filter_value.setAttribute("label", ln["filterValue_" + ln["localization"]]);
},
|
0af843be
Renato De Donato
filters + alasql
|
295
296
297
298
299
|
_fieldName : function(field) {
return field.substring(field.lastIndexOf(",")+1, field.length);
},
_showFiltersPanel : function() {
|
89558a41
Renato De Donato
datatype, provide...
|
300
301
|
// ? filter class hiddend & hover:
|
0af843be
Renato De Donato
filters + alasql
|
302
|
if(!this.show) {
|
89558a41
Renato De Donato
datatype, provide...
|
303
304
305
306
307
|
this.$.filters_container.style.height = "100%";
$(this.$.header).removeClass("hide");
$(this.$.header).addClass("show");
this.$.panel.style.display = "block";
|
0af843be
Renato De Donato
filters + alasql
|
308
309
|
}
else {
|
89558a41
Renato De Donato
datatype, provide...
|
310
311
312
313
|
this.$.filters_container.style.height = "48px";
$(this.$.header).removeClass("show");
$(this.$.header).addClass("hide");
this.$.panel.style.display = "none";
|
0af843be
Renato De Donato
filters + alasql
|
314
315
|
}
|
89558a41
Renato De Donato
datatype, provide...
|
316
317
|
this.fire('filters-controllet_show', {show: this.show});
|
0af843be
Renato De Donato
filters + alasql
|
318
319
320
|
this.show = !this.show;
},
|
89558a41
Renato De Donato
datatype, provide...
|
321
322
323
324
325
326
327
|
_fire : function() {
if (this.filters.length > 1)
this.fire('filters-controllet_filters', {filters: this.filters});
else
this.fire('filters-controllet_filters', {filters: []});
},
|
0af843be
Renato De Donato
filters + alasql
|
328
|
_addFilter : function() {
|
e94f9513
Renato De Donato
filter ln
|
329
330
|
if (this.$.filter_field.selectedItem && this.$.filter_operation_menu.selectedItem && this.$.filter_value.value != "" && !this.$.filter_value.invalid) {
var field = this.$.filter_field.value;
|
93ba7167
Renato De Donato
filters bug fix + ln
|
331
332
333
|
var id = this.$.filter_operation.selectedItem.id;
var operation = this.operations[id];
// var operation = this.$.filter_operation.value;
|
e94f9513
Renato De Donato
filter ln
|
334
|
var value = this.$.filter_value.value;
|
0af843be
Renato De Donato
filters + alasql
|
335
|
|
89558a41
Renato De Donato
datatype, provide...
|
336
337
338
339
340
|
// var filters = this.filters;
// filters.push({"field": field, "operation": operation, "value": value});
// this.filters = filters;
this.filters.push({"field": field, "operation": operation, "value": value});
|
98d9d8a5
Renato De Donato
filters+groupby
|
341
|
|
e94f9513
Renato De Donato
filter ln
|
342
343
344
|
this.$.filter_field_menu.select(-1);
this.$.filter_operation_menu.select(-1);
this.$.filter_value.value = "";
|
39d5ab70
Renato De Donato
update filters
|
345
|
|
89558a41
Renato De Donato
datatype, provide...
|
346
347
348
|
this._fire();
this._renderFilters();
|
e94f9513
Renato De Donato
filter ln
|
349
|
}
|
0af843be
Renato De Donato
filters + alasql
|
350
351
352
353
354
|
},
_deleteFilter : function(e) {
var index = e.model.index;
|
89558a41
Renato De Donato
datatype, provide...
|
355
356
357
358
359
360
361
|
// var filters = this.filters;
// filters.splice(index, 1);
// this.filters = this._copy(filters);
this.filters.splice(index, 1);
this._fire();
|
98d9d8a5
Renato De Donato
filters+groupby
|
362
|
|
89558a41
Renato De Donato
datatype, provide...
|
363
|
this._renderFilters();
|
0af843be
Renato De Donato
filters + alasql
|
364
365
|
},
|
e94f9513
Renato De Donato
filter ln
|
366
|
_getOperationlName: function(operation) {
|
7464051f
Renato De Donato
not contains
|
367
368
|
if(operation.indexOf("not") > -1)
return ln["notContains_" + ln["localization"]];
|
e94f9513
Renato De Donato
filter ln
|
369
370
371
372
373
374
375
376
377
|
if(operation.indexOf("contains") > -1)
return ln["contains_" + ln["localization"]];
if(operation.indexOf("start") > -1)
return ln["start_" + ln["localization"]];
if(operation.indexOf("ends") > -1)
return ln["ends_" + ln["localization"]];
return operation;
},
|
89558a41
Renato De Donato
datatype, provide...
|
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
// _changeLogicalOperator : function() {
// if(this.logicalOperator == "AND")
// this.logicalOperator = "OR";
// else
// this.logicalOperator = "AND";
//
// this._fire();
//
// this._renderFilters();
// },
_changeLogicalOperator : function() {
if(this.logicalOperator == "AND")
this.logicalOperator = "OR";
else
this.logicalOperator = "AND";
this.filters[0] = {logicalOperator: this.logicalOperator}
this._fire();
this._renderFilters();
},
_renderFilters : function() {
var filters = this.filters.slice();
this.filters = [];
this.async(function() {
this.filters = filters;
}, 0);
},
_getLogicalOperator : function(index) {
if(index == this.filters.length -1)
return "";
else
return this.filters[0].logicalOperator;
},
// _copy : function(o) {
// var out, v, key;
// out = Array.isArray(o) ? [] : {};
// for (key in o) {
// v = o[key];
// out[key] = (typeof v === "object") ? this._copy(v) : v;
// }
// return out;
// }
|
0af843be
Renato De Donato
filters + alasql
|
426
427
428
429
430
431
|
});
</script>
</dom-module>
|