jsl-ui 9.28.2 → 9.28.4
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/lib/components/IntervalComponent.js +32 -35
- package/lib/components/auto-suggest/AutoSuggestComponent.js +19 -21
- package/lib/components/button/ButtonComponent.js +13 -30
- package/lib/components/checkbox/CheckBoxComponent.js +22 -39
- package/lib/components/date/DateComponent.js +29 -46
- package/lib/components/date-range/DateRangeComponent.js +48 -63
- package/lib/components/date-time/DateTimeComponent.js +17 -31
- package/lib/components/dialog/DialogComponent.js +75 -134
- package/lib/components/drop-down/DropDownComponent.js +23 -37
- package/lib/components/expander/ExpanderComponent.js +20 -23
- package/lib/components/form-field/FormComponent.js +9 -12
- package/lib/components/form-field/FormFieldComponent.js +28 -30
- package/lib/components/grid/GridComponent.js +46 -52
- package/lib/components/input/InputComponent.js +26 -47
- package/lib/components/loading/LoadingComponent.js +7 -9
- package/lib/components/navigation/NavigationComponent.js +20 -43
- package/lib/components/notification/Notification.js +18 -22
- package/lib/components/number/NumberComponent.js +28 -46
- package/lib/components/overlay/OverlayComponent.js +45 -60
- package/lib/components/progress/ProgressComponent.js +15 -17
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +9 -20
- package/lib/components/select/SelectComponent.js +105 -122
- package/lib/components/select/SelectDDAreaComponent.js +108 -122
- package/lib/components/slider/nouislider.js +1 -1
- package/lib/components/stack-panel/SplitterComponent.js +27 -29
- package/lib/components/stack-panel/StackPanelComponent.js +17 -31
- package/lib/components/tabs/TabsComponent.js +53 -66
- package/lib/components/time/TimeComponent.js +32 -43
- package/lib/components/tree-view/TreeViewComponent.js +13 -16
- package/lib/components/virtual-render/VirtualRenderComponent.js +30 -44
- package/lib/core/culture.js +2 -2
- package/lib/core/date.js +68 -72
- package/lib/core/helper.js +30 -34
- package/lib/core/jq.js +54 -63
- package/lib/core/lang.js +24 -28
- package/lib/core/numeric.js +35 -39
- package/lib/grid/filterDialogs/dateRangeFilter.js +98 -148
- package/lib/grid/filterDialogs/excelFilter.js +205 -271
- package/lib/grid/plugins/ext.overlay.js +9 -9
- package/lib/grid/plugins/slick.cellrangedecorator.js +2 -2
- package/lib/grid/plugins/slick.cellrangeselector.js +1 -1
- package/lib/grid/plugins/slick.cellselectionmodel.js +8 -8
- package/lib/grid/plugins/slick.headerbuttons.js +1 -1
- package/lib/grid/plugins/slick.headermenu.js +1 -1
- package/lib/grid/plugins/slick.rowmovemanager.js +2 -2
- package/lib/grid/plugins/slick.rowselectionmodel.js +1 -1
- package/lib/grid/slick.core.js +1 -1
- package/lib/grid/slick.creator.js +144 -144
- package/lib/grid/slick.dataview.js +127 -138
- package/lib/grid/slick.editors.core.js +1 -1
- package/lib/grid/slick.editors.date.js +2 -2
- package/lib/grid/slick.editors.lookup.js +36 -37
- package/lib/grid/slick.editors.nav.js +1 -1
- package/lib/grid/slick.formatters.js +26 -26
- package/lib/grid/slick.grid.js +163 -166
- package/lib/grid/slick.groupitemmetadataprovider.js +4 -4
- package/lib/grid/slick.tree.js +91 -103
- package/lib/index.js.map +1 -1
- package/lib/interaction/eventhandler.js +20 -23
- package/lib/interaction/moveable.js +76 -90
- package/lib/interaction/resizable.js +58 -72
- package/lib/ui/auto.suggest.js +13 -28
- package/lib/ui/date.picker/lib/fns.js +1 -5
- package/lib/ui/dialog.js +28 -43
- package/lib/ui/drop.down.js +4 -4
- package/lib/ui/number.input.js +8 -19
- package/package.json +1 -1
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jQueryReplacement } from "../core/jq";
|
|
13
2
|
import { Slick } from "./slick.core";
|
|
14
|
-
|
|
3
|
+
const $ = jQueryReplacement;
|
|
15
4
|
/***
|
|
16
5
|
* A sample Model implementation.
|
|
17
6
|
* Provides a filtered view of the underlying data.
|
|
@@ -19,35 +8,35 @@ var $ = jQueryReplacement;
|
|
|
19
8
|
* Relies on the data item having an "id" property uniquely identifying it.
|
|
20
9
|
*/
|
|
21
10
|
export function DataView(options) {
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
let self = this;
|
|
12
|
+
let defaults = {
|
|
24
13
|
groupItemMetadataProvider: null,
|
|
25
14
|
inlineFilters: false
|
|
26
15
|
};
|
|
27
16
|
// private
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
let idProperty = "id"; // property holding a unique row id
|
|
18
|
+
let items = []; // data by index
|
|
19
|
+
let rows = []; // data by row
|
|
20
|
+
let idxById = {}; // indexes by id
|
|
21
|
+
let rowsById = null; // rows by id; lazy-calculated
|
|
22
|
+
let filter = null; // filter function
|
|
23
|
+
let updated = null; // updated item ids
|
|
24
|
+
let suspend = false; // suspends the recalculation
|
|
25
|
+
let sortAsc = true;
|
|
37
26
|
// var fastSortField;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
let sortComparer;
|
|
28
|
+
let refreshHints = {};
|
|
29
|
+
let prevRefreshHints = {};
|
|
30
|
+
let filterArgs;
|
|
31
|
+
let filteredItems = [];
|
|
43
32
|
// let compiledFilter;
|
|
44
33
|
// let compiledFilterWithCaching;
|
|
45
|
-
|
|
34
|
+
let filterCache = [];
|
|
46
35
|
// grouping
|
|
47
|
-
|
|
36
|
+
let groupingInfoDefaults = {
|
|
48
37
|
getter: null,
|
|
49
38
|
formatter: null,
|
|
50
|
-
comparer
|
|
39
|
+
comparer(a, b) {
|
|
51
40
|
return (a.value === b.value ? 0 :
|
|
52
41
|
(a.value > b.value ? 1 : -1));
|
|
53
42
|
},
|
|
@@ -60,18 +49,18 @@ export function DataView(options) {
|
|
|
60
49
|
displayTotalsRow: true,
|
|
61
50
|
lazyTotalsCalculation: false
|
|
62
51
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
let groupingInfos = [];
|
|
53
|
+
let groups = [];
|
|
54
|
+
let toggledGroupsByLevel = [];
|
|
55
|
+
let groupingDelimiter = ":|:";
|
|
56
|
+
let pagesize = 0;
|
|
57
|
+
let pagenum = 0;
|
|
58
|
+
let totalRows = 0;
|
|
70
59
|
// events
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
let onRowCountChanged = new Slick.Event();
|
|
61
|
+
let onRowsChanged = new Slick.Event();
|
|
62
|
+
let onRowsOrCountChanged = new Slick.Event();
|
|
63
|
+
let onPagingInfoChanged = new Slick.Event();
|
|
75
64
|
options = $.deepExtend({}, defaults, options);
|
|
76
65
|
function beginUpdate() {
|
|
77
66
|
suspend = true;
|
|
@@ -88,8 +77,8 @@ export function DataView(options) {
|
|
|
88
77
|
}
|
|
89
78
|
function updateIdxById(startingIndex) {
|
|
90
79
|
startingIndex = startingIndex || 0;
|
|
91
|
-
|
|
92
|
-
for (
|
|
80
|
+
let id;
|
|
81
|
+
for (let i = startingIndex, l = items.length; i < l; i++) {
|
|
93
82
|
id = items[i][idProperty];
|
|
94
83
|
if (id === undefined) {
|
|
95
84
|
// throw new Error("Each data element must implement a unique 'id' property");
|
|
@@ -99,8 +88,8 @@ export function DataView(options) {
|
|
|
99
88
|
}
|
|
100
89
|
}
|
|
101
90
|
function ensureIdUniqueness() {
|
|
102
|
-
|
|
103
|
-
for (
|
|
91
|
+
let id;
|
|
92
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
104
93
|
id = items[i][idProperty];
|
|
105
94
|
if (id === undefined) {
|
|
106
95
|
throw new Error("Id (" + idProperty + ") of element at index " + i + " was undefined");
|
|
@@ -135,8 +124,8 @@ export function DataView(options) {
|
|
|
135
124
|
refresh();
|
|
136
125
|
}
|
|
137
126
|
function getPagingInfo() {
|
|
138
|
-
|
|
139
|
-
return { pageSize: pagesize, pageNum: pagenum, totalRows
|
|
127
|
+
let totalPages = pagesize ? Math.max(1, Math.ceil(totalRows / pagesize)) : 1;
|
|
128
|
+
return { pageSize: pagesize, pageNum: pagenum, totalRows, totalPages, dataView: self };
|
|
140
129
|
}
|
|
141
130
|
function sort(comparer, ascending) {
|
|
142
131
|
sortAsc = ascending;
|
|
@@ -183,12 +172,12 @@ export function DataView(options) {
|
|
|
183
172
|
toggledGroupsByLevel = [];
|
|
184
173
|
groupingInfo = groupingInfo || [];
|
|
185
174
|
groupingInfos = (groupingInfo instanceof Array) ? groupingInfo : [groupingInfo];
|
|
186
|
-
for (
|
|
187
|
-
|
|
175
|
+
for (let i = 0; i < groupingInfos.length; i++) {
|
|
176
|
+
const gi = groupingInfos[i] = $.deepExtend({}, groupingInfoDefaults, groupingInfos[i]);
|
|
188
177
|
gi.getterIsAFn = typeof gi.getter === "function";
|
|
189
178
|
// pre-compile accumulator loops
|
|
190
179
|
gi.compiledAccumulators = [];
|
|
191
|
-
|
|
180
|
+
let idx = gi.aggregators.length;
|
|
192
181
|
while (idx--) {
|
|
193
182
|
gi.compiledAccumulators[idx] = compileAccumulatorLoop(gi.aggregators[idx]);
|
|
194
183
|
}
|
|
@@ -233,7 +222,7 @@ export function DataView(options) {
|
|
|
233
222
|
function ensureRowsByIdCache() {
|
|
234
223
|
if (!rowsById) {
|
|
235
224
|
rowsById = {};
|
|
236
|
-
for (
|
|
225
|
+
for (let i = 0, l = rows.length; i < l; i++) {
|
|
237
226
|
rowsById[rows[i][idProperty]] = i;
|
|
238
227
|
}
|
|
239
228
|
}
|
|
@@ -250,10 +239,10 @@ export function DataView(options) {
|
|
|
250
239
|
return items[idxById[id]];
|
|
251
240
|
}
|
|
252
241
|
function mapItemsToRows(itemArray) {
|
|
253
|
-
|
|
242
|
+
let rows = [];
|
|
254
243
|
ensureRowsByIdCache();
|
|
255
|
-
for (
|
|
256
|
-
|
|
244
|
+
for (let i = 0, l = itemArray.length; i < l; i++) {
|
|
245
|
+
let row = rowsById[itemArray[i][idProperty]];
|
|
257
246
|
if (row != null) {
|
|
258
247
|
rows[rows.length] = row;
|
|
259
248
|
}
|
|
@@ -261,10 +250,10 @@ export function DataView(options) {
|
|
|
261
250
|
return rows;
|
|
262
251
|
}
|
|
263
252
|
function mapIdsToRows(idArray) {
|
|
264
|
-
|
|
253
|
+
let rows = [];
|
|
265
254
|
ensureRowsByIdCache();
|
|
266
|
-
for (
|
|
267
|
-
|
|
255
|
+
for (let i = 0, l = idArray.length; i < l; i++) {
|
|
256
|
+
let row = rowsById[idArray[i]];
|
|
268
257
|
if (row != null) {
|
|
269
258
|
rows[rows.length] = row;
|
|
270
259
|
}
|
|
@@ -272,8 +261,8 @@ export function DataView(options) {
|
|
|
272
261
|
return rows;
|
|
273
262
|
}
|
|
274
263
|
function mapRowsToIds(rowArray) {
|
|
275
|
-
|
|
276
|
-
for (
|
|
264
|
+
let ids = [];
|
|
265
|
+
for (let i = 0, l = rowArray.length; i < l; i++) {
|
|
277
266
|
if (rowArray[i] < rows.length) {
|
|
278
267
|
ids[ids.length] = rows[rowArray[i]][idProperty];
|
|
279
268
|
}
|
|
@@ -289,7 +278,7 @@ export function DataView(options) {
|
|
|
289
278
|
// then we'll have to update the index as well, and possibly the `updated` cache too.
|
|
290
279
|
if (id !== item[idProperty]) {
|
|
291
280
|
// make sure the new id is unique:
|
|
292
|
-
|
|
281
|
+
let newId = item[idProperty];
|
|
293
282
|
if (newId == null) {
|
|
294
283
|
throw new Error("Cannot update item to associate with a null id");
|
|
295
284
|
}
|
|
@@ -324,7 +313,7 @@ export function DataView(options) {
|
|
|
324
313
|
refresh();
|
|
325
314
|
}
|
|
326
315
|
function deleteItem(id) {
|
|
327
|
-
|
|
316
|
+
let idx = idxById[id];
|
|
328
317
|
if (idx === undefined) {
|
|
329
318
|
throw new Error("Invalid id");
|
|
330
319
|
}
|
|
@@ -346,7 +335,7 @@ export function DataView(options) {
|
|
|
346
335
|
if (!sortComparer) {
|
|
347
336
|
throw new Error("sortedUpdateItem() requires a sort comparer, use sort()");
|
|
348
337
|
}
|
|
349
|
-
|
|
338
|
+
let oldItem = getItemById(id);
|
|
350
339
|
if (sortComparer(oldItem, item) !== 0) {
|
|
351
340
|
// item affects sorting -> must use sorted add
|
|
352
341
|
deleteItem(id);
|
|
@@ -357,9 +346,9 @@ export function DataView(options) {
|
|
|
357
346
|
}
|
|
358
347
|
}
|
|
359
348
|
function sortedIndex(searchItem) {
|
|
360
|
-
|
|
349
|
+
let low = 0, high = items.length;
|
|
361
350
|
while (low < high) {
|
|
362
|
-
|
|
351
|
+
let mid = low + high >>> 1;
|
|
363
352
|
if (sortComparer(items[mid], searchItem) === -1) {
|
|
364
353
|
low = mid + 1;
|
|
365
354
|
}
|
|
@@ -373,10 +362,10 @@ export function DataView(options) {
|
|
|
373
362
|
return rows.length;
|
|
374
363
|
}
|
|
375
364
|
function getItem(i) {
|
|
376
|
-
|
|
365
|
+
let item = rows[i];
|
|
377
366
|
// if this is a group row, make sure totals are calculated and update the title
|
|
378
367
|
if (item && item.__group && item.totals && !item.totals.initialized) {
|
|
379
|
-
|
|
368
|
+
let gi = groupingInfos[item.level];
|
|
380
369
|
if (!gi.displayTotalsRow) {
|
|
381
370
|
calculateTotals(item.totals);
|
|
382
371
|
item.title = gi.formatter ? gi.formatter(item) : item.value;
|
|
@@ -388,7 +377,7 @@ export function DataView(options) {
|
|
|
388
377
|
return item;
|
|
389
378
|
}
|
|
390
379
|
function getItemMetadata(i) {
|
|
391
|
-
|
|
380
|
+
let item = rows[i];
|
|
392
381
|
if (item === undefined) {
|
|
393
382
|
return null;
|
|
394
383
|
}
|
|
@@ -402,7 +391,7 @@ export function DataView(options) {
|
|
|
402
391
|
}
|
|
403
392
|
if (item.__height) {
|
|
404
393
|
if (item.getItemMetadata != null) {
|
|
405
|
-
return
|
|
394
|
+
return { height: item.__height, ...(item.getItemMetadata || {}) };
|
|
406
395
|
}
|
|
407
396
|
return { height: item.__height };
|
|
408
397
|
}
|
|
@@ -410,7 +399,7 @@ export function DataView(options) {
|
|
|
410
399
|
}
|
|
411
400
|
function expandCollapseAllGroups(level, collapse) {
|
|
412
401
|
if (level == null) {
|
|
413
|
-
for (
|
|
402
|
+
for (let i = 0; i < groupingInfos.length; i++) {
|
|
414
403
|
toggledGroupsByLevel[i] = {};
|
|
415
404
|
groupingInfos[i].collapsed = collapse;
|
|
416
405
|
}
|
|
@@ -444,8 +433,8 @@ export function DataView(options) {
|
|
|
444
433
|
* the 'high' group.
|
|
445
434
|
*/
|
|
446
435
|
function collapseGroup(varArgs) {
|
|
447
|
-
|
|
448
|
-
|
|
436
|
+
let args = Array.prototype.slice.call(arguments);
|
|
437
|
+
let arg0 = args[0];
|
|
449
438
|
if (args.length == 1 && arg0.indexOf(groupingDelimiter) != -1) {
|
|
450
439
|
expandCollapseGroup(arg0.split(groupingDelimiter).length - 1, arg0, true);
|
|
451
440
|
}
|
|
@@ -460,8 +449,8 @@ export function DataView(options) {
|
|
|
460
449
|
* the 'high' group.
|
|
461
450
|
*/
|
|
462
451
|
function expandGroup(varArgs) {
|
|
463
|
-
|
|
464
|
-
|
|
452
|
+
let args = Array.prototype.slice.call(arguments);
|
|
453
|
+
let arg0 = args[0];
|
|
465
454
|
if (args.length == 1 && arg0.indexOf(groupingDelimiter) != -1) {
|
|
466
455
|
expandCollapseGroup(arg0.split(groupingDelimiter).length - 1, arg0, false);
|
|
467
456
|
}
|
|
@@ -473,14 +462,14 @@ export function DataView(options) {
|
|
|
473
462
|
return groups;
|
|
474
463
|
}
|
|
475
464
|
function extractGroups(rows, parentGroup) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
for (
|
|
465
|
+
let group;
|
|
466
|
+
let val;
|
|
467
|
+
let groups = [];
|
|
468
|
+
let groupsByVal = {};
|
|
469
|
+
let r;
|
|
470
|
+
let level = parentGroup ? parentGroup.level + 1 : 0;
|
|
471
|
+
let gi = groupingInfos[level];
|
|
472
|
+
for (let i = 0, l = gi.predefinedValues.length; i < l; i++) {
|
|
484
473
|
val = gi.predefinedValues[i];
|
|
485
474
|
group = groupsByVal[val];
|
|
486
475
|
if (!group) {
|
|
@@ -492,7 +481,7 @@ export function DataView(options) {
|
|
|
492
481
|
groupsByVal[val] = group;
|
|
493
482
|
}
|
|
494
483
|
}
|
|
495
|
-
for (
|
|
484
|
+
for (let i = 0, l = rows.length; i < l; i++) {
|
|
496
485
|
r = rows[i];
|
|
497
486
|
val = gi.getterIsAFn ? gi.getter(r) : r[gi.getter];
|
|
498
487
|
group = groupsByVal[val];
|
|
@@ -507,7 +496,7 @@ export function DataView(options) {
|
|
|
507
496
|
group.rows[group.count++] = r;
|
|
508
497
|
}
|
|
509
498
|
if (level < groupingInfos.length - 1) {
|
|
510
|
-
for (
|
|
499
|
+
for (let i = 0; i < groups.length; i++) {
|
|
511
500
|
group = groups[i];
|
|
512
501
|
group.groups = extractGroups(group.rows, group);
|
|
513
502
|
}
|
|
@@ -516,13 +505,13 @@ export function DataView(options) {
|
|
|
516
505
|
return groups;
|
|
517
506
|
}
|
|
518
507
|
function calculateTotals(totals) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
508
|
+
let group = totals.group;
|
|
509
|
+
let gi = groupingInfos[group.level];
|
|
510
|
+
let isLeafLevel = (group.level == groupingInfos.length);
|
|
511
|
+
let agg, idx = gi.aggregators.length;
|
|
523
512
|
if (!isLeafLevel && gi.aggregateChildGroups) {
|
|
524
513
|
// make sure all the subgroups are calculated
|
|
525
|
-
|
|
514
|
+
let i = group.groups.length;
|
|
526
515
|
while (i--) {
|
|
527
516
|
if (!group.groups[i].totals.initialized) {
|
|
528
517
|
calculateTotals(group.groups[i].totals);
|
|
@@ -543,8 +532,8 @@ export function DataView(options) {
|
|
|
543
532
|
totals.initialized = true;
|
|
544
533
|
}
|
|
545
534
|
function addGroupTotals(group) {
|
|
546
|
-
|
|
547
|
-
|
|
535
|
+
let gi = groupingInfos[group.level];
|
|
536
|
+
let totals = new Slick.GroupTotals();
|
|
548
537
|
totals.group = group;
|
|
549
538
|
group.totals = totals;
|
|
550
539
|
if (!gi.lazyTotalsCalculation) {
|
|
@@ -553,10 +542,10 @@ export function DataView(options) {
|
|
|
553
542
|
}
|
|
554
543
|
function addTotals(groups, level) {
|
|
555
544
|
level = level || 0;
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
545
|
+
let gi = groupingInfos[level];
|
|
546
|
+
let groupCollapsed = gi.collapsed;
|
|
547
|
+
let toggledGroups = toggledGroupsByLevel[level];
|
|
548
|
+
let idx = groups.length, g;
|
|
560
549
|
while (idx--) {
|
|
561
550
|
g = groups[idx];
|
|
562
551
|
if (g.collapsed && !gi.aggregateCollapsed) {
|
|
@@ -575,14 +564,14 @@ export function DataView(options) {
|
|
|
575
564
|
}
|
|
576
565
|
function flattenGroupedRows(groups, level) {
|
|
577
566
|
level = level || 0;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
for (
|
|
567
|
+
let gi = groupingInfos[level];
|
|
568
|
+
let groupedRows = [], rows, gl = 0, g;
|
|
569
|
+
for (let i = 0, l = groups.length; i < l; i++) {
|
|
581
570
|
g = groups[i];
|
|
582
571
|
groupedRows[gl++] = g;
|
|
583
572
|
if (!g.collapsed) {
|
|
584
573
|
rows = g.groups ? flattenGroupedRows(g.groups, level + 1) : g.rows;
|
|
585
|
-
for (
|
|
574
|
+
for (let j = 0, jj = rows.length; j < jj; j++) {
|
|
586
575
|
groupedRows[gl++] = rows[j];
|
|
587
576
|
}
|
|
588
577
|
}
|
|
@@ -593,16 +582,16 @@ export function DataView(options) {
|
|
|
593
582
|
return groupedRows;
|
|
594
583
|
}
|
|
595
584
|
function getFunctionInfo(fn) {
|
|
596
|
-
|
|
597
|
-
|
|
585
|
+
let fnRegex = /^function[^(]*\(([^)]*)\)\s*{([\s\S]*)}$/;
|
|
586
|
+
let matches = fn.toString().match(fnRegex);
|
|
598
587
|
return {
|
|
599
588
|
params: matches[1].split(","),
|
|
600
589
|
body: matches[2]
|
|
601
590
|
};
|
|
602
591
|
}
|
|
603
592
|
function compileAccumulatorLoop(aggregator) {
|
|
604
|
-
|
|
605
|
-
|
|
593
|
+
let accumulatorInfo = getFunctionInfo(aggregator.accumulate);
|
|
594
|
+
let fn = new Function("_items", "for (var " + accumulatorInfo.params[0] + ", _i=0, _il=_items.length; _i<_il; _i++) {" +
|
|
606
595
|
accumulatorInfo.params[0] + " = _items[_i]; " +
|
|
607
596
|
accumulatorInfo.body +
|
|
608
597
|
"}");
|
|
@@ -680,8 +669,8 @@ export function DataView(options) {
|
|
|
680
669
|
// return fn;
|
|
681
670
|
// }
|
|
682
671
|
function uncompiledFilter(items, args) {
|
|
683
|
-
|
|
684
|
-
for (
|
|
672
|
+
let retval = [], idx = 0;
|
|
673
|
+
for (let i = 0, ii = items.length; i < ii; i++) {
|
|
685
674
|
if (filter(items[i], args)) {
|
|
686
675
|
retval[idx++] = items[i];
|
|
687
676
|
}
|
|
@@ -689,8 +678,8 @@ export function DataView(options) {
|
|
|
689
678
|
return retval;
|
|
690
679
|
}
|
|
691
680
|
function uncompiledFilterWithCaching(items, args, cache) {
|
|
692
|
-
|
|
693
|
-
for (
|
|
681
|
+
let retval = [], idx = 0, item;
|
|
682
|
+
for (let i = 0, ii = items.length; i < ii; i++) {
|
|
694
683
|
item = items[i];
|
|
695
684
|
if (cache[i]) {
|
|
696
685
|
retval[idx++] = item;
|
|
@@ -704,8 +693,8 @@ export function DataView(options) {
|
|
|
704
693
|
}
|
|
705
694
|
function getFilteredAndPagedItems(items) {
|
|
706
695
|
if (filter) {
|
|
707
|
-
|
|
708
|
-
|
|
696
|
+
let batchFilter = uncompiledFilter; // options.inlineFilters ? compiledFilter : uncompiledFilter;
|
|
697
|
+
let batchFilterWithCaching = uncompiledFilterWithCaching; // options.inlineFilters ? compiledFilterWithCaching : uncompiledFilterWithCaching;
|
|
709
698
|
if (refreshHints.isFilterNarrowing) {
|
|
710
699
|
filteredItems = batchFilter(filteredItems, filterArgs);
|
|
711
700
|
}
|
|
@@ -723,7 +712,7 @@ export function DataView(options) {
|
|
|
723
712
|
filteredItems = pagesize ? items : items.concat();
|
|
724
713
|
}
|
|
725
714
|
// get the current page
|
|
726
|
-
|
|
715
|
+
let paged;
|
|
727
716
|
if (pagesize) {
|
|
728
717
|
if (filteredItems.length <= pagenum * pagesize) {
|
|
729
718
|
if (filteredItems.length === 0) {
|
|
@@ -741,15 +730,15 @@ export function DataView(options) {
|
|
|
741
730
|
return { totalRows: filteredItems.length, rows: paged };
|
|
742
731
|
}
|
|
743
732
|
function getRowDiffs(rows, newRows) {
|
|
744
|
-
|
|
745
|
-
|
|
733
|
+
let item, r, eitherIsNonData, diff = [];
|
|
734
|
+
let from = 0, to = newRows.length;
|
|
746
735
|
if (refreshHints && refreshHints.ignoreDiffsBefore) {
|
|
747
736
|
from = Math.max(0, Math.min(newRows.length, refreshHints.ignoreDiffsBefore));
|
|
748
737
|
}
|
|
749
738
|
if (refreshHints && refreshHints.ignoreDiffsAfter) {
|
|
750
739
|
to = Math.min(newRows.length, Math.max(0, refreshHints.ignoreDiffsAfter));
|
|
751
740
|
}
|
|
752
|
-
for (
|
|
741
|
+
for (let i = from, rl = rows.length; i < to; i++) {
|
|
753
742
|
if (i >= rl) {
|
|
754
743
|
diff[diff.length] = i;
|
|
755
744
|
}
|
|
@@ -778,9 +767,9 @@ export function DataView(options) {
|
|
|
778
767
|
refreshHints.isFilterExpanding != prevRefreshHints.isFilterExpanding) {
|
|
779
768
|
filterCache = [];
|
|
780
769
|
}
|
|
781
|
-
|
|
770
|
+
let filteredItems = getFilteredAndPagedItems(_items);
|
|
782
771
|
totalRows = filteredItems.totalRows;
|
|
783
|
-
|
|
772
|
+
let newRows = filteredItems.rows;
|
|
784
773
|
groups = [];
|
|
785
774
|
if (groupingInfos.length) {
|
|
786
775
|
groups = extractGroups(newRows);
|
|
@@ -789,7 +778,7 @@ export function DataView(options) {
|
|
|
789
778
|
newRows = flattenGroupedRows(groups);
|
|
790
779
|
}
|
|
791
780
|
}
|
|
792
|
-
|
|
781
|
+
let diff = getRowDiffs(rows, newRows);
|
|
793
782
|
rows = newRows;
|
|
794
783
|
return diff;
|
|
795
784
|
}
|
|
@@ -797,9 +786,9 @@ export function DataView(options) {
|
|
|
797
786
|
if (suspend) {
|
|
798
787
|
return;
|
|
799
788
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
789
|
+
let countBefore = rows.length;
|
|
790
|
+
let totalRowsBefore = totalRows;
|
|
791
|
+
let diff = recalc(items, filter); // pass as direct refs to avoid closure perf hit
|
|
803
792
|
// if the current page is no longer valid, go to last page and recalc
|
|
804
793
|
// we suffer a performance penalty here, but the main loop (recalc) remains highly optimized
|
|
805
794
|
if (pagesize && totalRows < pagenum * pagesize) {
|
|
@@ -845,10 +834,10 @@ export function DataView(options) {
|
|
|
845
834
|
* @method syncGridSelection
|
|
846
835
|
*/
|
|
847
836
|
function syncGridSelection(grid, preserveHidden, preserveHiddenOnSelectionChange) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
837
|
+
let self = this;
|
|
838
|
+
let inHandler;
|
|
839
|
+
let selectedRowIds = self.mapRowsToIds(grid.getSelectedRows());
|
|
840
|
+
let onSelectedRowIdsChanged = new Slick.Event();
|
|
852
841
|
function setSelectedRowIds(rowIds) {
|
|
853
842
|
if (selectedRowIds.join(",") == rowIds.join(",")) {
|
|
854
843
|
return;
|
|
@@ -863,7 +852,7 @@ export function DataView(options) {
|
|
|
863
852
|
function update() {
|
|
864
853
|
if (selectedRowIds.length > 0) {
|
|
865
854
|
inHandler = true;
|
|
866
|
-
|
|
855
|
+
let selectedRows = self.mapIdsToRows(selectedRowIds);
|
|
867
856
|
if (!preserveHidden) {
|
|
868
857
|
setSelectedRowIds(self.mapRowsToIds(selectedRows));
|
|
869
858
|
}
|
|
@@ -875,14 +864,14 @@ export function DataView(options) {
|
|
|
875
864
|
if (inHandler) {
|
|
876
865
|
return;
|
|
877
866
|
}
|
|
878
|
-
|
|
867
|
+
let newSelectedRowIds = self.mapRowsToIds(grid.getSelectedRows());
|
|
879
868
|
if (!preserveHiddenOnSelectionChange || !grid.getOptions().multiSelect) {
|
|
880
869
|
setSelectedRowIds(newSelectedRowIds);
|
|
881
870
|
}
|
|
882
871
|
else {
|
|
883
872
|
// keep the ones that are hidden
|
|
884
|
-
|
|
885
|
-
for (
|
|
873
|
+
let existing = [];
|
|
874
|
+
for (let i = 0; i < selectedRowIds.length; i++) {
|
|
886
875
|
if (self.getRowById(selectedRowIds[i]) === undefined) {
|
|
887
876
|
existing.push(selectedRowIds[i]);
|
|
888
877
|
}
|
|
@@ -896,15 +885,15 @@ export function DataView(options) {
|
|
|
896
885
|
return onSelectedRowIdsChanged;
|
|
897
886
|
}
|
|
898
887
|
function syncGridCellCssStyles(grid, key) {
|
|
899
|
-
|
|
900
|
-
|
|
888
|
+
let hashById;
|
|
889
|
+
let inHandler;
|
|
901
890
|
// since this method can be called after the cell styles have been set,
|
|
902
891
|
// get the existing ones right away
|
|
903
892
|
storeCellCssStyles(grid.getCellCssStyles(key));
|
|
904
893
|
function storeCellCssStyles(hash) {
|
|
905
894
|
hashById = {};
|
|
906
|
-
for (
|
|
907
|
-
|
|
895
|
+
for (let row in hash) {
|
|
896
|
+
let id = rows[row][idProperty];
|
|
908
897
|
hashById[id] = hash[row];
|
|
909
898
|
}
|
|
910
899
|
}
|
|
@@ -912,9 +901,9 @@ export function DataView(options) {
|
|
|
912
901
|
if (hashById) {
|
|
913
902
|
inHandler = true;
|
|
914
903
|
ensureRowsByIdCache();
|
|
915
|
-
|
|
916
|
-
for (
|
|
917
|
-
|
|
904
|
+
let newHash = {};
|
|
905
|
+
for (let id in hashById) {
|
|
906
|
+
let row = rowsById[id];
|
|
918
907
|
if (row != undefined) {
|
|
919
908
|
newHash[row] = hashById[id];
|
|
920
909
|
}
|
|
@@ -1002,7 +991,7 @@ export function AvgAggregator(field) {
|
|
|
1002
991
|
this.sum_ = 0;
|
|
1003
992
|
};
|
|
1004
993
|
this.accumulate = function (item) {
|
|
1005
|
-
|
|
994
|
+
let val = item[this.field_];
|
|
1006
995
|
this.count_++;
|
|
1007
996
|
if (val != null && val !== "" && !isNaN(val)) {
|
|
1008
997
|
this.nonNullCount_++;
|
|
@@ -1024,7 +1013,7 @@ export function MinAggregator(field) {
|
|
|
1024
1013
|
this.min_ = null;
|
|
1025
1014
|
};
|
|
1026
1015
|
this.accumulate = function (item) {
|
|
1027
|
-
|
|
1016
|
+
let val = item[this.field_];
|
|
1028
1017
|
if (val != null && val !== "" && !isNaN(val)) {
|
|
1029
1018
|
if (this.min_ == null || val < this.min_) {
|
|
1030
1019
|
this.min_ = val;
|
|
@@ -1044,7 +1033,7 @@ export function MaxAggregator(field) {
|
|
|
1044
1033
|
this.max_ = null;
|
|
1045
1034
|
};
|
|
1046
1035
|
this.accumulate = function (item) {
|
|
1047
|
-
|
|
1036
|
+
let val = item[this.field_];
|
|
1048
1037
|
if (val != null && val !== "" && !isNaN(val)) {
|
|
1049
1038
|
if (this.max_ == null || val > this.max_) {
|
|
1050
1039
|
this.max_ = val;
|
|
@@ -1064,7 +1053,7 @@ export function SumAggregator(field) {
|
|
|
1064
1053
|
this.sum_ = null;
|
|
1065
1054
|
};
|
|
1066
1055
|
this.accumulate = function (item) {
|
|
1067
|
-
|
|
1056
|
+
let val = item[this.field_];
|
|
1068
1057
|
if (val != null && val !== "" && !isNaN(val)) {
|
|
1069
1058
|
this.sum_ += parseFloat(val);
|
|
1070
1059
|
}
|
|
@@ -151,7 +151,7 @@ export function NumericEditor(args) {
|
|
|
151
151
|
if (defaultValue === null) {
|
|
152
152
|
defaultValue = undefined;
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
let val_as_str = numeric.format(defaultValue, args.column.format);
|
|
155
155
|
input.value = val_as_str;
|
|
156
156
|
input.select();
|
|
157
157
|
};
|
|
@@ -14,7 +14,7 @@ export function DateEditor(args) {
|
|
|
14
14
|
input.addEventListener("keydown", navOnLR ? handleKeydownLRNav : handleKeydownLRNoNav);
|
|
15
15
|
args.container.appendChild(input);
|
|
16
16
|
datePicker = DatePicker(input, { mode: 'dp-below' });
|
|
17
|
-
datePicker.on("close",
|
|
17
|
+
datePicker.on("close", () => {
|
|
18
18
|
input.focus();
|
|
19
19
|
input.select();
|
|
20
20
|
});
|
|
@@ -38,7 +38,7 @@ export function DateEditor(args) {
|
|
|
38
38
|
};
|
|
39
39
|
this.loadValue = function (item) {
|
|
40
40
|
defaultValue = date.onlyDate(item[args.column.field]);
|
|
41
|
-
|
|
41
|
+
let val_as_str = date.format(defaultValue, args.column.format);
|
|
42
42
|
input.value = val_as_str;
|
|
43
43
|
input.select();
|
|
44
44
|
};
|