dtable-statistic 4.3.6 → 4.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) 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 +20 -34
  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/thread-manager.js +41 -41
  16. package/es/calculator/trend-calculator.js +6 -20
  17. package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
  18. package/es/calculator/workers/calculator.worker.js +5 -2
  19. package/es/calculator/workers/card-calculator-worker.js +13 -9
  20. package/es/calculator/workers/combination-calculator-worker.js +20 -16
  21. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
  22. package/es/calculator/workers/completeness-calculator-worker.js +21 -17
  23. package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
  24. package/es/calculator/workers/mirror-calculator-worker.js +14 -10
  25. package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
  26. package/es/calculator/workers/scatter-calculator-worker.js +15 -11
  27. package/es/calculator/workers/trend-calculator-worker.js +14 -10
  28. package/es/calculator/world-map-calculator.js +6 -20
  29. package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
  30. package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
  31. package/es/components/dialog/statistic-record-dialog/index.js +21 -11
  32. package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
  33. package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
  34. package/es/components/popover/color-rules-popover.js +2 -2
  35. package/es/components/select/select.js +3 -3
  36. package/es/components/toast/alert.js +2 -0
  37. package/es/components/toast/toastManager.js +1 -0
  38. package/es/constants/color-rules.js +3 -3
  39. package/es/constants/index.js +9 -9
  40. package/es/dashboard.js +7 -13
  41. package/es/desktop-dashboard.js +1 -1
  42. package/es/locale/lang/de.js +10 -10
  43. package/es/locale/lang/en.js +8 -8
  44. package/es/locale/lang/fr.js +10 -10
  45. package/es/locale/lang/zh_CN.js +8 -8
  46. package/es/model/basic-number-card.js +3 -3
  47. package/es/model/compare-bar.js +2 -2
  48. package/es/model/generic-model.js +11 -11
  49. package/es/model/heat-map.js +2 -2
  50. package/es/model/horizontal-bar.js +2 -2
  51. package/es/model/index.js +3 -2
  52. package/es/model/map.js +3 -3
  53. package/es/model/mirror.js +2 -2
  54. package/es/model/trend.js +2 -2
  55. package/es/model/world-map.js +3 -3
  56. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
  57. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
  58. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
  59. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  60. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
  61. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
  62. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
  63. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
  64. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
  65. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
  66. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
  67. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
  68. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
  69. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
  70. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +4 -18
  71. package/es/stat-editor/stat-settings/color-setting/color-picker.js +1 -0
  72. package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
  73. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
  74. package/es/stat-view/area-chart.js +4 -4
  75. package/es/stat-view/bar-chart.js +4 -4
  76. package/es/stat-view/base-chart.js +2 -2
  77. package/es/stat-view/basic-number-card.js +49 -49
  78. package/es/stat-view/combination-chart.js +69 -69
  79. package/es/stat-view/compare-chart.js +4 -4
  80. package/es/stat-view/completeness-chart.js +3 -3
  81. package/es/stat-view/custom-bar.js +2 -2
  82. package/es/stat-view/dashboard-chart.js +50 -50
  83. package/es/stat-view/heat-map.js +2 -2
  84. package/es/stat-view/horizontal-bar-chart.js +4 -4
  85. package/es/stat-view/line-chart.js +4 -4
  86. package/es/stat-view/map.js +3 -3
  87. package/es/stat-view/mirror.js +2 -2
  88. package/es/stat-view/pivot-table/index.js +6 -6
  89. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
  90. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
  91. package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
  92. package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
  93. package/es/stat-view/ring-chart.js +2 -2
  94. package/es/stat-view/scatter-chart.js +56 -56
  95. package/es/stat-view/treemap-chart.js +50 -49
  96. package/es/stat-view/trend-chart.js +52 -52
  97. package/es/stat-view/world-map.js +3 -3
  98. package/es/utils/cell-format.js +16 -16
  99. package/es/utils/cell-value.js +3 -3
  100. package/es/utils/color-utils.js +3 -3
  101. package/es/utils/column-utils.js +10 -10
  102. package/es/utils/column.js +2 -2
  103. package/es/utils/common-utils.js +10 -8
  104. package/es/utils/export-table-utils.js +38 -38
  105. package/es/utils/object.js +3 -3
  106. package/es/utils/pivot-table.js +3 -3
  107. package/es/utils/row-utils.js +17 -17
  108. package/es/utils/search.js +14 -14
  109. package/es/utils/sql-utils.js +23 -20
  110. package/es/utils/stat-utils.js +52 -52
  111. package/es/utils/trend-utils.js +1 -0
  112. package/package.json +6 -3
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.updateStatisticToTable = exports.exportStatisticToTable = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
10
- var _dtableStore = require("dtable-store");
10
+ var _dtableUtils = require("dtable-utils");
11
11
  var _cellValue = require("./cell-value");
12
12
  var _column = require("./column");
13
13
  var _collaborator = require("./collaborator");
@@ -21,7 +21,7 @@ const isSummaryDateColumn = summaryColumn => {
21
21
  const {
22
22
  type
23
23
  } = summaryColumn;
24
- return type !== _dtableStore.CellType.LINK && (0, _dtableStore.isDateColumn)(summaryColumn);
24
+ return type !== _dtableUtils.CellType.LINK && (0, _dtableUtils.isDateColumn)(summaryColumn);
25
25
  };
26
26
 
27
27
  // eslint-disable-next-line
@@ -34,31 +34,31 @@ const getTableValueDisplayName = (value, column) => {
34
34
  collaborators
35
35
  } = window.app.state;
36
36
  switch (type) {
37
- case _dtableStore.CellType.SINGLE_SELECT:
38
- case _dtableStore.CellType.MULTIPLE_SELECT:
37
+ case _dtableUtils.CellType.SINGLE_SELECT:
38
+ case _dtableUtils.CellType.MULTIPLE_SELECT:
39
39
  {
40
40
  let options = (0, _column.getSelectColumnOptions)(column);
41
- let option = (0, _dtableStore.getOption)(options, value) || {};
41
+ let option = (0, _dtableUtils.getOption)(options, value) || {};
42
42
  return option.name;
43
43
  }
44
- case _dtableStore.CellType.COLLABORATOR:
44
+ case _dtableUtils.CellType.COLLABORATOR:
45
45
  {
46
- let collaborator = (0, _dtableStore.getCollaborator)(collaborators, value) || {};
46
+ let collaborator = (0, _dtableUtils.getCollaborator)(collaborators, value) || {};
47
47
  return collaborator.name;
48
48
  }
49
- case _dtableStore.CellType.CREATOR:
50
- case _dtableStore.CellType.LAST_MODIFIER:
49
+ case _dtableUtils.CellType.CREATOR:
50
+ case _dtableUtils.CellType.LAST_MODIFIER:
51
51
  {
52
52
  let collaborator = (0, _collaborator.getKnownCreatorByEmail)(collaborators, value) || {};
53
53
  return collaborator.name;
54
54
  }
55
- case _dtableStore.CellType.NUMBER:
55
+ case _dtableUtils.CellType.NUMBER:
56
56
  {
57
57
  let valueNumber = parseFloat(value);
58
- let displayValue = (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, data) : value;
58
+ let displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
59
59
  return displayValue;
60
60
  }
61
- case _dtableStore.CellType.DATE:
61
+ case _dtableUtils.CellType.DATE:
62
62
  {
63
63
  let displayValue = value;
64
64
  if (value && value.split('-').length === 3) {
@@ -71,16 +71,16 @@ const getTableValueDisplayName = (value, column) => {
71
71
  }
72
72
  return displayValue;
73
73
  }
74
- case _dtableStore.CellType.FORMULA:
75
- case _dtableStore.CellType.LINK_FORMULA:
74
+ case _dtableUtils.CellType.FORMULA:
75
+ case _dtableUtils.CellType.LINK_FORMULA:
76
76
  {
77
77
  let displayValue = value;
78
78
  let {
79
79
  result_type
80
80
  } = data || {};
81
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
81
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
82
82
  let valueNumber = parseFloat(value);
83
- displayValue = (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, data) : value;
83
+ displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
84
84
  }
85
85
  return displayValue;
86
86
  }
@@ -96,19 +96,19 @@ const getValidValueForColumn = (column, value) => {
96
96
  type,
97
97
  data
98
98
  } = column;
99
- if (_dtableStore.FORMULA_COLUMN_TYPES.includes(type)) return '';
100
- if (type === _dtableStore.CellType.NUMBER) {
99
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) return '';
100
+ if (type === _dtableUtils.CellType.NUMBER) {
101
101
  if (!value && value !== 0) return '';
102
102
  if (typeof value === 'number') return value;
103
103
  return '';
104
104
  }
105
- if (type === _dtableStore.CellType.DATE) {
105
+ if (type === _dtableUtils.CellType.DATE) {
106
106
  if (!value) return '';
107
107
  if (typeof value !== 'string') return '';
108
108
  const validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
109
109
  return (0, _dayjs.default)(value).format(validValueFormat);
110
110
  }
111
- if (type === _dtableStore.CellType.TEXT) return value ? value : '';
111
+ if (type === _dtableUtils.CellType.TEXT) return value ? value : '';
112
112
  return '';
113
113
  };
114
114
  const exportOneDimensionToTable = _ref => {
@@ -132,7 +132,7 @@ const exportOneDimensionToTable = _ref => {
132
132
  let columns = [{
133
133
  // first column
134
134
  key: '0000',
135
- type: _dtableStore.CellType.TEXT,
135
+ type: _dtableUtils.CellType.TEXT,
136
136
  name: groupbyColumn.name,
137
137
  data: null
138
138
  }];
@@ -179,7 +179,7 @@ const exportOneDimensionToTable = _ref => {
179
179
 
180
180
  // total column
181
181
  const totalColumn = {
182
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
182
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
183
183
  name: _reactIntlUniversal.default.get('Total'),
184
184
  data: columnData
185
185
  };
@@ -218,9 +218,9 @@ const exportOneDimensionToTable = _ref => {
218
218
  if (column) {
219
219
  const columnName = column.name;
220
220
  let columnData;
221
- let columnType = _dtableStore.CellType.NUMBER;
221
+ let columnType = _dtableUtils.CellType.NUMBER;
222
222
  if (isSummaryDateColumn(column)) {
223
- columnType = _dtableStore.CellType.DATE;
223
+ columnType = _dtableUtils.CellType.DATE;
224
224
  const {
225
225
  format
226
226
  } = column.data || {};
@@ -282,7 +282,7 @@ const exportOneDimensionToTable = _ref => {
282
282
  data
283
283
  } = column;
284
284
  let cellValue = total[cellValueKey];
285
- if (type === _dtableStore.CellType.DATE && cellValue) {
285
+ if (type === _dtableUtils.CellType.DATE && cellValue) {
286
286
  const dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
287
287
  cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
288
288
  }
@@ -315,7 +315,7 @@ const exportTwoDimensionToTable = _ref2 => {
315
315
  let columns = [{
316
316
  // first column
317
317
  key: '0000',
318
- type: _dtableStore.CellType.TEXT,
318
+ type: _dtableUtils.CellType.TEXT,
319
319
  name: groupbyColumn.name,
320
320
  data: null
321
321
  }];
@@ -363,7 +363,7 @@ const exportTwoDimensionToTable = _ref2 => {
363
363
  } = item;
364
364
  const columnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : key;
365
365
  const newColumn = {
366
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
366
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
367
367
  name: columnName,
368
368
  data: columnData
369
369
  };
@@ -373,7 +373,7 @@ const exportTwoDimensionToTable = _ref2 => {
373
373
 
374
374
  // total column
375
375
  const totalColumn = {
376
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
376
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
377
377
  name: _reactIntlUniversal.default.get('Total'),
378
378
  data: columnData
379
379
  };
@@ -435,7 +435,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
435
435
  let columns = [{
436
436
  // name column
437
437
  key: '0000',
438
- type: _dtableStore.CellType.TEXT,
438
+ type: _dtableUtils.CellType.TEXT,
439
439
  name: groupbyColumnName,
440
440
  data: null
441
441
  }];
@@ -458,7 +458,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
458
458
  const newColumnName = "".concat(pivotColumnColumnName, "-").concat(column_name);
459
459
  columns.push({
460
460
  // just support number column
461
- type: _dtableStore.CellType.NUMBER,
461
+ type: _dtableUtils.CellType.NUMBER,
462
462
  name: newColumnName,
463
463
  data
464
464
  });
@@ -473,7 +473,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
473
473
  });
474
474
  });
475
475
  columns.push({
476
- type: _dtableStore.CellType.NUMBER,
476
+ type: _dtableUtils.CellType.NUMBER,
477
477
  name: _reactIntlUniversal.default.get('Total'),
478
478
  data: firstSummaryColumn.data
479
479
  });
@@ -537,7 +537,7 @@ const updatedOneDimensionToTable = _ref5 => {
537
537
  statisticTableColumns
538
538
  } = statisticalResult;
539
539
  if (!groupbyColumn) return {};
540
- const nameColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
540
+ const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
541
541
  if (!nameColumn) return {};
542
542
  const {
543
543
  pivot_rows,
@@ -554,7 +554,7 @@ const updatedOneDimensionToTable = _ref5 => {
554
554
 
555
555
  // one dimension table no summary columns
556
556
  if (pivot_columns.length < 2) {
557
- columnMap['total'] = _dtableStore.TableUtils.getTableColumnByName(updateTable, _reactIntlUniversal.default.get('Total'));
557
+ columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
558
558
 
559
559
  // updated rows
560
560
  pivot_rows.forEach(item => {
@@ -606,7 +606,7 @@ const updatedOneDimensionToTable = _ref5 => {
606
606
  } = item;
607
607
  const column = statisticTableColumns.find(column => column.key === key);
608
608
  if (column) {
609
- columnMap[key] = _dtableStore.TableUtils.getTableColumnByName(updateTable, column.name);
609
+ columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
610
610
  }
611
611
  });
612
612
 
@@ -679,7 +679,7 @@ const updateTwoDimensionToTable = _ref6 => {
679
679
  pivotResult,
680
680
  groupbyColumn
681
681
  } = statisticalResult;
682
- const nameColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
682
+ const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
683
683
  if (!nameColumn) return {};
684
684
  const {
685
685
  pivot_rows,
@@ -702,11 +702,11 @@ const updateTwoDimensionToTable = _ref6 => {
702
702
  original_key
703
703
  } = item;
704
704
  const columnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : key;
705
- const column = _dtableStore.TableUtils.getTableColumnByName(updateTable, columnName);
705
+ const column = (0, _dtableUtils.getTableColumnByName)(updateTable, columnName);
706
706
  columnMap[columnName] = column;
707
707
  updateColumns.push(column);
708
708
  });
709
- const totalColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, _reactIntlUniversal.default.get('Total'));
709
+ const totalColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
710
710
  columnMap['total'] = totalColumn;
711
711
  updateColumns.push(totalColumn);
712
712
 
@@ -800,7 +800,7 @@ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
800
800
  const {
801
801
  groupbyColumn
802
802
  } = statisticalResult;
803
- const nameColumn = groupbyColumn && _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
803
+ const nameColumn = groupbyColumn && (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
804
804
  if (!nameColumn) return {};
805
805
  const {
806
806
  columns: exportingColumns,
@@ -8,17 +8,17 @@ var _react = require("react");
8
8
  const isSameObject = (a, b) => {
9
9
  let k;
10
10
  for (k in a) {
11
- if (a.hasOwnProperty(k)) {
11
+ if (hasOwnProperty(a, k)) {
12
12
  if (typeof a[k] === 'function' && typeof b[k] === 'function' || /*#__PURE__*/(0, _react.isValidElement)(a[k]) && /*#__PURE__*/(0, _react.isValidElement)(b[k])) {
13
13
  continue;
14
14
  }
15
- if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
15
+ if (!hasOwnProperty(b, k) || a[k] !== b[k]) {
16
16
  return false;
17
17
  }
18
18
  }
19
19
  }
20
20
  for (k in b) {
21
- if (b.hasOwnProperty(k) && !a.hasOwnProperty(k)) {
21
+ if (hasOwnProperty(b, k) && !hasOwnProperty(a, k)) {
22
22
  return false;
23
23
  }
24
24
  }
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getPivotTableSummaryTotal = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _constants = require("../constants");
9
9
  const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) => {
10
10
  if (!isSqlQuery) {
11
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
11
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
12
12
  const cellValue = formulaRow[columnKey];
13
13
  return Array.isArray(cellValue) ? cellValue[0] : cellValue;
14
14
  }
@@ -53,7 +53,7 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
53
53
  rows.forEach(row => {
54
54
  const formulaRow = formulaRows && formulaRows[row._id];
55
55
  let cellValue = getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
56
- if ((0, _dtableStore.isNumber)(cellValue)) {
56
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
57
57
  validNumbersCount++;
58
58
  sum += cellValue;
59
59
  }
@@ -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