@sme.up/ketchup 5.0.0 → 5.2.1-SNAPSHOT
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/README.md +1 -1
- package/dist/cjs/{cell-utils-720be0c8.js → cell-utils-d96b2993.js} +4 -4
- package/dist/cjs/{f-button-dbf3cd3a.js → f-button-2b9b99b1.js} +2 -2
- package/dist/cjs/{f-cell-93d984ad.js → f-cell-8351cb84.js} +8 -96
- package/dist/cjs/{f-chip-438213eb.js → f-chip-df59e1b0.js} +3 -3
- package/dist/cjs/{f-image-21865ab7.js → f-image-12bab3b5.js} +2 -2
- package/dist/cjs/f-text-field-e7c35b5b.js +94 -0
- package/dist/cjs/f-text-field-mdc-a67f5dfe.js +2852 -0
- package/dist/cjs/{index-ab119fad.js → index-eb556444.js} +6 -1
- package/dist/cjs/ketchup.cjs.js +3 -3
- package/dist/cjs/kup-accordion.cjs.entry.js +5 -5
- package/dist/cjs/kup-autocomplete_27.cjs.entry.js +641 -3331
- package/dist/cjs/kup-calendar.cjs.entry.js +8 -8
- package/dist/cjs/kup-cell.cjs.entry.js +9 -8
- package/dist/cjs/kup-dash-list.cjs.entry.js +5 -5
- package/dist/cjs/kup-dash_2.cjs.entry.js +5 -5
- package/dist/cjs/kup-drawer.cjs.entry.js +8 -5
- package/dist/cjs/kup-echart.cjs.entry.js +210 -60
- package/dist/cjs/kup-field.cjs.entry.js +3 -3
- package/dist/cjs/kup-iframe.cjs.entry.js +4 -4
- package/dist/cjs/kup-lazy.cjs.entry.js +4 -4
- package/dist/cjs/kup-magic-box.cjs.entry.js +7 -7
- package/dist/cjs/{kup-manager-09c0c1fc.js → kup-manager-5c03da64.js} +3061 -2642
- package/dist/cjs/kup-nav-bar.cjs.entry.js +6 -6
- package/dist/cjs/kup-numeric-picker.cjs.entry.js +423 -0
- package/dist/cjs/kup-photo-frame.cjs.entry.js +179 -0
- package/dist/cjs/kup-probe.cjs.entry.js +3 -3
- package/dist/cjs/kup-qlik.cjs.entry.js +3 -3
- package/dist/cjs/kup-snackbar.cjs.entry.js +6 -6
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{utils-a60ab5fa.js → utils-e99921c1.js} +4 -38
- package/dist/collection/assets/card.js +30 -30
- package/dist/collection/assets/data-table.js +24 -74
- package/dist/collection/assets/echart.js +481 -0
- package/dist/collection/assets/index.js +87 -79
- package/dist/collection/assets/kupdata.js +29 -41
- package/dist/collection/assets/kuptooltip.js +608 -0
- package/dist/collection/assets/list.js +6 -6
- package/dist/collection/assets/nav-bar.js +4 -4
- package/dist/collection/assets/probe.js +18 -18
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +4 -4
- package/dist/collection/components/kup-box/kup-box.js +9 -9
- package/dist/collection/components/kup-button-list/kup-button-list.js +4 -4
- package/dist/collection/components/kup-card/built-in/kup-card-built-in.js +10 -0
- package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +20 -20
- package/dist/collection/components/kup-card/built-in/kup-card-numeric.js +153 -0
- package/dist/collection/components/kup-card/kup-card.css +35 -0
- package/dist/collection/components/kup-card/kup-card.js +1 -0
- package/dist/collection/components/kup-chip/kup-chip.js +4 -4
- package/dist/collection/components/kup-combobox/kup-combobox.js +5 -5
- package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +0 -2
- package/dist/collection/components/kup-data-table/kup-data-table-helper.js +31 -32
- package/dist/collection/components/kup-data-table/kup-data-table-state.js +1 -1
- package/dist/collection/components/kup-data-table/kup-data-table.js +112 -159
- package/dist/collection/components/kup-date-picker/kup-date-picker.js +1 -1
- package/dist/collection/components/kup-drawer/kup-drawer.js +4 -1
- package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.css +3 -3
- package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +14 -14
- package/dist/collection/components/kup-echart/kup-echart-declarations.js +3 -0
- package/dist/collection/components/kup-echart/kup-echart.js +246 -58
- package/dist/collection/components/kup-image/assets/svg/instagram.svg +1 -0
- package/dist/collection/components/kup-image/assets/svg/pinterest.svg +1 -0
- package/dist/collection/components/kup-image/assets/svg/reddit.svg +1 -0
- package/dist/collection/components/kup-list/kup-list-helper.js +26 -26
- package/dist/collection/components/kup-list/kup-list.css +35 -3
- package/dist/collection/components/kup-list/kup-list.js +52 -44
- package/dist/collection/components/kup-magic-box/kup-magic-box.js +3 -3
- package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +2 -2
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker-declarations.js +16 -0
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.css +50 -0
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +895 -0
- package/dist/collection/components/kup-photo-frame/kup-photo-frame-declarations.js +10 -0
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.css +70 -0
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +382 -0
- package/dist/collection/components/kup-tab-bar/kup-tab-bar.css +1 -1
- package/dist/collection/components/kup-time-picker/kup-time-picker.js +8 -8
- package/dist/collection/components/kup-tree/kup-tree.js +25 -38
- package/dist/collection/f-components/f-paginator/f-paginator.js +6 -6
- package/dist/collection/managers/kup-data/kup-data-cell-helper.js +2 -2
- package/dist/collection/managers/kup-data/kup-data-column-helper.js +27 -3
- package/dist/collection/managers/kup-data/kup-data-declarations.js +2 -1
- package/dist/collection/managers/kup-data/kup-data-node-helper.js +1 -1
- package/dist/collection/managers/kup-data/kup-data-row-helper.js +2 -2
- package/dist/collection/managers/kup-data/kup-data.js +337 -155
- package/dist/collection/managers/kup-dates/kup-dates.js +2 -2
- package/dist/collection/managers/kup-debug/kup-debug.js +7 -6
- package/dist/collection/managers/kup-dynamic-position/kup-dynamic-position.js +1 -1
- package/dist/collection/managers/kup-language/kup-language.js +2 -2
- package/dist/collection/managers/kup-manager/kup-manager.js +25 -1
- package/dist/collection/managers/kup-math/kup-math-declarations.js +13 -0
- package/dist/collection/managers/kup-math/kup-math-helper.js +39 -0
- package/dist/collection/managers/kup-math/kup-math.js +161 -0
- package/dist/collection/managers/kup-objects/kup-objects.js +48 -1
- package/dist/collection/managers/kup-theme/kup-theme-declarations.js +1 -0
- package/dist/collection/managers/kup-theme/kup-theme.js +2 -2
- package/dist/collection/managers/kup-tooltip/kup-tooltip-declarations.js +1 -0
- package/dist/collection/managers/kup-tooltip/kup-tooltip.js +191 -0
- package/dist/collection/types/GenericTypes.js +1 -0
- package/dist/collection/utils/cell-utils.js +2 -3
- package/dist/collection/utils/kup-column-menu/kup-column-menu.js +1 -1
- package/dist/collection/utils/utils.js +3 -74
- package/dist/esm/{cell-utils-b80ccb8c.js → cell-utils-f4bdbbc8.js} +4 -4
- package/dist/esm/{f-button-9e835467.js → f-button-54a49fd8.js} +2 -2
- package/dist/esm/{f-cell-f8bb2e04.js → f-cell-d5dac50b.js} +8 -95
- package/dist/esm/{f-chip-953c6915.js → f-chip-a3035b4b.js} +3 -3
- package/dist/esm/{f-image-78c5265e.js → f-image-d32465e3.js} +2 -2
- package/dist/esm/f-text-field-c25cc63f.js +92 -0
- package/dist/esm/f-text-field-mdc-9fbbefc3.js +2850 -0
- package/dist/esm/{index-78f3699d.js → index-baeab1ac.js} +6 -2
- package/dist/esm/ketchup.js +3 -3
- package/dist/esm/kup-accordion.entry.js +5 -5
- package/dist/esm/kup-autocomplete_27.entry.js +625 -3315
- package/dist/esm/kup-calendar.entry.js +8 -8
- package/dist/esm/kup-cell.entry.js +9 -8
- package/dist/esm/kup-dash-list.entry.js +5 -5
- package/dist/esm/kup-dash_2.entry.js +5 -5
- package/dist/esm/kup-drawer.entry.js +8 -5
- package/dist/esm/kup-echart.entry.js +210 -60
- package/dist/esm/kup-field.entry.js +3 -3
- package/dist/esm/kup-iframe.entry.js +4 -4
- package/dist/esm/kup-lazy.entry.js +4 -4
- package/dist/esm/kup-magic-box.entry.js +7 -7
- package/dist/esm/{kup-manager-bba62291.js → kup-manager-9316a184.js} +3062 -2642
- package/dist/esm/kup-nav-bar.entry.js +6 -6
- package/dist/esm/kup-numeric-picker.entry.js +419 -0
- package/dist/esm/kup-photo-frame.entry.js +175 -0
- package/dist/esm/kup-probe.entry.js +3 -3
- package/dist/esm/kup-qlik.entry.js +3 -3
- package/dist/esm/kup-snackbar.entry.js +6 -6
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{utils-d1569956.js → utils-f24319a0.js} +5 -37
- package/dist/ketchup/assets/svg/instagram.svg +1 -0
- package/dist/ketchup/assets/svg/pinterest.svg +1 -0
- package/dist/ketchup/assets/svg/reddit.svg +1 -0
- package/dist/ketchup/ketchup.esm.js +1 -1
- package/dist/ketchup/p-09d708c4.entry.js +1 -0
- package/dist/ketchup/p-11e72a8c.entry.js +1 -0
- package/dist/ketchup/p-12773ca8.js +9 -0
- package/dist/ketchup/p-203d6295.entry.js +1 -0
- package/dist/ketchup/p-34748c91.js +1 -0
- package/dist/ketchup/p-34b74425.js +1 -0
- package/dist/ketchup/p-40f97429.js +1 -0
- package/dist/ketchup/p-4173422f.entry.js +1 -0
- package/dist/ketchup/p-41741c28.entry.js +1 -0
- package/dist/ketchup/p-44192f30.entry.js +1 -0
- package/dist/ketchup/{p-ebf4cf56.js → p-44f8da2a.js} +1 -1
- package/dist/ketchup/{p-fa540f82.js → p-4f56932b.js} +1 -1
- package/dist/ketchup/p-669bde31.js +1 -0
- package/dist/ketchup/p-67842f1e.entry.js +1 -0
- package/dist/ketchup/{p-f993f813.js → p-7a74ad17.js} +1 -1
- package/dist/ketchup/p-7ba8fa4a.entry.js +39 -0
- package/dist/ketchup/p-7de0d7e1.js +1 -0
- package/dist/ketchup/p-8418e8fa.entry.js +1 -0
- package/dist/ketchup/p-96bf19aa.entry.js +1 -0
- package/dist/ketchup/p-9a61d8dc.entry.js +1 -0
- package/dist/ketchup/p-b0ddcce9.entry.js +9 -0
- package/dist/ketchup/{p-aa27f9f7.entry.js → p-b6c21223.entry.js} +2 -2
- package/dist/ketchup/p-bb8844bf.entry.js +1 -0
- package/dist/ketchup/p-c58a2a81.entry.js +1 -0
- package/dist/ketchup/p-ca3d585b.entry.js +1 -0
- package/dist/ketchup/p-e6709c26.entry.js +1 -0
- package/dist/ketchup/p-e8e3c9da.entry.js +1 -0
- package/dist/ketchup/p-ecb7069b.js +135 -0
- package/dist/types/components/kup-button-list/kup-button-list-declarations.d.ts +2 -1
- package/dist/types/components/kup-card/built-in/kup-card-built-in.d.ts +7 -0
- package/dist/types/components/kup-card/built-in/kup-card-numeric.d.ts +2 -0
- package/dist/types/components/kup-card/kup-card-declarations.d.ts +26 -1
- package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +2 -2
- package/dist/types/components/kup-data-table/kup-data-table-state.d.ts +1 -1
- package/dist/types/components/kup-data-table/kup-data-table.d.ts +7 -15
- package/dist/types/components/kup-dropdown-button/kup-dropdown-button.d.ts +1 -1
- package/dist/types/components/kup-echart/kup-echart-declarations.d.ts +3 -0
- package/dist/types/components/kup-echart/kup-echart.d.ts +12 -1
- package/dist/types/components/kup-list/kup-list-declarations.d.ts +3 -7
- package/dist/types/components/kup-list/kup-list-helper.d.ts +6 -6
- package/dist/types/components/kup-list/kup-list.d.ts +2 -2
- package/dist/types/components/kup-numeric-picker/kup-numeric-picker-declarations.d.ts +19 -0
- package/dist/types/components/kup-numeric-picker/kup-numeric-picker.d.ts +121 -0
- package/dist/types/components/kup-photo-frame/kup-photo-frame-declarations.d.ts +9 -0
- package/dist/types/components/kup-photo-frame/kup-photo-frame.d.ts +61 -0
- package/dist/types/components.d.ts +249 -28
- package/dist/types/managers/kup-data/kup-data-column-helper.d.ts +9 -1
- package/dist/types/managers/kup-data/kup-data-declarations.d.ts +4 -25
- package/dist/types/managers/kup-data/kup-data-node-helper.d.ts +1 -1
- package/dist/types/managers/kup-data/kup-data.d.ts +63 -27
- package/dist/types/managers/kup-manager/kup-manager-declarations.d.ts +21 -0
- package/dist/types/managers/kup-manager/kup-manager.d.ts +4 -0
- package/dist/types/managers/kup-math/kup-math-declarations.d.ts +27 -0
- package/dist/types/managers/kup-math/kup-math-helper.d.ts +17 -0
- package/dist/types/managers/kup-math/kup-math.d.ts +61 -0
- package/dist/types/managers/kup-objects/kup-objects.d.ts +22 -0
- package/dist/types/managers/kup-tooltip/kup-tooltip-declarations.d.ts +8 -0
- package/dist/types/managers/kup-tooltip/kup-tooltip.d.ts +40 -0
- package/dist/types/types/GenericTypes.d.ts +1 -0
- package/dist/types/utils/utils.d.ts +0 -18
- package/package.json +3 -3
- package/CHANGELOG.md +0 -5
- package/dist/collection/managers/kup-data/kup-data-dataset-helper.js +0 -262
- package/dist/collection/managers/kup-data/kup-data-helper.js +0 -61
- package/dist/collection/utils/state-utils.js +0 -9
- package/dist/ketchup/p-0032a782.entry.js +0 -1
- package/dist/ketchup/p-18c4d083.entry.js +0 -1
- package/dist/ketchup/p-199c972e.entry.js +0 -1
- package/dist/ketchup/p-29800a2e.js +0 -1
- package/dist/ketchup/p-34aa8d8a.entry.js +0 -1
- package/dist/ketchup/p-542279e9.entry.js +0 -1
- package/dist/ketchup/p-5b26a7a8.entry.js +0 -39
- package/dist/ketchup/p-5c97e7ab.js +0 -1
- package/dist/ketchup/p-6817ca85.entry.js +0 -1
- package/dist/ketchup/p-76e674ca.entry.js +0 -1
- package/dist/ketchup/p-78aa6f1b.js +0 -1
- package/dist/ketchup/p-842b66aa.entry.js +0 -1
- package/dist/ketchup/p-894981c0.entry.js +0 -143
- package/dist/ketchup/p-8ac2fa75.entry.js +0 -1
- package/dist/ketchup/p-907c9e11.entry.js +0 -1
- package/dist/ketchup/p-9ae9149b.entry.js +0 -1
- package/dist/ketchup/p-b0d1bdd8.js +0 -9
- package/dist/ketchup/p-e1e4c951.entry.js +0 -1
- package/dist/ketchup/p-eba369d9.entry.js +0 -1
- package/dist/ketchup/p-ed0b8666.js +0 -1
- package/dist/types/managers/kup-data/kup-data-dataset-helper.d.ts +0 -42
- package/dist/types/managers/kup-data/kup-data-helper.d.ts +0 -11
- package/dist/types/utils/state-utils.d.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const dom = document.documentElement;
|
|
2
2
|
/**
|
|
3
3
|
* Finds all the cells matching the filters criteria in the input dataset.
|
|
4
4
|
* @param {KupDataDataset} dataset - Input dataset.
|
|
@@ -6,7 +6,7 @@ import { finder } from './kup-data-helper';
|
|
|
6
6
|
* @returns {KupDataCell[]} Array of cells fetched after applying the filters.
|
|
7
7
|
*/
|
|
8
8
|
export function findCell(dataset, filters) {
|
|
9
|
-
return finder(dataset, filters).cells;
|
|
9
|
+
return dom.ketchup.data.finder(dataset, filters).cells;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Returns all the cells values of the specified columns.
|
|
@@ -20,6 +20,9 @@ export function findColumns(dataset, filters) {
|
|
|
20
20
|
if (column[key] === filter) {
|
|
21
21
|
result.push(column);
|
|
22
22
|
}
|
|
23
|
+
else if (dom.ketchup.objects.deepEqual(column[key], filter)) {
|
|
24
|
+
result.push(column);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
return result;
|
|
@@ -55,6 +58,8 @@ export function newColumn(dataset, type, options) {
|
|
|
55
58
|
switch (type) {
|
|
56
59
|
case KupDataNewColumnTypes.CONCATENATE:
|
|
57
60
|
return newColumnFromConcatenate(dataset, options.columns, options.separator);
|
|
61
|
+
case KupDataNewColumnTypes.DUPLICATE:
|
|
62
|
+
return newColumnFromDuplication(dataset, options.columns, options.newColumn);
|
|
58
63
|
case KupDataNewColumnTypes.MATH:
|
|
59
64
|
return newColumnFromMath(dataset, options.operation, options.columns);
|
|
60
65
|
case KupDataNewColumnTypes.MERGE:
|
|
@@ -70,7 +75,7 @@ export function newColumn(dataset, type, options) {
|
|
|
70
75
|
* @param {KupDataDataset} dataset - Input dataset.
|
|
71
76
|
* @param {string[]} columns - Array of column names.
|
|
72
77
|
* @param {string} separator - Characters used to separate values.
|
|
73
|
-
* @returns {string|
|
|
78
|
+
* @returns {string|KupDataColumn} Returns the new column created or a string containing the error message (if something went wrong).
|
|
74
79
|
*/
|
|
75
80
|
function newColumnFromConcatenate(dataset, columns, separator) {
|
|
76
81
|
if (!columns || columns.length === 0) {
|
|
@@ -130,6 +135,25 @@ function newColumnFromConcatenate(dataset, columns, separator) {
|
|
|
130
135
|
dataset.columns.splice(dataset.columns.indexOf(firstColumn) + 1, 0, newColumn);
|
|
131
136
|
return newColumn;
|
|
132
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Creates a duplicate of the specified column.
|
|
140
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
141
|
+
* @param {string[]} column2duplicate - Name of the column to duplicate (the first occurrence of the array will be used).
|
|
142
|
+
* @param {KupDataColumn} newColumn - Column created.
|
|
143
|
+
* @returns {KupDataColumn} Resulting column.
|
|
144
|
+
*/
|
|
145
|
+
export function newColumnFromDuplication(dataset, column2duplicate, newColumn) {
|
|
146
|
+
const duplicatedName = column2duplicate[0];
|
|
147
|
+
for (let index = 0; index < dataset.rows.length; index++) {
|
|
148
|
+
const row = dataset.rows[index];
|
|
149
|
+
const cells = row.cells;
|
|
150
|
+
if (cells && cells[duplicatedName]) {
|
|
151
|
+
cells[newColumn.name] = Object.assign({}, cells[duplicatedName]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
dataset.columns.push(newColumn);
|
|
155
|
+
return newColumn;
|
|
156
|
+
}
|
|
133
157
|
/**
|
|
134
158
|
* This method is used to create a new column from a mathematical formula.
|
|
135
159
|
* @param {KupDataDataset} dataset - Input dataset.
|
|
@@ -219,11 +243,11 @@ function newColumnFromMath(dataset, operation, columns) {
|
|
|
219
243
|
if (!base) {
|
|
220
244
|
base = cell;
|
|
221
245
|
}
|
|
222
|
-
formulaRow[column] = dom.ketchup.
|
|
246
|
+
formulaRow[column] = dom.ketchup.math.numberify(cell.value);
|
|
223
247
|
}
|
|
224
248
|
}
|
|
225
249
|
}
|
|
226
|
-
const value = dom.ketchup.
|
|
250
|
+
const value = dom.ketchup.math.formulas
|
|
227
251
|
.custom(formula, formulaRow)
|
|
228
252
|
.toString();
|
|
229
253
|
cells[newName] = Object.assign(Object.assign({}, base), { displayedValue: null, obj: Object.assign(Object.assign({}, newObj), { k: value }), value: value });
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Types of column creation when invoking
|
|
2
|
+
* Types of column creation when invoking column.new.
|
|
3
3
|
*/
|
|
4
4
|
export var KupDataNewColumnTypes;
|
|
5
5
|
(function (KupDataNewColumnTypes) {
|
|
6
6
|
KupDataNewColumnTypes["CONCATENATE"] = "concatenate";
|
|
7
|
+
KupDataNewColumnTypes["DUPLICATE"] = "duplicate";
|
|
7
8
|
KupDataNewColumnTypes["MATH"] = "math";
|
|
8
9
|
KupDataNewColumnTypes["MERGE"] = "merge";
|
|
9
10
|
})(KupDataNewColumnTypes || (KupDataNewColumnTypes = {}));
|
|
@@ -25,7 +25,7 @@ export function removeNode(nodes, node2remove) {
|
|
|
25
25
|
return removed;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Sets the values specified in the
|
|
28
|
+
* Sets the values specified in the properties to every node of the input array.
|
|
29
29
|
* @param {KupDataNode[]} nodes - Input array of nodes.
|
|
30
30
|
* @param {Partial<KupDataNode>} properties - New properties values to set.
|
|
31
31
|
* @param {boolean} recursively - Sets values to every child node.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const dom = document.documentElement;
|
|
2
2
|
/**
|
|
3
3
|
* Finds all the rows containing cells matching the filters criteria in the input dataset.
|
|
4
4
|
* @param {KupDataDataset} dataset - Input dataset.
|
|
@@ -6,7 +6,7 @@ import { finder } from './kup-data-helper';
|
|
|
6
6
|
* @returns {KupDataRow[]} Array of rows fetched after applying the filters.
|
|
7
7
|
*/
|
|
8
8
|
export function findRow(dataset, filters) {
|
|
9
|
-
return finder(dataset, filters).rows;
|
|
9
|
+
return dom.ketchup.data.finder(dataset, filters).rows;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Converts the rows of the input dataset to tree nodes.
|
|
@@ -1,200 +1,382 @@
|
|
|
1
|
-
import
|
|
2
|
-
import 'numeral/locales/chs';
|
|
3
|
-
import 'numeral/locales/es';
|
|
4
|
-
import 'numeral/locales/fr';
|
|
5
|
-
import 'numeral/locales/it';
|
|
6
|
-
import 'numeral/locales/pl';
|
|
7
|
-
import 'numeral/locales/ru';
|
|
8
|
-
import { KupDebugCategory } from '../kup-debug/kup-debug-declarations';
|
|
9
|
-
import { distinctDataset, newDataset, rangedDistinctDataset, sortDataset, transposeDataset, } from './kup-data-dataset-helper';
|
|
1
|
+
import { KupDataNewColumnTypes, } from './kup-data-declarations';
|
|
10
2
|
import { findCell, getCellValue, replaceCell } from './kup-data-cell-helper';
|
|
11
3
|
import { findColumns, hideColumns, newColumn } from './kup-data-column-helper';
|
|
12
4
|
import { findRow, toNode } from './kup-data-row-helper';
|
|
13
5
|
import { removeNode, setPropertiesNode, toStreamNode, } from './kup-data-node-helper';
|
|
6
|
+
import { fieldColumn } from '../../components/kup-data-table/kup-data-table-declarations';
|
|
7
|
+
import { KupDebugCategory } from '../kup-debug/kup-debug-declarations';
|
|
14
8
|
const dom = document.documentElement;
|
|
15
9
|
/**
|
|
16
10
|
* Handles data operations.
|
|
17
11
|
* @module KupData
|
|
18
12
|
*/
|
|
19
13
|
export class KupData {
|
|
20
|
-
/**
|
|
21
|
-
* Initializes KupData.
|
|
22
|
-
*/
|
|
23
14
|
constructor() {
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.datasetOperations = {
|
|
28
|
-
cell: {
|
|
29
|
-
find(dataset, filters) {
|
|
30
|
-
return findCell(dataset, filters);
|
|
31
|
-
},
|
|
32
|
-
getValue(dataset, columns) {
|
|
33
|
-
return getCellValue(dataset, columns);
|
|
34
|
-
},
|
|
35
|
-
replace(dataset, cell, columns) {
|
|
36
|
-
return replaceCell(dataset, cell, columns);
|
|
37
|
-
},
|
|
15
|
+
this.cell = {
|
|
16
|
+
find(dataset, filters) {
|
|
17
|
+
return findCell(dataset, filters);
|
|
38
18
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return findColumns(dataset, filters);
|
|
42
|
-
},
|
|
43
|
-
hide(dataset, columns2hide) {
|
|
44
|
-
return hideColumns(dataset, columns2hide);
|
|
45
|
-
},
|
|
46
|
-
new(dataset, type, options) {
|
|
47
|
-
return newColumn(dataset, type, options);
|
|
48
|
-
},
|
|
19
|
+
getValue(dataset, columns) {
|
|
20
|
+
return getCellValue(dataset, columns);
|
|
49
21
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return removeNode(nodes, node2remove);
|
|
53
|
-
},
|
|
54
|
-
setProperties(nodes, properties, recursively, exclude) {
|
|
55
|
-
return setPropertiesNode(nodes, properties, recursively, exclude);
|
|
56
|
-
},
|
|
57
|
-
toStream(nodes) {
|
|
58
|
-
return toStreamNode(nodes);
|
|
59
|
-
},
|
|
22
|
+
replace(dataset, cell, columns) {
|
|
23
|
+
return replaceCell(dataset, cell, columns);
|
|
60
24
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
toNode(dataset) {
|
|
66
|
-
return toNode(dataset);
|
|
67
|
-
},
|
|
25
|
+
};
|
|
26
|
+
this.column = {
|
|
27
|
+
find(dataset, filters) {
|
|
28
|
+
return findColumns(dataset, filters);
|
|
68
29
|
},
|
|
69
|
-
|
|
70
|
-
return
|
|
30
|
+
hide(dataset, columns2hide) {
|
|
31
|
+
return hideColumns(dataset, columns2hide);
|
|
71
32
|
},
|
|
72
|
-
new(dataset,
|
|
73
|
-
return
|
|
33
|
+
new(dataset, type, options) {
|
|
34
|
+
return newColumn(dataset, type, options);
|
|
74
35
|
},
|
|
75
|
-
|
|
76
|
-
|
|
36
|
+
};
|
|
37
|
+
this.node = {
|
|
38
|
+
remove(nodes, node2remove) {
|
|
39
|
+
return removeNode(nodes, node2remove);
|
|
77
40
|
},
|
|
78
|
-
|
|
79
|
-
return
|
|
41
|
+
setProperties(nodes, properties, recursively, exclude) {
|
|
42
|
+
return setPropertiesNode(nodes, properties, recursively, exclude);
|
|
80
43
|
},
|
|
81
|
-
|
|
82
|
-
return
|
|
44
|
+
toStream(nodes) {
|
|
45
|
+
return toStreamNode(nodes);
|
|
83
46
|
},
|
|
84
47
|
};
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* @param {string} formula - Mathematical operation (i.e.: ([COL1] - [COL2]) * 100 / [COL3]).
|
|
89
|
-
* @param {{ [index: string]: number }} row - Object containing column names as indexes and the related values as keys.
|
|
90
|
-
* @returns {number} Result of the formula.
|
|
91
|
-
*/
|
|
92
|
-
custom(formula, row) {
|
|
93
|
-
const keys = Object.keys(row);
|
|
94
|
-
for (let i = 0; i < keys.length; i++) {
|
|
95
|
-
let key = keys[i];
|
|
96
|
-
let value = row[key];
|
|
97
|
-
if (value != null && !isNaN(value)) {
|
|
98
|
-
let re = new RegExp(key, 'g');
|
|
99
|
-
formula = formula.replace(re, value.toString());
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
formula = formula.replace(/[\[\]']+/g, '');
|
|
103
|
-
try {
|
|
104
|
-
const result = Function('"use strict"; return (' + formula + ')')();
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
catch (e) {
|
|
108
|
-
dom.ketchup.debug.logMessage('kup-data', 'Error while evaluating the following formula!(' +
|
|
109
|
-
formula +
|
|
110
|
-
')', KupDebugCategory.ERROR);
|
|
111
|
-
return NaN;
|
|
112
|
-
}
|
|
48
|
+
this.row = {
|
|
49
|
+
find(dataset, filters) {
|
|
50
|
+
return findRow(dataset, filters);
|
|
113
51
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* @param {number} average - Average.
|
|
117
|
-
* @param {number} variance - Variance.
|
|
118
|
-
* @param {number} x - X coordinate.
|
|
119
|
-
* @returns {number} Result.
|
|
120
|
-
*/
|
|
121
|
-
normalDistribution(average, variance, x) {
|
|
122
|
-
return ((1 / Math.sqrt(variance * 2 * Math.PI)) *
|
|
123
|
-
Math.exp(-Math.pow(x - average, 2) / (2 * variance)));
|
|
52
|
+
toNode(dataset) {
|
|
53
|
+
return toNode(dataset);
|
|
124
54
|
},
|
|
125
55
|
};
|
|
126
56
|
}
|
|
127
57
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @param {
|
|
130
|
-
* @param {
|
|
131
|
-
* @returns {
|
|
58
|
+
* Utility used by findRow and findCell.
|
|
59
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
60
|
+
* @param {KupDataFindCellFilters} filters - Filters of the research.
|
|
61
|
+
* @returns {{cells: KupDataCell[], rows: KupDataRow[]}} Object containing rows and cells.
|
|
62
|
+
*/
|
|
63
|
+
finder(dataset, filters) {
|
|
64
|
+
const columns = filters ? filters.columns : null;
|
|
65
|
+
const range = filters ? filters.range : null;
|
|
66
|
+
const value = filters ? filters.value : null;
|
|
67
|
+
const min = range && range.min ? range.min : null;
|
|
68
|
+
const max = range && range.max ? range.max : null;
|
|
69
|
+
const result = {
|
|
70
|
+
cells: [],
|
|
71
|
+
rows: [],
|
|
72
|
+
};
|
|
73
|
+
for (let index = 0; index < dataset.rows.length; index++) {
|
|
74
|
+
const row = dataset.rows[index];
|
|
75
|
+
const cells = row.cells;
|
|
76
|
+
for (const key in cells) {
|
|
77
|
+
const cell = cells[key];
|
|
78
|
+
if (!columns || !columns.length || columns.includes(key)) {
|
|
79
|
+
if (min && max) {
|
|
80
|
+
let d = null, s = '', n = 0;
|
|
81
|
+
if (dom.ketchup.objects.isDate(cell.obj)) {
|
|
82
|
+
d = dom.ketchup.dates.toDate(cell.value);
|
|
83
|
+
const dMax = dom.ketchup.dates.toDate(max instanceof String ? max.valueOf() : max);
|
|
84
|
+
const dMin = dom.ketchup.dates.toDate(min instanceof String ? min.valueOf() : min);
|
|
85
|
+
if (d === dMax ||
|
|
86
|
+
d === dMin ||
|
|
87
|
+
(d < dMax && d > dMin)) {
|
|
88
|
+
result.cells.push(cell);
|
|
89
|
+
result.rows.push(row);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (typeof min === 'string' ||
|
|
93
|
+
min instanceof String) {
|
|
94
|
+
s = cell.value;
|
|
95
|
+
if (s === max ||
|
|
96
|
+
s === min ||
|
|
97
|
+
(s < max && s > min)) {
|
|
98
|
+
result.cells.push(cell);
|
|
99
|
+
result.rows.push(row);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
n = dom.ketchup.math.numberify(cell.value);
|
|
104
|
+
if (n === max ||
|
|
105
|
+
n === min ||
|
|
106
|
+
(n < max && n > min)) {
|
|
107
|
+
result.cells.push(cell);
|
|
108
|
+
result.rows.push(row);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (value === cell.value) {
|
|
113
|
+
result.cells.push(cell);
|
|
114
|
+
result.rows.push(row);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Creates a new dataset with an amount of cells equal to a distinct calculation applied to the given columns.
|
|
123
|
+
* The original value of cells will be stored in the title property of the new cells.
|
|
124
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
125
|
+
* @param {string[]} columns - Column names to manage. When missing, defaults to all columns.
|
|
126
|
+
* @param {KupDataColumn} valuesColumn - When present, this column will be included in the final dataset containing the original values of the cells.
|
|
127
|
+
* @returns {KupDataDataset} New dataset with processed data.
|
|
132
128
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
distinct(dataset, columns, valuesColumn) {
|
|
130
|
+
const occurrencies = {};
|
|
131
|
+
const rows = dataset.rows;
|
|
132
|
+
for (let index = 0; index < rows.length; index++) {
|
|
133
|
+
const row = rows[index];
|
|
134
|
+
const cells = row.cells;
|
|
135
|
+
for (const key in cells) {
|
|
136
|
+
const cell = cells[key];
|
|
137
|
+
if (!columns ||
|
|
138
|
+
!columns.length ||
|
|
139
|
+
(columns && columns.includes(key))) {
|
|
140
|
+
if (!occurrencies[key]) {
|
|
141
|
+
occurrencies[key] = {};
|
|
142
|
+
}
|
|
143
|
+
const occurrency = occurrencies[key];
|
|
144
|
+
occurrency[cell.value] = occurrency[cell.value]
|
|
145
|
+
? occurrency[cell.value] + 1
|
|
146
|
+
: 1;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let variance = 0;
|
|
142
|
-
for (let index = 0; index < values.length; index++) {
|
|
143
|
-
const value = values[index];
|
|
144
|
-
average += this.numberify(value);
|
|
150
|
+
const newColumns = [];
|
|
151
|
+
const newRows = [];
|
|
152
|
+
if (valuesColumn) {
|
|
153
|
+
newColumns.push(valuesColumn);
|
|
145
154
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
155
|
+
for (const key in occurrencies) {
|
|
156
|
+
const occurrency = occurrencies[key];
|
|
157
|
+
const column = Object.assign({}, dataset.columns.find((col) => col.name === key));
|
|
158
|
+
column.obj = {
|
|
159
|
+
t: 'NR',
|
|
160
|
+
p: '',
|
|
161
|
+
k: '',
|
|
162
|
+
};
|
|
163
|
+
let rowIndex = 0;
|
|
164
|
+
newColumns.push(column);
|
|
165
|
+
for (const j in occurrency) {
|
|
166
|
+
const value = occurrency[j];
|
|
167
|
+
let row = null;
|
|
168
|
+
if (!newRows[rowIndex]) {
|
|
169
|
+
newRows[rowIndex] = { cells: {} };
|
|
170
|
+
}
|
|
171
|
+
row = newRows[rowIndex];
|
|
172
|
+
row.cells[key] = {
|
|
173
|
+
obj: {
|
|
174
|
+
t: 'NR',
|
|
175
|
+
p: '',
|
|
176
|
+
k: value.toString(),
|
|
177
|
+
},
|
|
178
|
+
title: j,
|
|
179
|
+
value: value.toString(),
|
|
180
|
+
};
|
|
181
|
+
if (valuesColumn) {
|
|
182
|
+
row.cells[valuesColumn.name] = {
|
|
183
|
+
value: j,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
rowIndex++;
|
|
187
|
+
}
|
|
150
188
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
189
|
+
return {
|
|
190
|
+
columns: newColumns,
|
|
191
|
+
rows: newRows,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Creates a new dataset from the input one.
|
|
196
|
+
* The new columns are to be specified in the columns argument along with their creation criteria.
|
|
197
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
198
|
+
* @param {KupDataNewColumn[]} newColumns - Array containing the specifics of the new columns to be created.
|
|
199
|
+
* @returns {KupDataDataset} Resulting dataset.
|
|
200
|
+
*/
|
|
201
|
+
new(dataset, newColumns) {
|
|
202
|
+
const outputColumns = [];
|
|
203
|
+
const outputRows = [];
|
|
204
|
+
for (let index = 0; index < newColumns.length; index++) {
|
|
205
|
+
const newColumn = newColumns[index].column;
|
|
206
|
+
const criteria = newColumns[index].criteria;
|
|
207
|
+
const cells = findCell(dataset, criteria);
|
|
208
|
+
let rowIndex = 0;
|
|
209
|
+
for (let index = 0; index < cells.length; index++) {
|
|
210
|
+
const cell = cells[index];
|
|
211
|
+
let outputRow = null;
|
|
212
|
+
if (!outputRows[rowIndex]) {
|
|
213
|
+
outputRows[rowIndex] = { cells: {} };
|
|
214
|
+
}
|
|
215
|
+
outputRow = outputRows[rowIndex];
|
|
216
|
+
outputRow.cells[newColumn.name] = JSON.parse(JSON.stringify(cell));
|
|
217
|
+
rowIndex++;
|
|
218
|
+
}
|
|
219
|
+
outputColumns.push(newColumn);
|
|
154
220
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
221
|
+
return {
|
|
222
|
+
columns: outputColumns,
|
|
223
|
+
rows: outputRows,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Performs a distinct/count after previously grouping columns by ranges.
|
|
228
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
229
|
+
* @param {KupDataNewColumn[]} rangeColumns - A list of columns coupled with their criteria for creation. These are used to define ranges.
|
|
230
|
+
* @param {KupDataColumn} resultingColumn - The resulting column.
|
|
231
|
+
* @param {KupDataColumn} valuesColumn - When present, this column will be included in the final dataset containing the original values of the cells.
|
|
232
|
+
* @returns {KupDataDataset} New dataset with processed data.
|
|
233
|
+
*/
|
|
234
|
+
rangedDistinct(dataset, rangeColumns, resultingColumn, valuesColumn) {
|
|
235
|
+
const newD = this.new(dataset, rangeColumns);
|
|
236
|
+
const columnNames = [];
|
|
237
|
+
for (let index = 0; index < rangeColumns.length; index++) {
|
|
238
|
+
const newColumn = rangeColumns[index].column;
|
|
239
|
+
columnNames.push(newColumn.name);
|
|
240
|
+
replaceCell(newD, { value: newColumn.title }, [newColumn.name]);
|
|
163
241
|
}
|
|
164
|
-
|
|
242
|
+
newColumn(newD, KupDataNewColumnTypes.MERGE, {
|
|
243
|
+
columns: columnNames,
|
|
244
|
+
newColumn: resultingColumn,
|
|
245
|
+
});
|
|
246
|
+
return this.distinct(newD, null, valuesColumn);
|
|
165
247
|
}
|
|
166
248
|
/**
|
|
167
|
-
*
|
|
168
|
-
* @param {
|
|
169
|
-
* @
|
|
249
|
+
* Creates a new dataset with sorted elements.
|
|
250
|
+
* @param {KupDataDataset} dataset Input dataset.
|
|
251
|
+
* @param {KupDataDatasetSort} sortType Type of sort to apply.
|
|
252
|
+
* @param {string} headerColumn The column used for sorting.
|
|
253
|
+
* @returns {KupDataDataset} Sorted dataset.
|
|
170
254
|
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
255
|
+
sort(dataset, sortType, headerColumn) {
|
|
256
|
+
if (sortType != 'normalDistribution') {
|
|
257
|
+
const message = 'Wrong sort type! (' + sortType + ')';
|
|
258
|
+
dom.ketchup.debug.logMessage('kup-data', message, KupDebugCategory.WARNING);
|
|
259
|
+
return dataset;
|
|
260
|
+
}
|
|
261
|
+
const output = {
|
|
262
|
+
columns: JSON.parse(JSON.stringify(dataset.columns)),
|
|
263
|
+
rows: [],
|
|
264
|
+
};
|
|
265
|
+
const length = dataset.rows.length;
|
|
266
|
+
// sort all columns values by descending
|
|
267
|
+
let values = getCellValue(dataset, [headerColumn]);
|
|
268
|
+
values.sort(function (a, b) {
|
|
269
|
+
return Number(a) - Number(b);
|
|
270
|
+
});
|
|
271
|
+
values.reverse();
|
|
272
|
+
// excluding duplicates values.
|
|
273
|
+
values = [...new Set(values)];
|
|
274
|
+
// calculating middle index
|
|
275
|
+
const idx = Math.floor(length / 2);
|
|
276
|
+
let lastIdx = idx - 1;
|
|
277
|
+
let leftIdx = idx - 1;
|
|
278
|
+
let rightIdx = idx + 1;
|
|
279
|
+
// sort the rows like a "mountain", the greatest is in the middle and the other ones are splitted left and right
|
|
280
|
+
for (let i = 0; i < length; i++) {
|
|
281
|
+
const value = values[i];
|
|
282
|
+
// looping the rows because we have many rows with same value.
|
|
283
|
+
this.finder(dataset, {
|
|
284
|
+
columns: [headerColumn],
|
|
285
|
+
value: value,
|
|
286
|
+
}).rows.forEach((row) => {
|
|
287
|
+
const xC = output.rows[idx];
|
|
288
|
+
if (xC == null) {
|
|
289
|
+
output.rows[idx] = JSON.parse(JSON.stringify(row));
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
output.rows[lastIdx] = JSON.parse(JSON.stringify(row));
|
|
293
|
+
if (lastIdx > idx) {
|
|
294
|
+
// right from the middle index.
|
|
295
|
+
lastIdx = leftIdx;
|
|
296
|
+
rightIdx++;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
// left from the middle index.
|
|
300
|
+
lastIdx = rightIdx;
|
|
301
|
+
leftIdx--;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
175
305
|
}
|
|
176
|
-
return
|
|
306
|
+
return output;
|
|
177
307
|
}
|
|
178
308
|
/**
|
|
179
|
-
*
|
|
180
|
-
* @param {
|
|
181
|
-
* @param {string}
|
|
182
|
-
* @returns {
|
|
309
|
+
* Creates a new dataset with transposed columns and rows.
|
|
310
|
+
* @param {KupDataDataset} dataset - Input dataset.
|
|
311
|
+
* @param {string} headerColumn - When specified, it will be the column used as header. When missing, the header will be a series of progressive numbers.
|
|
312
|
+
* @returns {KupDataDataset} Transposed dataset.
|
|
183
313
|
*/
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
314
|
+
transpose(dataset, headerColumn) {
|
|
315
|
+
const transposed = { columns: [], rows: [] };
|
|
316
|
+
let firstColumn = null;
|
|
317
|
+
if (headerColumn) {
|
|
318
|
+
firstColumn = findColumns(dataset, { name: headerColumn })[0];
|
|
319
|
+
transposed.columns.push(firstColumn);
|
|
320
|
+
for (let index = 0; index < dataset.rows.length; index++) {
|
|
321
|
+
const row = dataset.rows[index];
|
|
322
|
+
const cell = row.cells[firstColumn.name];
|
|
323
|
+
const title = cell.displayedValue
|
|
324
|
+
? cell.displayedValue
|
|
325
|
+
: cell.value;
|
|
326
|
+
transposed.columns.push({
|
|
327
|
+
name: cell.value + '_' + row.id,
|
|
328
|
+
title,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
firstColumn = {
|
|
334
|
+
name: fieldColumn.toUpperCase(),
|
|
335
|
+
title: fieldColumn,
|
|
336
|
+
};
|
|
337
|
+
transposed.columns.push(firstColumn);
|
|
338
|
+
for (let index = 0; index < dataset.rows.length; index++) {
|
|
339
|
+
const row = dataset.rows[index];
|
|
340
|
+
transposed.columns.push({
|
|
341
|
+
name: row.id,
|
|
342
|
+
title: '#' + index,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
for (let index = headerColumn ? 1 : 0; index < dataset.columns.length; index++) {
|
|
347
|
+
const oldColumn = dataset.columns[index];
|
|
348
|
+
const cells = {};
|
|
349
|
+
cells[firstColumn.name] = {
|
|
350
|
+
value: oldColumn.title,
|
|
351
|
+
};
|
|
352
|
+
for (let index = 1; index < transposed.columns.length; index++) {
|
|
353
|
+
const newColumn = transposed.columns[index];
|
|
354
|
+
const oldRow = dataset.rows[index - 1];
|
|
355
|
+
const cellName = headerColumn ? newColumn.name : oldRow.id;
|
|
356
|
+
cells[cellName] = oldRow.cells[oldColumn.name];
|
|
357
|
+
if (oldColumn.icon && !cells[cellName].icon) {
|
|
358
|
+
cells[cellName].icon = oldColumn.icon;
|
|
359
|
+
}
|
|
360
|
+
if (oldColumn.shape && !cells[cellName].shape) {
|
|
361
|
+
cells[cellName].shape = oldColumn.shape;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// If a record is key and no column argument is provided, it will be placed on top
|
|
365
|
+
if (!headerColumn && oldColumn.isKey) {
|
|
366
|
+
transposed.rows.unshift({
|
|
367
|
+
id: String(index),
|
|
368
|
+
cells,
|
|
369
|
+
transposedColumnName: oldColumn.name,
|
|
370
|
+
});
|
|
191
371
|
}
|
|
192
372
|
else {
|
|
193
|
-
|
|
373
|
+
transposed.rows.push({
|
|
374
|
+
id: String(index),
|
|
375
|
+
cells,
|
|
376
|
+
transposedColumnName: oldColumn.name,
|
|
377
|
+
});
|
|
194
378
|
}
|
|
195
379
|
}
|
|
196
|
-
|
|
197
|
-
this.numeral.locale('en'); // TODO: Remove when KupData locale is handled [KupDataLocale]
|
|
198
|
-
return formatted;
|
|
380
|
+
return transposed;
|
|
199
381
|
}
|
|
200
382
|
}
|
|
@@ -314,7 +314,7 @@ export class KupDates {
|
|
|
314
314
|
* @param {any} component - The Ketchup component to be registered.
|
|
315
315
|
*/
|
|
316
316
|
register(component) {
|
|
317
|
-
this.managedComponents.add(component.rootElement);
|
|
317
|
+
this.managedComponents.add(component.rootElement ? component.rootElement : component);
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
320
320
|
* Unregisters a KupComponent, so it won't be refreshed when the locale changes.
|
|
@@ -323,7 +323,7 @@ export class KupDates {
|
|
|
323
323
|
*/
|
|
324
324
|
unregister(component) {
|
|
325
325
|
if (this.managedComponents) {
|
|
326
|
-
this.managedComponents.delete(component.rootElement);
|
|
326
|
+
this.managedComponents.delete(component.rootElement ? component.rootElement : component);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|