94601c1f
Renato De Donato
trevieww multitable
|
1
2
3
4
5
6
7
8
9
|
<link rel="import" href="../../bower_components/polymer/polymer.html" />
<link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tab.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animation.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">
<link rel="import" href="../../bower_components/neon-animation/neon-animations.html">
|
e0e4a976
Renato De Donato
data-sevc-control...
|
10
|
<link rel="import" href="../../datalets/dynamic-datatable-datalet/dynamic-datatable-datalet.html" />
|
94601c1f
Renato De Donato
trevieww multitable
|
11
12
13
14
15
16
|
<dom-module id="multi-table-controllet">
<template>
<style is="custom-style">
|
98d9d8a5
Renato De Donato
filters+groupby
|
17
18
|
paper-tabs {
|
94601c1f
Renato De Donato
trevieww multitable
|
19
20
21
22
23
24
|
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
--paper-tabs-selection-bar-color: #2196F3;
}
|
98d9d8a5
Renato De Donato
filters+groupby
|
25
|
paper-tab {
|
94601c1f
Renato De Donato
trevieww multitable
|
26
27
28
29
30
31
32
|
transition: all 1.0s;
}
paper-tab.iron-selected{
background-color: #B6B6B6;
}
|
98d9d8a5
Renato De Donato
filters+groupby
|
33
|
paper-tab:hover {
|
94601c1f
Renato De Donato
trevieww multitable
|
34
35
|
color: #2196F3;
}
|
98d9d8a5
Renato De Donato
filters+groupby
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#multi_table_container {
height: 100%;
width: 100%;
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
}
#multi_table_tables {
position: relative;
height: calc(100% - 48px);
}
|
94601c1f
Renato De Donato
trevieww multitable
|
50
51
|
</style>
|
98d9d8a5
Renato De Donato
filters+groupby
|
52
|
<div id="multi_table_container">
|
94601c1f
Renato De Donato
trevieww multitable
|
53
|
|
98d9d8a5
Renato De Donato
filters+groupby
|
54
55
56
57
58
|
<paper-tabs selected="{{selected}}">
<template id="dom-tabs" is="dom-repeat" items="{{_toArrayTabs(selectedFields)}}">
<paper-tab noink>{{item.name}}</paper-tab>
</template>
</paper-tabs>
|
94601c1f
Renato De Donato
trevieww multitable
|
59
|
|
98d9d8a5
Renato De Donato
filters+groupby
|
60
61
62
63
64
65
66
67
68
69
70
|
<div id="multi_table_tables">
<neon-animated-pages selected="{{selected}}" entry-animation="fade-in-animation" exit-animation="fade-out-animation">
<template id="dom_pages" is="dom-repeat" items="{{_toArrayPages(selectedFields)}}">
<neon-animatable>
<dynamic-datatable-datalet id="{{item.name}}" data-url={{dataUrl}} fields$='{{_getFields(item.value)}}' filters$='{{_getFilters(item.value)}}'></dynamic-datatable-datalet>
</neon-animatable>
</template>
</neon-animated-pages>
</div>
</div>
|
94601c1f
Renato De Donato
trevieww multitable
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
</template>
<script>
Polymer({
is : 'multi-table-controllet',
properties : {
selected : {
type : Number,
value : undefined
},
selectedFields : {
type : Array,
value : undefined
},
dataUrl : {
type : String,
value : undefined
},
toSelect : {
type : Number,
value : undefined
}
},
listeners: {
'dom-change': '_onDomChange'
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
108
109
110
111
|
ready : function() {
$(this.$.multi_table_tables).perfectScrollbar();
},
|
94601c1f
Renato De Donato
trevieww multitable
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
setSelectedFields : function(selectedFields) {
this.toSelect = this._calculateSelected(this.selectedFields, selectedFields);
this.selectedFields = this._copy(selectedFields);
},
_calculateSelected : function(preselectedFields, selectedFields) {
if(!preselectedFields)
return 0;//new multi-table
if(Object.keys(selectedFields).length == 0)
return 0;//no fields
for(var key in selectedFields){
if(!preselectedFields[key])
return Object.keys(selectedFields).indexOf(key);//new field
if(JSON.stringify(selectedFields[key]) != JSON.stringify(preselectedFields[key]))
return Object.keys(selectedFields).indexOf(key);//modified field
}
//removed field
if(this.selected == 0){
this.selected = 1;
return 0;
}
/******** optional ********/
var removedIndex;
for(var key in preselectedFields){
if(!selectedFields[key]){
// if(Object.keys(preselectedFields).indexOf(key) != 0)
removedIndex = Object.keys(preselectedFields).indexOf(key);//
}
}
//'select the selected' (index changed after remove)
if(removedIndex <= this.selected){
return this.selected - 1;
}
else{
this.selected = this.selected + 1;
return this.selected -1;
}
},
|
a31f0660
root
sevc-controllet i...
|
157
|
_copy : function(o) {
|
94601c1f
Renato De Donato
trevieww multitable
|
158
159
160
161
162
163
164
165
166
167
|
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;
},
_onDomChange : function(e) {
|
98d9d8a5
Renato De Donato
filters+groupby
|
168
|
if (e.target.id == "dom_pages")
|
94601c1f
Renato De Donato
trevieww multitable
|
169
170
171
|
this.async(function () {this.selected = this.toSelect;}, 0);
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
172
|
_toArrayTabs : function(obj) {
|
94601c1f
Renato De Donato
trevieww multitable
|
173
174
175
176
177
|
return Object.keys(obj).map(function(key) {
return {name: key.replace(/,/g, " / "), value: obj[key]};
});
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
178
|
_toArrayPages : function(obj) {
|
94601c1f
Renato De Donato
trevieww multitable
|
179
180
181
182
183
|
return Object.keys(obj).map(function(key) {
return {name: key, value: obj[key]};
});
},
|
98d9d8a5
Renato De Donato
filters+groupby
|
184
|
_getFields : function(value) {
|
94601c1f
Renato De Donato
trevieww multitable
|
185
|
return value;
|
98d9d8a5
Renato De Donato
filters+groupby
|
186
187
188
189
|
},
_getFilters : function(value) {
return JSON.stringify(this.filters);
|
94601c1f
Renato De Donato
trevieww multitable
|
190
191
192
193
194
195
196
|
}
});
</script>
</dom-module>
|