cx 25.10.0 → 25.11.1
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/dist/manifest.js +637 -637
- package/dist/ui.js +5 -5
- package/dist/widgets.js +2 -0
- package/package.json +1 -1
- package/src/data/Grouper.spec.js +57 -57
- package/src/ui/Instance.js +1 -4
- package/src/ui/adapter/ArrayAdapter.js +152 -152
- package/src/ui/adapter/GroupAdapter.js +143 -140
- package/src/widgets/grid/Grid.d.ts +445 -442
- package/src/widgets/grid/Grid.js +3431 -3429
|
@@ -1,140 +1,143 @@
|
|
|
1
|
-
import { ArrayAdapter } from "./ArrayAdapter";
|
|
2
|
-
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
3
|
-
import { Grouper } from "../../data/Grouper";
|
|
4
|
-
import { isArray } from "../../util/isArray";
|
|
5
|
-
import { isDefined } from "../../util/isDefined";
|
|
6
|
-
import { getComparer } from "../../data/comparer";
|
|
7
|
-
import { Culture } from "../Culture";
|
|
8
|
-
import { isObject } from "../../util/isObject";
|
|
9
|
-
|
|
10
|
-
export class GroupAdapter extends ArrayAdapter {
|
|
11
|
-
init() {
|
|
12
|
-
super.init();
|
|
13
|
-
|
|
14
|
-
if (this.groupRecordsAlias) this.groupRecordsName = this.groupRecordsAlias;
|
|
15
|
-
|
|
16
|
-
if (this.groupings) this.groupBy(this.groupings);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getRecords(context, instance, records, parentStore) {
|
|
20
|
-
let result = super.getRecords(context, instance, records, parentStore);
|
|
21
|
-
|
|
22
|
-
if (this.groupings) {
|
|
23
|
-
let groupedResults = [];
|
|
24
|
-
this.processLevel([], result, groupedResults, parentStore);
|
|
25
|
-
result = groupedResults;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
processLevel(keys, records, result, parentStore) {
|
|
32
|
-
let level = keys.length;
|
|
33
|
-
let inverseLevel = this.groupings.length - level;
|
|
34
|
-
|
|
35
|
-
if (inverseLevel == 0) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
grouper
|
|
46
|
-
grouper.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
results.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
$
|
|
61
|
-
$
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
key[name]
|
|
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
|
-
|
|
1
|
+
import { ArrayAdapter } from "./ArrayAdapter";
|
|
2
|
+
import { ReadOnlyDataView } from "../../data/ReadOnlyDataView";
|
|
3
|
+
import { Grouper } from "../../data/Grouper";
|
|
4
|
+
import { isArray } from "../../util/isArray";
|
|
5
|
+
import { isDefined } from "../../util/isDefined";
|
|
6
|
+
import { getComparer } from "../../data/comparer";
|
|
7
|
+
import { Culture } from "../Culture";
|
|
8
|
+
import { isObject } from "../../util/isObject";
|
|
9
|
+
|
|
10
|
+
export class GroupAdapter extends ArrayAdapter {
|
|
11
|
+
init() {
|
|
12
|
+
super.init();
|
|
13
|
+
|
|
14
|
+
if (this.groupRecordsAlias) this.groupRecordsName = this.groupRecordsAlias;
|
|
15
|
+
|
|
16
|
+
if (this.groupings) this.groupBy(this.groupings);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getRecords(context, instance, records, parentStore) {
|
|
20
|
+
let result = super.getRecords(context, instance, records, parentStore);
|
|
21
|
+
|
|
22
|
+
if (this.groupings) {
|
|
23
|
+
let groupedResults = [];
|
|
24
|
+
this.processLevel([], result, groupedResults, parentStore);
|
|
25
|
+
result = groupedResults;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
processLevel(keys, records, result, parentStore) {
|
|
32
|
+
let level = keys.length;
|
|
33
|
+
let inverseLevel = this.groupings.length - level;
|
|
34
|
+
|
|
35
|
+
if (inverseLevel == 0) {
|
|
36
|
+
if (this.preserveOrder && this.sorter) records = this.sorter(records);
|
|
37
|
+
for (let i = 0; i < records.length; i++) {
|
|
38
|
+
records[i].store.setStore(parentStore);
|
|
39
|
+
result.push(records[i]);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let grouping = this.groupings[level];
|
|
45
|
+
let { grouper } = grouping;
|
|
46
|
+
grouper.reset();
|
|
47
|
+
grouper.processAll(records);
|
|
48
|
+
let results = grouper.getResults();
|
|
49
|
+
|
|
50
|
+
if (grouping.comparer && !this.preserveOrder) results.sort(grouping.comparer);
|
|
51
|
+
|
|
52
|
+
results.forEach((gr) => {
|
|
53
|
+
keys.push(gr.key);
|
|
54
|
+
|
|
55
|
+
let key = keys.map(serializeKey).join("|");
|
|
56
|
+
|
|
57
|
+
let $group = {
|
|
58
|
+
...gr.key,
|
|
59
|
+
...gr.aggregates,
|
|
60
|
+
$name: gr.name,
|
|
61
|
+
$level: inverseLevel,
|
|
62
|
+
$records: gr.records || [],
|
|
63
|
+
$key: key,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
let data = {
|
|
67
|
+
[this.recordName]: gr.records.length > 0 ? gr.records[0].data : null,
|
|
68
|
+
[this.groupName]: $group,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
let groupStore = new ReadOnlyDataView({
|
|
72
|
+
store: parentStore,
|
|
73
|
+
data,
|
|
74
|
+
immutable: this.immutable,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
let group = {
|
|
78
|
+
key,
|
|
79
|
+
data,
|
|
80
|
+
group: $group,
|
|
81
|
+
grouping,
|
|
82
|
+
store: groupStore,
|
|
83
|
+
level: inverseLevel,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (grouping.includeHeader !== false)
|
|
87
|
+
result.push({
|
|
88
|
+
...group,
|
|
89
|
+
type: "group-header",
|
|
90
|
+
key: "header:" + group.key,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
this.processLevel(keys, gr.records, result, groupStore);
|
|
94
|
+
|
|
95
|
+
if (grouping.includeFooter !== false)
|
|
96
|
+
result.push({
|
|
97
|
+
...group,
|
|
98
|
+
type: "group-footer",
|
|
99
|
+
key: "footer:" + group.key,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
keys.pop();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
groupBy(groupings) {
|
|
107
|
+
if (!groupings) this.groupings = null;
|
|
108
|
+
else if (isArray(groupings)) {
|
|
109
|
+
this.groupings = groupings;
|
|
110
|
+
this.groupings.forEach((g) => {
|
|
111
|
+
let groupSorters = [];
|
|
112
|
+
let key = {};
|
|
113
|
+
for (let name in g.key) {
|
|
114
|
+
if (!g.key[name] || !isDefined(g.key[name].direction) || !isDefined(g.key[name].value))
|
|
115
|
+
g.key[name] = { value: g.key[name], direction: "ASC" };
|
|
116
|
+
key[name] = g.key[name].value;
|
|
117
|
+
groupSorters.push({
|
|
118
|
+
field: name,
|
|
119
|
+
direction: g.key[name].direction,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
g.grouper = new Grouper(key, { ...this.aggregates, ...g.aggregates }, (r) => r.store.getData(), g.text);
|
|
123
|
+
if (g.comparer == null && groupSorters.length > 0)
|
|
124
|
+
g.comparer = getComparer(
|
|
125
|
+
groupSorters,
|
|
126
|
+
(x) => x.key,
|
|
127
|
+
this.sortOptions ? Culture.getComparer(this.sortOptions) : null,
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
} else throw new Error("Invalid grouping provided.");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
GroupAdapter.prototype.groupName = "$group";
|
|
135
|
+
GroupAdapter.prototype.preserveOrder = false;
|
|
136
|
+
|
|
137
|
+
function serializeKey(data) {
|
|
138
|
+
if (isObject(data))
|
|
139
|
+
return Object.keys(data)
|
|
140
|
+
.map((k) => serializeKey(data[k]))
|
|
141
|
+
.join(":");
|
|
142
|
+
return data?.toString() ?? "";
|
|
143
|
+
}
|