dtable-statistic 4.2.2 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/es/api/dtable-db-api.js +31 -37
  2. package/es/calculator/base-calculator.js +49 -99
  3. package/es/calculator/basic-chart-calculator.js +335 -559
  4. package/es/calculator/combination-calculator.js +231 -299
  5. package/es/calculator/compare-bar-calculator.js +184 -281
  6. package/es/calculator/completeness-calculator.js +203 -288
  7. package/es/calculator/copy-value.js +18 -18
  8. package/es/calculator/dashboard-calculator.js +68 -137
  9. package/es/calculator/heat-map-calculator.js +139 -220
  10. package/es/calculator/horizontal-bar-calculator.js +64 -93
  11. package/es/calculator/index.js +53 -69
  12. package/es/calculator/map-calculator.js +98 -174
  13. package/es/calculator/mirror-calculator.js +137 -216
  14. package/es/calculator/number-card-calculator.js +58 -126
  15. package/es/calculator/pivot-table-calculator.js +750 -792
  16. package/es/calculator/scatter-calculator.js +72 -140
  17. package/es/calculator/thread-manager.js +48 -67
  18. package/es/calculator/trend-calculator.js +107 -191
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +194 -165
  20. package/es/calculator/workers/calculator.worker.js +22 -6
  21. package/es/calculator/workers/card-calculator-worker.js +16 -14
  22. package/es/calculator/workers/combination-calculator-worker.js +128 -135
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +80 -96
  24. package/es/calculator/workers/completeness-calculator-worker.js +56 -49
  25. package/es/calculator/workers/dashboard-calculator-worker.js +24 -22
  26. package/es/calculator/workers/mirror-calculator-worker.js +52 -52
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +247 -230
  28. package/es/calculator/workers/scatter-calculator-worker.js +34 -32
  29. package/es/calculator/workers/trend-calculator-worker.js +33 -29
  30. package/es/calculator/world-map-calculator.js +120 -197
  31. package/es/components/common-add-tool.js +7 -5
  32. package/es/components/dialog/chart-addition-edit-dialog.js +67 -77
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +57 -67
  34. package/es/components/dialog/color-theme-dialog.js +34 -47
  35. package/es/components/dialog/delete-confirmation-dialog.js +7 -5
  36. package/es/components/dialog/enlarged-chart-dialog.js +68 -81
  37. package/es/components/dialog/new-table-dialog.js +62 -80
  38. package/es/components/dialog/new-view-dialog.js +50 -62
  39. package/es/components/dialog/rename-view-dialog.js +49 -58
  40. package/es/components/dialog/statistic-record-dialog/index.js +233 -231
  41. package/es/components/dialog/statistic-types-dialog/index.js +40 -49
  42. package/es/components/dialog/table-select-dialog.js +61 -70
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +129 -142
  44. package/es/components/dtable-popover.js +62 -81
  45. package/es/components/dtable-search-input.js +89 -99
  46. package/es/components/dtable-select.js +55 -74
  47. package/es/components/icon.js +5 -3
  48. package/es/components/loading.js +1 -1
  49. package/es/components/modal-portal.js +15 -32
  50. package/es/components/popover/color-rules/color-rule.js +137 -141
  51. package/es/components/popover/color-rules/index.js +58 -66
  52. package/es/components/popover/color-rules/rule-filters/filter.js +124 -124
  53. package/es/components/popover/color-rules/rule-filters/index.js +50 -58
  54. package/es/components/popover/color-rules/rule-filters/number-input.js +42 -57
  55. package/es/components/popover/color-rules-popover.js +117 -121
  56. package/es/components/popover/color-selector-popover.js +60 -70
  57. package/es/components/seatable-radio/index.js +2 -2
  58. package/es/components/select/option-group.js +139 -157
  59. package/es/components/select/option.js +26 -40
  60. package/es/components/select/select.js +97 -112
  61. package/es/components/toast/alert.js +65 -80
  62. package/es/components/toast/index.js +1 -1
  63. package/es/components/toast/toast.js +76 -103
  64. package/es/components/toast/toastManager.js +57 -93
  65. package/es/components/toast/toaster.js +58 -56
  66. package/es/constants/color-rules.js +8 -5
  67. package/es/constants/dtable-select-style.js +44 -48
  68. package/es/constants/event-types.js +4 -4
  69. package/es/constants/index.js +328 -242
  70. package/es/constants/map.js +2 -2
  71. package/es/constants/model.js +20 -20
  72. package/es/constants/regions.js +1 -1
  73. package/es/constants/zIndexes.js +1 -1
  74. package/es/custom-g2.js +11 -11
  75. package/es/dashboard.js +343 -333
  76. package/es/desktop-dashboard.js +217 -224
  77. package/es/index.js +45 -58
  78. package/es/locale/index.js +3 -3
  79. package/es/locale/lang/de.js +1 -1
  80. package/es/locale/lang/en.js +7 -7
  81. package/es/locale/lang/fr.js +1 -1
  82. package/es/locale/lang/zh_CN.js +1 -1
  83. package/es/mobile-dashboard.js +76 -89
  84. package/es/model/bar-group.js +34 -44
  85. package/es/model/bar.js +26 -36
  86. package/es/model/base-model.js +11 -12
  87. package/es/model/basic-number-card.js +10 -20
  88. package/es/model/collaborators.js +10 -11
  89. package/es/model/combination.js +32 -42
  90. package/es/model/compare-bar.js +30 -40
  91. package/es/model/completeness-group.js +19 -29
  92. package/es/model/completeness.js +14 -24
  93. package/es/model/custom-bar.js +14 -24
  94. package/es/model/dashboard.js +9 -19
  95. package/es/model/generic-model.js +187 -197
  96. package/es/model/heat-map.js +16 -26
  97. package/es/model/horizontal-bar-group.js +32 -42
  98. package/es/model/horizontal-bar.js +26 -36
  99. package/es/model/index.js +31 -3
  100. package/es/model/map.js +20 -30
  101. package/es/model/mirror.js +15 -25
  102. package/es/model/pie.js +21 -31
  103. package/es/model/ring.js +23 -33
  104. package/es/model/scatter.js +11 -21
  105. package/es/model/statistic-dashboard.js +7 -8
  106. package/es/model/table.js +19 -29
  107. package/es/model/trend.js +15 -25
  108. package/es/model/world-map.js +17 -27
  109. package/es/service/chart-service.js +69 -65
  110. package/es/service/dashboard-service.js +421 -419
  111. package/es/service/map-json.js +112 -132
  112. package/es/stat-editor/chart-name-editor.js +44 -58
  113. package/es/stat-editor/index.js +59 -70
  114. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +93 -98
  115. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +246 -248
  116. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +127 -126
  117. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +5 -3
  118. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +78 -90
  119. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +146 -150
  120. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +88 -98
  121. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +100 -118
  122. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +161 -148
  123. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +58 -66
  124. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +58 -60
  125. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +152 -148
  126. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +101 -105
  127. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +81 -91
  128. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +110 -122
  129. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +101 -113
  130. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +130 -120
  131. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +88 -102
  132. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +88 -102
  133. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +200 -194
  134. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +98 -110
  135. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +106 -118
  136. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +212 -223
  137. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +109 -119
  138. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +329 -319
  139. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +82 -90
  140. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +58 -65
  141. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +126 -116
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +201 -182
  143. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +79 -79
  144. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +196 -175
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +35 -50
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +180 -147
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +31 -40
  148. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +56 -67
  149. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +60 -69
  150. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +165 -158
  151. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +61 -74
  152. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +199 -193
  153. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +25 -38
  154. package/es/stat-editor/stat-settings/color-setting/color-picker.js +79 -86
  155. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +138 -120
  156. package/es/stat-editor/stat-settings/map/map-level.js +31 -43
  157. package/es/stat-editor/stat-settings/map/map-province-city.js +82 -83
  158. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +48 -50
  159. package/es/stat-editor/stat-settings/public-setting/base-settings.js +96 -96
  160. package/es/stat-editor/stat-settings/public-setting/calender.js +69 -75
  161. package/es/stat-editor/stat-settings/public-setting/column-settings.js +5 -3
  162. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +36 -41
  163. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +37 -41
  164. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +25 -38
  165. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +40 -52
  166. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +90 -93
  167. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +23 -36
  168. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +39 -44
  169. package/es/stat-list/chart-preview.js +85 -98
  170. package/es/stat-list/index.js +170 -178
  171. package/es/stat-view/area-chart.js +282 -274
  172. package/es/stat-view/bar-chart.js +300 -292
  173. package/es/stat-view/base-chart.js +58 -52
  174. package/es/stat-view/basic-number-card.js +115 -168
  175. package/es/stat-view/combination-chart.js +298 -334
  176. package/es/stat-view/compare-chart.js +256 -254
  177. package/es/stat-view/completeness-chart.js +194 -206
  178. package/es/stat-view/custom-bar.js +221 -223
  179. package/es/stat-view/dashboard-chart.js +122 -180
  180. package/es/stat-view/heat-map.js +268 -294
  181. package/es/stat-view/horizontal-bar-chart.js +291 -281
  182. package/es/stat-view/index.js +136 -152
  183. package/es/stat-view/line-chart.js +267 -265
  184. package/es/stat-view/map.js +246 -246
  185. package/es/stat-view/mirror.js +141 -152
  186. package/es/stat-view/pie-chart.js +143 -156
  187. package/es/stat-view/pivot-table/index.js +113 -118
  188. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +104 -102
  189. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +116 -118
  190. package/es/stat-view/pivot-table/pivot-table-display-name.js +96 -95
  191. package/es/stat-view/pivot-table/two-dimension-table.js +238 -229
  192. package/es/stat-view/ring-chart.js +189 -200
  193. package/es/stat-view/scatter-chart.js +162 -213
  194. package/es/stat-view/treemap-chart.js +136 -200
  195. package/es/stat-view/trend-chart.js +137 -183
  196. package/es/stat-view/world-map.js +233 -243
  197. package/es/tabs/index.js +164 -169
  198. package/es/tabs/tab.js +101 -116
  199. package/es/utils/basic-chart-utils.js +7 -9
  200. package/es/utils/cell-format.js +48 -51
  201. package/es/utils/cell-value.js +1 -1
  202. package/es/utils/collaborator.js +15 -14
  203. package/es/utils/color-utils.js +48 -37
  204. package/es/utils/column-utils.js +47 -33
  205. package/es/utils/column.js +1 -1
  206. package/es/utils/common-utils.js +111 -117
  207. package/es/utils/date-format.js +17 -17
  208. package/es/utils/export-table-utils.js +507 -396
  209. package/es/utils/index.js +6 -6
  210. package/es/utils/map.js +30 -34
  211. package/es/utils/model.js +3 -5
  212. package/es/utils/object.js +4 -4
  213. package/es/utils/pivot-table.js +20 -20
  214. package/es/utils/row-utils.js +41 -33
  215. package/es/utils/search.js +18 -20
  216. package/es/utils/sql-utils.js +132 -98
  217. package/es/utils/stat-utils.js +303 -320
  218. package/es/utils/trend-utils.js +57 -67
  219. package/package.json +2 -2
@@ -1,4 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import dayjs from 'dayjs';
3
2
  import intl from 'react-intl-universal';
4
3
  import { getOption, getCollaborator, getNumberDisplayString, isNumber, CellType, FORMULA_RESULT_TYPE, FORMULA_COLUMN_TYPES, isDateColumn, TableUtils } from 'dtable-store';
@@ -7,70 +6,76 @@ import { getSelectColumnOptions, getDateColumnFormat } from './column';
7
6
  import { getKnownCreatorByEmail } from './collaborator';
8
7
  import { EMPTY_NAME, STATISTICS_COUNT_TYPE } from '../constants';
9
8
  import { getPivotTableSummaryTotal } from './pivot-table';
10
- var isEmptyName = function isEmptyName(title) {
9
+ const isEmptyName = title => {
11
10
  return title === null || title === '';
12
11
  };
13
- var isSummaryDateColumn = function isSummaryDateColumn(summaryColumn) {
12
+ const isSummaryDateColumn = summaryColumn => {
14
13
  if (!summaryColumn) return false;
15
- var type = summaryColumn.type;
14
+ const {
15
+ type
16
+ } = summaryColumn;
16
17
  return type !== CellType.LINK && isDateColumn(summaryColumn);
17
18
  };
18
19
 
19
20
  // eslint-disable-next-line
20
- var getTableValueDisplayName = function getTableValueDisplayName(value, column) {
21
- var _ref = column || {},
22
- type = _ref.type,
23
- data = _ref.data;
24
- var collaborators = window.app.state.collaborators;
21
+ const getTableValueDisplayName = (value, column) => {
22
+ let {
23
+ type,
24
+ data
25
+ } = column || {};
26
+ let {
27
+ collaborators
28
+ } = window.app.state;
25
29
  switch (type) {
26
30
  case CellType.SINGLE_SELECT:
27
31
  case CellType.MULTIPLE_SELECT:
28
32
  {
29
- var options = getSelectColumnOptions(column);
30
- var option = getOption(options, value) || {};
33
+ let options = getSelectColumnOptions(column);
34
+ let option = getOption(options, value) || {};
31
35
  return option.name;
32
36
  }
33
37
  case CellType.COLLABORATOR:
34
38
  {
35
- var collaborator = getCollaborator(collaborators, value) || {};
39
+ let collaborator = getCollaborator(collaborators, value) || {};
36
40
  return collaborator.name;
37
41
  }
38
42
  case CellType.CREATOR:
39
43
  case CellType.LAST_MODIFIER:
40
44
  {
41
- var _collaborator = getKnownCreatorByEmail(collaborators, value) || {};
42
- return _collaborator.name;
45
+ let collaborator = getKnownCreatorByEmail(collaborators, value) || {};
46
+ return collaborator.name;
43
47
  }
44
48
  case CellType.NUMBER:
45
49
  {
46
- var valueNumber = parseFloat(value);
47
- var displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
50
+ let valueNumber = parseFloat(value);
51
+ let displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
48
52
  return displayValue;
49
53
  }
50
54
  case CellType.DATE:
51
55
  {
52
- var _displayValue = value;
56
+ let displayValue = value;
53
57
  if (value && value.split('-').length === 3) {
54
- var format = getDateColumnFormat(column);
55
- var spaceIndex = format.indexOf(' ');
58
+ let format = getDateColumnFormat(column);
59
+ let spaceIndex = format.indexOf(' ');
56
60
  if (spaceIndex > -1) {
57
61
  format = format.slice(0, spaceIndex);
58
62
  }
59
- _displayValue = dayjs(value).format(format);
63
+ displayValue = dayjs(value).format(format);
60
64
  }
61
- return _displayValue;
65
+ return displayValue;
62
66
  }
63
67
  case CellType.FORMULA:
64
68
  case CellType.LINK_FORMULA:
65
69
  {
66
- var _displayValue2 = value;
67
- var _ref2 = data || {},
68
- result_type = _ref2.result_type;
70
+ let displayValue = value;
71
+ let {
72
+ result_type
73
+ } = data || {};
69
74
  if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
70
- var _valueNumber = parseFloat(value);
71
- _displayValue2 = isNumber(_valueNumber) ? getNumberDisplayString(_valueNumber, data) : value;
75
+ let valueNumber = parseFloat(value);
76
+ displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
72
77
  }
73
- return _displayValue2;
78
+ return displayValue;
74
79
  }
75
80
  default:
76
81
  {
@@ -78,10 +83,12 @@ var getTableValueDisplayName = function getTableValueDisplayName(value, column)
78
83
  }
79
84
  }
80
85
  };
81
- var getValidValueForColumn = function getValidValueForColumn(column, value) {
86
+ const getValidValueForColumn = (column, value) => {
82
87
  if (!column) return '';
83
- var type = column.type,
84
- data = column.data;
88
+ const {
89
+ type,
90
+ data
91
+ } = column;
85
92
  if (FORMULA_COLUMN_TYPES.includes(type)) return '';
86
93
  if (type === CellType.NUMBER) {
87
94
  if (!value && value !== 0) return '';
@@ -91,25 +98,31 @@ var getValidValueForColumn = function getValidValueForColumn(column, value) {
91
98
  if (type === CellType.DATE) {
92
99
  if (!value) return '';
93
100
  if (typeof value !== 'string') return '';
94
- var validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
101
+ const validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
95
102
  return dayjs(value).format(validValueFormat);
96
103
  }
97
104
  if (type === CellType.TEXT) return value ? value : '';
98
105
  return '';
99
106
  };
100
- var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
101
- var statisticalResult = _ref3.statisticalResult;
102
- var pivotResult = statisticalResult.pivotResult,
103
- groupbyColumn = statisticalResult.groupbyColumn,
104
- statisticTableColumns = statisticalResult.statisticTableColumns,
105
- summaryColumn = statisticalResult.summaryColumn;
106
- var pivot_rows = pivotResult.pivot_rows,
107
- pivot_columns = pivotResult.pivot_columns;
108
- var columnMap = {};
109
- var rows = [];
107
+ const exportOneDimensionToTable = _ref => {
108
+ let {
109
+ statisticalResult
110
+ } = _ref;
111
+ const {
112
+ pivotResult,
113
+ groupbyColumn,
114
+ statisticTableColumns,
115
+ summaryColumn
116
+ } = statisticalResult;
117
+ const {
118
+ pivot_rows,
119
+ pivot_columns
120
+ } = pivotResult;
121
+ let columnMap = {};
122
+ let rows = [];
110
123
 
111
124
  // generator columns
112
- var columns = [{
125
+ let columns = [{
113
126
  // first column
114
127
  key: '0000',
115
128
  type: CellType.TEXT,
@@ -119,17 +132,18 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
119
132
 
120
133
  // one dimension table no number columns
121
134
  if (pivot_columns.length < 2) {
122
- var columnData = {
135
+ let columnData = {
123
136
  format: 'number'
124
137
  };
125
- var _isDateSummaryColumn = false;
126
- var isIncludeHour = false;
138
+ let _isDateSummaryColumn = false;
139
+ let isIncludeHour = false;
127
140
  if (summaryColumn) {
128
141
  if (isSummaryDateColumn(summaryColumn)) {
129
- var _ref4 = summaryColumn.data || {},
130
- format = _ref4.format;
142
+ const {
143
+ format
144
+ } = summaryColumn.data || {};
131
145
  columnData = {
132
- format: format
146
+ format
133
147
  };
134
148
  _isDateSummaryColumn = true;
135
149
  isIncludeHour = format && format.indexOf('HH:mm') > -1;
@@ -139,24 +153,25 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
139
153
  such as the data attribute in the function column, which contains other content that is not
140
154
  useful for creating a new column
141
155
  */
142
- var _ref5 = summaryColumn.data || {},
143
- decimal = _ref5.decimal,
144
- thousands = _ref5.thousands,
145
- precision = _ref5.precision,
146
- enable_precision = _ref5.enable_precision,
147
- _format = _ref5.format;
156
+ const {
157
+ decimal,
158
+ thousands,
159
+ precision,
160
+ enable_precision,
161
+ format
162
+ } = summaryColumn.data || {};
148
163
  columnData = {
149
- decimal: decimal,
150
- thousands: thousands,
151
- precision: precision,
152
- enable_precision: enable_precision,
153
- format: _format
164
+ decimal,
165
+ thousands,
166
+ precision,
167
+ enable_precision,
168
+ format
154
169
  };
155
170
  }
156
171
  }
157
172
 
158
173
  // total column
159
- var totalColumn = {
174
+ const totalColumn = {
160
175
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
161
176
  name: intl.get('Total'),
162
177
  data: columnData
@@ -164,41 +179,46 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
164
179
  columns.push(totalColumn);
165
180
 
166
181
  // generator rows
167
- pivot_rows.forEach(function (item) {
168
- var _newRow;
169
- var name = item.name,
170
- original_name = item.original_name,
171
- total = item.total;
172
- var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
173
- var cellValue = total.total;
182
+ pivot_rows.forEach(item => {
183
+ const {
184
+ name,
185
+ original_name,
186
+ total
187
+ } = item;
188
+ const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
189
+ let cellValue = total.total;
174
190
  if (_isDateSummaryColumn && cellValue) {
175
191
  cellValue = isIncludeHour ? dayjs(cellValue).format('YYYY-MM-DD HH:mm') : dayjs(cellValue).format('YYYY-MM-DD');
176
192
  }
177
- var newRow = (_newRow = {}, _defineProperty(_newRow, groupbyColumn.name, groupName), _defineProperty(_newRow, intl.get('Total'), cellValue), _newRow);
193
+ const newRow = {
194
+ [groupbyColumn.name]: groupName,
195
+ [intl.get('Total')]: cellValue
196
+ };
178
197
  rows.push(newRow);
179
198
  });
180
199
  return {
181
- columns: columns,
182
- rows: rows
200
+ columns,
201
+ rows
183
202
  };
184
203
  }
185
204
 
186
205
  // one dimension table with number columns
187
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
188
- var key = item.key;
189
- var column = statisticTableColumns.find(function (column) {
190
- return column.key === key;
191
- });
206
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
207
+ const {
208
+ key
209
+ } = item;
210
+ const column = statisticTableColumns.find(column => column.key === key);
192
211
  if (column) {
193
- var columnName = column.name;
194
- var _columnData;
195
- var columnType = CellType.NUMBER;
212
+ const columnName = column.name;
213
+ let columnData;
214
+ let columnType = CellType.NUMBER;
196
215
  if (isSummaryDateColumn(column)) {
197
216
  columnType = CellType.DATE;
198
- var _ref6 = column.data || {},
199
- _format2 = _ref6.format;
200
- _columnData = {
201
- format: _format2
217
+ const {
218
+ format
219
+ } = column.data || {};
220
+ columnData = {
221
+ format
202
222
  };
203
223
  } else {
204
224
  /*
@@ -206,24 +226,25 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
206
226
  such as the data attribute in the function column, which contains other content that is not
207
227
  useful for creating a new column
208
228
  */
209
- var _ref7 = column.data || {},
210
- _decimal = _ref7.decimal,
211
- _thousands = _ref7.thousands,
212
- _precision = _ref7.precision,
213
- _enable_precision = _ref7.enable_precision,
214
- _format3 = _ref7.format;
215
- _columnData = {
216
- decimal: _decimal,
217
- thousands: _thousands,
218
- precision: _precision,
219
- enable_precision: _enable_precision,
220
- format: _format3
229
+ const {
230
+ decimal,
231
+ thousands,
232
+ precision,
233
+ enable_precision,
234
+ format
235
+ } = column.data || {};
236
+ columnData = {
237
+ decimal,
238
+ thousands,
239
+ precision,
240
+ enable_precision,
241
+ format
221
242
  };
222
243
  }
223
- var newColumn = {
244
+ const newColumn = {
224
245
  type: columnType,
225
246
  name: columnName,
226
- data: _columnData
247
+ data: columnData
227
248
  };
228
249
  columnMap[key] = newColumn;
229
250
  columns.push(newColumn);
@@ -231,23 +252,31 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
231
252
  });
232
253
 
233
254
  // generator rows
234
- pivot_rows.forEach(function (item) {
235
- var name = item.name,
236
- original_name = item.original_name,
237
- total = item.total;
238
- var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
239
- var newRow = _defineProperty({}, groupbyColumn.name, groupName);
240
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
241
- var key = item.key,
242
- method = item.method;
243
- var column = columnMap[key];
244
- var cellValueKey = key + method;
245
- var name = column.name,
246
- type = column.type,
247
- data = column.data;
248
- var cellValue = total[cellValueKey];
255
+ pivot_rows.forEach(item => {
256
+ const {
257
+ name,
258
+ original_name,
259
+ total
260
+ } = item;
261
+ const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
262
+ let newRow = {
263
+ [groupbyColumn.name]: groupName
264
+ };
265
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
266
+ const {
267
+ key,
268
+ method
269
+ } = item;
270
+ const column = columnMap[key];
271
+ const cellValueKey = key + method;
272
+ const {
273
+ name,
274
+ type,
275
+ data
276
+ } = column;
277
+ let cellValue = total[cellValueKey];
249
278
  if (type === CellType.DATE && cellValue) {
250
- var dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
279
+ const dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
251
280
  cellValue = dayjs(cellValue).format(dateFormat);
252
281
  }
253
282
  newRow[name] = cellValue;
@@ -255,40 +284,47 @@ var exportOneDimensionToTable = function exportOneDimensionToTable(_ref3) {
255
284
  rows.push(newRow);
256
285
  });
257
286
  return {
258
- columns: columns,
259
- rows: rows
287
+ columns,
288
+ rows
260
289
  };
261
290
  };
262
- var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
263
- var statisticalResult = _ref8.statisticalResult;
264
- var pivotResult = statisticalResult.pivotResult,
265
- groupbyColumn = statisticalResult.groupbyColumn,
266
- summaryColumn = statisticalResult.summaryColumn;
267
- var pivot_rows = pivotResult.pivot_rows,
268
- pivot_columns = pivotResult.pivot_columns;
269
- var columnMap = {};
270
- var rows = [];
291
+ const exportTwoDimensionToTable = _ref2 => {
292
+ let {
293
+ statisticalResult
294
+ } = _ref2;
295
+ const {
296
+ pivotResult,
297
+ groupbyColumn,
298
+ summaryColumn
299
+ } = statisticalResult;
300
+ const {
301
+ pivot_rows,
302
+ pivot_columns
303
+ } = pivotResult;
304
+ let columnMap = {};
305
+ let rows = [];
271
306
 
272
307
  // generator columns
273
- var columns = [{
308
+ let columns = [{
274
309
  // first column
275
310
  key: '0000',
276
311
  type: CellType.TEXT,
277
312
  name: groupbyColumn.name,
278
313
  data: null
279
314
  }];
280
- var columnData = {
315
+ let columnData = {
281
316
  format: 'number'
282
317
  };
283
- var _isDateSummaryColumn = false;
284
- var isIncludeHour = false;
318
+ let _isDateSummaryColumn = false;
319
+ let isIncludeHour = false;
285
320
  if (summaryColumn) {
286
321
  if (isSummaryDateColumn(summaryColumn)) {
287
322
  _isDateSummaryColumn = true;
288
- var _ref9 = summaryColumn.data || {},
289
- format = _ref9.format;
323
+ const {
324
+ format
325
+ } = summaryColumn.data || {};
290
326
  columnData = {
291
- format: format
327
+ format
292
328
  };
293
329
  isIncludeHour = format && format.indexOf('HH:mm') > -1;
294
330
  } else {
@@ -297,26 +333,29 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
297
333
  such as the data attribute in the function column, which contains other content that is not
298
334
  useful for creating a new column
299
335
  */
300
- var _ref10 = summaryColumn.data || {},
301
- decimal = _ref10.decimal,
302
- thousands = _ref10.thousands,
303
- precision = _ref10.precision,
304
- enable_precision = _ref10.enable_precision,
305
- _format4 = _ref10.format;
336
+ const {
337
+ decimal,
338
+ thousands,
339
+ precision,
340
+ enable_precision,
341
+ format
342
+ } = summaryColumn.data || {};
306
343
  columnData = {
307
- decimal: decimal,
308
- thousands: thousands,
309
- precision: precision,
310
- enable_precision: enable_precision,
311
- format: _format4
344
+ decimal,
345
+ thousands,
346
+ precision,
347
+ enable_precision,
348
+ format
312
349
  };
313
350
  }
314
351
  }
315
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
316
- var key = item.key,
317
- original_key = item.original_key;
318
- var columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
319
- var newColumn = {
352
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
353
+ const {
354
+ key,
355
+ original_key
356
+ } = item;
357
+ const columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
358
+ const newColumn = {
320
359
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
321
360
  name: columnName,
322
361
  data: columnData
@@ -326,7 +365,7 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
326
365
  });
327
366
 
328
367
  // total column
329
- var totalColumn = {
368
+ const totalColumn = {
330
369
  type: _isDateSummaryColumn ? CellType.DATE : CellType.NUMBER,
331
370
  name: intl.get('Total'),
332
371
  data: columnData
@@ -334,23 +373,27 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
334
373
  columns.push(totalColumn);
335
374
 
336
375
  // generator rows
337
- var dateFormat = isIncludeHour ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
338
- pivot_rows.forEach(function (item) {
339
- var name = item.name,
340
- original_name = item.original_name,
341
- cells = item.cells,
342
- total = item.total;
376
+ const dateFormat = isIncludeHour ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
377
+ pivot_rows.forEach(item => {
378
+ let {
379
+ name,
380
+ original_name,
381
+ cells,
382
+ total
383
+ } = item;
343
384
  if (isEmptyName(original_name)) {
344
385
  name = intl.get(EMPTY_NAME);
345
386
  }
346
- var newRow = _defineProperty({}, groupbyColumn.name, name);
347
- var cellValue = total;
387
+ let newRow = {
388
+ [groupbyColumn.name]: name
389
+ };
390
+ let cellValue = total;
348
391
  if (_isDateSummaryColumn && cellValue) {
349
392
  cellValue = dayjs(cellValue).format(dateFormat);
350
393
  }
351
394
  newRow[intl.get('Total')] = cellValue;
352
- Object.keys(cells).forEach(function (key) {
353
- var cellValue = cells[key].total;
395
+ Object.keys(cells).forEach(key => {
396
+ let cellValue = cells[key].total;
354
397
  if (_isDateSummaryColumn) {
355
398
  cellValue = cellValue ? dayjs(cellValue).format(dateFormat) : '';
356
399
  }
@@ -359,56 +402,66 @@ var exportTwoDimensionToTable = function exportTwoDimensionToTable(_ref8) {
359
402
  rows.push(newRow);
360
403
  });
361
404
  return {
362
- columns: columns,
363
- rows: rows
405
+ columns,
406
+ rows
364
407
  };
365
408
  };
366
- var getTwoDimensionWithSummaryColumns = function getTwoDimensionWithSummaryColumns(_ref11) {
367
- var statisticalResult = _ref11.statisticalResult;
368
- var pivotResult = statisticalResult.pivotResult,
369
- groupbyColumn = statisticalResult.groupbyColumn;
370
- var pivot_rows = pivotResult.pivot_rows,
371
- pivot_columns = pivotResult.pivot_columns,
372
- pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns,
373
- formulaRows = pivotResult.formulaRows,
374
- isSqlQuery = pivotResult.isSqlQuery;
375
- var summaryColumns = pivot_summary_multiple_columns.filter(Boolean);
409
+ const getTwoDimensionWithSummaryColumns = _ref3 => {
410
+ let {
411
+ statisticalResult
412
+ } = _ref3;
413
+ const {
414
+ pivotResult,
415
+ groupbyColumn
416
+ } = statisticalResult;
417
+ const {
418
+ pivot_rows,
419
+ pivot_columns,
420
+ pivot_summary_multiple_columns,
421
+ formulaRows,
422
+ isSqlQuery
423
+ } = pivotResult;
424
+ const summaryColumns = pivot_summary_multiple_columns.filter(Boolean);
376
425
  if (!groupbyColumn || summaryColumns.length === 0 || !Array.isArray(pivot_columns) || pivot_columns.length === 0 || !Array.isArray(pivot_rows) || pivot_rows.length === 0) return {};
377
- var groupbyColumnName = groupbyColumn.name;
378
- var firstSummaryColumn = summaryColumns[0];
379
- var columns = [{
426
+ const groupbyColumnName = groupbyColumn.name;
427
+ const firstSummaryColumn = summaryColumns[0];
428
+ let columns = [{
380
429
  // name column
381
430
  key: '0000',
382
431
  type: CellType.TEXT,
383
432
  name: groupbyColumnName,
384
433
  data: null
385
434
  }];
386
- var tmpColumns = [];
387
- pivot_columns.forEach(function (pivotColumn) {
388
- var pivotColumnKey = pivotColumn.key,
389
- original_key = pivotColumn.original_key;
390
- var pivotColumnColumnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : pivotColumnKey;
391
- summaryColumns.forEach(function (summaryColumn) {
392
- var key = summaryColumn.key,
393
- type = summaryColumn.type,
394
- sqlKey = summaryColumn.sqlKey,
395
- column_name = summaryColumn.column_name,
396
- data = summaryColumn.data,
397
- method = summaryColumn.method;
398
- var newColumnName = "".concat(pivotColumnColumnName, "-").concat(column_name);
435
+ let tmpColumns = [];
436
+ pivot_columns.forEach(pivotColumn => {
437
+ const {
438
+ key: pivotColumnKey,
439
+ original_key
440
+ } = pivotColumn;
441
+ const pivotColumnColumnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : pivotColumnKey;
442
+ summaryColumns.forEach(summaryColumn => {
443
+ const {
444
+ key,
445
+ type,
446
+ sqlKey,
447
+ column_name,
448
+ data,
449
+ method
450
+ } = summaryColumn;
451
+ const newColumnName = "".concat(pivotColumnColumnName, "-").concat(column_name);
399
452
  columns.push({
400
453
  // just support number column
401
454
  type: CellType.NUMBER,
402
455
  name: newColumnName,
403
- data: data
456
+ data
404
457
  });
405
458
  tmpColumns.push({
406
459
  name: newColumnName,
407
- pivotColumnKey: pivotColumnKey,
408
- key: key,
409
- type: type,
410
- sqlKey: sqlKey,
411
- method: method
460
+ pivotColumnKey,
461
+ key,
462
+ type,
463
+ sqlKey,
464
+ method
412
465
  });
413
466
  });
414
467
  });
@@ -417,29 +470,35 @@ var getTwoDimensionWithSummaryColumns = function getTwoDimensionWithSummaryColum
417
470
  name: intl.get('Total'),
418
471
  data: firstSummaryColumn.data
419
472
  });
420
- var rows = [];
421
- pivot_rows.forEach(function (pivotRow) {
422
- var name = pivotRow.name,
423
- original_name = pivotRow.original_name,
424
- cells = pivotRow.cells;
473
+ let rows = [];
474
+ pivot_rows.forEach(pivotRow => {
475
+ let {
476
+ name,
477
+ original_name,
478
+ cells
479
+ } = pivotRow;
425
480
  if (isEmptyName(original_name)) {
426
481
  name = intl.get(EMPTY_NAME);
427
482
  }
428
- var newRow = _defineProperty({}, groupbyColumnName, name);
429
- var total = 0;
430
- tmpColumns.forEach(function (tmpColumn) {
431
- var name = tmpColumn.name,
432
- pivotColumnKey = tmpColumn.pivotColumnKey,
433
- key = tmpColumn.key,
434
- type = tmpColumn.type,
435
- sqlKey = tmpColumn.sqlKey,
436
- method = tmpColumn.method;
437
- var cell = cells && cells[pivotColumnKey];
438
- var cellRows = cell && cell.rows;
483
+ let newRow = {
484
+ [groupbyColumnName]: name
485
+ };
486
+ let total = 0;
487
+ tmpColumns.forEach(tmpColumn => {
488
+ const {
489
+ name,
490
+ pivotColumnKey,
491
+ key,
492
+ type,
493
+ sqlKey,
494
+ method
495
+ } = tmpColumn;
496
+ const cell = cells && cells[pivotColumnKey];
497
+ const cellRows = cell && cell.rows;
439
498
  if (!Array.isArray(cellRows) || cellRows.length === 0) {
440
499
  newRow[name] = 0;
441
500
  } else {
442
- var cellValue = getPivotTableSummaryTotal(type, key, sqlKey, STATISTICS_COUNT_TYPE.ADVANCED, method, cellRows, formulaRows, isSqlQuery);
501
+ const cellValue = getPivotTableSummaryTotal(type, key, sqlKey, STATISTICS_COUNT_TYPE.ADVANCED, method, cellRows, formulaRows, isSqlQuery);
443
502
  newRow[name] = cellValue;
444
503
  total += cellValue;
445
504
  }
@@ -448,66 +507,76 @@ var getTwoDimensionWithSummaryColumns = function getTwoDimensionWithSummaryColum
448
507
  rows.push(newRow);
449
508
  });
450
509
  return {
451
- columns: columns,
452
- rows: rows
510
+ columns,
511
+ rows
453
512
  };
454
513
  };
455
- var exportTwoDimensionWithSummaryColumnsToTable = function exportTwoDimensionWithSummaryColumnsToTable(_ref12) {
456
- var statisticalResult = _ref12.statisticalResult;
514
+ const exportTwoDimensionWithSummaryColumnsToTable = _ref4 => {
515
+ let {
516
+ statisticalResult
517
+ } = _ref4;
457
518
  return getTwoDimensionWithSummaryColumns({
458
- statisticalResult: statisticalResult
519
+ statisticalResult
459
520
  });
460
521
  };
461
- var updatedOneDimensionToTable = function updatedOneDimensionToTable(_ref13) {
462
- var updateTable = _ref13.updateTable,
463
- statisticalResult = _ref13.statisticalResult;
464
- var pivotResult = statisticalResult.pivotResult,
465
- groupbyColumn = statisticalResult.groupbyColumn,
466
- statisticTableColumns = statisticalResult.statisticTableColumns;
522
+ const updatedOneDimensionToTable = _ref5 => {
523
+ let {
524
+ updateTable,
525
+ statisticalResult
526
+ } = _ref5;
527
+ const {
528
+ pivotResult,
529
+ groupbyColumn,
530
+ statisticTableColumns
531
+ } = statisticalResult;
467
532
  if (!groupbyColumn) return {};
468
- var nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
533
+ const nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
469
534
  if (!nameColumn) return {};
470
- var pivot_rows = pivotResult.pivot_rows,
471
- pivot_columns = pivotResult.pivot_columns;
472
- var tableRows = updateTable.rows;
473
- var columnMap = {};
474
- var newRows = [];
475
- var updatedRows = {};
476
- var oldRows = {};
477
- var rowIds = [];
535
+ const {
536
+ pivot_rows,
537
+ pivot_columns
538
+ } = pivotResult;
539
+ const {
540
+ rows: tableRows
541
+ } = updateTable;
542
+ let columnMap = {};
543
+ let newRows = [];
544
+ let updatedRows = {};
545
+ let oldRows = {};
546
+ let rowIds = [];
478
547
 
479
548
  // one dimension table no summary columns
480
549
  if (pivot_columns.length < 2) {
481
550
  columnMap['total'] = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
482
551
 
483
552
  // updated rows
484
- pivot_rows.forEach(function (item) {
485
- var name = item.name,
486
- original_name = item.original_name,
487
- total = item.total;
488
- var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
489
- var row = tableRows.find(function (row) {
490
- return row[nameColumn.key] === groupName;
491
- });
492
- var totalColumn = columnMap['total'];
553
+ pivot_rows.forEach(item => {
554
+ const {
555
+ name,
556
+ original_name,
557
+ total
558
+ } = item;
559
+ const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
560
+ const row = tableRows.find(row => row[nameColumn.key] === groupName);
561
+ const totalColumn = columnMap['total'];
493
562
  if (row) {
494
563
  // update old row
495
- var updateRow = {};
496
- var oldRow = {};
497
- var validTotalCellValue = getValidValueForColumn(totalColumn, total.total);
564
+ let updateRow = {};
565
+ let oldRow = {};
566
+ const validTotalCellValue = getValidValueForColumn(totalColumn, total.total);
498
567
  if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
499
568
  updateRow[totalColumn.key] = validTotalCellValue;
500
569
  oldRow[totalColumn.key] = row[totalColumn.key];
501
570
  }
502
571
  if (Object.keys(updateRow).length > 0) {
503
- var rowId = row._id;
572
+ const rowId = row._id;
504
573
  rowIds.push(rowId);
505
574
  updatedRows[rowId] = updateRow;
506
575
  oldRows[rowId] = oldRow;
507
576
  }
508
577
  } else {
509
578
  // insert new row
510
- var newRow = {};
579
+ let newRow = {};
511
580
  newRow[nameColumn.key] = groupName;
512
581
  if (totalColumn) {
513
582
  newRow[totalColumn.key] = getValidValueForColumn(totalColumn, total.total);
@@ -516,63 +585,71 @@ var updatedOneDimensionToTable = function updatedOneDimensionToTable(_ref13) {
516
585
  }
517
586
  });
518
587
  return {
519
- newRows: newRows,
520
- updatedRows: updatedRows,
521
- rowIds: rowIds,
522
- oldRows: oldRows
588
+ newRows,
589
+ updatedRows,
590
+ rowIds,
591
+ oldRows
523
592
  };
524
593
  }
525
594
 
526
595
  // one dimension table with summary columns
527
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
528
- var key = item.key;
529
- var column = statisticTableColumns.find(function (column) {
530
- return column.key === key;
531
- });
596
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
597
+ const {
598
+ key
599
+ } = item;
600
+ const column = statisticTableColumns.find(column => column.key === key);
532
601
  if (column) {
533
602
  columnMap[key] = TableUtils.getTableColumnByName(updateTable, column.name);
534
603
  }
535
604
  });
536
605
 
537
606
  // updated rows
538
- var nameColumnKey = nameColumn.key;
539
- pivot_rows.forEach(function (item) {
540
- var name = item.name,
541
- original_name = item.original_name,
542
- total = item.total;
543
- var groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
544
- var row = tableRows.find(function (row) {
545
- return row[nameColumnKey] === groupName;
546
- });
607
+ const {
608
+ key: nameColumnKey
609
+ } = nameColumn;
610
+ pivot_rows.forEach(item => {
611
+ const {
612
+ name,
613
+ original_name,
614
+ total
615
+ } = item;
616
+ const groupName = isEmptyName(original_name) ? intl.get(EMPTY_NAME) : name;
617
+ const row = tableRows.find(row => row[nameColumnKey] === groupName);
547
618
  if (row) {
548
- var updateRow = {};
549
- var oldRow = {};
550
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
551
- var key = item.key,
552
- method = item.method;
553
- var column = columnMap[key];
554
- var cellValueKey = key + method;
555
- var totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
619
+ let updateRow = {};
620
+ let oldRow = {};
621
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
622
+ const {
623
+ key,
624
+ method
625
+ } = item;
626
+ const column = columnMap[key];
627
+ const cellValueKey = key + method;
628
+ const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
556
629
  if (column && isCellValueChanged(row[column.key], totalCellValue, column.type)) {
557
630
  updateRow[column.key] = totalCellValue;
558
631
  oldRow[column.key] = row[column.key];
559
632
  }
560
633
  });
561
634
  if (Object.keys(updateRow).length > 0) {
562
- var rowId = row._id;
635
+ const rowId = row._id;
563
636
  rowIds.push(rowId);
564
637
  updatedRows[rowId] = updateRow;
565
638
  oldRows[rowId] = oldRow;
566
639
  }
567
640
  } else {
568
- var newRow = _defineProperty({}, nameColumn.key, groupName);
569
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
570
- var key = item.key,
571
- method = item.method;
572
- var cellValueKey = key + method;
573
- var column = columnMap[key];
641
+ let newRow = {
642
+ [nameColumn.key]: groupName
643
+ };
644
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
645
+ const {
646
+ key,
647
+ method
648
+ } = item;
649
+ const cellValueKey = key + method;
650
+ const column = columnMap[key];
574
651
  if (column) {
575
- var totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
652
+ const totalCellValue = getValidValueForColumn(column, total[cellValueKey]);
576
653
  newRow[column.key] = totalCellValue;
577
654
  }
578
655
  });
@@ -580,83 +657,97 @@ var updatedOneDimensionToTable = function updatedOneDimensionToTable(_ref13) {
580
657
  }
581
658
  });
582
659
  return {
583
- newRows: newRows,
584
- updatedRows: updatedRows,
585
- rowIds: rowIds,
586
- oldRows: oldRows
660
+ newRows,
661
+ updatedRows,
662
+ rowIds,
663
+ oldRows
587
664
  };
588
665
  };
589
- var updateTwoDimensionToTable = function updateTwoDimensionToTable(_ref14) {
590
- var updateTable = _ref14.updateTable,
591
- statisticalResult = _ref14.statisticalResult;
592
- var pivotResult = statisticalResult.pivotResult,
593
- groupbyColumn = statisticalResult.groupbyColumn;
594
- var nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
666
+ const updateTwoDimensionToTable = _ref6 => {
667
+ let {
668
+ updateTable,
669
+ statisticalResult
670
+ } = _ref6;
671
+ const {
672
+ pivotResult,
673
+ groupbyColumn
674
+ } = statisticalResult;
675
+ const nameColumn = TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
595
676
  if (!nameColumn) return {};
596
- var pivot_rows = pivotResult.pivot_rows,
597
- pivot_columns = pivotResult.pivot_columns;
598
- var tableRows = updateTable.rows;
599
- var columnMap = {};
600
- var newRows = [];
601
- var updatedRows = {};
602
- var rowIds = [];
603
- var oldRows = {};
677
+ const {
678
+ pivot_rows,
679
+ pivot_columns
680
+ } = pivotResult;
681
+ const {
682
+ rows: tableRows
683
+ } = updateTable;
684
+ let columnMap = {};
685
+ let newRows = [];
686
+ let updatedRows = {};
687
+ let rowIds = [];
688
+ let oldRows = {};
604
689
 
605
690
  // updated columns
606
- var updateColumns = [];
607
- Array.isArray(pivot_columns) && pivot_columns.forEach(function (item) {
608
- var key = item.key,
609
- original_key = item.original_key;
610
- var columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
611
- var column = TableUtils.getTableColumnByName(updateTable, columnName);
691
+ let updateColumns = [];
692
+ Array.isArray(pivot_columns) && pivot_columns.forEach(item => {
693
+ const {
694
+ key,
695
+ original_key
696
+ } = item;
697
+ const columnName = isEmptyName(original_key) ? intl.get(EMPTY_NAME) : key;
698
+ const column = TableUtils.getTableColumnByName(updateTable, columnName);
612
699
  columnMap[columnName] = column;
613
700
  updateColumns.push(column);
614
701
  });
615
- var totalColumn = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
702
+ const totalColumn = TableUtils.getTableColumnByName(updateTable, intl.get('Total'));
616
703
  columnMap['total'] = totalColumn;
617
704
  updateColumns.push(totalColumn);
618
705
 
619
706
  // updated rows
620
- var _loop = function _loop(i) {
621
- var pivotRow = pivot_rows[i];
622
- var name = pivotRow.name,
623
- original_name = pivotRow.original_name,
624
- cells = pivotRow.cells,
625
- total = pivotRow.total;
707
+ for (let i = 0; i < pivot_rows.length; i++) {
708
+ const pivotRow = pivot_rows[i];
709
+ let {
710
+ name,
711
+ original_name,
712
+ cells,
713
+ total
714
+ } = pivotRow;
626
715
  if (isEmptyName(original_name)) {
627
716
  name = intl.get(EMPTY_NAME);
628
717
  }
629
- var nameColumnKey = nameColumn.key;
630
- var row = tableRows.find(function (row) {
631
- return row[nameColumnKey] === name;
632
- });
633
- var totalColumn = columnMap['total'];
718
+ const {
719
+ key: nameColumnKey
720
+ } = nameColumn;
721
+ const row = tableRows.find(row => row[nameColumnKey] === name);
722
+ const totalColumn = columnMap['total'];
634
723
  if (row) {
635
724
  // update old row
636
- var rowId = row._id;
637
- var updatedRow = {};
638
- var oldRow = {}; // op used
639
- var validTotalCellValue = getValidValueForColumn(totalColumn, total);
725
+ const rowId = row._id;
726
+ let updatedRow = {};
727
+ let oldRow = {}; // op used
728
+ const validTotalCellValue = getValidValueForColumn(totalColumn, total);
640
729
  if (totalColumn && isCellValueChanged(row[totalColumn.key], validTotalCellValue, totalColumn.type)) {
641
730
  updatedRow[totalColumn.key] = validTotalCellValue;
642
731
  oldRow[totalColumn.key] = row[totalColumn.key];
643
732
  }
644
- var keys = Object.keys(cells);
733
+ const keys = Object.keys(cells);
645
734
  if (keys.length === 0) {
646
- updateColumns.forEach(function (column) {
647
- var key = column.key,
648
- type = column.type;
649
- var newCellValue = key === totalColumn.key ? 0 : null;
735
+ updateColumns.forEach(column => {
736
+ const {
737
+ key,
738
+ type
739
+ } = column;
740
+ const newCellValue = key === totalColumn.key ? 0 : null;
650
741
  if (isCellValueChanged(row[key], newCellValue, type)) {
651
742
  updatedRow[key] = newCellValue;
652
743
  oldRow[key] = row[key];
653
744
  }
654
745
  });
655
746
  } else {
656
- keys.forEach(function (key) {
657
- var columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
658
- var column = columnMap[columnName];
659
- var validCellValue = getValidValueForColumn(column, cells[key].total);
747
+ keys.forEach(key => {
748
+ const columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
749
+ const column = columnMap[columnName];
750
+ let validCellValue = getValidValueForColumn(column, cells[key].total);
660
751
  if (column && isCellValueChanged(row[column.key], validCellValue, column.type)) {
661
752
  updatedRow[column.key] = validCellValue;
662
753
  oldRow[column.key] = row[column.key];
@@ -670,14 +761,14 @@ var updateTwoDimensionToTable = function updateTwoDimensionToTable(_ref14) {
670
761
  }
671
762
  } else {
672
763
  // insert new row
673
- var newRow = {};
764
+ let newRow = {};
674
765
  newRow[nameColumnKey] = name;
675
766
  if (totalColumn) {
676
767
  newRow[totalColumn.key] = getValidValueForColumn(totalColumn, name);
677
768
  }
678
- Object.keys(cells).forEach(function (key) {
679
- var columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
680
- var column = columnMap[columnName];
769
+ Object.keys(cells).forEach(key => {
770
+ const columnName = isEmptyName(key) ? intl.get(EMPTY_NAME) : key;
771
+ const column = columnMap[columnName];
681
772
  if (column) {
682
773
  newRow[column.key] = getValidValueForColumn(column, cells[key].total);
683
774
  }
@@ -686,66 +777,74 @@ var updateTwoDimensionToTable = function updateTwoDimensionToTable(_ref14) {
686
777
  newRows.push(newRow);
687
778
  }
688
779
  }
689
- };
690
- for (var i = 0; i < pivot_rows.length; i++) {
691
- _loop(i);
692
780
  }
693
781
  return {
694
- newRows: newRows,
695
- updatedRows: updatedRows,
696
- oldRows: oldRows,
697
- rowIds: rowIds
782
+ newRows,
783
+ updatedRows,
784
+ oldRows,
785
+ rowIds
698
786
  };
699
787
  };
700
- var updateTwoDimensionWithSummaryColumnsToTable = function updateTwoDimensionWithSummaryColumnsToTable(_ref15) {
701
- var updateTable = _ref15.updateTable,
702
- statisticalResult = _ref15.statisticalResult;
703
- var groupbyColumn = statisticalResult.groupbyColumn;
704
- var nameColumn = groupbyColumn && TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
788
+ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
789
+ let {
790
+ updateTable,
791
+ statisticalResult
792
+ } = _ref7;
793
+ const {
794
+ groupbyColumn
795
+ } = statisticalResult;
796
+ const nameColumn = groupbyColumn && TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
705
797
  if (!nameColumn) return {};
706
- var _getTwoDimensionWithS = getTwoDimensionWithSummaryColumns({
707
- statisticalResult: statisticalResult
708
- }),
709
- exportingColumns = _getTwoDimensionWithS.columns,
710
- exportingRows = _getTwoDimensionWithS.rows;
798
+ const {
799
+ columns: exportingColumns,
800
+ rows: exportingRows
801
+ } = getTwoDimensionWithSummaryColumns({
802
+ statisticalResult
803
+ });
711
804
  if (!Array.isArray(exportingColumns) || exportingColumns.length === 0 || !Array.isArray(exportingRows) || exportingRows.length === 0) {
712
805
  return {};
713
806
  }
714
- var tableRows = updateTable.rows,
715
- tableColumns = updateTable.columns;
716
- var nameColumnKey = nameColumn.key;
717
- var groupbyColumnName = groupbyColumn.name;
718
- var newRows = [];
719
- var updatedRows = {};
720
- var rowIds = [];
721
- var oldRows = {};
722
- var nameCellValueExistRowMap = {};
723
- tableRows.forEach(function (row) {
724
- var nameCellValue = row[nameColumnKey];
807
+ const {
808
+ rows: tableRows,
809
+ columns: tableColumns
810
+ } = updateTable;
811
+ const {
812
+ key: nameColumnKey
813
+ } = nameColumn;
814
+ const groupbyColumnName = groupbyColumn.name;
815
+ let newRows = [];
816
+ let updatedRows = {};
817
+ let rowIds = [];
818
+ let oldRows = {};
819
+ let nameCellValueExistRowMap = {};
820
+ tableRows.forEach(row => {
821
+ const nameCellValue = row[nameColumnKey];
725
822
  if (!nameCellValueExistRowMap[nameCellValue]) {
726
823
  nameCellValueExistRowMap[nameCellValue] = row;
727
824
  }
728
825
  });
729
- exportingRows.forEach(function (exportingRow) {
730
- var nameCellValue = exportingRow[groupbyColumnName];
731
- var existRow = nameCellValueExistRowMap[nameCellValue];
826
+ exportingRows.forEach(exportingRow => {
827
+ const nameCellValue = exportingRow[groupbyColumnName];
828
+ const existRow = nameCellValueExistRowMap[nameCellValue];
732
829
  if (existRow) {
733
830
  // update the row already exist
734
- var exportingRowData = {};
735
- var existRowData = {};
736
- tableColumns.forEach(function (tableColumn) {
737
- var tableColumnKey = tableColumn.key,
738
- tableColumnType = tableColumn.type,
739
- tableColumnName = tableColumn.name;
740
- var existCellValue = existRow[tableColumnKey];
741
- var exportingCellValue = exportingRow[tableColumnName];
831
+ let exportingRowData = {};
832
+ let existRowData = {};
833
+ tableColumns.forEach(tableColumn => {
834
+ const {
835
+ key: tableColumnKey,
836
+ type: tableColumnType,
837
+ name: tableColumnName
838
+ } = tableColumn;
839
+ const existCellValue = existRow[tableColumnKey];
840
+ const exportingCellValue = exportingRow[tableColumnName];
742
841
  if (tableColumn && isCellValueChanged(existCellValue, exportingCellValue, tableColumnType)) {
743
842
  exportingRowData[tableColumnKey] = exportingCellValue;
744
843
  existRowData[tableColumnKey] = existCellValue;
745
844
  }
746
845
  });
747
846
  if (Object.keys(exportingRowData).length > 0) {
748
- var rowId = existRow._id;
847
+ let rowId = existRow._id;
749
848
  rowIds.push(rowId);
750
849
  updatedRows[rowId] = exportingRowData;
751
850
  oldRows[rowId] = existRowData;
@@ -756,10 +855,10 @@ var updateTwoDimensionWithSummaryColumnsToTable = function updateTwoDimensionWit
756
855
  }
757
856
  });
758
857
  return {
759
- newRows: newRows,
760
- updatedRows: updatedRows,
761
- oldRows: oldRows,
762
- rowIds: rowIds
858
+ newRows,
859
+ updatedRows,
860
+ oldRows,
861
+ rowIds
763
862
  };
764
863
  };
765
864
 
@@ -794,57 +893,69 @@ var updateTwoDimensionWithSummaryColumnsToTable = function updateTwoDimensionWit
794
893
  * ]
795
894
  * }
796
895
  */
797
- export var exportStatisticToTable = function exportStatisticToTable(_ref16) {
798
- var statisticalResult = _ref16.statisticalResult;
799
- var pivotResult = statisticalResult.pivotResult,
800
- groupbyColumn = statisticalResult.groupbyColumn,
801
- columnGroupbyColumn = statisticalResult.columnGroupbyColumn;
802
- var pivot_columns = pivotResult.pivot_columns,
803
- pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns;
896
+ export const exportStatisticToTable = _ref8 => {
897
+ let {
898
+ statisticalResult
899
+ } = _ref8;
900
+ const {
901
+ pivotResult,
902
+ groupbyColumn,
903
+ columnGroupbyColumn
904
+ } = statisticalResult;
905
+ const {
906
+ pivot_columns,
907
+ pivot_summary_multiple_columns
908
+ } = pivotResult;
804
909
  if (!groupbyColumn) return {};
805
910
 
806
911
  // two dimension table
807
912
  if (columnGroupbyColumn) {
808
913
  if (Array.isArray(pivot_summary_multiple_columns) && pivot_summary_multiple_columns.length > 0) {
809
914
  return exportTwoDimensionWithSummaryColumnsToTable({
810
- statisticalResult: statisticalResult
915
+ statisticalResult
811
916
  });
812
917
  }
813
918
  return exportTwoDimensionToTable({
814
- statisticalResult: statisticalResult
919
+ statisticalResult
815
920
  });
816
921
  }
817
922
  if (!Array.isArray(pivot_columns)) return {};
818
923
  return exportOneDimensionToTable({
819
- statisticalResult: statisticalResult
924
+ statisticalResult
820
925
  });
821
926
  };
822
- export var updateStatisticToTable = function updateStatisticToTable(_ref17) {
823
- var updateTable = _ref17.updateTable,
824
- statisticalResult = _ref17.statisticalResult;
825
- var groupbyColumn = statisticalResult.groupbyColumn,
826
- columnGroupbyColumn = statisticalResult.columnGroupbyColumn,
827
- pivotResult = statisticalResult.pivotResult;
828
- var pivot_summary_multiple_columns = pivotResult.pivot_summary_multiple_columns;
927
+ export const updateStatisticToTable = _ref9 => {
928
+ let {
929
+ updateTable,
930
+ statisticalResult
931
+ } = _ref9;
932
+ const {
933
+ groupbyColumn,
934
+ columnGroupbyColumn,
935
+ pivotResult
936
+ } = statisticalResult;
937
+ const {
938
+ pivot_summary_multiple_columns
939
+ } = pivotResult;
829
940
  if (!groupbyColumn) return {};
830
941
 
831
942
  // two dimension table
832
943
  if (columnGroupbyColumn) {
833
944
  if (Array.isArray(pivot_summary_multiple_columns) && pivot_summary_multiple_columns.length > 0) {
834
945
  return updateTwoDimensionWithSummaryColumnsToTable({
835
- updateTable: updateTable,
836
- statisticalResult: statisticalResult
946
+ updateTable,
947
+ statisticalResult
837
948
  });
838
949
  }
839
950
  return updateTwoDimensionToTable({
840
- updateTable: updateTable,
841
- statisticalResult: statisticalResult
951
+ updateTable,
952
+ statisticalResult
842
953
  });
843
954
  }
844
955
 
845
956
  // one dimension table
846
957
  return updatedOneDimensionToTable({
847
- updateTable: updateTable,
848
- statisticalResult: statisticalResult
958
+ updateTable,
959
+ statisticalResult
849
960
  });
850
961
  };