dtable-statistic 4.3.6 → 4.3.7

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 (107) hide show
  1. package/es/calculator/base-calculator.js +16 -5
  2. package/es/calculator/basic-chart-calculator.js +17 -31
  3. package/es/calculator/combination-calculator.js +19 -30
  4. package/es/calculator/compare-bar-calculator.js +9 -20
  5. package/es/calculator/completeness-calculator.js +10 -24
  6. package/es/calculator/dashboard-calculator.js +6 -20
  7. package/es/calculator/heat-map-calculator.js +6 -20
  8. package/es/calculator/horizontal-bar-calculator.js +2 -13
  9. package/es/calculator/index.js +2 -0
  10. package/es/calculator/map-calculator.js +7 -21
  11. package/es/calculator/mirror-calculator.js +8 -22
  12. package/es/calculator/number-card-calculator.js +4 -18
  13. package/es/calculator/pivot-table-calculator.js +40 -54
  14. package/es/calculator/scatter-calculator.js +6 -20
  15. package/es/calculator/trend-calculator.js +6 -20
  16. package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
  17. package/es/calculator/workers/calculator.worker.js +5 -2
  18. package/es/calculator/workers/card-calculator-worker.js +13 -9
  19. package/es/calculator/workers/combination-calculator-worker.js +20 -16
  20. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
  21. package/es/calculator/workers/completeness-calculator-worker.js +21 -17
  22. package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
  23. package/es/calculator/workers/mirror-calculator-worker.js +14 -10
  24. package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
  25. package/es/calculator/workers/scatter-calculator-worker.js +15 -11
  26. package/es/calculator/workers/trend-calculator-worker.js +14 -10
  27. package/es/calculator/world-map-calculator.js +6 -20
  28. package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
  29. package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
  30. package/es/components/dialog/statistic-record-dialog/index.js +21 -11
  31. package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
  32. package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
  33. package/es/components/popover/color-rules-popover.js +2 -2
  34. package/es/components/toast/alert.js +2 -0
  35. package/es/components/toast/toastManager.js +1 -0
  36. package/es/constants/color-rules.js +3 -3
  37. package/es/constants/index.js +9 -9
  38. package/es/dashboard.js +7 -13
  39. package/es/desktop-dashboard.js +1 -1
  40. package/es/locale/lang/de.js +10 -10
  41. package/es/locale/lang/en.js +8 -8
  42. package/es/locale/lang/fr.js +10 -10
  43. package/es/locale/lang/zh_CN.js +8 -8
  44. package/es/model/basic-number-card.js +3 -3
  45. package/es/model/compare-bar.js +2 -2
  46. package/es/model/generic-model.js +11 -11
  47. package/es/model/heat-map.js +2 -2
  48. package/es/model/horizontal-bar.js +2 -2
  49. package/es/model/index.js +3 -2
  50. package/es/model/map.js +3 -3
  51. package/es/model/mirror.js +2 -2
  52. package/es/model/trend.js +2 -2
  53. package/es/model/world-map.js +3 -3
  54. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
  55. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
  56. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
  57. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  58. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
  59. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
  60. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
  61. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
  62. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
  63. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
  64. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
  65. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
  66. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
  67. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
  68. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -1
  69. package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
  70. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
  71. package/es/stat-view/area-chart.js +4 -4
  72. package/es/stat-view/bar-chart.js +4 -4
  73. package/es/stat-view/base-chart.js +2 -2
  74. package/es/stat-view/basic-number-card.js +2 -2
  75. package/es/stat-view/combination-chart.js +9 -9
  76. package/es/stat-view/compare-chart.js +4 -4
  77. package/es/stat-view/completeness-chart.js +3 -3
  78. package/es/stat-view/custom-bar.js +2 -2
  79. package/es/stat-view/heat-map.js +2 -2
  80. package/es/stat-view/horizontal-bar-chart.js +4 -4
  81. package/es/stat-view/line-chart.js +4 -4
  82. package/es/stat-view/map.js +3 -3
  83. package/es/stat-view/mirror.js +2 -2
  84. package/es/stat-view/pivot-table/index.js +6 -6
  85. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
  86. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
  87. package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
  88. package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
  89. package/es/stat-view/ring-chart.js +2 -2
  90. package/es/stat-view/scatter-chart.js +5 -5
  91. package/es/stat-view/treemap-chart.js +3 -2
  92. package/es/stat-view/trend-chart.js +2 -2
  93. package/es/stat-view/world-map.js +3 -3
  94. package/es/utils/cell-format.js +14 -15
  95. package/es/utils/cell-value.js +3 -3
  96. package/es/utils/color-utils.js +3 -3
  97. package/es/utils/column-utils.js +10 -10
  98. package/es/utils/column.js +2 -2
  99. package/es/utils/common-utils.js +10 -8
  100. package/es/utils/export-table-utils.js +38 -38
  101. package/es/utils/pivot-table.js +3 -3
  102. package/es/utils/row-utils.js +17 -17
  103. package/es/utils/search.js +14 -14
  104. package/es/utils/sql-utils.js +23 -20
  105. package/es/utils/stat-utils.js +52 -52
  106. package/es/utils/trend-utils.js +1 -0
  107. package/package.json +3 -2
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getCellValue = getCellValue;
7
7
  exports.isValidRow = exports.isEmptyGeolocationCell = exports.getFormattedLabel = void 0;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _utils = require("../utils");
10
10
  const isEmptyGeolocationCell = (cellValue, format) => {
11
11
  if (!cellValue) return null;
@@ -23,15 +23,15 @@ const isValidRow = (row, formulaRow, column, includeEmpty) => {
23
23
  type: columnType,
24
24
  key: columnKey
25
25
  } = column;
26
- if (includeEmpty || columnType === _dtableStore.CellType.CHECKBOX) return true;
27
- if (columnType === _dtableStore.CellType.GEOLOCATION) {
26
+ if (includeEmpty || columnType === _dtableUtils.CellType.CHECKBOX) return true;
27
+ if (columnType === _dtableUtils.CellType.GEOLOCATION) {
28
28
  const {
29
29
  geo_format
30
30
  } = column.data;
31
31
  return isEmptyGeolocationCell(row[columnKey], geo_format);
32
32
  }
33
33
  let cellValue = row[columnKey];
34
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableStore.CellType.LINK) {
34
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableUtils.CellType.LINK) {
35
35
  cellValue = formulaRow ? formulaRow[columnKey] : null;
36
36
  }
37
37
  return cellValue || cellValue === 0;
@@ -42,7 +42,7 @@ const getFormattedLabel = (column, name, collaborators) => {
42
42
  type: columnType,
43
43
  data: columnData
44
44
  } = column;
45
- if (columnType === _dtableStore.CellType.SINGLE_SELECT || columnType === _dtableStore.CellType.MULTIPLE_SELECT) {
45
+ if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
46
46
  let options = columnData ? columnData.options : [];
47
47
  let selectedOption = options.find(o => {
48
48
  let id = name;
@@ -57,7 +57,7 @@ const getFormattedLabel = (column, name, collaborators) => {
57
57
  if (selectedOption) {
58
58
  return optionName;
59
59
  }
60
- } else if (columnType === _dtableStore.CellType.COLLABORATOR) {
60
+ } else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
61
61
  let collaborator = collaborators.find(item => {
62
62
  let email = name;
63
63
  if (Array.isArray(name)) {
@@ -68,7 +68,7 @@ const getFormattedLabel = (column, name, collaborators) => {
68
68
  if (collaborator) {
69
69
  return collaborator.name;
70
70
  }
71
- } else if (columnType === _dtableStore.CellType.CREATOR || columnType === _dtableStore.CellType.LAST_MODIFIER) {
71
+ } else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
72
72
  if (name === 'anonymous') {
73
73
  return name;
74
74
  } else {
@@ -77,25 +77,25 @@ const getFormattedLabel = (column, name, collaborators) => {
77
77
  return collaborator.name;
78
78
  }
79
79
  }
80
- } else if (columnType === _dtableStore.CellType.LINK) {
80
+ } else if (columnType === _dtableUtils.CellType.LINK) {
81
81
  return (0, _utils.getClientFormulaDisplayString)(Array.isArray(name) ? name : [name], columnData, {
82
82
  collaborators
83
83
  });
84
- } else if (columnType === _dtableStore.CellType.CHECKBOX) {
84
+ } else if (columnType === _dtableUtils.CellType.CHECKBOX) {
85
85
  return name === 'true' ? 'Checked' : 'Unchecked';
86
- } else if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
86
+ } else if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
87
87
  const {
88
88
  result_type,
89
89
  array_type
90
90
  } = columnData || {};
91
- if (!name && !(0, _dtableStore.isNumber)(name)) return '';
92
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
91
+ if (!name && !(0, _dtableUtils.isNumber)(name)) return '';
92
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
93
93
  const valueNumber = parseFloat(name);
94
- return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : name;
94
+ return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : name;
95
95
  }
96
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
97
- if (_dtableStore.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
98
- if ([_dtableStore.CellType.CREATOR, _dtableStore.CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
96
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
97
+ if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
98
+ if ([_dtableUtils.CellType.CREATOR, _dtableUtils.CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
99
99
  return name;
100
100
  }
101
101
  const collaborator = collaborators.find(item => {
@@ -123,7 +123,7 @@ function getCellValue(row, formulaRow, column) {
123
123
  type,
124
124
  key
125
125
  } = column;
126
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
126
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
127
127
  const cellValue = formulaRow && formulaRow[key];
128
128
  if (Array.isArray(cellValue)) {
129
129
  return cellValue[0];
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.searchRows = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
- var _dtableStore = require("dtable-store");
9
+ var _dtableUtils = require("dtable-utils");
10
10
  var _column = require("./column");
11
- const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableStore.CellType.DATE, _dtableStore.CellType.TEXT, _dtableStore.CellType.LONG_TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.URL, _dtableStore.CellType.EMAIL, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.MULTIPLE_SELECT, _dtableStore.CellType.LAST_MODIFIER, _dtableStore.CellType.CREATOR, _dtableStore.CellType.COLLABORATOR, _dtableStore.CellType.LINK, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.AUTO_NUMBER, _dtableStore.CellType.GEOLOCATION, _dtableStore.CellType.DURATION];
11
+ const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableUtils.CellType.DATE, _dtableUtils.CellType.TEXT, _dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.URL, _dtableUtils.CellType.EMAIL, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.LAST_MODIFIER, _dtableUtils.CellType.CREATOR, _dtableUtils.CellType.COLLABORATOR, _dtableUtils.CellType.LINK, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.AUTO_NUMBER, _dtableUtils.CellType.GEOLOCATION, _dtableUtils.CellType.DURATION];
12
12
  const searchRows = (rows, columns, val, processRow) => {
13
13
  let dtableCollaborators = window.app.collaboratorsCache || [];
14
14
  let collaborators = window.app.state.collaborators;
@@ -25,20 +25,20 @@ const searchRows = (rows, columns, val, processRow) => {
25
25
  const cellValue = row[columnKey];
26
26
  if (cellValue) {
27
27
  let text;
28
- if (columnType === _dtableStore.CellType.LONG_TEXT) {
28
+ if (columnType === _dtableUtils.CellType.LONG_TEXT) {
29
29
  text = cellValue.text;
30
- } else if (columnType === _dtableStore.CellType.NUMBER || columnType === _dtableStore.CellType.DURATION) {
31
- text = (0, _dtableStore.getNumberDisplayString)(cellValue, column.data);
32
- } else if (columnType === _dtableStore.CellType.SINGLE_SELECT) {
30
+ } else if (columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.DURATION) {
31
+ text = (0, _dtableUtils.getNumberDisplayString)(cellValue, column.data);
32
+ } else if (columnType === _dtableUtils.CellType.SINGLE_SELECT) {
33
33
  const options = (0, _column.getSelectColumnOptions)(column);
34
34
  const option = options.find(option => option.id === cellValue);
35
35
  text = option ? option.name : '';
36
- } else if (columnType === _dtableStore.CellType.MULTIPLE_SELECT) {
36
+ } else if (columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
37
37
  const options = (0, _column.getSelectColumnOptions)(column);
38
- text = (0, _dtableStore.getMultipleOptionName)(options, cellValue);
39
- } else if (columnType === _dtableStore.CellType.COLLABORATOR) {
40
- text = (0, _dtableStore.getCollaboratorsName)(collaborators, cellValue);
41
- } else if (columnType === _dtableStore.CellType.LAST_MODIFIER || columnType === _dtableStore.CellType.CREATOR) {
38
+ text = (0, _dtableUtils.getMultipleOptionName)(options, cellValue);
39
+ } else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
40
+ text = (0, _dtableUtils.getCollaboratorsName)(collaborators, cellValue);
41
+ } else if (columnType === _dtableUtils.CellType.LAST_MODIFIER || columnType === _dtableUtils.CellType.CREATOR) {
42
42
  if (cellValue === 'anonymous') {
43
43
  text = cellValue;
44
44
  } else {
@@ -50,9 +50,9 @@ const searchRows = (rows, columns, val, processRow) => {
50
50
  text = collaborator.name;
51
51
  }
52
52
  }
53
- } else if (columnType === _dtableStore.CellType.GEOLOCATION) {
54
- text = (0, _dtableStore.getGeolocationDisplayString)(cellValue, column.data);
55
- } else if (columnType === _dtableStore.CellType.CTIME || columnType === _dtableStore.CellType.MTIME) {
53
+ } else if (columnType === _dtableUtils.CellType.GEOLOCATION) {
54
+ text = (0, _dtableUtils.getGeolocationDisplayString)(cellValue, column.data);
55
+ } else if (columnType === _dtableUtils.CellType.CTIME || columnType === _dtableUtils.CellType.MTIME) {
56
56
  text = (0, _dayjs.default)(cellValue).format('YYYY-MM-DD HH:mm:ss');
57
57
  } else {
58
58
  text = cellValue;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getSqlString = exports.getSqlOrder = exports.getSqlGroup = exports.getPieChartSqlGroupName = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _constants = require("../constants");
9
9
  const getSqlOrder = (sortType, groupName) => {
10
10
  if (!sortType) {
@@ -33,7 +33,7 @@ const getSqlGroup = (granularity, column) => {
33
33
  return "CONCATENATE(year(".concat(columnName, "), \"-Q\", quarter(").concat(columnName, "))");
34
34
  }
35
35
  return "YEAR(".concat(columnName, ")");
36
- } else if (type === _dtableStore.CellType.GEOLOCATION) {
36
+ } else if (type === _dtableUtils.CellType.GEOLOCATION) {
37
37
  if (granularity === _constants.STATISTICS_COUNT_TYPE.PROVINCE) {
38
38
  return "PROVINCE(".concat(columnName, ")");
39
39
  }
@@ -70,7 +70,10 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
70
70
  isColumn,
71
71
  isCurrentView,
72
72
  isRow,
73
- getTableById
73
+ getTableById,
74
+ username,
75
+ userId,
76
+ userDepartmentIdsMap
74
77
  } = _ref;
75
78
  const {
76
79
  table_id,
@@ -80,7 +83,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
80
83
  type
81
84
  } = statItem;
82
85
  const selectedTable = getTableById(table_id);
83
- const selectedView = _dtableStore.Views.getViewById(selectedTable.views, view_id);
86
+ const selectedView = (0, _dtableUtils.getViewById)(selectedTable.views, view_id);
84
87
  const {
85
88
  groupName,
86
89
  selectedColumn,
@@ -89,7 +92,7 @@ const getSqlString = (statItem, statisticRecord, _ref) => {
89
92
  } = getDatabaseGroupName(statItem, selectedTable, {
90
93
  isCurrentView
91
94
  });
92
- const sqlCondition = (0, _dtableStore.filter2SqlCondition)(selectedTable, selectedView);
95
+ const sqlCondition = (0, _dtableUtils.filter2SqlCondition)(selectedTable, selectedView, username, userId, userDepartmentIdsMap);
93
96
  const isGroup = column_groupby_column_key && !column_groupby_multiple_numeric_column;
94
97
  const {
95
98
  name,
@@ -143,7 +146,7 @@ const getSqlGroupName = (name, original_name, column) => {
143
146
  const {
144
147
  type
145
148
  } = column || {};
146
- if (type === _dtableStore.CellType.SINGLE_SELECT || type === _dtableStore.CellType.MULTIPLE_SELECT) {
149
+ if (type === _dtableUtils.CellType.SINGLE_SELECT || type === _dtableUtils.CellType.MULTIPLE_SELECT) {
147
150
  return "'".concat(name, "'");
148
151
  }
149
152
  const newName = original_name ? original_name : name;
@@ -161,7 +164,7 @@ const getGroupName = (selectedColumn, _ref2) => {
161
164
  const isTimeColumn = _constants.TIME_COLUMN_LIST.includes(selectedColumn.type);
162
165
  if (isTimeColumn) {
163
166
  groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
164
- } else if (selectedColumn.type === _dtableStore.CellType.GEOLOCATION) {
167
+ } else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
165
168
  groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
166
169
  }
167
170
  return groupName;
@@ -209,13 +212,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
209
212
  groupby_geolocation_granularity = statItem.x_axis_geolocation_granularity;
210
213
  }
211
214
  if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
212
- columnSelectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
215
+ columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
213
216
  columnGroupName = getGroupName(columnSelectedColumn, {
214
217
  groupby_date_granularity: column_groupby_date_granularity,
215
218
  groupby_geolocation_granularity: column_groupby_geolocation_granularity
216
219
  });
217
220
  }
218
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
221
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
219
222
  groupName = getGroupName(selectedColumn, {
220
223
  groupby_date_granularity,
221
224
  groupby_geolocation_granularity
@@ -229,7 +232,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
229
232
  geolocation_granularity,
230
233
  geo_column
231
234
  } = statItem;
232
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, geo_column);
235
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, geo_column);
233
236
  groupName = getSqlGroup(geolocation_granularity, selectedColumn);
234
237
  break;
235
238
  }
@@ -240,7 +243,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
240
243
  const {
241
244
  column
242
245
  } = statItem;
243
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column);
246
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column);
244
247
  groupName = selectedColumn.name;
245
248
  break;
246
249
  }
@@ -249,7 +252,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
249
252
  const {
250
253
  time_column
251
254
  } = statItem;
252
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, time_column);
255
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, time_column);
253
256
  groupName = "ISODATE(".concat(selectedColumn.name, ")");
254
257
  break;
255
258
  }
@@ -258,7 +261,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
258
261
  const {
259
262
  group_column
260
263
  } = statItem;
261
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, group_column);
264
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, group_column);
262
265
  groupName = selectedColumn.name;
263
266
  break;
264
267
  }
@@ -273,7 +276,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
273
276
  x_axis_column_key,
274
277
  x_axis_date_granularity
275
278
  } = statItem;
276
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
279
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
277
280
  groupName = getSqlGroup(x_axis_date_granularity, selectedColumn);
278
281
  break;
279
282
  }
@@ -284,12 +287,12 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
284
287
  x_axis_date_granularity: groupby_date_granularity,
285
288
  x_axis_geolocation_granularity: groupby_geolocation_granularity
286
289
  } = statItem;
287
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, x_axis_column_key);
290
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, x_axis_column_key);
288
291
  if (!selectedColumn) return [];
289
292
  groupName = "`".concat(selectedColumn.name, "`");
290
293
  if (_constants.TIME_COLUMN_LIST.includes(selectedColumn.type)) {
291
294
  groupName = getSqlGroup(groupby_date_granularity, selectedColumn);
292
- } else if (selectedColumn.type === _dtableStore.CellType.GEOLOCATION) {
295
+ } else if (selectedColumn.type === _dtableUtils.CellType.GEOLOCATION) {
293
296
  groupName = getSqlGroup(groupby_geolocation_granularity, selectedColumn);
294
297
  }
295
298
  break;
@@ -300,7 +303,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
300
303
  date_column,
301
304
  date_granularity
302
305
  } = statItem;
303
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, date_column);
306
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, date_column);
304
307
  groupName = getSqlGroup(date_granularity, selectedColumn);
305
308
  break;
306
309
  }
@@ -310,7 +313,7 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
310
313
  const {
311
314
  name_column
312
315
  } = statItem;
313
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, name_column);
316
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, name_column);
314
317
  groupName = "`".concat(selectedColumn.name, "`");
315
318
  break;
316
319
  }
@@ -331,13 +334,13 @@ const getDatabaseGroupName = (statItem, selectedTable, _ref3) => {
331
334
  column_groupby_multiple_numeric_column
332
335
  } = statItem;
333
336
  if (!column_groupby_multiple_numeric_column && column_groupby_column_key) {
334
- columnSelectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, column_groupby_column_key);
337
+ columnSelectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, column_groupby_column_key);
335
338
  columnGroupName = getGroupName(columnSelectedColumn, {
336
339
  groupby_date_granularity: column_groupby_date_granularity,
337
340
  groupby_geolocation_granularity: column_groupby_geolocation_granularity
338
341
  });
339
342
  }
340
- selectedColumn = _dtableStore.TableUtils.getTableColumnByKey(selectedTable, groupby_column_key);
343
+ selectedColumn = (0, _dtableUtils.getTableColumnByKey)(selectedTable, groupby_column_key);
341
344
  groupName = getGroupName(selectedColumn, {
342
345
  groupby_date_granularity,
343
346
  groupby_geolocation_granularity
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _utils = require("../utils");
9
9
  var _collaborator = require("./collaborator");
10
10
  var _constants = require("../constants");
11
- const SUPPORT_SORT_COLUMNS = [_dtableStore.CellType.TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.DATE, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.RATE];
11
+ const SUPPORT_SORT_COLUMNS = [_dtableUtils.CellType.TEXT, _dtableUtils.CellType.NUMBER, _dtableUtils.CellType.DATE, _dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.FORMULA, _dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.CTIME, _dtableUtils.CellType.MTIME, _dtableUtils.CellType.RATE];
12
12
  class StatUtils {
13
13
  static getGroupLabel(cellValue, formulaRow, column, dateGranularity, geoGranularity, value) {
14
14
  let {
@@ -17,20 +17,20 @@ class StatUtils {
17
17
  data
18
18
  } = column;
19
19
  switch (type) {
20
- case _dtableStore.CellType.TEXT:
20
+ case _dtableUtils.CellType.TEXT:
21
21
  {
22
22
  return cellValue || null;
23
23
  }
24
- case _dtableStore.CellType.NUMBER:
24
+ case _dtableUtils.CellType.NUMBER:
25
25
  {
26
26
  if (!cellValue && cellValue !== 0) {
27
27
  return null;
28
28
  }
29
- const number = (0, _dtableStore.getPrecisionNumber)(cellValue, data);
29
+ const number = (0, _dtableUtils.getPrecisionNumber)(cellValue, data);
30
30
  let valueNumber = parseFloat(number);
31
- return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
31
+ return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
32
32
  }
33
- case _dtableStore.CellType.SINGLE_SELECT:
33
+ case _dtableUtils.CellType.SINGLE_SELECT:
34
34
  {
35
35
  let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
36
36
  if (isInvalidValue) {
@@ -38,20 +38,20 @@ class StatUtils {
38
38
  }
39
39
  return cellValue;
40
40
  }
41
- case _dtableStore.CellType.DATE:
42
- case _dtableStore.CellType.CTIME:
43
- case _dtableStore.CellType.MTIME:
41
+ case _dtableUtils.CellType.DATE:
42
+ case _dtableUtils.CellType.CTIME:
43
+ case _dtableUtils.CellType.MTIME:
44
44
  {
45
45
  if (!dateGranularity) {
46
- return (0, _dtableStore.getDateDisplayString)(cellValue);
46
+ return (0, _dtableUtils.getDateDisplayString)(cellValue);
47
47
  }
48
48
  if (dateGranularity.toUpperCase() === 'QUARTER') {
49
49
  // TODO: fix the unknown word 'QUARTAR'
50
- return _dtableStore.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
50
+ return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
51
51
  }
52
- return _dtableStore.DateUtils.getDateByGranularity(cellValue, dateGranularity);
52
+ return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity);
53
53
  }
54
- case _dtableStore.CellType.MULTIPLE_SELECT:
54
+ case _dtableUtils.CellType.MULTIPLE_SELECT:
55
55
  {
56
56
  let options = data && data.options;
57
57
  if (!Array.isArray(cellValue)) {
@@ -59,45 +59,45 @@ class StatUtils {
59
59
  }
60
60
  return cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
61
61
  }
62
- case _dtableStore.CellType.COLLABORATOR:
62
+ case _dtableUtils.CellType.COLLABORATOR:
63
63
  {
64
64
  if (!Array.isArray(cellValue)) return [];
65
65
  return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
66
66
  }
67
- case _dtableStore.CellType.CREATOR:
68
- case _dtableStore.CellType.LAST_MODIFIER:
67
+ case _dtableUtils.CellType.CREATOR:
68
+ case _dtableUtils.CellType.LAST_MODIFIER:
69
69
  {
70
70
  return cellValue ? cellValue : null;
71
71
  }
72
- case _dtableStore.CellType.LINK_FORMULA:
73
- case _dtableStore.CellType.FORMULA:
72
+ case _dtableUtils.CellType.LINK_FORMULA:
73
+ case _dtableUtils.CellType.FORMULA:
74
74
  {
75
75
  if (!formulaRow) return '';
76
76
  let formulaCellValue = formulaRow[key];
77
77
  let {
78
78
  result_type
79
79
  } = data || {};
80
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
81
- return (0, _dtableStore.getFormulaDisplayString)(formulaCellValue, data, {
80
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
81
+ return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
82
82
  tables: value.tables
83
83
  }) || null;
84
84
  }
85
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
86
- return (0, _dtableStore.getPrecisionNumber)(formulaCellValue, data);
85
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
86
+ return (0, _dtableUtils.getPrecisionNumber)(formulaCellValue, data);
87
87
  }
88
88
  return formulaCellValue ? formulaCellValue + '' : null;
89
89
  }
90
- case _dtableStore.CellType.GEOLOCATION:
90
+ case _dtableUtils.CellType.GEOLOCATION:
91
91
  {
92
92
  const {
93
93
  geo_format
94
94
  } = data || {};
95
95
  if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
96
- return (0, _dtableStore.getGeolocationDisplayString)(cellValue, data);
96
+ return (0, _dtableUtils.getGeolocationDisplayString)(cellValue, data);
97
97
  }
98
98
  return cellValue ? cellValue[geoGranularity] : null;
99
99
  }
100
- case _dtableStore.CellType.LINK:
100
+ case _dtableUtils.CellType.LINK:
101
101
  {
102
102
  const linkCellValue = formulaRow && formulaRow[key];
103
103
  if (!Array.isArray(linkCellValue)) {
@@ -105,11 +105,11 @@ class StatUtils {
105
105
  }
106
106
  return linkCellValue.map(linkVal => linkVal.display_value);
107
107
  }
108
- case _dtableStore.CellType.CHECKBOX:
108
+ case _dtableUtils.CellType.CHECKBOX:
109
109
  {
110
110
  return String(!!cellValue);
111
111
  }
112
- case _dtableStore.CellType.RATE:
112
+ case _dtableUtils.CellType.RATE:
113
113
  {
114
114
  if (!cellValue) return null;
115
115
  return cellValue + '';
@@ -127,7 +127,7 @@ class StatUtils {
127
127
  } = column;
128
128
  let sortType = 'up';
129
129
  let option_id_index_map = {};
130
- if (column_type === _dtableStore.CellType.SINGLE_SELECT) {
130
+ if (column_type === _dtableUtils.CellType.SINGLE_SELECT) {
131
131
  const {
132
132
  options
133
133
  } = data || {};
@@ -150,7 +150,7 @@ class StatUtils {
150
150
  }
151
151
  if (SUPPORT_SORT_COLUMNS.includes(column_type)) {
152
152
  switch (column_type) {
153
- case _dtableStore.CellType.NUMBER:
153
+ case _dtableUtils.CellType.NUMBER:
154
154
  {
155
155
  if (current) {
156
156
  current = current - 0;
@@ -158,42 +158,42 @@ class StatUtils {
158
158
  if (next) {
159
159
  next = next - 0;
160
160
  }
161
- return (0, _dtableStore.sortNumber)(current, next, sortType);
161
+ return (0, _dtableUtils.sortNumber)(current, next, sortType);
162
162
  }
163
- case _dtableStore.CellType.DATE:
164
- case _dtableStore.CellType.CTIME:
165
- case _dtableStore.CellType.MTIME:
163
+ case _dtableUtils.CellType.DATE:
164
+ case _dtableUtils.CellType.CTIME:
165
+ case _dtableUtils.CellType.MTIME:
166
166
  {
167
- return (0, _dtableStore.sortDate)(current, next, sortType);
167
+ return (0, _dtableUtils.sortDate)(current, next, sortType);
168
168
  }
169
- case _dtableStore.CellType.SINGLE_SELECT:
170
- case _dtableStore.CellType.MULTIPLE_SELECT:
169
+ case _dtableUtils.CellType.SINGLE_SELECT:
170
+ case _dtableUtils.CellType.MULTIPLE_SELECT:
171
171
  {
172
- return (0, _dtableStore.sortSingleSelect)(current, next, {
172
+ return (0, _dtableUtils.sortSingleSelect)(current, next, {
173
173
  sort_type: sortType,
174
174
  option_id_index_map
175
175
  });
176
176
  }
177
- case _dtableStore.CellType.FORMULA:
178
- case _dtableStore.CellType.LINK_FORMULA:
177
+ case _dtableUtils.CellType.FORMULA:
178
+ case _dtableUtils.CellType.LINK_FORMULA:
179
179
  {
180
180
  let {
181
181
  result_type
182
182
  } = data || {};
183
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
183
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
184
184
  if (current) {
185
185
  current = current - 0;
186
186
  }
187
187
  if (next) {
188
188
  next = next - 0;
189
189
  }
190
- return (0, _dtableStore.sortNumber)(current, next, sortType);
190
+ return (0, _dtableUtils.sortNumber)(current, next, sortType);
191
191
  }
192
- return (0, _dtableStore.sortText)(result_type, current, next, sortType);
192
+ return (0, _dtableUtils.sortText)(result_type, current, next, sortType);
193
193
  }
194
194
  default:
195
195
  {
196
- return (0, _dtableStore.sortText)(current, next, sortType);
196
+ return (0, _dtableUtils.sortText)(current, next, sortType);
197
197
  }
198
198
  }
199
199
  }
@@ -235,7 +235,7 @@ class StatUtils {
235
235
  let existMap = {};
236
236
  rows.forEach(r => {
237
237
  let num;
238
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
238
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
239
239
  const formulaRow = formula_rows[r._id] || {};
240
240
  num = formulaRow[summary_column_key];
241
241
  num = Array.isArray(num) ? num[0] : num;
@@ -264,14 +264,14 @@ class StatUtils {
264
264
  let validNumbersCount = 0;
265
265
  rows.forEach(r => {
266
266
  let num;
267
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
267
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
268
268
  let formulaRow = formula_rows[r._id] || {};
269
269
  num = formulaRow[summary_column_key];
270
270
  num = Array.isArray(num) ? num[0] : num;
271
271
  } else {
272
272
  num = r[summary_column_key];
273
273
  }
274
- if ((0, _dtableStore.isNumber)(num)) {
274
+ if ((0, _dtableUtils.isNumber)(num)) {
275
275
  validNumbersCount++;
276
276
  sum += num;
277
277
  }
@@ -289,7 +289,7 @@ class StatUtils {
289
289
  if (rowsLength > 0) {
290
290
  let result = rows.reduce((current, next) => {
291
291
  let currentValue, nextValue;
292
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
292
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
293
293
  let currentFormulaRow = formula_rows[current._id];
294
294
  let nextFormulaRow = formula_rows[next._id];
295
295
  currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
@@ -310,7 +310,7 @@ class StatUtils {
310
310
  return isNextGreater ? next : current;
311
311
  }
312
312
  });
313
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
313
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
314
314
  let formulaRow = formula_rows[result._id];
315
315
  total = formulaRow && formulaRow[summary_column_key];
316
316
  total = Array.isArray(total) ? total[0] : total;
@@ -339,10 +339,10 @@ class StatUtils {
339
339
  type,
340
340
  data
341
341
  } = column;
342
- if ((0, _dtableStore.isNumericColumn)(column)) {
343
- return (0, _dtableStore.getNumberDisplayString)(value, data);
342
+ if ((0, _dtableUtils.isNumericColumn)(column)) {
343
+ return (0, _dtableUtils.getNumberDisplayString)(value, data);
344
344
  }
345
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
345
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
346
346
  return (0, _utils.getClientFormulaDisplayString)(value, data);
347
347
  }
348
348
  return value;
@@ -103,6 +103,7 @@ function summaryDurationResult(result, duration, summaryType, summaryMethod, use
103
103
  }
104
104
  }
105
105
  } else {
106
+ // eslint-disable-next-line
106
107
  for (let item of result) {
107
108
  const key = item[0];
108
109
  if (key >= startDate && key < middleDate) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.3.6",
3
+ "version": "4.3.7",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -12,7 +12,7 @@
12
12
  "@seafile/seafile-calendar": "0.0.24",
13
13
  "comlink": "^4.3.1",
14
14
  "dayjs": "1.10.7",
15
- "dtable-store": "4.3.6",
15
+ "dtable-utils": "4.3.3",
16
16
  "dtable-web-api": "4.3.5",
17
17
  "glamor": "^2.20.40",
18
18
  "html2canvas": "^1.4.1",
@@ -55,6 +55,7 @@
55
55
  "css-minimizer-webpack-plugin": "^3.2.0",
56
56
  "dotenv": "^10.0.0",
57
57
  "dotenv-expand": "^5.1.0",
58
+ "dtable-store": "4.3.6",
58
59
  "eslint": "^8.3.0",
59
60
  "eslint-config-react-app": "^7.0.1",
60
61
  "eslint-webpack-plugin": "^3.1.1",