dtable-statistic 4.3.3 → 4.3.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/es/api/dtable-db-api.js +3 -10
- package/es/calculator/base-calculator.js +12 -20
- package/es/calculator/basic-chart-calculator.js +65 -72
- package/es/calculator/combination-calculator.js +57 -64
- package/es/calculator/compare-bar-calculator.js +26 -33
- package/es/calculator/completeness-calculator.js +30 -37
- package/es/calculator/copy-value.js +1 -7
- package/es/calculator/dashboard-calculator.js +13 -20
- package/es/calculator/heat-map-calculator.js +18 -25
- package/es/calculator/horizontal-bar-calculator.js +8 -15
- package/es/calculator/index.js +35 -42
- package/es/calculator/map-calculator.js +22 -29
- package/es/calculator/mirror-calculator.js +20 -27
- package/es/calculator/number-card-calculator.js +10 -17
- package/es/calculator/pivot-table-calculator.js +58 -65
- package/es/calculator/scatter-calculator.js +14 -21
- package/es/calculator/thread-manager.js +1 -7
- package/es/calculator/trend-calculator.js +22 -29
- package/es/calculator/workers/basic-chart-calculator-worker.js +76 -83
- package/es/calculator/workers/calculator.worker.js +30 -33
- package/es/calculator/workers/card-calculator-worker.js +13 -19
- package/es/calculator/workers/combination-calculator-worker.js +46 -53
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +22 -29
- package/es/calculator/workers/completeness-calculator-worker.js +34 -41
- package/es/calculator/workers/dashboard-calculator-worker.js +18 -24
- package/es/calculator/workers/mirror-calculator-worker.js +22 -29
- package/es/calculator/workers/pivot-table-calculator-worker.js +77 -84
- package/es/calculator/workers/scatter-calculator-worker.js +20 -27
- package/es/calculator/workers/trend-calculator-worker.js +27 -34
- package/es/calculator/world-map-calculator.js +17 -24
- package/es/components/common-add-tool.js +5 -12
- package/es/components/dialog/chart-addition-edit-dialog.js +12 -20
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +101 -108
- package/es/components/dialog/color-theme-dialog.js +15 -22
- package/es/components/dialog/delete-confirmation-dialog.js +11 -18
- package/es/components/dialog/enlarged-chart-dialog.js +20 -28
- package/es/components/dialog/new-table-dialog.js +16 -23
- package/es/components/dialog/new-view-dialog.js +14 -21
- package/es/components/dialog/rename-view-dialog.js +14 -22
- package/es/components/dialog/statistic-record-dialog/index.js +37 -45
- package/es/components/dialog/statistic-types-dialog/index.js +14 -22
- package/es/components/dialog/table-select-dialog.js +15 -23
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +41 -49
- package/es/components/dtable-popover.js +12 -19
- package/es/components/dtable-search-input.js +13 -21
- package/es/components/dtable-select.js +15 -21
- package/es/components/icon.js +4 -11
- package/es/components/index.js +11 -76
- package/es/components/loading.js +3 -10
- package/es/components/modal-portal.js +5 -12
- package/es/components/popover/color-rules/color-rule.js +25 -33
- package/es/components/popover/color-rules/index.js +6 -14
- package/es/components/popover/color-rules/rule-filters/filter.js +27 -34
- package/es/components/popover/color-rules/rule-filters/index.js +17 -25
- package/es/components/popover/color-rules/rule-filters/number-input.js +9 -17
- package/es/components/popover/color-rules-popover.js +24 -32
- package/es/components/popover/color-selector-popover.js +10 -17
- package/es/components/seatable-radio/index.js +9 -16
- package/es/components/select/index.js +2 -9
- package/es/components/select/option-group.js +19 -27
- package/es/components/select/option.js +6 -14
- package/es/components/select/select.js +17 -25
- package/es/components/toast/alert.js +24 -31
- package/es/components/toast/index.js +3 -10
- package/es/components/toast/toast.js +12 -20
- package/es/components/toast/toastManager.js +9 -17
- package/es/components/toast/toaster.js +6 -14
- package/es/constants/color-rules.js +6 -12
- package/es/constants/dtable-select-style.js +4 -9
- package/es/constants/event-types.js +4 -10
- package/es/constants/index.js +67 -96
- package/es/constants/key-codes.js +0 -2
- package/es/constants/map.js +2 -8
- package/es/constants/model.js +20 -26
- package/es/constants/regions.js +3 -8
- package/es/constants/zIndexes.js +1 -7
- package/es/custom-g2.js +208 -236
- package/es/dashboard.js +50 -58
- package/es/desktop-dashboard.js +47 -55
- package/es/index.js +3 -6
- package/es/locale/index.js +10 -13
- package/es/locale/lang/de.js +1 -7
- package/es/locale/lang/en.js +1 -7
- package/es/locale/lang/fr.js +1 -7
- package/es/locale/lang/zh_CN.js +1 -7
- package/es/mobile-dashboard.js +38 -46
- package/es/model/bar-group.js +11 -19
- package/es/model/bar.js +10 -18
- package/es/model/base-model.js +2 -9
- package/es/model/basic-number-card.js +8 -16
- package/es/model/collaborators.js +2 -9
- package/es/model/combination.js +12 -20
- package/es/model/compare-bar.js +16 -24
- package/es/model/completeness-group.js +8 -16
- package/es/model/completeness.js +5 -13
- package/es/model/custom-bar.js +6 -14
- package/es/model/dashboard.js +6 -14
- package/es/model/generic-model.js +133 -141
- package/es/model/heat-map.js +11 -19
- package/es/model/horizontal-bar-group.js +10 -18
- package/es/model/horizontal-bar.js +10 -18
- package/es/model/index.js +53 -185
- package/es/model/map.js +15 -23
- package/es/model/mirror.js +13 -21
- package/es/model/pie.js +10 -18
- package/es/model/ring.js +11 -19
- package/es/model/scatter.js +6 -14
- package/es/model/statistic-dashboard.js +2 -9
- package/es/model/table.js +10 -18
- package/es/model/trend.js +12 -20
- package/es/model/world-map.js +13 -21
- package/es/service/chart-service.js +7 -14
- package/es/service/dashboard-service.js +34 -41
- package/es/service/map-json.js +8 -14
- package/es/stat-editor/chart-name-editor.js +8 -15
- package/es/stat-editor/index.js +16 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +21 -29
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +49 -57
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +4 -11
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +43 -51
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +37 -45
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +26 -34
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +47 -55
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +22 -30
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +27 -35
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +24 -32
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +33 -41
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +22 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +27 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +46 -54
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +23 -31
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +26 -34
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +77 -85
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +21 -29
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +73 -81
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +16 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +19 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +49 -57
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +47 -55
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +11 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +45 -53
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +9 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +20 -28
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +30 -38
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +50 -58
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +47 -55
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +11 -19
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +12 -19
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +62 -70
- package/es/stat-editor/stat-settings/map/map-level.js +13 -20
- package/es/stat-editor/stat-settings/map/map-province-city.js +20 -27
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +20 -28
- package/es/stat-editor/stat-settings/public-setting/calender.js +22 -29
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +6 -13
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +9 -16
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +13 -21
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +27 -35
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +18 -26
- package/es/stat-list/chart-preview.js +20 -28
- package/es/stat-list/index.js +27 -35
- package/es/stat-view/area-chart.js +43 -50
- package/es/stat-view/bar-chart.js +47 -54
- package/es/stat-view/base-chart.js +24 -32
- package/es/stat-view/basic-number-card.js +19 -26
- package/es/stat-view/combination-chart.js +49 -56
- package/es/stat-view/compare-chart.js +39 -46
- package/es/stat-view/completeness-chart.js +28 -35
- package/es/stat-view/custom-bar.js +31 -38
- package/es/stat-view/dashboard-chart.js +15 -22
- package/es/stat-view/heat-map.js +43 -50
- package/es/stat-view/horizontal-bar-chart.js +51 -58
- package/es/stat-view/index.js +73 -80
- package/es/stat-view/line-chart.js +39 -46
- package/es/stat-view/map.js +33 -40
- package/es/stat-view/mirror.js +21 -28
- package/es/stat-view/pie-chart.js +29 -36
- package/es/stat-view/pivot-table/index.js +32 -39
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +31 -39
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +29 -37
- package/es/stat-view/pivot-table/pivot-table-display-name.js +46 -54
- package/es/stat-view/pivot-table/two-dimension-table.js +62 -70
- package/es/stat-view/ring-chart.js +38 -45
- package/es/stat-view/scatter-chart.js +30 -37
- package/es/stat-view/treemap-chart.js +37 -44
- package/es/stat-view/trend-chart.js +32 -39
- package/es/stat-view/world-map.js +33 -40
- package/es/tabs/index.js +32 -40
- package/es/tabs/tab.js +26 -34
- package/es/utils/basic-chart-utils.js +2 -9
- package/es/utils/cell-format.js +14 -22
- package/es/utils/cell-value.js +7 -14
- package/es/utils/collaborator.js +4 -13
- package/es/utils/color-utils.js +18 -29
- package/es/utils/column-utils.js +18 -29
- package/es/utils/column.js +4 -11
- package/es/utils/common-utils.js +41 -65
- package/es/utils/date-format.js +2 -8
- package/es/utils/export-table-utils.js +82 -91
- package/es/utils/index.js +11 -100
- package/es/utils/map.js +26 -36
- package/es/utils/model.js +6 -14
- package/es/utils/object.js +6 -15
- package/es/utils/pivot-table.js +16 -23
- package/es/utils/row-utils.js +23 -33
- package/es/utils/search.js +21 -29
- package/es/utils/sql-utils.js +65 -75
- package/es/utils/stat-utils.js +60 -66
- package/es/utils/trend-utils.js +32 -40
- package/package.json +1 -1
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var _dtableStore = require("dtable-store");
|
|
12
|
-
var _pivotTableDisplayName = _interopRequireDefault(require("./pivot-table-display-name"));
|
|
13
|
-
var _utils = require("../../utils");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _statisticPivotTableModule = _interopRequireDefault(require("./statistic-pivot-table.module.css"));
|
|
16
|
-
class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
1
|
+
import React, { PureComponent } from 'react';
|
|
2
|
+
import intl from 'react-intl-universal';
|
|
3
|
+
import { TableUtils } from 'dtable-store';
|
|
4
|
+
import PivotTableDisplayName from './pivot-table-display-name';
|
|
5
|
+
import { isMobile } from '../../utils';
|
|
6
|
+
import { TITLE_TOTAL } from '../../constants';
|
|
7
|
+
import styles from './statistic-pivot-table.module.css';
|
|
8
|
+
class OneDimensionTableWithNumericColumns extends PureComponent {
|
|
17
9
|
constructor() {
|
|
18
10
|
var _this;
|
|
19
11
|
super(...arguments);
|
|
@@ -23,7 +15,7 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
23
15
|
isColumn = false,
|
|
24
16
|
isCurrentView = false
|
|
25
17
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
-
if (
|
|
18
|
+
if (isMobile) return;
|
|
27
19
|
_this.props.toggleStatisticRecordsDialog(cell, _this.props.statItem, {
|
|
28
20
|
isColumn,
|
|
29
21
|
isCurrentView
|
|
@@ -42,7 +34,7 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
42
34
|
column_groupby_column_key
|
|
43
35
|
} = statItem;
|
|
44
36
|
const statisticTableColumns = table.columns;
|
|
45
|
-
const columnGroupbyColumn =
|
|
37
|
+
const columnGroupbyColumn = TableUtils.getTableColumnByKey(table, column_groupby_column_key);
|
|
46
38
|
const {
|
|
47
39
|
name: groupName
|
|
48
40
|
} = groupbyColumn;
|
|
@@ -52,17 +44,17 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
52
44
|
const {
|
|
53
45
|
pivot_columns
|
|
54
46
|
} = pivotResult;
|
|
55
|
-
return /*#__PURE__*/
|
|
47
|
+
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
56
48
|
className: "pivot-table-header"
|
|
57
49
|
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map((item, index) => {
|
|
58
50
|
const {
|
|
59
51
|
key
|
|
60
52
|
} = item;
|
|
61
53
|
const column = statisticTableColumns.find(column => column.key === key);
|
|
62
|
-
return /*#__PURE__*/
|
|
54
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
63
55
|
className: 'pivot-table-header',
|
|
64
56
|
key: "pivot-column-".concat(index)
|
|
65
|
-
}, /*#__PURE__*/
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", null, column.name));
|
|
66
58
|
})));
|
|
67
59
|
};
|
|
68
60
|
this.renderRows = _ref2 => {
|
|
@@ -85,7 +77,7 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
85
77
|
pivot_columns_total
|
|
86
78
|
} = pivotResult;
|
|
87
79
|
let pivotColumnCells = [];
|
|
88
|
-
return /*#__PURE__*/
|
|
80
|
+
return /*#__PURE__*/React.createElement("tbody", null, pivot_rows.map((rowItem, rowIdx) => {
|
|
89
81
|
const {
|
|
90
82
|
original_name,
|
|
91
83
|
total,
|
|
@@ -94,11 +86,11 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
94
86
|
if (!Array.isArray(pivot_columns)) {
|
|
95
87
|
pivotColumnCells[rowIdx] = rowItem.rows || [];
|
|
96
88
|
}
|
|
97
|
-
return /*#__PURE__*/
|
|
89
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
98
90
|
key: 'table-row' + rowIdx
|
|
99
|
-
}, /*#__PURE__*/
|
|
91
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
100
92
|
className: 'pivot-row-name'
|
|
101
|
-
}, /*#__PURE__*/
|
|
93
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
102
94
|
value: original_name,
|
|
103
95
|
column: groupbyColumn
|
|
104
96
|
})), Array.isArray(pivot_columns) && pivot_columns.map((columnMap, cellIdx) => {
|
|
@@ -116,23 +108,23 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
116
108
|
const column = statisticTableColumns.find(item => item.key === key);
|
|
117
109
|
const displayValue = getSummaryValueDisplayString(column, total[key + method], method);
|
|
118
110
|
const isValidDisplayValue = this.props.isValidValue(displayValue);
|
|
119
|
-
return /*#__PURE__*/
|
|
120
|
-
className: "".concat(
|
|
111
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
112
|
+
className: "".concat(styles['pivot-cell'], " ").concat(isValidDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
121
113
|
key: "table-cell-".concat(cellIdx),
|
|
122
114
|
onClick: () => this.toggleRecords(rowItem),
|
|
123
115
|
title: isValidDisplayValue ? displayValue : ''
|
|
124
|
-
}, isValidDisplayValue ? /*#__PURE__*/
|
|
116
|
+
}, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null));
|
|
125
117
|
}));
|
|
126
|
-
}), display_total && /*#__PURE__*/
|
|
118
|
+
}), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
127
119
|
className: 'pivot-column-total'
|
|
128
|
-
}, /*#__PURE__*/
|
|
120
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL))), Array.isArray(pivot_columns) && pivot_columns.map((c, index) => {
|
|
129
121
|
const pivotColumnCell = pivotColumnCells[index];
|
|
130
122
|
const pivotColumnTotal = pivot_columns_total[c.key + c.method];
|
|
131
123
|
const column = statisticTableColumns.find(column => column.key === c.key);
|
|
132
124
|
const displayValue = getSummaryValueDisplayString(column, pivotColumnTotal, c.method);
|
|
133
125
|
const isValidDisplayValue = this.props.isValidValue(displayValue);
|
|
134
|
-
return /*#__PURE__*/
|
|
135
|
-
className: "".concat(
|
|
126
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
127
|
+
className: "".concat(styles['pivot-cell'], " ").concat(isValidDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
136
128
|
key: "total-cell-".concat(index),
|
|
137
129
|
title: isValidDisplayValue ? displayValue : '',
|
|
138
130
|
onClick: () => this.toggleRecords({
|
|
@@ -141,7 +133,7 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
141
133
|
}, {
|
|
142
134
|
isCurrentView: true
|
|
143
135
|
})
|
|
144
|
-
}, isValidDisplayValue ? /*#__PURE__*/
|
|
136
|
+
}, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null));
|
|
145
137
|
})));
|
|
146
138
|
};
|
|
147
139
|
}
|
|
@@ -157,13 +149,13 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
157
149
|
groupby_column_key
|
|
158
150
|
} = statItem;
|
|
159
151
|
const table = getTableById(table_id);
|
|
160
|
-
const groupbyColumn =
|
|
152
|
+
const groupbyColumn = TableUtils.getTableColumnByKey(table, groupby_column_key);
|
|
161
153
|
if (!groupbyColumn) return '';
|
|
162
|
-
return /*#__PURE__*/
|
|
154
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
163
155
|
style: {
|
|
164
156
|
color: textColor
|
|
165
157
|
},
|
|
166
|
-
className: "".concat(isPreview ?
|
|
158
|
+
className: "".concat(isPreview ? styles['preview-pivot-table'] : styles['large-pivot-table'], " ").concat(styles['pivot-table'])
|
|
167
159
|
}, this.renderHeader({
|
|
168
160
|
table,
|
|
169
161
|
groupbyColumn
|
|
@@ -173,4 +165,4 @@ class OneDimensionTableWithNumericColumns extends _react.PureComponent {
|
|
|
173
165
|
}));
|
|
174
166
|
}
|
|
175
167
|
}
|
|
176
|
-
|
|
168
|
+
export default OneDimensionTableWithNumericColumns;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
|
|
11
|
-
var _dtableStore = require("dtable-store");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _commonUtils = require("../../utils/common-utils");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
class PivotTableDisplayName extends _react.default.Component {
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import intl from 'react-intl-universal';
|
|
3
|
+
import { getOption, getCollaborator, CellType, getNumberDisplayString, isNumber, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE } from 'dtable-store';
|
|
4
|
+
import { getClientFormulaDisplayString, getKnownCreatorByEmail, generateDefaultUser, getSelectColumnOptions } from '../../utils';
|
|
5
|
+
import { shallowEqual } from '../../utils/common-utils';
|
|
6
|
+
import { EMPTY_NAME } from '../../constants';
|
|
7
|
+
class PivotTableDisplayName extends React.Component {
|
|
16
8
|
constructor(props) {
|
|
17
9
|
super(props);
|
|
18
10
|
this.updateCreator = email => {
|
|
@@ -22,7 +14,7 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
22
14
|
let {
|
|
23
15
|
collaborators
|
|
24
16
|
} = window.app.state;
|
|
25
|
-
let creator =
|
|
17
|
+
let creator = getKnownCreatorByEmail(collaborators, email);
|
|
26
18
|
if (creator) {
|
|
27
19
|
this.setState({
|
|
28
20
|
creator
|
|
@@ -41,7 +33,7 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
41
33
|
}
|
|
42
34
|
|
|
43
35
|
// error handle
|
|
44
|
-
creator =
|
|
36
|
+
creator = generateDefaultUser(email);
|
|
45
37
|
dtableCollaborators[email] = creator;
|
|
46
38
|
this.setState({
|
|
47
39
|
creator
|
|
@@ -58,17 +50,17 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
58
50
|
} = window.app.state;
|
|
59
51
|
let displayName;
|
|
60
52
|
switch (type) {
|
|
61
|
-
case
|
|
62
|
-
case
|
|
53
|
+
case CellType.SINGLE_SELECT:
|
|
54
|
+
case CellType.MULTIPLE_SELECT:
|
|
63
55
|
{
|
|
64
|
-
let options =
|
|
65
|
-
let option =
|
|
56
|
+
let options = getSelectColumnOptions(column);
|
|
57
|
+
let option = getOption(options, value) || {};
|
|
66
58
|
let {
|
|
67
59
|
name: optionName,
|
|
68
60
|
color,
|
|
69
61
|
textColor
|
|
70
62
|
} = option;
|
|
71
|
-
displayName = /*#__PURE__*/
|
|
63
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
72
64
|
style: {
|
|
73
65
|
color: textColor,
|
|
74
66
|
backgroundColor: color
|
|
@@ -79,70 +71,70 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
79
71
|
}, optionName);
|
|
80
72
|
break;
|
|
81
73
|
}
|
|
82
|
-
case
|
|
74
|
+
case CellType.COLLABORATOR:
|
|
83
75
|
{
|
|
84
|
-
let collaborator =
|
|
85
|
-
displayName = /*#__PURE__*/
|
|
76
|
+
let collaborator = getCollaborator(collaborators, value) || {};
|
|
77
|
+
displayName = /*#__PURE__*/React.createElement(Collaborator, {
|
|
86
78
|
collaborator: collaborator
|
|
87
79
|
});
|
|
88
80
|
break;
|
|
89
81
|
}
|
|
90
|
-
case
|
|
91
|
-
case
|
|
82
|
+
case CellType.CREATOR:
|
|
83
|
+
case CellType.LAST_MODIFIER:
|
|
92
84
|
{
|
|
93
85
|
let {
|
|
94
86
|
creator
|
|
95
87
|
} = this.state;
|
|
96
|
-
displayName = /*#__PURE__*/
|
|
88
|
+
displayName = /*#__PURE__*/React.createElement(Collaborator, {
|
|
97
89
|
collaborator: creator
|
|
98
90
|
});
|
|
99
91
|
break;
|
|
100
92
|
}
|
|
101
|
-
case
|
|
93
|
+
case CellType.NUMBER:
|
|
102
94
|
{
|
|
103
|
-
const displayValue =
|
|
104
|
-
displayName = /*#__PURE__*/
|
|
95
|
+
const displayValue = isNumber(value) ? getNumberDisplayString(value, data) : value;
|
|
96
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
105
97
|
title: displayValue,
|
|
106
98
|
"aria-label": displayValue
|
|
107
99
|
}, displayValue);
|
|
108
100
|
break;
|
|
109
101
|
}
|
|
110
|
-
case
|
|
102
|
+
case CellType.LINK:
|
|
111
103
|
{
|
|
112
|
-
const displayValue =
|
|
104
|
+
const displayValue = getClientFormulaDisplayString(Array.isArray(value) ? value : [value], data, {
|
|
113
105
|
collaborators
|
|
114
106
|
}) || null;
|
|
115
107
|
if (!displayValue) {
|
|
116
108
|
break;
|
|
117
109
|
}
|
|
118
|
-
displayName = /*#__PURE__*/
|
|
110
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
119
111
|
title: displayValue,
|
|
120
112
|
"aria-label": displayValue
|
|
121
113
|
}, displayValue);
|
|
122
114
|
break;
|
|
123
115
|
}
|
|
124
|
-
case
|
|
125
|
-
case
|
|
116
|
+
case CellType.FORMULA:
|
|
117
|
+
case CellType.LINK_FORMULA:
|
|
126
118
|
{
|
|
127
119
|
let displayValue = value;
|
|
128
120
|
let {
|
|
129
121
|
result_type,
|
|
130
122
|
array_type
|
|
131
123
|
} = data || {};
|
|
132
|
-
if (result_type ===
|
|
124
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
133
125
|
let valueNumber = parseFloat(value);
|
|
134
|
-
displayValue =
|
|
135
|
-
} else if (result_type ===
|
|
136
|
-
if (
|
|
126
|
+
displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
127
|
+
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
128
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
137
129
|
const currentCollaborators = Array.isArray(value) ? value : [value];
|
|
138
130
|
displayValue = currentCollaborators.map(email => {
|
|
139
|
-
let user = array_type ===
|
|
131
|
+
let user = array_type === CellType.COLLABORATOR ? getCollaborator(collaborators, email) : getKnownCreatorByEmail(collaborators, email);
|
|
140
132
|
return (user || {}).name;
|
|
141
133
|
});
|
|
142
134
|
displayValue = displayValue + '';
|
|
143
135
|
}
|
|
144
136
|
}
|
|
145
|
-
displayName = /*#__PURE__*/
|
|
137
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
146
138
|
title: displayValue,
|
|
147
139
|
"aria-label": displayValue
|
|
148
140
|
}, displayValue);
|
|
@@ -151,7 +143,7 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
151
143
|
default:
|
|
152
144
|
{
|
|
153
145
|
const displayValue = typeof value !== 'string' ? String(value) : value;
|
|
154
|
-
displayName = /*#__PURE__*/
|
|
146
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
155
147
|
title: displayValue,
|
|
156
148
|
"aria-label": displayValue
|
|
157
149
|
}, displayValue);
|
|
@@ -169,7 +161,7 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
169
161
|
column,
|
|
170
162
|
value
|
|
171
163
|
} = this.props;
|
|
172
|
-
if (column.type !==
|
|
164
|
+
if (column.type !== CellType.CREATOR && column.type !== CellType.LAST_MODIFIER) return;
|
|
173
165
|
this.updateCreator(value);
|
|
174
166
|
}
|
|
175
167
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
@@ -180,8 +172,8 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
180
172
|
let {
|
|
181
173
|
type
|
|
182
174
|
} = column;
|
|
183
|
-
if (type !==
|
|
184
|
-
if (value !== this.props.value ||
|
|
175
|
+
if (type !== CellType.CREATOR && type !== CellType.LAST_MODIFIER) return;
|
|
176
|
+
if (value !== this.props.value || shallowEqual(nextProps.column, this.props.column)) {
|
|
185
177
|
this.updateCreator(value);
|
|
186
178
|
}
|
|
187
179
|
}
|
|
@@ -192,28 +184,28 @@ class PivotTableDisplayName extends _react.default.Component {
|
|
|
192
184
|
} = this.props;
|
|
193
185
|
const displayName = value && this.getDisplayName(value, column);
|
|
194
186
|
if (!displayName) {
|
|
195
|
-
return /*#__PURE__*/
|
|
187
|
+
return /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get(EMPTY_NAME), ")"));
|
|
196
188
|
}
|
|
197
|
-
return /*#__PURE__*/
|
|
189
|
+
return /*#__PURE__*/React.createElement(Fragment, null, displayName);
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
|
-
|
|
192
|
+
export default PivotTableDisplayName;
|
|
201
193
|
function Collaborator(props) {
|
|
202
194
|
let {
|
|
203
195
|
avatar_url,
|
|
204
196
|
name
|
|
205
197
|
} = props.collaborator || {};
|
|
206
|
-
return /*#__PURE__*/
|
|
198
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
207
199
|
className: "collaborators-formatter"
|
|
208
|
-
}, /*#__PURE__*/
|
|
200
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
209
201
|
className: "collaborator"
|
|
210
|
-
}, /*#__PURE__*/
|
|
202
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
211
203
|
className: "collaborator-avatar-container"
|
|
212
|
-
}, /*#__PURE__*/
|
|
204
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
213
205
|
src: avatar_url,
|
|
214
206
|
alt: name,
|
|
215
207
|
className: "collaborator-avatar"
|
|
216
|
-
})), /*#__PURE__*/
|
|
208
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
217
209
|
className: "collaborator-name",
|
|
218
210
|
title: name,
|
|
219
211
|
"aria-label": name
|