dtable-statistic 4.0.6 → 4.0.8
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/assets/css/dashboard.css +22 -0
- package/es/calculator/basic-chart-calculator.js +27 -18
- package/es/calculator/combination-calculator.js +34 -9
- package/es/calculator/compare-bar-calculator.js +37 -30
- package/es/calculator/heat-map-calculator.js +25 -14
- package/es/calculator/map-calculator.js +25 -14
- package/es/calculator/mirror-calculator.js +29 -14
- package/es/calculator/pivot-table-calculator.js +132 -76
- package/es/calculator/workers/basic-chart-calculator-worker.js +21 -6
- package/es/calculator/workers/combination-calculator-worker.js +20 -5
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -6
- package/es/calculator/workers/mirror-calculator-worker.js +15 -6
- package/es/calculator/workers/pivot-table-calculator-worker.js +97 -44
- package/es/calculator/world-map-calculator.js +25 -14
- package/es/components/dialog/enlarged-chart-dialog.js +2 -2
- package/es/components/dialog/statistic-record-dialog/index.css +2 -0
- package/es/components/dialog/statistic-record-dialog/index.js +80 -52
- package/es/constants/index.js +30 -29
- package/es/dashboard.js +57 -43
- package/es/desktop-dashboard.js +21 -56
- package/es/index.js +34 -2
- package/es/locale/lang/de.js +7 -3
- package/es/locale/lang/en.js +5 -1
- package/es/locale/lang/fr.js +7 -3
- package/es/locale/lang/zh_CN.js +5 -1
- package/es/mobile-dashboard.js +5 -5
- package/es/model/horizontal-bar-group.js +2 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +1 -2
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +20 -3
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +2 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +23 -2
- package/es/stat-list/chart-preview.js +3 -4
- package/es/stat-list/index.js +10 -4
- package/es/stat-view/area-chart.js +177 -162
- package/es/stat-view/bar-chart.js +221 -222
- package/es/stat-view/base-chart.js +79 -7
- package/es/stat-view/basic-number-card.js +11 -19
- package/es/stat-view/combination-chart.js +100 -83
- package/es/stat-view/compare-chart.js +133 -144
- package/es/stat-view/completeness-chart.js +108 -102
- package/es/stat-view/custom-bar.js +79 -99
- package/es/stat-view/dashboard-chart.js +57 -57
- package/es/stat-view/heat-map.js +13 -32
- package/es/stat-view/horizontal-bar-chart.js +200 -230
- package/es/stat-view/index.js +2 -2
- package/es/stat-view/line-chart.js +162 -158
- package/es/stat-view/map.js +26 -40
- package/es/stat-view/mirror.js +88 -94
- package/es/stat-view/pie-chart.js +11 -39
- package/es/stat-view/pivot-table/index.js +4 -16
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +36 -23
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +11 -5
- package/es/stat-view/pivot-table/pivot-table-display-name.js +206 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +104 -60
- package/es/stat-view/ring-chart.js +24 -42
- package/es/stat-view/scatter-chart.js +4 -21
- package/es/stat-view/treemap-chart.js +3 -12
- package/es/stat-view/trend-chart.js +6 -17
- package/es/stat-view/world-map.js +39 -50
- package/es/tabs/tab.js +2 -1
- package/es/utils/collaborator.js +9 -0
- package/es/utils/common-utils.js +24 -6
- package/es/utils/index.js +1 -1
- package/es/utils/sql-utils.js +10 -9
- package/es/utils/stat-utils.js +8 -5
- package/package.json +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Fragment } from 'react';
|
|
6
|
+
import intl from 'react-intl-universal';
|
|
7
|
+
import { getOption, getCollaborator, CellType, getNumberDisplayString, isNumber, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE } from 'dtable-store';
|
|
8
|
+
import { getClientFormulaDisplayString, getKnownCreatorByEmail, generateDefaultUser, getSelectColumnOptions } from '../../utils';
|
|
9
|
+
import { shallowEqual } from '../../utils/common-utils';
|
|
10
|
+
import { EMPTY_NAME } from '../../constants';
|
|
11
|
+
var PivotTableDisplayName = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(PivotTableDisplayName, _React$Component);
|
|
13
|
+
var _super = _createSuper(PivotTableDisplayName);
|
|
14
|
+
function PivotTableDisplayName(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
_classCallCheck(this, PivotTableDisplayName);
|
|
17
|
+
_this = _super.call(this, props);
|
|
18
|
+
_this.updateCreator = function (email) {
|
|
19
|
+
if (!window || !window.app) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var collaborators = window.app.state.collaborators;
|
|
23
|
+
var creator = getKnownCreatorByEmail(collaborators, email);
|
|
24
|
+
if (creator) {
|
|
25
|
+
_this.setState({
|
|
26
|
+
creator: creator
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var dtableCollaborators = window.app.collaboratorsCache;
|
|
31
|
+
window.app.queryUsers([email], function (emailUserMap) {
|
|
32
|
+
creator = emailUserMap && emailUserMap[email];
|
|
33
|
+
if (creator) {
|
|
34
|
+
dtableCollaborators[email] = creator;
|
|
35
|
+
_this.setState({
|
|
36
|
+
creator: creator
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// error handle
|
|
42
|
+
creator = generateDefaultUser(email);
|
|
43
|
+
dtableCollaborators[email] = creator;
|
|
44
|
+
_this.setState({
|
|
45
|
+
creator: creator
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
_this.getDisplayName = function (value, column) {
|
|
50
|
+
var type = column.type,
|
|
51
|
+
data = column.data;
|
|
52
|
+
var collaborators = window.app.state.collaborators;
|
|
53
|
+
var displayName;
|
|
54
|
+
switch (type) {
|
|
55
|
+
case CellType.SINGLE_SELECT:
|
|
56
|
+
case CellType.MULTIPLE_SELECT:
|
|
57
|
+
{
|
|
58
|
+
var options = getSelectColumnOptions(column);
|
|
59
|
+
var option = getOption(options, value) || {};
|
|
60
|
+
var optionName = option.name,
|
|
61
|
+
color = option.color,
|
|
62
|
+
textColor = option.textColor;
|
|
63
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
style: {
|
|
65
|
+
color: textColor,
|
|
66
|
+
backgroundColor: color
|
|
67
|
+
},
|
|
68
|
+
className: "multiple-select-option d-inline-block align-middle mw-100",
|
|
69
|
+
title: optionName,
|
|
70
|
+
"aria-label": optionName
|
|
71
|
+
}, optionName);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case CellType.COLLABORATOR:
|
|
75
|
+
{
|
|
76
|
+
var collaborator = getCollaborator(collaborators, value) || {};
|
|
77
|
+
displayName = /*#__PURE__*/React.createElement(Collaborator, {
|
|
78
|
+
collaborator: collaborator
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case CellType.CREATOR:
|
|
83
|
+
case CellType.LAST_MODIFIER:
|
|
84
|
+
{
|
|
85
|
+
var creator = _this.state.creator;
|
|
86
|
+
displayName = /*#__PURE__*/React.createElement(Collaborator, {
|
|
87
|
+
collaborator: creator
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case CellType.NUMBER:
|
|
92
|
+
{
|
|
93
|
+
var displayValue = isNumber(value) ? getNumberDisplayString(value, data) : value;
|
|
94
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
title: displayValue,
|
|
96
|
+
"aria-label": displayValue
|
|
97
|
+
}, displayValue);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
case CellType.LINK:
|
|
101
|
+
{
|
|
102
|
+
var _displayValue = getClientFormulaDisplayString([value], data, {
|
|
103
|
+
collaborators: collaborators
|
|
104
|
+
}) || null;
|
|
105
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
title: _displayValue,
|
|
107
|
+
"aria-label": _displayValue
|
|
108
|
+
}, _displayValue);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case CellType.FORMULA:
|
|
112
|
+
case CellType.LINK_FORMULA:
|
|
113
|
+
{
|
|
114
|
+
var _displayValue2 = value;
|
|
115
|
+
var _ref = data || {},
|
|
116
|
+
result_type = _ref.result_type,
|
|
117
|
+
array_type = _ref.array_type;
|
|
118
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
119
|
+
var valueNumber = parseFloat(value);
|
|
120
|
+
_displayValue2 = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
|
|
121
|
+
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
122
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
123
|
+
var currentCollaborators = Array.isArray(value) ? value : [value];
|
|
124
|
+
_displayValue2 = currentCollaborators.map(function (email) {
|
|
125
|
+
var user = array_type === CellType.COLLABORATOR ? getCollaborator(collaborators, email) : getKnownCreatorByEmail(collaborators, email);
|
|
126
|
+
return (user || {}).name;
|
|
127
|
+
});
|
|
128
|
+
_displayValue2 = _displayValue2 + '';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
title: _displayValue2,
|
|
133
|
+
"aria-label": _displayValue2
|
|
134
|
+
}, _displayValue2);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default:
|
|
138
|
+
{
|
|
139
|
+
var _displayValue3 = typeof value !== 'string' ? String(value) : value;
|
|
140
|
+
displayName = /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
title: _displayValue3,
|
|
142
|
+
"aria-label": _displayValue3
|
|
143
|
+
}, _displayValue3);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return displayName;
|
|
148
|
+
};
|
|
149
|
+
_this.state = {
|
|
150
|
+
creator: {}
|
|
151
|
+
};
|
|
152
|
+
return _this;
|
|
153
|
+
}
|
|
154
|
+
_createClass(PivotTableDisplayName, [{
|
|
155
|
+
key: "componentDidMount",
|
|
156
|
+
value: function componentDidMount() {
|
|
157
|
+
var _this$props = this.props,
|
|
158
|
+
column = _this$props.column,
|
|
159
|
+
value = _this$props.value;
|
|
160
|
+
if (column.type !== CellType.CREATOR && column.type !== CellType.LAST_MODIFIER) return;
|
|
161
|
+
this.updateCreator(value);
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
165
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
166
|
+
var column = nextProps.column,
|
|
167
|
+
value = nextProps.value;
|
|
168
|
+
var type = column.type;
|
|
169
|
+
if (type !== CellType.CREATOR && type !== CellType.LAST_MODIFIER) return;
|
|
170
|
+
if (value !== this.props.value || shallowEqual(nextProps.column, this.props.column)) {
|
|
171
|
+
this.updateCreator(value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "render",
|
|
176
|
+
value: function render() {
|
|
177
|
+
var _this$props2 = this.props,
|
|
178
|
+
value = _this$props2.value,
|
|
179
|
+
column = _this$props2.column;
|
|
180
|
+
var displayName = value ? this.getDisplayName(value, column) : /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get(EMPTY_NAME), ")"));
|
|
181
|
+
return /*#__PURE__*/React.createElement(Fragment, null, displayName);
|
|
182
|
+
}
|
|
183
|
+
}]);
|
|
184
|
+
return PivotTableDisplayName;
|
|
185
|
+
}(React.Component);
|
|
186
|
+
export default PivotTableDisplayName;
|
|
187
|
+
function Collaborator(props) {
|
|
188
|
+
var _ref2 = props.collaborator || {},
|
|
189
|
+
avatar_url = _ref2.avatar_url,
|
|
190
|
+
name = _ref2.name;
|
|
191
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
className: "collaborators-formatter"
|
|
193
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
className: "collaborator"
|
|
195
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
196
|
+
className: "collaborator-avatar-container"
|
|
197
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
198
|
+
src: avatar_url,
|
|
199
|
+
alt: name,
|
|
200
|
+
className: "collaborator-avatar"
|
|
201
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
202
|
+
className: "collaborator-name",
|
|
203
|
+
title: name,
|
|
204
|
+
"aria-label": name
|
|
205
|
+
}, name)));
|
|
206
|
+
}
|
|
@@ -7,8 +7,9 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
7
7
|
import React, { PureComponent } from 'react';
|
|
8
8
|
import intl from 'react-intl-universal';
|
|
9
9
|
import { CellType, isNumber, TableUtils, Views } from 'dtable-store';
|
|
10
|
+
import PivotTableDisplayName from './pivot-table-display-name';
|
|
10
11
|
import { isMobile } from '../../utils';
|
|
11
|
-
import {
|
|
12
|
+
import { TITLE_TOTAL } from '../../constants';
|
|
12
13
|
import styles from './statistic-pivot-table.module.css';
|
|
13
14
|
var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
14
15
|
_inherits(TwoDimensionTable, _PureComponent);
|
|
@@ -59,7 +60,9 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
59
60
|
return 0;
|
|
60
61
|
};
|
|
61
62
|
_this.getCells = function (row, summaryColumn) {
|
|
62
|
-
var
|
|
63
|
+
var _this$props2 = _this.props,
|
|
64
|
+
pivotResult = _this$props2.pivotResult,
|
|
65
|
+
getSummaryValueDisplayString = _this$props2.getSummaryValueDisplayString;
|
|
63
66
|
var pivot_columns = pivotResult.pivot_columns,
|
|
64
67
|
pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns,
|
|
65
68
|
formulaRows = pivotResult.formulaRows,
|
|
@@ -72,39 +75,49 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
72
75
|
return pivot_columns.map(function (item) {
|
|
73
76
|
var cell = cells[item.key];
|
|
74
77
|
var rowData = cell && cell.rows;
|
|
75
|
-
var summary_multiple_columns =
|
|
78
|
+
var summary_multiple_columns = [];
|
|
79
|
+
var formatted_summary_multiple_columns = [];
|
|
80
|
+
pivot_summary_multiple_columns.forEach(function (column) {
|
|
81
|
+
var key = column.key,
|
|
82
|
+
type = column.type,
|
|
83
|
+
sqlKey = column.sqlKey,
|
|
84
|
+
method = column.method;
|
|
76
85
|
if (Array.isArray(rowData)) {
|
|
77
86
|
var sum = 0;
|
|
78
87
|
rowData.forEach(function (rowDataItem) {
|
|
79
88
|
if (!isSqlQuery) {
|
|
80
|
-
if (
|
|
89
|
+
if (type === CellType.FORMULA) {
|
|
81
90
|
var formulaRow = formulaRows[rowDataItem._id];
|
|
82
|
-
sum += _this.getNumberValue(formulaRow[
|
|
91
|
+
sum += _this.getNumberValue(formulaRow[key]);
|
|
83
92
|
return;
|
|
84
93
|
}
|
|
85
|
-
sum += _this.getNumberValue(rowDataItem[
|
|
94
|
+
sum += _this.getNumberValue(rowDataItem[key]);
|
|
86
95
|
return;
|
|
87
96
|
}
|
|
88
|
-
sum += _this.getNumberValue(rowDataItem[
|
|
97
|
+
sum += _this.getNumberValue(rowDataItem[sqlKey]);
|
|
89
98
|
});
|
|
90
|
-
|
|
99
|
+
summary_multiple_columns.push(sum);
|
|
100
|
+
formatted_summary_multiple_columns.push(getSummaryValueDisplayString(column, sum, method));
|
|
101
|
+
return;
|
|
91
102
|
}
|
|
92
|
-
|
|
103
|
+
summary_multiple_columns.push(0);
|
|
104
|
+
formatted_summary_multiple_columns.push(getSummaryValueDisplayString(column, 0, method));
|
|
93
105
|
});
|
|
94
106
|
return _objectSpread(_objectSpread({}, cells[item.key]), {}, {
|
|
95
107
|
group_original_name: item.original_name,
|
|
96
108
|
group_name: item.key,
|
|
97
109
|
column: summaryColumn,
|
|
98
|
-
summary_multiple_columns: summary_multiple_columns
|
|
110
|
+
summary_multiple_columns: summary_multiple_columns,
|
|
111
|
+
formatted_summary_multiple_columns: formatted_summary_multiple_columns
|
|
99
112
|
});
|
|
100
113
|
});
|
|
101
114
|
};
|
|
102
115
|
_this.renderHeader = function (_ref3) {
|
|
103
116
|
var groupbyColumn = _ref3.groupbyColumn,
|
|
104
117
|
columnGroupbyColumn = _ref3.columnGroupbyColumn;
|
|
105
|
-
var _this$
|
|
106
|
-
pivotResult = _this$
|
|
107
|
-
statItem = _this$
|
|
118
|
+
var _this$props3 = _this.props,
|
|
119
|
+
pivotResult = _this$props3.pivotResult,
|
|
120
|
+
statItem = _this$props3.statItem;
|
|
108
121
|
var column_groupby_column_key = statItem.column_groupby_column_key,
|
|
109
122
|
column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
|
|
110
123
|
_statItem$display_tot = statItem.display_total,
|
|
@@ -118,11 +131,14 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
118
131
|
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
119
132
|
className: "pivot-table-header"
|
|
120
133
|
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
|
|
121
|
-
var
|
|
134
|
+
var original_key = item.original_key;
|
|
122
135
|
return /*#__PURE__*/React.createElement("th", {
|
|
123
136
|
className: 'pivot-table-header',
|
|
124
137
|
key: "pivot-column-".concat(index)
|
|
125
|
-
}, /*#__PURE__*/React.createElement(
|
|
138
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
139
|
+
value: original_key,
|
|
140
|
+
column: columnGroupbyColumn
|
|
141
|
+
}));
|
|
126
142
|
}), display_total && /*#__PURE__*/React.createElement("th", {
|
|
127
143
|
className: 'pivot-table-header'
|
|
128
144
|
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL)))), isMultipleColumnHeader && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
@@ -142,12 +158,49 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
142
158
|
className: "pivot-table-header ".concat(styles['pivot-empty-cell'])
|
|
143
159
|
})));
|
|
144
160
|
};
|
|
161
|
+
_this.renderRowTotal = function (isValidSummaryDisplayValue, summaryDisplayValue, cells, pivotRowCells, rowItem, firstSummaryColumnFromMultiple) {
|
|
162
|
+
var rowTotal = summaryDisplayValue;
|
|
163
|
+
if (firstSummaryColumnFromMultiple) {
|
|
164
|
+
rowTotal = _this.props.getSummaryValueDisplayString(firstSummaryColumnFromMultiple, summaryDisplayValue, firstSummaryColumnFromMultiple.method);
|
|
165
|
+
}
|
|
166
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
167
|
+
className: "".concat(styles['pivot-cell'], " ").concat(isValidSummaryDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
168
|
+
title: isValidSummaryDisplayValue ? rowTotal : '',
|
|
169
|
+
onClick: function onClick() {
|
|
170
|
+
return _this.toggleRecords({
|
|
171
|
+
rows: Array.isArray(cells) && cells.length > 0 ? pivotRowCells : rowItem.rows,
|
|
172
|
+
name: rowItem.name,
|
|
173
|
+
rowItem: rowItem,
|
|
174
|
+
original_name: rowItem.original_name
|
|
175
|
+
}, {
|
|
176
|
+
isRow: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}, isValidSummaryDisplayValue ? /*#__PURE__*/React.createElement("div", null, rowTotal) : /*#__PURE__*/React.createElement("i", null));
|
|
180
|
+
};
|
|
181
|
+
_this.renderAllTotal = function (allTotalDisplay, pivotColumnCells, firstSummaryColumnFromMultiple) {
|
|
182
|
+
var isValidAllTotalDisplay = _this.props.isValidValue(allTotalDisplay);
|
|
183
|
+
var allTotal = allTotalDisplay;
|
|
184
|
+
if (firstSummaryColumnFromMultiple) {
|
|
185
|
+
allTotal = _this.props.getSummaryValueDisplayString(firstSummaryColumnFromMultiple, allTotalDisplay, firstSummaryColumnFromMultiple.method);
|
|
186
|
+
}
|
|
187
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
188
|
+
className: "".concat(styles['pivot-cell'], " pivot-table-total ").concat(isValidAllTotalDisplay ? '' : styles['pivot-empty-cell']),
|
|
189
|
+
onClick: function onClick() {
|
|
190
|
+
return _this.onClickTotals(pivotColumnCells, {
|
|
191
|
+
isCurrentView: true
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
title: isValidAllTotalDisplay ? allTotal : ''
|
|
195
|
+
}, isValidAllTotalDisplay ? /*#__PURE__*/React.createElement("div", null, allTotal) : /*#__PURE__*/React.createElement("i", null));
|
|
196
|
+
};
|
|
145
197
|
_this.renderRows = function (_ref5) {
|
|
146
|
-
var table = _ref5.table
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
198
|
+
var table = _ref5.table,
|
|
199
|
+
groupbyColumn = _ref5.groupbyColumn;
|
|
200
|
+
var _this$props4 = _this.props,
|
|
201
|
+
pivotResult = _this$props4.pivotResult,
|
|
202
|
+
statItem = _this$props4.statItem,
|
|
203
|
+
getSummaryValueDisplayString = _this$props4.getSummaryValueDisplayString;
|
|
151
204
|
var summary_column_key = statItem.summary_column_key,
|
|
152
205
|
summary_method = statItem.summary_method,
|
|
153
206
|
column_groupby_multiple_numeric_column = statItem.column_groupby_multiple_numeric_column,
|
|
@@ -163,10 +216,11 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
163
216
|
isSqlQuery = _pivotResult$isSqlQue2 === void 0 ? false : _pivotResult$isSqlQue2;
|
|
164
217
|
var summaryColumn = TableUtils.getTableColumnByKey(table, summary_column_key) || {};
|
|
165
218
|
var allTotalDisplay = column_groupby_multiple_numeric_column ? 0 : getSummaryValueDisplayString(summaryColumn, pivot_table_total, summary_method);
|
|
166
|
-
var
|
|
219
|
+
var firstSummaryColumnFromMultiple = column_groupby_multiple_numeric_column && pivot_summary_multiple_columns[0] || null;
|
|
167
220
|
var pivotColumnCells = [];
|
|
168
221
|
return /*#__PURE__*/React.createElement("tbody", null, pivot_rows.map(function (rowItem, rowIdx) {
|
|
169
222
|
var name = rowItem.name,
|
|
223
|
+
original_name = rowItem.original_name,
|
|
170
224
|
total = rowItem.total;
|
|
171
225
|
var cells = _this.getCells(rowItem, summaryColumn);
|
|
172
226
|
var pivotRowCells = [];
|
|
@@ -182,7 +236,10 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
182
236
|
key: 'table-row' + rowIdx
|
|
183
237
|
}, /*#__PURE__*/React.createElement("td", {
|
|
184
238
|
className: 'pivot-row-name'
|
|
185
|
-
}, /*#__PURE__*/React.createElement(
|
|
239
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
240
|
+
value: original_name,
|
|
241
|
+
column: groupbyColumn
|
|
242
|
+
})), Array.isArray(cells) && cells.map(function (c, cellIdx) {
|
|
186
243
|
if (c && Array.isArray(c.rows) && c.rows.length > 0) {
|
|
187
244
|
pivotRowCells.push.apply(pivotRowCells, _toConsumableArray(c.rows));
|
|
188
245
|
if (pivotColumnCells[cellIdx]) {
|
|
@@ -193,7 +250,8 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
193
250
|
}
|
|
194
251
|
}
|
|
195
252
|
if (column_groupby_multiple_numeric_column) {
|
|
196
|
-
var summary_multiple_columns = c.summary_multiple_columns
|
|
253
|
+
var summary_multiple_columns = c.summary_multiple_columns,
|
|
254
|
+
formatted_summary_multiple_columns = c.formatted_summary_multiple_columns;
|
|
197
255
|
summary_multiple_columns.forEach(function (item) {
|
|
198
256
|
summaryDisplayValue += _this.getNumberValue(item);
|
|
199
257
|
});
|
|
@@ -212,12 +270,11 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
212
270
|
}
|
|
213
271
|
}, /*#__PURE__*/React.createElement("div", {
|
|
214
272
|
className: styles['pivot-summary-multiple-columns-div']
|
|
215
|
-
},
|
|
273
|
+
}, formatted_summary_multiple_columns.map(function (label, index) {
|
|
216
274
|
return /*#__PURE__*/React.createElement("div", {
|
|
217
|
-
key: index
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}) : label);
|
|
275
|
+
key: index,
|
|
276
|
+
title: label
|
|
277
|
+
}, label);
|
|
221
278
|
})), /*#__PURE__*/React.createElement("span", null));
|
|
222
279
|
}
|
|
223
280
|
var displayValue = getSummaryValueDisplayString(c.column, c.total, summary_method);
|
|
@@ -237,27 +294,14 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
237
294
|
});
|
|
238
295
|
}
|
|
239
296
|
}, isValidDisplayValue ? /*#__PURE__*/React.createElement("div", null, displayValue) : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", null));
|
|
240
|
-
}), display_total &&
|
|
241
|
-
className: "".concat(styles['pivot-cell'], " ").concat(isValidSummaryDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
242
|
-
title: isValidSummaryDisplayValue ? summaryDisplayValue : '',
|
|
243
|
-
onClick: function onClick() {
|
|
244
|
-
return _this.toggleRecords({
|
|
245
|
-
rows: Array.isArray(cells) && cells.length > 0 ? pivotRowCells : rowItem.rows,
|
|
246
|
-
name: name,
|
|
247
|
-
rowItem: rowItem,
|
|
248
|
-
original_name: rowItem.original_name
|
|
249
|
-
}, {
|
|
250
|
-
isRow: true
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
}, isValidSummaryDisplayValue ? /*#__PURE__*/React.createElement("div", null, summaryDisplayValue) : /*#__PURE__*/React.createElement("i", null)));
|
|
297
|
+
}), display_total && _this.renderRowTotal(isValidSummaryDisplayValue, summaryDisplayValue, cells, pivotRowCells, rowItem, firstSummaryColumnFromMultiple));
|
|
254
298
|
}), display_total && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
255
299
|
className: 'pivot-column-total'
|
|
256
300
|
}, /*#__PURE__*/React.createElement("div", null, intl.get(TITLE_TOTAL))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
|
|
257
301
|
var pivotColumnCell = pivotColumnCells[index] || [];
|
|
258
302
|
var pivotColumnTotal = pivot_columns_total[c.key];
|
|
259
|
-
var totalDisplayValue =
|
|
260
|
-
var isValidTotalDisplayValue =
|
|
303
|
+
var totalDisplayValue = 0;
|
|
304
|
+
var isValidTotalDisplayValue = true;
|
|
261
305
|
if (column_groupby_multiple_numeric_column) {
|
|
262
306
|
var total = 0;
|
|
263
307
|
pivotColumnCell.forEach(function (item) {
|
|
@@ -279,6 +323,13 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
279
323
|
});
|
|
280
324
|
totalDisplayValue = total;
|
|
281
325
|
allTotalDisplay += total;
|
|
326
|
+
isValidTotalDisplayValue = _this.props.isValidValue(totalDisplayValue);
|
|
327
|
+
if (firstSummaryColumnFromMultiple) {
|
|
328
|
+
totalDisplayValue = getSummaryValueDisplayString(firstSummaryColumnFromMultiple, totalDisplayValue, firstSummaryColumnFromMultiple.method);
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
totalDisplayValue = getSummaryValueDisplayString(summaryColumn, pivotColumnTotal, summary_method);
|
|
332
|
+
isValidTotalDisplayValue = _this.props.isValidValue(totalDisplayValue);
|
|
282
333
|
}
|
|
283
334
|
return /*#__PURE__*/React.createElement("td", {
|
|
284
335
|
className: "".concat(styles['pivot-cell'], " ").concat(isValidTotalDisplayValue ? '' : styles['pivot-empty-cell']),
|
|
@@ -294,27 +345,19 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
294
345
|
});
|
|
295
346
|
}
|
|
296
347
|
}, isValidTotalDisplayValue ? /*#__PURE__*/React.createElement("div", null, totalDisplayValue) : /*#__PURE__*/React.createElement("i", null));
|
|
297
|
-
}),
|
|
298
|
-
className: "".concat(styles['pivot-cell'], " pivot-table-total ").concat(isValidAllTotalDisplay ? '' : styles['pivot-empty-cell']),
|
|
299
|
-
onClick: function onClick() {
|
|
300
|
-
return _this.onClickTotals(pivotColumnCells, {
|
|
301
|
-
isCurrentView: true
|
|
302
|
-
});
|
|
303
|
-
},
|
|
304
|
-
title: isValidAllTotalDisplay ? allTotalDisplay : ''
|
|
305
|
-
}, isValidAllTotalDisplay ? /*#__PURE__*/React.createElement("div", null, allTotalDisplay) : /*#__PURE__*/React.createElement("i", null))));
|
|
348
|
+
}), _this.renderAllTotal(allTotalDisplay, pivotColumnCells, firstSummaryColumnFromMultiple)));
|
|
306
349
|
};
|
|
307
350
|
return _this;
|
|
308
351
|
}
|
|
309
352
|
_createClass(TwoDimensionTable, [{
|
|
310
353
|
key: "render",
|
|
311
354
|
value: function render() {
|
|
312
|
-
var _this$
|
|
313
|
-
pivotResult = _this$
|
|
314
|
-
statItem = _this$
|
|
315
|
-
isPreview = _this$
|
|
316
|
-
textColor = _this$
|
|
317
|
-
getTableById = _this$
|
|
355
|
+
var _this$props5 = this.props,
|
|
356
|
+
pivotResult = _this$props5.pivotResult,
|
|
357
|
+
statItem = _this$props5.statItem,
|
|
358
|
+
isPreview = _this$props5.isPreview,
|
|
359
|
+
textColor = _this$props5.textColor,
|
|
360
|
+
getTableById = _this$props5.getTableById;
|
|
318
361
|
if (!pivotResult) return '';
|
|
319
362
|
var table_id = statItem.table_id,
|
|
320
363
|
groupby_column_key = statItem.groupby_column_key,
|
|
@@ -335,7 +378,8 @@ var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
|
335
378
|
groupbyColumn: groupbyColumn,
|
|
336
379
|
columnGroupbyColumn: columnGroupbyColumn
|
|
337
380
|
}), this.renderRows({
|
|
338
|
-
table: table
|
|
381
|
+
table: table,
|
|
382
|
+
groupbyColumn: groupbyColumn
|
|
339
383
|
}));
|
|
340
384
|
}
|
|
341
385
|
}]);
|