dtable-statistic 4.0.2-test-2
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 +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { getOption, getCollaborator, getNumberDisplayString, isNumber, CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, isDateColumn, TableUtils } from 'dtable-store';
|
|
4
|
+
import { isCellValueChanged } from './cell-value';
|
|
5
|
+
import { getSelectColumnOptions, getDateColumnFormat } from './column';
|
|
6
|
+
import { getKnownCreatorByEmail } from './collaborator';
|
|
7
|
+
import { EMPTY_NAME } from '../constants';
|
|
8
|
+
var isSummaryDateColumn = function isSummaryDateColumn(summaryColumn) {
|
|
9
|
+
if (!summaryColumn) return false;
|
|
10
|
+
var type = summaryColumn.type;
|
|
11
|
+
return type !== CellType.LINK && isDateColumn(summaryColumn);
|
|
12
|
+
};
|
|
13
|
+
var getTableValueDisplayName = function getTableValueDisplayName(value, column) {
|
|
14
|
+
var _ref = column || {},
|
|
15
|
+
type = _ref.type,
|
|
16
|
+
data = _ref.data;
|
|
17
|
+
var collaborators = window.app.state.collaborators;
|
|
18
|
+
switch (type) {
|
|
19
|
+
case CellType.SINGLE_SELECT:
|
|
20
|
+
case CellType.MULTIPLE_SELECT:
|
|
21
|
+
{
|
|
22
|
+
var options = getSelectColumnOptions(column);
|
|
23
|
+
var option = getOption(options, value) || {};
|
|
24
|
+
return option.name;
|
|
25
|
+
}
|
|
26
|
+
case CellType.COLLABORATOR:
|
|
27
|
+
{
|
|
28
|
+
var collaborator = getCollaborator(collaborators, value) || {};
|
|
29
|
+
return collaborator.name;
|
|
30
|
+
}
|
|
31
|
+
case CellType.CREATOR:
|
|
32
|
+
case CellType.LAST_MODIFIER:
|
|
33
|
+
{
|
|
34
|
+
var _collaborator = getKnownCreatorByEmail(collaborators, value) || {};
|
|
35
|
+
return _collaborator.name;
|
|
36
|
+
}
|
|
37
|
+
case CellType.NUMBER:
|
|
38
|
+
{
|
|
39
|
+
var valueNumber = parseFloat(value);
|
|
40
|
+
var displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
41
|
+
return displayValue;
|
|
42
|
+
}
|
|
43
|
+
case CellType.DATE:
|
|
44
|
+
{
|
|
45
|
+
var _displayValue = value;
|
|
46
|
+
if (value && value.split('-').length === 3) {
|
|
47
|
+
var format = getDateColumnFormat(column);
|
|
48
|
+
var spaceIndex = format.indexOf(' ');
|
|
49
|
+
if (spaceIndex > -1) {
|
|
50
|
+
format = format.slice(0, spaceIndex);
|
|
51
|
+
}
|
|
52
|
+
_displayValue = dayjs(value).format(format);
|
|
53
|
+
}
|
|
54
|
+
return _displayValue;
|
|
55
|
+
}
|
|
56
|
+
case CellType.FORMULA:
|
|
57
|
+
case CellType.LINK_FORMULA:
|
|
58
|
+
{
|
|
59
|
+
var _displayValue2 = value;
|
|
60
|
+
var _ref2 = data || {},
|
|
61
|
+
result_type = _ref2.result_type;
|
|
62
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
63
|
+
var _valueNumber = parseFloat(value);
|
|
64
|
+
_displayValue2 = isNumber(_valueNumber) ? getNumberDisplayString(_valueNumber, data) : value;
|
|
65
|
+
}
|
|
66
|
+
return _displayValue2;
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
{
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var getValidValueForColumn = function getValidValueForColumn(column, value) {
|
|
75
|
+
if (!column) return '';
|
|
76
|
+
var type = column.type,
|
|
77
|
+
data = column.data;
|
|
78
|
+
if (FORMULA_COLUMN_TYPES.includes(type)) return '';
|
|
79
|
+
if (type === CellType.NUMBER) {
|
|
80
|
+
if (!value && value !== 0) return '';
|
|
81
|
+
if (typeof value === 'number') return value;
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
if (type === CellType.DATE) {
|
|
85
|
+
if (!value) return '';
|
|
86
|
+
if (typeof value !== 'string') return '';
|
|
87
|
+
var validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
88
|
+
return dayjs(value).format(validValueFormat);
|
|
89
|
+
}
|
|
90
|
+
if (type === CellType.TEXT) return value ? value : '';
|
|
91
|
+
return '';
|
|
92
|
+
};
|
|
93
|
+
var getUpdatedOneDimensionStatisticTableResultToTable = function getUpdatedOneDimensionStatisticTableResultToTable(_ref3) {
|
|
94
|
+
var updateTable = _ref3.updateTable,
|
|
95
|
+
statisticalResult = _ref3.statisticalResult,
|
|
96
|
+
t = _ref3.t;
|
|
97
|
+
var pivotResult = statisticalResult.pivotResult,
|
|
98
|
+
groupbyColumn = statisticalResult.groupbyColumn,
|
|
99
|
+
statisticTableColumns = statisticalResult.statisticTableColumns;
|
|
100
|
+
if (!groupbyColumn) return {};
|
|
101
|
+
var nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
|
|
102
|
+
if (!nameColumn) return {};
|
|
103
|
+
var pivot_rows = pivotResult.pivot_rows,
|
|
104
|
+
pivot_columns = pivotResult.pivot_columns;
|
|
105
|
+
var tableRows = updateTable.rows;
|
|
106
|
+
var columnMap = {};
|
|
107
|
+
var newRows = [];
|
|
108
|
+
var updatedRows = {};
|
|
109
|
+
var oldRows = {};
|
|
110
|
+
var rowIds = [];
|
|
111
|
+
|
|
112
|
+
// one dimension table no summary columns
|
|
113
|
+
if (pivot_columns.length < 2) {
|
|
114
|
+
columnMap['total'] = TableUtils.getTableColumnByName(updateTable, t('Total'));
|
|
115
|
+
|
|
116
|
+
// updated rows
|
|
117
|
+
pivot_rows.forEach(function (item) {
|
|
118
|
+
var name = item.name,
|
|
119
|
+
total = item.total;
|
|
120
|
+
var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
121
|
+
var row = tableRows.find(function (row) {
|
|
122
|
+
return row[nameColumn.key] === groupName;
|
|
123
|
+
});
|
|
124
|
+
var totalColumn = columnMap['total'];
|
|
125
|
+
if (row) {
|
|
126
|
+
// update old row
|
|
127
|
+
var updateRow = {};
|
|
128
|
+
var oldRow = {};
|
|
129
|
+
var validTotalCellValue = getValidValueForColumn(totalColumn, total.total);
|
|
130
|
+
if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
|
|
131
|
+
updateRow[totalColumn.key] = validTotalCellValue;
|
|
132
|
+
oldRow[totalColumn.key] = row[totalColumn.key];
|
|
133
|
+
}
|
|
134
|
+
if (Object.keys(updateRow).length > 0) {
|
|
135
|
+
var rowId = row._id;
|
|
136
|
+
rowIds.push(rowId);
|
|
137
|
+
updatedRows[rowId] = updateRow;
|
|
138
|
+
oldRows[rowId] = oldRow;
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
// insert new row
|
|
142
|
+
var newRow = {};
|
|
143
|
+
newRow[nameColumn.key] = groupName;
|
|
144
|
+
if (totalColumn) {
|
|
145
|
+
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
|
|
146
|
+
}
|
|
147
|
+
newRows.push(newRow);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return {
|
|
151
|
+
newRows: newRows,
|
|
152
|
+
updatedRows: updatedRows,
|
|
153
|
+
rowIds: rowIds,
|
|
154
|
+
oldRows: oldRows
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// one dimension table with summary columns
|
|
159
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
160
|
+
var key = item.key;
|
|
161
|
+
var column = statisticTableColumns.find(function (column) {
|
|
162
|
+
return column.key === key;
|
|
163
|
+
});
|
|
164
|
+
if (column) {
|
|
165
|
+
columnMap[key] = TableUtils.getTableColumnByName(updateTable, column.name);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// updated rows
|
|
170
|
+
var nameColumnKey = nameColumn.key;
|
|
171
|
+
pivot_rows.forEach(function (item) {
|
|
172
|
+
var name = item.name,
|
|
173
|
+
total = item.total;
|
|
174
|
+
var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
175
|
+
var row = tableRows.find(function (row) {
|
|
176
|
+
return row[nameColumnKey] === name;
|
|
177
|
+
});
|
|
178
|
+
if (row) {
|
|
179
|
+
var updateRow = {};
|
|
180
|
+
var oldRow = {};
|
|
181
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
182
|
+
var key = item.key;
|
|
183
|
+
var column = columnMap[key];
|
|
184
|
+
var totalCellValue = getValidValueForColumn(column, total[key]);
|
|
185
|
+
if (column && isCellValueChanged(row[column.key], totalCellValue, column.type)) {
|
|
186
|
+
updateRow[column.key] = totalCellValue;
|
|
187
|
+
oldRow[column.key] = row[column.key];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
if (Object.keys(updateRow).length > 0) {
|
|
191
|
+
var rowId = row._id;
|
|
192
|
+
rowIds.push(rowId);
|
|
193
|
+
updatedRows[rowId] = updateRow;
|
|
194
|
+
oldRows[rowId] = oldRow;
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
var newRow = _defineProperty({}, nameColumn.key, groupName);
|
|
198
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
199
|
+
var key = item.key;
|
|
200
|
+
var column = columnMap[key];
|
|
201
|
+
if (column) {
|
|
202
|
+
var totalCellValue = getValidValueForColumn(column, total[key]);
|
|
203
|
+
newRow[column.key] = totalCellValue;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
newRows.push(newRow);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
newRows: newRows,
|
|
211
|
+
updatedRows: updatedRows,
|
|
212
|
+
rowIds: rowIds,
|
|
213
|
+
oldRows: oldRows
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
var getUpdatedTwoDimensionStatisticTableResultToTable = function getUpdatedTwoDimensionStatisticTableResultToTable(_ref4) {
|
|
217
|
+
var updateTable = _ref4.updateTable,
|
|
218
|
+
statisticalResult = _ref4.statisticalResult,
|
|
219
|
+
t = _ref4.t;
|
|
220
|
+
var pivotResult = statisticalResult.pivotResult,
|
|
221
|
+
groupbyColumn = statisticalResult.groupbyColumn,
|
|
222
|
+
columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
|
|
223
|
+
var nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
|
|
224
|
+
if (!nameColumn) return {};
|
|
225
|
+
var pivot_rows = pivotResult.pivot_rows,
|
|
226
|
+
pivot_columns = pivotResult.pivot_columns;
|
|
227
|
+
var tableRows = updateTable.rows;
|
|
228
|
+
var columnMap = {};
|
|
229
|
+
var newRows = [];
|
|
230
|
+
var updatedRows = {};
|
|
231
|
+
var rowIds = [];
|
|
232
|
+
var oldRows = {};
|
|
233
|
+
|
|
234
|
+
// updated columns
|
|
235
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
236
|
+
var key = item.key;
|
|
237
|
+
var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
|
|
238
|
+
columnMap[columnName] = TableUtils.getTableColumnByName(updateTable, columnName);
|
|
239
|
+
});
|
|
240
|
+
columnMap['total'] = TableUtils.getTableColumnByName(updateTable, t('Total'));
|
|
241
|
+
|
|
242
|
+
// updated rows
|
|
243
|
+
var _loop = function _loop(i) {
|
|
244
|
+
var pivotRow = pivot_rows[i];
|
|
245
|
+
var name = pivotRow.name,
|
|
246
|
+
cells = pivotRow.cells,
|
|
247
|
+
total = pivotRow.total;
|
|
248
|
+
name = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
249
|
+
var nameColumnKey = nameColumn.key;
|
|
250
|
+
var row = tableRows.find(function (row) {
|
|
251
|
+
return row[nameColumnKey] === name;
|
|
252
|
+
});
|
|
253
|
+
var totalColumn = columnMap['total'];
|
|
254
|
+
if (row) {
|
|
255
|
+
// update old row
|
|
256
|
+
var updatedRow = {};
|
|
257
|
+
var oldRow = {}; // op used
|
|
258
|
+
var validTotalCellValue = getValidValueForColumn(totalColumn, total);
|
|
259
|
+
if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
|
|
260
|
+
updatedRow[totalColumn.key] = validTotalCellValue;
|
|
261
|
+
oldRow = row[totalColumn.key];
|
|
262
|
+
}
|
|
263
|
+
Object.keys(cells).forEach(function (key) {
|
|
264
|
+
var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
|
|
265
|
+
var column = columnMap[columnName];
|
|
266
|
+
var validCellValue = getValidValueForColumn(column, cells[key].total);
|
|
267
|
+
if (column && isCellValueChanged(row[column.key], validCellValue, column.type)) {
|
|
268
|
+
updatedRow[column.key] = validCellValue;
|
|
269
|
+
oldRow = row[column.key];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (Object.keys(updatedRow).length > 0) {
|
|
273
|
+
var rowId = row._id;
|
|
274
|
+
rowIds.push(rowId);
|
|
275
|
+
updatedRows[rowId] = updatedRow;
|
|
276
|
+
oldRows[rowId] = oldRow;
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
// insert new row
|
|
280
|
+
var newRow = {};
|
|
281
|
+
newRow[nameColumnKey] = name;
|
|
282
|
+
if (totalColumn) {
|
|
283
|
+
newRow[totalColumn.key] = getValidValueForColumn(totalColumn, name);
|
|
284
|
+
}
|
|
285
|
+
Object.keys(cells).forEach(function (key) {
|
|
286
|
+
var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
|
|
287
|
+
var column = columnMap[columnName];
|
|
288
|
+
if (column) {
|
|
289
|
+
newRow[column.key] = getValidValueForColumn(column, cells[key].total);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
if (Object.keys(newRow).length > 0) {
|
|
293
|
+
newRows.push(newRow);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
for (var i = 0; i < pivot_rows.length; i++) {
|
|
298
|
+
_loop(i);
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
newRows: newRows,
|
|
302
|
+
updatedRows: updatedRows,
|
|
303
|
+
oldRows: oldRows,
|
|
304
|
+
rowIds: rowIds
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @return {
|
|
310
|
+
* columns: [
|
|
311
|
+
* {
|
|
312
|
+
* name: xxx,
|
|
313
|
+
* type: CellType.DATE
|
|
314
|
+
* data: { format }
|
|
315
|
+
* }, {
|
|
316
|
+
* name: xxx,
|
|
317
|
+
* type: CellType.NUMBER
|
|
318
|
+
* data: { decimal, thousands, precision, enable_precision, format }
|
|
319
|
+
* },
|
|
320
|
+
* ],
|
|
321
|
+
* rows: [
|
|
322
|
+
* { columnName: value, xxx },
|
|
323
|
+
* ]
|
|
324
|
+
* }
|
|
325
|
+
*/
|
|
326
|
+
export var exportStatisticToTable = function exportStatisticToTable(_ref5) {
|
|
327
|
+
var statisticalResult = _ref5.statisticalResult,
|
|
328
|
+
t = _ref5.t;
|
|
329
|
+
var pivotResult = statisticalResult.pivotResult,
|
|
330
|
+
groupbyColumn = statisticalResult.groupbyColumn,
|
|
331
|
+
columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
|
|
332
|
+
var pivot_columns = pivotResult.pivot_columns;
|
|
333
|
+
if (!groupbyColumn) return {};
|
|
334
|
+
|
|
335
|
+
// two dimension table
|
|
336
|
+
if (columnGroupbyColumn) {
|
|
337
|
+
return getTwoDimensionStatisticTableResultToTable({
|
|
338
|
+
statisticalResult: statisticalResult,
|
|
339
|
+
t: t
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
if (!Array.isArray(pivot_columns)) return {};
|
|
343
|
+
return getOneDimensionStatisticTableResultToTable({
|
|
344
|
+
statisticalResult: statisticalResult,
|
|
345
|
+
t: t
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
export var getOneDimensionStatisticTableResultToTable = function getOneDimensionStatisticTableResultToTable(_ref6) {
|
|
349
|
+
var statisticalResult = _ref6.statisticalResult,
|
|
350
|
+
t = _ref6.t;
|
|
351
|
+
var pivotResult = statisticalResult.pivotResult,
|
|
352
|
+
groupbyColumn = statisticalResult.groupbyColumn,
|
|
353
|
+
statisticTableColumns = statisticalResult.statisticTableColumns,
|
|
354
|
+
summaryColumn = statisticalResult.summaryColumn;
|
|
355
|
+
var pivot_rows = pivotResult.pivot_rows,
|
|
356
|
+
pivot_columns = pivotResult.pivot_columns;
|
|
357
|
+
var columnMap = {};
|
|
358
|
+
var rows = [];
|
|
359
|
+
|
|
360
|
+
// generator columns
|
|
361
|
+
var columns = [{
|
|
362
|
+
// first column
|
|
363
|
+
key: '0000',
|
|
364
|
+
type: CellType.TEXT,
|
|
365
|
+
name: groupbyColumn.name,
|
|
366
|
+
data: null
|
|
367
|
+
}];
|
|
368
|
+
|
|
369
|
+
// one dimension table no number columns
|
|
370
|
+
if (pivot_columns.length < 2) {
|
|
371
|
+
var columnData = {
|
|
372
|
+
format: 'number'
|
|
373
|
+
};
|
|
374
|
+
var _isDateSummaryColumn = false;
|
|
375
|
+
var isIncludeHour = false;
|
|
376
|
+
if (summaryColumn) {
|
|
377
|
+
if (isSummaryDateColumn(summaryColumn)) {
|
|
378
|
+
var _ref7 = summaryColumn.data || {},
|
|
379
|
+
format = _ref7.format;
|
|
380
|
+
columnData = {
|
|
381
|
+
format: format
|
|
382
|
+
};
|
|
383
|
+
_isDateSummaryColumn = true;
|
|
384
|
+
isIncludeHour = format && format.indexOf('HH:mm') > -1;
|
|
385
|
+
} else {
|
|
386
|
+
/*
|
|
387
|
+
Take out the attributes needed by the number column data, and remove the extra attributes,
|
|
388
|
+
such as the data attribute in the function column, which contains other content that is not
|
|
389
|
+
useful for creating a new column
|
|
390
|
+
*/
|
|
391
|
+
var _ref8 = summaryColumn.data || {},
|
|
392
|
+
decimal = _ref8.decimal,
|
|
393
|
+
thousands = _ref8.thousands,
|
|
394
|
+
precision = _ref8.precision,
|
|
395
|
+
enable_precision = _ref8.enable_precision,
|
|
396
|
+
_format = _ref8.format;
|
|
397
|
+
columnData = {
|
|
398
|
+
decimal: decimal,
|
|
399
|
+
thousands: thousands,
|
|
400
|
+
precision: precision,
|
|
401
|
+
enable_precision: enable_precision,
|
|
402
|
+
format: _format
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// total column
|
|
408
|
+
var totalColumn = {
|
|
409
|
+
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
410
|
+
name: t('Total'),
|
|
411
|
+
data: columnData
|
|
412
|
+
};
|
|
413
|
+
columns.push(totalColumn);
|
|
414
|
+
|
|
415
|
+
// generator rows
|
|
416
|
+
pivot_rows.forEach(function (item) {
|
|
417
|
+
var _newRow2;
|
|
418
|
+
var name = item.name,
|
|
419
|
+
total = item.total;
|
|
420
|
+
var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
421
|
+
var cellValue = total.total;
|
|
422
|
+
if (_isDateSummaryColumn && cellValue) {
|
|
423
|
+
cellValue = isIncludeHour ? dayjs(cellValue).format('YYYY-MM-DD HH:mm') : dayjs(cellValue).format('YYYY-MM-DD');
|
|
424
|
+
}
|
|
425
|
+
var newRow = (_newRow2 = {}, _defineProperty(_newRow2, groupbyColumn.name, groupName), _defineProperty(_newRow2, t('Total'), cellValue), _newRow2);
|
|
426
|
+
rows.push(newRow);
|
|
427
|
+
});
|
|
428
|
+
return {
|
|
429
|
+
columns: columns,
|
|
430
|
+
rows: rows
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// one dimension table with number columns
|
|
435
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
436
|
+
var key = item.key;
|
|
437
|
+
var column = statisticTableColumns.find(function (column) {
|
|
438
|
+
return column.key === key;
|
|
439
|
+
});
|
|
440
|
+
if (column) {
|
|
441
|
+
var columnName = column.name;
|
|
442
|
+
var _columnData;
|
|
443
|
+
var columnType = CellType.NUMBER;
|
|
444
|
+
if (isSummaryDateColumn(column)) {
|
|
445
|
+
columnType = CellType.DATE;
|
|
446
|
+
var _ref9 = column.data || {},
|
|
447
|
+
_format2 = _ref9.format;
|
|
448
|
+
_columnData = {
|
|
449
|
+
format: _format2
|
|
450
|
+
};
|
|
451
|
+
} else {
|
|
452
|
+
/*
|
|
453
|
+
Take out the attributes needed by the number column data, and remove the extra attributes,
|
|
454
|
+
such as the data attribute in the function column, which contains other content that is not
|
|
455
|
+
useful for creating a new column
|
|
456
|
+
*/
|
|
457
|
+
var _ref10 = column.data || {},
|
|
458
|
+
_decimal = _ref10.decimal,
|
|
459
|
+
_thousands = _ref10.thousands,
|
|
460
|
+
_precision = _ref10.precision,
|
|
461
|
+
_enable_precision = _ref10.enable_precision,
|
|
462
|
+
_format3 = _ref10.format;
|
|
463
|
+
_columnData = {
|
|
464
|
+
decimal: _decimal,
|
|
465
|
+
thousands: _thousands,
|
|
466
|
+
precision: _precision,
|
|
467
|
+
enable_precision: _enable_precision,
|
|
468
|
+
format: _format3
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
var newColumn = {
|
|
472
|
+
type: columnType,
|
|
473
|
+
name: columnName,
|
|
474
|
+
data: _columnData
|
|
475
|
+
};
|
|
476
|
+
columnMap[key] = newColumn;
|
|
477
|
+
columns.push(newColumn);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// generator rows
|
|
482
|
+
pivot_rows.forEach(function (item) {
|
|
483
|
+
var name = item.name,
|
|
484
|
+
total = item.total;
|
|
485
|
+
var groupName = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
486
|
+
var newRow = _defineProperty({}, groupbyColumn.name, groupName);
|
|
487
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
488
|
+
var key = item.key;
|
|
489
|
+
var column = columnMap[key];
|
|
490
|
+
var name = column.name,
|
|
491
|
+
type = column.type,
|
|
492
|
+
data = column.data;
|
|
493
|
+
var cellValue = total[key];
|
|
494
|
+
if (type === CellType.DATE && cellValue) {
|
|
495
|
+
var dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
496
|
+
cellValue = dayjs(cellValue).format(dateFormat);
|
|
497
|
+
}
|
|
498
|
+
newRow[name] = cellValue;
|
|
499
|
+
});
|
|
500
|
+
rows.push(newRow);
|
|
501
|
+
});
|
|
502
|
+
return {
|
|
503
|
+
columns: columns,
|
|
504
|
+
rows: rows
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
export var getTwoDimensionStatisticTableResultToTable = function getTwoDimensionStatisticTableResultToTable(_ref11) {
|
|
508
|
+
var statisticalResult = _ref11.statisticalResult,
|
|
509
|
+
t = _ref11.t;
|
|
510
|
+
var pivotResult = statisticalResult.pivotResult,
|
|
511
|
+
groupbyColumn = statisticalResult.groupbyColumn,
|
|
512
|
+
columnGroupbyColumn = statisticalResult.columnGroupbyColumn,
|
|
513
|
+
summaryColumn = statisticalResult.summaryColumn;
|
|
514
|
+
var pivot_rows = pivotResult.pivot_rows,
|
|
515
|
+
pivot_columns = pivotResult.pivot_columns;
|
|
516
|
+
var columnMap = {};
|
|
517
|
+
var rows = [];
|
|
518
|
+
|
|
519
|
+
// generator columns
|
|
520
|
+
var columns = [{
|
|
521
|
+
// first column
|
|
522
|
+
key: '0000',
|
|
523
|
+
type: CellType.TEXT,
|
|
524
|
+
name: groupbyColumn.name,
|
|
525
|
+
data: null
|
|
526
|
+
}];
|
|
527
|
+
var columnData = {
|
|
528
|
+
format: 'number'
|
|
529
|
+
};
|
|
530
|
+
var _isDateSummaryColumn = false;
|
|
531
|
+
var isIncludeHour = false;
|
|
532
|
+
if (summaryColumn) {
|
|
533
|
+
if (isSummaryDateColumn(summaryColumn)) {
|
|
534
|
+
_isDateSummaryColumn = true;
|
|
535
|
+
var _ref12 = summaryColumn.data || {},
|
|
536
|
+
format = _ref12.format;
|
|
537
|
+
columnData = {
|
|
538
|
+
format: format
|
|
539
|
+
};
|
|
540
|
+
isIncludeHour = format && format.indexOf('HH:mm') > -1;
|
|
541
|
+
} else {
|
|
542
|
+
/*
|
|
543
|
+
Take out the attributes needed by the number column data, and remove the extra attributes,
|
|
544
|
+
such as the data attribute in the function column, which contains other content that is not
|
|
545
|
+
useful for creating a new column
|
|
546
|
+
*/
|
|
547
|
+
var _ref13 = summaryColumn.data || {},
|
|
548
|
+
decimal = _ref13.decimal,
|
|
549
|
+
thousands = _ref13.thousands,
|
|
550
|
+
precision = _ref13.precision,
|
|
551
|
+
enable_precision = _ref13.enable_precision,
|
|
552
|
+
_format4 = _ref13.format;
|
|
553
|
+
columnData = {
|
|
554
|
+
decimal: decimal,
|
|
555
|
+
thousands: thousands,
|
|
556
|
+
precision: precision,
|
|
557
|
+
enable_precision: enable_precision,
|
|
558
|
+
format: _format4
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
|
|
563
|
+
var key = item.key;
|
|
564
|
+
var columnName = key === null ? t(EMPTY_NAME) : getTableValueDisplayName(key, columnGroupbyColumn);
|
|
565
|
+
var newColumn = {
|
|
566
|
+
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
567
|
+
name: columnName,
|
|
568
|
+
data: columnData
|
|
569
|
+
};
|
|
570
|
+
columnMap[item.key] = columnName;
|
|
571
|
+
columns.push(newColumn);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// total column
|
|
575
|
+
var totalColumn = {
|
|
576
|
+
type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
|
|
577
|
+
name: t('Total'),
|
|
578
|
+
data: columnData
|
|
579
|
+
};
|
|
580
|
+
columns.push(totalColumn);
|
|
581
|
+
|
|
582
|
+
// generator rows
|
|
583
|
+
var dateFormat = isIncludeHour ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
|
|
584
|
+
pivot_rows.forEach(function (item) {
|
|
585
|
+
var name = item.name,
|
|
586
|
+
cells = item.cells,
|
|
587
|
+
total = item.total;
|
|
588
|
+
name = name === null ? t(EMPTY_NAME) : getTableValueDisplayName(name, groupbyColumn);
|
|
589
|
+
var newRow = _defineProperty({}, groupbyColumn.name, name);
|
|
590
|
+
var cellValue = total;
|
|
591
|
+
if (_isDateSummaryColumn && cellValue) {
|
|
592
|
+
cellValue = dayjs(cellValue).format(dateFormat);
|
|
593
|
+
}
|
|
594
|
+
newRow[t('Total')] = cellValue;
|
|
595
|
+
Object.keys(cells).forEach(function (key) {
|
|
596
|
+
var cellValue = cells[key].total;
|
|
597
|
+
if (_isDateSummaryColumn) {
|
|
598
|
+
cellValue = cellValue ? dayjs(cellValue).format(dateFormat) : '';
|
|
599
|
+
}
|
|
600
|
+
newRow[columnMap[key]] = cellValue;
|
|
601
|
+
});
|
|
602
|
+
rows.push(newRow);
|
|
603
|
+
});
|
|
604
|
+
return {
|
|
605
|
+
columns: columns,
|
|
606
|
+
rows: rows
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
export var updateStatisticToTable = function updateStatisticToTable(_ref14) {
|
|
610
|
+
var updateTable = _ref14.updateTable,
|
|
611
|
+
statisticalResult = _ref14.statisticalResult,
|
|
612
|
+
t = _ref14.t;
|
|
613
|
+
var groupbyColumn = statisticalResult.groupbyColumn,
|
|
614
|
+
columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
|
|
615
|
+
if (!groupbyColumn) return {};
|
|
616
|
+
|
|
617
|
+
// two dimension table
|
|
618
|
+
if (columnGroupbyColumn) {
|
|
619
|
+
return getUpdatedTwoDimensionStatisticTableResultToTable({
|
|
620
|
+
updateTable: updateTable,
|
|
621
|
+
statisticalResult: statisticalResult,
|
|
622
|
+
t: t
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// one dimension table
|
|
627
|
+
return getUpdatedOneDimensionStatisticTableResultToTable({
|
|
628
|
+
updateTable: updateTable,
|
|
629
|
+
statisticalResult: statisticalResult,
|
|
630
|
+
t: t
|
|
631
|
+
});
|
|
632
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var isFunction = function isFunction(functionToCheck) {
|
|
2
|
+
var getType = {};
|
|
3
|
+
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
4
|
+
};
|
|
5
|
+
export var getEventClassName = function getEventClassName(e) {
|
|
6
|
+
// svg mouseEvent event.target.className is an object
|
|
7
|
+
if (!e || !e.target) return '';
|
|
8
|
+
return e.target.getAttribute('class') || '';
|
|
9
|
+
};
|
|
10
|
+
export var hexToRgb = function hexToRgb(hex) {
|
|
11
|
+
hex = hex.replace('#', '');
|
|
12
|
+
var bigint = parseInt(hex, 16);
|
|
13
|
+
return {
|
|
14
|
+
r: bigint >> 16 & 255,
|
|
15
|
+
g: bigint >> 8 & 255,
|
|
16
|
+
b: bigint & 255
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export var isMobile = typeof window !== 'undefined' && (window.innerWidth < 768 || navigator.userAgent.toLowerCase().match(/(ipod|ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null);
|
|
20
|
+
export { getClientCellValueDisplayString, getClientFormulaDisplayString } from './cell-format';
|
|
21
|
+
export { hasOwnProperty, isEmptyObject, isSameObject } from './object';
|
|
22
|
+
export { isCellValueChanged } from './cell-value';
|
|
23
|
+
export { getKnownCreatorByEmail } from './collaborator';
|
|
24
|
+
export { getDateColumnFormat, getSelectColumnOptions } from './column';
|
|
25
|
+
export { translateCalendar, getTodayDate } from './date-format';
|
|
26
|
+
export { searchRows } from './search';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
export var isSameObject = function isSameObject(a, b) {
|
|
3
|
+
var k;
|
|
4
|
+
for (k in a) {
|
|
5
|
+
if (a.hasOwnProperty(k)) {
|
|
6
|
+
if (typeof a[k] === 'function' && typeof b[k] === 'function' || isValidElement(a[k]) && isValidElement(b[k])) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
for (k in b) {
|
|
15
|
+
if (b.hasOwnProperty(k) && !a.hasOwnProperty(k)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
export var isEmptyObject = function isEmptyObject(obj) {
|
|
22
|
+
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
23
|
+
};
|
|
24
|
+
export var hasOwnProperty = function hasOwnProperty(obj, prop) {
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
};
|