tabulator-tables 5.0.7 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +6 -0
- package/LICENSE +1 -1
- package/bower.json +1 -1
- package/build/rollup.js +1 -1
- package/dist/css/tabulator.css +15 -2
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +15 -2
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +15 -2
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bulma.css +15 -2
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +22 -6
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +19 -2
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +15 -2
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +15 -2
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +15 -2
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +19 -2
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/tabulator.js +1121 -533
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +1566 -991
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/ColumnManager.js +4 -2
- package/src/js/core/CoreFeature.js +1 -5
- package/src/js/core/RowManager.js +15 -9
- package/src/js/core/Tabulator.js +14 -59
- package/src/js/core/cell/Cell.js +5 -1
- package/src/js/core/column/Column.js +21 -6
- package/src/js/core/column/ColumnComponent.js +4 -0
- package/src/js/core/column/defaults/options.js +1 -0
- package/src/js/core/defaults/options.js +3 -3
- package/src/js/core/modules/optional.js +1 -0
- package/src/js/core/rendering/Renderer.js +3 -2
- package/src/js/core/rendering/renderers/BasicVertical.js +2 -1
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +165 -151
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +1 -1
- package/src/js/core/row/Row.js +2 -2
- package/src/js/core/tools/{ComponentFuctionBinder.js → ComponentFunctionBinder.js} +1 -1
- package/src/js/core/tools/DataLoader.js +6 -6
- package/src/js/core/tools/InteractionMonitor.js +149 -49
- package/src/js/core/tools/OptionsList.js +2 -2
- package/src/js/modules/Ajax/Ajax.js +62 -82
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +15 -2
- package/src/js/modules/DataTree/DataTree.js +23 -9
- package/src/js/modules/Download/defaults/downloaders/json.js +1 -1
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
- package/src/js/modules/Download/defaults/downloaders/pdf.js +0 -2
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +3 -2
- package/src/js/modules/Download/defaults/downloaders.js +2 -0
- package/src/js/modules/Edit/Edit.js +27 -39
- package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
- package/src/js/modules/Export/Export.js +1 -1
- package/src/js/modules/Filter/Filter.js +2 -2
- package/src/js/modules/Format/defaults/formatters/datetime.js +2 -2
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +2 -1
- package/src/js/modules/FrozenColumns/FrozenColumns.js +1 -1
- package/src/js/modules/FrozenRows/FrozenRows.js +9 -0
- package/src/js/modules/GroupRows/Group.js +18 -67
- package/src/js/modules/GroupRows/GroupRows.js +8 -3
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +4 -7
- package/src/js/modules/Import/Import.js +197 -0
- package/src/js/modules/Import/defaults/importers/csv.js +63 -0
- package/src/js/modules/Import/defaults/importers/json.js +8 -0
- package/src/js/modules/Import/defaults/importers.js +7 -0
- package/src/js/modules/Interaction/Interaction.js +5 -0
- package/src/js/modules/Keybindings/Keybindings.js +9 -14
- package/src/js/modules/Keybindings/defaults/bindings.js +3 -3
- package/src/js/modules/Localize/defaults/langs.js +6 -0
- package/src/js/modules/Menu/Menu.js +200 -155
- package/src/js/modules/MoveColumns/MoveColumns.js +58 -57
- package/src/js/modules/MoveRows/MoveRows.js +4 -0
- package/src/js/modules/Page/Page.js +279 -183
- package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
- package/src/js/modules/Page/defaults/pageCounters/rows.js +32 -0
- package/src/js/modules/Page/defaults/pageCounters.js +8 -0
- package/src/js/modules/ResizeRows/ResizeRows.js +1 -1
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +3 -5
- package/src/js/modules/SelectRow/SelectRow.js +4 -8
- package/src/js/modules/Sort/Sort.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/datetime.js +3 -2
- package/src/js/modules/Validate/Validate.js +7 -5
- package/src/scss/tabulator.scss +20 -2
- package/src/scss/themes/materialize/tabulator_materialize.scss +5 -4
- package/src/scss/themes/tabulator_midnight.scss +4 -0
- package/src/scss/themes/tabulator_site.scss +4 -0
|
@@ -2,29 +2,29 @@ import CoreFeature from '../CoreFeature.js';
|
|
|
2
2
|
import Helpers from './Helpers.js';
|
|
3
3
|
|
|
4
4
|
export default class InteractionManager extends CoreFeature {
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
constructor (table){
|
|
7
7
|
super(table);
|
|
8
|
-
|
|
9
|
-
this.el =
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
this.el = null;
|
|
10
|
+
|
|
11
11
|
this.abortClasses = ["tabulator-headers", "tabulator-table"];
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
this.previousTargets = {};
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
this.listeners = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
"click",
|
|
17
|
+
"dblclick",
|
|
18
|
+
"contextmenu",
|
|
19
|
+
"mouseenter",
|
|
20
|
+
"mouseleave",
|
|
21
|
+
"mouseover",
|
|
22
|
+
"mouseout",
|
|
23
|
+
"mousemove",
|
|
24
|
+
"touchstart",
|
|
25
|
+
"touchend",
|
|
26
26
|
];
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
this.componentMap = {
|
|
29
29
|
"tabulator-cell":"cell",
|
|
30
30
|
"tabulator-row":"row",
|
|
@@ -32,36 +32,111 @@ export default class InteractionManager extends CoreFeature {
|
|
|
32
32
|
"tabulator-col":"column",
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
this.pseudoTrackers = {
|
|
36
|
+
"row":{
|
|
37
|
+
subscriber:null,
|
|
38
|
+
target:null,
|
|
39
|
+
},
|
|
40
|
+
"cell":{
|
|
41
|
+
subscriber:null,
|
|
42
|
+
target:null,
|
|
43
|
+
},
|
|
44
|
+
"group":{
|
|
45
|
+
subscriber:null,
|
|
46
|
+
target:null,
|
|
47
|
+
},
|
|
48
|
+
"column":{
|
|
49
|
+
subscriber:null,
|
|
50
|
+
target:null,
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.pseudoTracking = false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
initialize(){
|
|
58
|
+
this.el = this.table.element;
|
|
35
59
|
this.buildListenerMap();
|
|
36
60
|
this.bindSubscriptionWatchers();
|
|
37
61
|
}
|
|
38
|
-
|
|
62
|
+
|
|
39
63
|
buildListenerMap(){
|
|
40
64
|
var listenerMap = {};
|
|
41
|
-
|
|
65
|
+
|
|
42
66
|
this.listeners.forEach((listener) => {
|
|
43
67
|
listenerMap[listener] = {
|
|
44
68
|
handler:null,
|
|
45
69
|
components:[],
|
|
46
70
|
}
|
|
47
71
|
})
|
|
48
|
-
|
|
72
|
+
|
|
49
73
|
this.listeners = listenerMap;
|
|
50
74
|
}
|
|
51
75
|
|
|
76
|
+
bindPseudoEvents(){
|
|
77
|
+
Object.keys(this.pseudoTrackers).forEach((key) => {
|
|
78
|
+
this.pseudoTrackers[key].subscriber = this.pseudoMouseEnter.bind(this, key);
|
|
79
|
+
this.subscribe(key + "-mouseover", this.pseudoTrackers[key].subscriber);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
this.pseudoTracking = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
pseudoMouseEnter(key, e, target){
|
|
86
|
+
if(this.pseudoTrackers[key].target !== target){
|
|
87
|
+
|
|
88
|
+
if(this.pseudoTrackers[key].target){
|
|
89
|
+
this.dispatch(key + "-mouseleave", e, target);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.pseudoMouseLeave(key, e);
|
|
93
|
+
|
|
94
|
+
this.pseudoTrackers[key].target = target;
|
|
95
|
+
|
|
96
|
+
this.dispatch(key + "-mouseenter", e, target);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pseudoMouseLeave(key, e){
|
|
101
|
+
var leaveList = Object.keys(this.pseudoTrackers),
|
|
102
|
+
linkedKeys = {
|
|
103
|
+
"row":["cell"],
|
|
104
|
+
"cell":["row"],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
leaveList = leaveList.filter((item) => {
|
|
108
|
+
var links = linkedKeys[key];
|
|
109
|
+
return item !== key && (!links || (links && !links.includes(item)));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
leaveList.forEach((key) => {
|
|
114
|
+
var target = this.pseudoTrackers[key].target;
|
|
115
|
+
|
|
116
|
+
if(this.pseudoTrackers[key].target){
|
|
117
|
+
this.dispatch(key + "-mouseleave", e, target);
|
|
118
|
+
|
|
119
|
+
this.pseudoTrackers[key].target = null;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
52
125
|
bindSubscriptionWatchers(){
|
|
53
126
|
var listeners = Object.keys(this.listeners),
|
|
54
127
|
components = Object.values(this.componentMap);
|
|
55
|
-
|
|
128
|
+
|
|
56
129
|
for(let comp of components){
|
|
57
130
|
for(let listener of listeners){
|
|
58
131
|
let key = comp + "-" + listener;
|
|
59
|
-
|
|
132
|
+
|
|
60
133
|
this.subscriptionChange(key, this.subscriptionChanged.bind(this, comp, listener));
|
|
61
134
|
}
|
|
62
135
|
}
|
|
136
|
+
|
|
137
|
+
this.subscribe("table-destroy", this.clearWatchers.bind(this))
|
|
63
138
|
}
|
|
64
|
-
|
|
139
|
+
|
|
65
140
|
subscriptionChanged(component, key, added){
|
|
66
141
|
var listener = this.listeners[key].components,
|
|
67
142
|
index = listener.indexOf(component),
|
|
@@ -81,15 +156,19 @@ export default class InteractionManager extends CoreFeature {
|
|
|
81
156
|
}
|
|
82
157
|
}
|
|
83
158
|
|
|
159
|
+
if((key === "mouseenter" || key === "mouseleave") && !this.pseudoTracking){
|
|
160
|
+
this.bindPseudoEvents();
|
|
161
|
+
}
|
|
162
|
+
|
|
84
163
|
if(changed){
|
|
85
164
|
this.updateEventListeners();
|
|
86
165
|
}
|
|
87
166
|
}
|
|
88
|
-
|
|
167
|
+
|
|
89
168
|
updateEventListeners(){
|
|
90
169
|
for(let key in this.listeners){
|
|
91
170
|
let listener = this.listeners[key];
|
|
92
|
-
|
|
171
|
+
|
|
93
172
|
if(listener.components.length){
|
|
94
173
|
if(!listener.handler){
|
|
95
174
|
listener.handler = this.track.bind(this, key);
|
|
@@ -104,86 +183,96 @@ export default class InteractionManager extends CoreFeature {
|
|
|
104
183
|
}
|
|
105
184
|
}
|
|
106
185
|
}
|
|
107
|
-
|
|
186
|
+
|
|
108
187
|
track(type, e){
|
|
109
188
|
var path = (e.composedPath && e.composedPath()) || e.path;
|
|
189
|
+
|
|
110
190
|
var targets = this.findTargets(path);
|
|
111
191
|
targets = this.bindComponents(type, targets);
|
|
192
|
+
|
|
112
193
|
this.triggerEvents(type, e, targets);
|
|
113
|
-
}
|
|
114
194
|
|
|
195
|
+
if(this.pseudoTracking && (type == "mouseover" || type == "mouseleave") && !Object.keys(targets).length){
|
|
196
|
+
this.pseudoMouseLeave("none", e);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
115
200
|
findTargets(path){
|
|
116
201
|
var targets = {};
|
|
117
|
-
|
|
202
|
+
|
|
118
203
|
let componentMap = Object.keys(this.componentMap);
|
|
119
|
-
|
|
204
|
+
|
|
120
205
|
for (let el of path) {
|
|
121
206
|
let classList = el.classList ? [...el.classList] : [];
|
|
122
|
-
|
|
207
|
+
|
|
123
208
|
let abort = classList.filter((item) => {
|
|
124
209
|
return this.abortClasses.includes(item);
|
|
125
210
|
})
|
|
126
|
-
|
|
211
|
+
|
|
127
212
|
if(abort.length){
|
|
128
213
|
break;
|
|
129
214
|
}
|
|
130
|
-
|
|
215
|
+
|
|
131
216
|
let elTargets = classList.filter((item) => {
|
|
132
217
|
return componentMap.includes(item);
|
|
133
218
|
})
|
|
134
|
-
|
|
219
|
+
|
|
135
220
|
for (let target of elTargets) {
|
|
136
221
|
targets[this.componentMap[target]] = el;
|
|
137
222
|
}
|
|
138
223
|
}
|
|
139
|
-
|
|
224
|
+
|
|
140
225
|
if(targets.group && targets.group === targets.row){
|
|
141
226
|
delete targets.row;
|
|
142
227
|
}
|
|
143
|
-
|
|
228
|
+
|
|
144
229
|
return targets;
|
|
145
230
|
}
|
|
146
|
-
|
|
231
|
+
|
|
147
232
|
bindComponents(type, targets){
|
|
148
233
|
//ensure row component is looked up before cell
|
|
149
234
|
var keys = Object.keys(targets).reverse(),
|
|
150
235
|
listener = this.listeners[type],
|
|
151
236
|
targetMatches = {};
|
|
152
|
-
|
|
237
|
+
|
|
153
238
|
for(let key of keys){
|
|
154
239
|
let component;
|
|
155
240
|
let target = targets[key];
|
|
156
241
|
let previousTarget = this.previousTargets[key];
|
|
157
|
-
|
|
242
|
+
|
|
158
243
|
if(previousTarget && previousTarget.target === target){
|
|
159
244
|
component = previousTarget.component;
|
|
160
245
|
}else{
|
|
161
246
|
switch(key){
|
|
162
247
|
case "row":
|
|
163
248
|
case "group":
|
|
164
|
-
if(listener.components.includes("row") || listener.components.includes("cell")){
|
|
165
|
-
let rows = this.table.rowManager.getVisibleRows();
|
|
166
|
-
|
|
249
|
+
if(listener.components.includes("row") || listener.components.includes("cell") || listener.components.includes("group")){
|
|
250
|
+
let rows = this.table.rowManager.getVisibleRows(true);
|
|
251
|
+
|
|
167
252
|
component = rows.find((row) => {
|
|
168
253
|
return row.getElement() === target;
|
|
169
254
|
});
|
|
170
255
|
}
|
|
171
256
|
break;
|
|
172
|
-
|
|
257
|
+
|
|
173
258
|
case "column":
|
|
174
259
|
if(listener.components.includes("column")){
|
|
175
260
|
component = this.table.columnManager.findColumn(target);
|
|
176
261
|
}
|
|
177
262
|
break
|
|
178
|
-
|
|
263
|
+
|
|
179
264
|
case "cell":
|
|
180
265
|
if(listener.components.includes("cell")){
|
|
181
|
-
|
|
266
|
+
if(targets["row"]){
|
|
267
|
+
component = targets["row"].findCell(target);
|
|
268
|
+
}else{
|
|
269
|
+
console.warn("Event Target Lookup Error - The row this cell is attached to cannot be found, has the table been reinitialized without being destroyed first?")
|
|
270
|
+
}
|
|
182
271
|
}
|
|
183
272
|
break;
|
|
184
273
|
}
|
|
185
274
|
}
|
|
186
|
-
|
|
275
|
+
|
|
187
276
|
if(component){
|
|
188
277
|
targets[key] = component;
|
|
189
278
|
targetMatches[key] = {
|
|
@@ -192,19 +281,30 @@ export default class InteractionManager extends CoreFeature {
|
|
|
192
281
|
}
|
|
193
282
|
}
|
|
194
283
|
}
|
|
195
|
-
|
|
284
|
+
|
|
196
285
|
this.previousTargets = targetMatches;
|
|
197
|
-
|
|
286
|
+
|
|
198
287
|
return targets;
|
|
199
288
|
}
|
|
200
|
-
|
|
289
|
+
|
|
201
290
|
triggerEvents(type, e, targets){
|
|
202
291
|
var listener = this.listeners[type];
|
|
203
|
-
|
|
292
|
+
|
|
204
293
|
for(let key in targets){
|
|
205
294
|
if(targets[key] && listener.components.includes(key)){
|
|
206
295
|
this.dispatch(key + "-" + type, e, targets[key]);
|
|
207
296
|
}
|
|
208
297
|
}
|
|
209
298
|
}
|
|
299
|
+
|
|
300
|
+
clearWatchers(){
|
|
301
|
+
for(let key in this.listeners){
|
|
302
|
+
let listener = this.listeners[key];
|
|
303
|
+
|
|
304
|
+
if(listener.handler){
|
|
305
|
+
this.el.removeEventListener(key, listener.handler)
|
|
306
|
+
listener.handler = null;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
210
310
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default class OptionsList {
|
|
2
|
-
constructor(table, msgType){
|
|
2
|
+
constructor(table, msgType, defaults = {}){
|
|
3
3
|
this.table = table;
|
|
4
4
|
this.msgType = msgType;
|
|
5
|
-
this.registeredDefaults = {}
|
|
5
|
+
this.registeredDefaults = Object.assign({}, defaults)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
register(option, value){
|
|
@@ -6,145 +6,125 @@ import defaultLoaderPromise from './defaults/loaderPromise.js';
|
|
|
6
6
|
import defaultContentTypeFormatters from './defaults/contentTypeFormatters.js';
|
|
7
7
|
|
|
8
8
|
class Ajax extends Module{
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
constructor(table){
|
|
11
11
|
super(table);
|
|
12
|
-
|
|
13
|
-
this.config =
|
|
12
|
+
|
|
13
|
+
this.config = {}; //hold config object for ajax request
|
|
14
14
|
this.url = ""; //request URL
|
|
15
15
|
this.urlGenerator = false;
|
|
16
16
|
this.params = false; //request parameters
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
this.loaderPromise = false;
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
this.registerTableOption("ajaxURL", false); //url for ajax loading
|
|
21
21
|
this.registerTableOption("ajaxURLGenerator", false);
|
|
22
22
|
this.registerTableOption("ajaxParams", {}); //params for ajax loading
|
|
23
23
|
this.registerTableOption("ajaxConfig", "get"); //ajax request type
|
|
24
24
|
this.registerTableOption("ajaxContentType", "form"); //ajax request type
|
|
25
25
|
this.registerTableOption("ajaxRequestFunc", false); //promise function
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
this.registerTableOption("ajaxRequesting", function(){});
|
|
28
28
|
this.registerTableOption("ajaxResponse", false);
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
this.contentTypeFormatters = Ajax.contentTypeFormatters;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
//initialize setup options
|
|
34
34
|
initialize(){
|
|
35
35
|
this.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise;
|
|
36
36
|
this.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator;
|
|
37
|
-
|
|
38
|
-
if(this.table.options.ajaxParams){
|
|
39
|
-
this.setParams(this.table.options.ajaxParams);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if(this.table.options.ajaxConfig){
|
|
43
|
-
this.setConfig(this.table.options.ajaxConfig);
|
|
44
|
-
}
|
|
45
|
-
|
|
37
|
+
|
|
46
38
|
if(this.table.options.ajaxURL){
|
|
47
39
|
this.setUrl(this.table.options.ajaxURL);
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this));
|
|
51
42
|
|
|
43
|
+
this.setDefaultConfig(this.table.options.ajaxConfig);
|
|
44
|
+
|
|
45
|
+
this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this));
|
|
46
|
+
|
|
52
47
|
this.subscribe("data-loading", this.requestDataCheck.bind(this));
|
|
48
|
+
this.subscribe("data-params", this.requestParams.bind(this));
|
|
53
49
|
this.subscribe("data-load", this.requestData.bind(this));
|
|
54
50
|
}
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
|
|
52
|
+
requestParams(data, config, silent, params){
|
|
53
|
+
var ajaxParams = this.table.options.ajaxParams;
|
|
54
|
+
|
|
55
|
+
if(ajaxParams){
|
|
56
|
+
if(typeof ajaxParams === "function"){
|
|
57
|
+
ajaxParams = ajaxParams.call(this.table);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
params = Object.assign(params, ajaxParams);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return params;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
requestDataCheck(data, params, config, silent){
|
|
58
67
|
return !!((!data && this.url) || typeof data === "string");
|
|
59
68
|
}
|
|
60
|
-
|
|
61
|
-
requestData(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if(params){
|
|
68
|
-
this.setParams(params, true);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if(config){
|
|
72
|
-
this.setConfig(config);
|
|
69
|
+
|
|
70
|
+
requestData(url, params, config, silent, previousData){
|
|
71
|
+
var ajaxConfig;
|
|
72
|
+
|
|
73
|
+
if(!previousData && this.requestDataCheck(url)){
|
|
74
|
+
if(url){
|
|
75
|
+
this.setUrl(url);
|
|
73
76
|
}
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
|
|
78
|
+
ajaxConfig = this.generateConfig(config);
|
|
79
|
+
|
|
80
|
+
return this.sendRequest(this.url, params, ajaxConfig);
|
|
76
81
|
}else{
|
|
77
82
|
return previousData;
|
|
78
83
|
}
|
|
79
84
|
}
|
|
85
|
+
|
|
86
|
+
setDefaultConfig(config = {}){
|
|
87
|
+
this.config = Object.assign({}, Ajax.defaultConfig);
|
|
80
88
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if(update){
|
|
84
|
-
this.params = this.params || {};
|
|
85
|
-
|
|
86
|
-
for(let key in params){
|
|
87
|
-
this.params[key] = params[key];
|
|
88
|
-
}
|
|
89
|
+
if(typeof config == "string"){
|
|
90
|
+
this.config.method = config;
|
|
89
91
|
}else{
|
|
90
|
-
this.
|
|
92
|
+
Object.assign(this.config, config);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
|
-
|
|
94
|
-
getParams(){
|
|
95
|
-
return this.params || {};
|
|
96
|
-
}
|
|
97
|
-
|
|
95
|
+
|
|
98
96
|
//load config object
|
|
99
|
-
|
|
100
|
-
this.
|
|
101
|
-
|
|
97
|
+
generateConfig(config = {}){
|
|
98
|
+
var ajaxConfig = Object.assign({}, this.config)
|
|
99
|
+
|
|
102
100
|
if(typeof config == "string"){
|
|
103
|
-
|
|
101
|
+
ajaxConfig.method = config;
|
|
104
102
|
}else{
|
|
105
|
-
|
|
106
|
-
this.config[key] = config[key];
|
|
107
|
-
}
|
|
103
|
+
Object.assign(ajaxConfig, config);
|
|
108
104
|
}
|
|
105
|
+
|
|
106
|
+
return ajaxConfig;
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
//create config object from default
|
|
112
|
-
_loadDefaultConfig(force){
|
|
113
|
-
if(!this.config || force){
|
|
114
|
-
|
|
115
|
-
this.config = {};
|
|
116
|
-
|
|
117
|
-
//load base config from defaults
|
|
118
|
-
for(let key in Ajax.defaultConfig){
|
|
119
|
-
this.config[key] = Ajax.defaultConfig[key];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
108
|
+
|
|
124
109
|
//set request url
|
|
125
110
|
setUrl(url){
|
|
126
111
|
this.url = url;
|
|
127
112
|
}
|
|
128
|
-
|
|
113
|
+
|
|
129
114
|
//get request url
|
|
130
115
|
getUrl(){
|
|
131
116
|
return this.url;
|
|
132
117
|
}
|
|
133
|
-
|
|
118
|
+
|
|
134
119
|
//send ajax request
|
|
135
|
-
sendRequest(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this._loadDefaultConfig();
|
|
140
|
-
|
|
141
|
-
if(this.table.options.ajaxRequesting.call(this.table, this.url, this.params) !== false){
|
|
142
|
-
return this.loaderPromise(url, this.config, this.params)
|
|
120
|
+
sendRequest(url, params, config){
|
|
121
|
+
if(this.table.options.ajaxRequesting.call(this.table, url, params) !== false){
|
|
122
|
+
return this.loaderPromise(url, config, params)
|
|
143
123
|
.then((data)=>{
|
|
144
124
|
if(this.table.options.ajaxResponse){
|
|
145
|
-
data = this.table.options.ajaxResponse.call(this.table,
|
|
125
|
+
data = this.table.options.ajaxResponse.call(this.table, url, params, data);
|
|
146
126
|
}
|
|
147
|
-
|
|
127
|
+
|
|
148
128
|
return data;
|
|
149
129
|
});
|
|
150
130
|
}else{
|
|
@@ -51,8 +51,9 @@ class ColumnCalcs extends Module{
|
|
|
51
51
|
this.subscribe("row-added", this.rowsUpdated.bind(this));
|
|
52
52
|
this.subscribe("column-moved", this.recalcActiveRows.bind(this));
|
|
53
53
|
this.subscribe("column-add", this.recalcActiveRows.bind(this));
|
|
54
|
-
this.subscribe("data-
|
|
54
|
+
this.subscribe("data-refreshed", this.recalcActiveRows.bind(this));
|
|
55
55
|
this.subscribe("table-redraw", this.tableRedraw.bind(this));
|
|
56
|
+
this.subscribe("rows-visible", this.visibleRows.bind(this));
|
|
56
57
|
|
|
57
58
|
this.registerTableFunction("getCalcResults", this.getResults.bind(this));
|
|
58
59
|
this.registerTableFunction("recalc", this.userRecalc.bind(this));
|
|
@@ -78,6 +79,18 @@ class ColumnCalcs extends Module{
|
|
|
78
79
|
///////// Internal Logic //////////
|
|
79
80
|
///////////////////////////////////
|
|
80
81
|
|
|
82
|
+
visibleRows(viewable, rows){
|
|
83
|
+
if(this.topRow){
|
|
84
|
+
rows.unshift(this.topRow);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if(this.botRow){
|
|
88
|
+
rows.push(this.botRow);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return rows;
|
|
92
|
+
}
|
|
93
|
+
|
|
81
94
|
rowsUpdated(row){
|
|
82
95
|
if(this.table.options.groupBy){
|
|
83
96
|
this.recalcRowGroup(this);
|
|
@@ -354,7 +367,7 @@ class ColumnCalcs extends Module{
|
|
|
354
367
|
|
|
355
368
|
row.getComponent = () => {
|
|
356
369
|
if(!row.component){
|
|
357
|
-
row.component = new CalcComponent(
|
|
370
|
+
row.component = new CalcComponent(row);
|
|
358
371
|
}
|
|
359
372
|
|
|
360
373
|
return row.component;
|
|
@@ -38,17 +38,16 @@ class DataTree extends Module{
|
|
|
38
38
|
this.registerComponentFunction("row", "getTreeParent", this.getTreeParent.bind(this));
|
|
39
39
|
this.registerComponentFunction("row", "getTreeChildren", this.getRowChildren.bind(this));
|
|
40
40
|
this.registerComponentFunction("row", "addTreeChild", this.addTreeChildRow.bind(this));
|
|
41
|
+
this.registerComponentFunction("row", "isTreeExpanded", this.isRowExpanded.bind(this));
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
initialize(){
|
|
44
45
|
if(this.table.options.dataTree){
|
|
45
46
|
var dummyEl = null,
|
|
46
|
-
firstCol = this.table.columnManager.getFirstVisibileColumn(),
|
|
47
47
|
options = this.table.options;
|
|
48
48
|
|
|
49
49
|
this.field = options.dataTreeChildField;
|
|
50
50
|
this.indent = options.dataTreeChildIndent;
|
|
51
|
-
this.elementField = options.dataTreeElementColumn || (firstCol ? firstCol.field : false);
|
|
52
51
|
|
|
53
52
|
if(options.dataTreeBranchElement){
|
|
54
53
|
|
|
@@ -117,15 +116,23 @@ class DataTree extends Module{
|
|
|
117
116
|
|
|
118
117
|
this.subscribe("row-init", this.initializeRow.bind(this));
|
|
119
118
|
this.subscribe("row-layout-after", this.layoutRow.bind(this));
|
|
120
|
-
this.subscribe("row-relayout", this.layoutRow.bind(this));
|
|
121
119
|
this.subscribe("row-deleted", this.rowDelete.bind(this),0);
|
|
122
120
|
this.subscribe("row-data-changed", this.rowDataChanged.bind(this), 10);
|
|
121
|
+
this.subscribe("cell-value-updated", this.cellValueChanged.bind(this));
|
|
122
|
+
this.subscribe("edit-cancelled", this.cellValueChanged.bind(this));
|
|
123
123
|
this.subscribe("column-moving-rows", this.columnMoving.bind(this));
|
|
124
|
+
this.subscribe("table-built", this.initializeElementField.bind(this));
|
|
124
125
|
|
|
125
126
|
this.registerDisplayHandler(this.getRows.bind(this), 30);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
initializeElementField(){
|
|
131
|
+
var firstCol = this.table.columnManager.getFirstVisibleColumn();
|
|
132
|
+
|
|
133
|
+
this.elementField = this.table.options.dataTreeElementColumn || (firstCol ? firstCol.field : false);
|
|
134
|
+
}
|
|
135
|
+
|
|
129
136
|
getRowChildren(row){
|
|
130
137
|
return this.getTreeChildren(row, true);
|
|
131
138
|
}
|
|
@@ -151,6 +158,14 @@ class DataTree extends Module{
|
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
160
|
|
|
161
|
+
cellValueChanged(cell){
|
|
162
|
+
var field = cell.column.getField();
|
|
163
|
+
|
|
164
|
+
if(field === this.elementField){
|
|
165
|
+
this.layoutRow(cell.row);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
154
169
|
initializeRow(row){
|
|
155
170
|
var childArray = row.getData()[this.field];
|
|
156
171
|
var isArray = Array.isArray(childArray);
|
|
@@ -396,6 +411,10 @@ class DataTree extends Module{
|
|
|
396
411
|
}
|
|
397
412
|
}
|
|
398
413
|
|
|
414
|
+
isRowExpanded(row){
|
|
415
|
+
return row.modules.dataTree.open;
|
|
416
|
+
}
|
|
417
|
+
|
|
399
418
|
getTreeParent(row){
|
|
400
419
|
return row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() : false;
|
|
401
420
|
}
|
|
@@ -555,17 +574,12 @@ class DataTree extends Module{
|
|
|
555
574
|
return output;
|
|
556
575
|
}
|
|
557
576
|
|
|
558
|
-
checkForRestyle(cell){
|
|
559
|
-
if(!cell.row.cells.indexOf(cell)){
|
|
560
|
-
this.layoutRow(cell.row);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
577
|
getChildField(){
|
|
565
578
|
return this.field;
|
|
566
579
|
}
|
|
567
580
|
|
|
568
581
|
redrawNeeded(data){
|
|
582
|
+
console.log("needed?", data)
|
|
569
583
|
return (this.field ? typeof data[this.field] !== "undefined" : false) || (this.elementField ? typeof data[this.elementField] !== "undefined" : false);
|
|
570
584
|
}
|
|
571
585
|
}
|
|
@@ -19,7 +19,7 @@ export default function(list, options, setFileContents){
|
|
|
19
19
|
case "row":
|
|
20
20
|
row.columns.forEach((col) => {
|
|
21
21
|
if(col){
|
|
22
|
-
item[col.component.getField()] = col.value;
|
|
22
|
+
item[col.component.getTitleDownload() || col.component.getField()] = col.value;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
|