sea-chart 2.0.47 → 2.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.js +11 -4
- package/dist/components/cell-factory/FormatterConfig.js +62 -55
- package/dist/components/cell-factory/SimpleCellFormatter.js +11 -4
- package/dist/components/cell-factory/SingleSelectOption.js +18 -11
- package/dist/components/cell-factory/cell-editor-factory.js +12 -5
- package/dist/components/cell-factory/cell-formatter-factory.js +11 -4
- package/dist/components/cell-factory/link-content.js +35 -27
- package/dist/components/chart-color-selector/color-selector.js +18 -11
- package/dist/components/collaborator/index.js +14 -7
- package/dist/components/color-picker/index.js +18 -11
- package/dist/components/color-popover/color-rules/color-rule.js +33 -25
- package/dist/components/color-popover/color-rules/index.js +14 -6
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +34 -27
- package/dist/components/color-popover/color-rules/rule-filters/index.js +25 -17
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +18 -10
- package/dist/components/color-popover/color-rules-popover.js +34 -26
- package/dist/components/color-popover/color-selector-popover.js +18 -10
- package/dist/components/color-setting/color-group-selector.js +20 -12
- package/dist/components/common-add-tool/index.js +13 -6
- package/dist/components/data-process-setter/data-setting-header.js +14 -7
- package/dist/components/data-process-setter/hide-column-setter.js +19 -12
- package/dist/components/data-process-setter/index.js +27 -4
- package/dist/components/data-process-setter/sort-setter.js +24 -16
- package/dist/components/draggable/Draggable.js +13 -7
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +48 -40
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +18 -10
- package/dist/components/drill-down-settings/index.js +18 -11
- package/dist/components/dtable-popover/index.js +20 -13
- package/dist/components/dtable-search-input/index.js +21 -13
- package/dist/components/font-settings/index.js +22 -14
- package/dist/components/goal-line-setting/goal-setting-item.js +14 -6
- package/dist/components/goal-line-setting/index.js +19 -12
- package/dist/components/highlighter/highlighter.js +14 -7
- package/dist/components/icon/index.js +11 -4
- package/dist/components/index.js +48 -7
- package/dist/components/loading/index.js +13 -6
- package/dist/components/number-input/index.js +11 -4
- package/dist/components/pixel-editor/index.js +23 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +15 -8
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +33 -25
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +18 -9
- package/dist/components/popover/sort-popover/sort-popover.js +64 -54
- package/dist/components/resize-handle/ResizeHandle.js +13 -6
- package/dist/components/row-card/row-card-header-cell.js +22 -15
- package/dist/components/row-card/row-card-header.js +21 -14
- package/dist/components/row-card/row-card-item.js +41 -33
- package/dist/components/row-card/row-card.js +23 -15
- package/dist/components/statistic-record-dialog/index.js +64 -56
- package/dist/components/tooltip/index.js +22 -15
- package/dist/components/types-dialog/index.js +64 -56
- package/dist/components/types-dialog/use-force-update.js +10 -4
- package/dist/constants/color-rules.js +14 -8
- package/dist/constants/common-constants.js +14 -8
- package/dist/constants/error.js +8 -2
- package/dist/constants/geolocation.js +15 -9
- package/dist/constants/index.js +274 -145
- package/dist/constants/key-codes.js +2 -0
- package/dist/constants/model.js +9 -3
- package/dist/constants/regions.js +8 -3
- package/dist/constants/style.js +12 -6
- package/dist/constants/table.js +7 -1
- package/dist/constants/type-image.js +39 -33
- package/dist/constants/type.js +9 -3
- package/dist/context.js +18 -11
- package/dist/editor/index.js +15 -8
- package/dist/index.js +104 -13
- package/dist/intl.js +17 -10
- package/dist/locale/index.js +23 -16
- package/dist/locale/lang/de.js +7 -1
- package/dist/locale/lang/en.js +7 -1
- package/dist/locale/lang/es.js +7 -1
- package/dist/locale/lang/fr.js +7 -1
- package/dist/locale/lang/pt.js +7 -1
- package/dist/locale/lang/ru.js +7 -1
- package/dist/locale/lang/zh_CN.js +7 -1
- package/dist/model/area-group.js +19 -12
- package/dist/model/area.js +19 -12
- package/dist/model/bar-custom.js +18 -11
- package/dist/model/bar-group.js +19 -12
- package/dist/model/bar-stack.js +17 -10
- package/dist/model/bar.js +18 -11
- package/dist/model/base-model.js +11 -4
- package/dist/model/basic-number-card.js +20 -13
- package/dist/model/chart.js +13 -7
- package/dist/model/combination.js +22 -15
- package/dist/model/compare-bar.js +21 -14
- package/dist/model/completeness-group.js +18 -11
- package/dist/model/completeness.js +17 -10
- package/dist/model/dashboard.js +14 -7
- package/dist/model/funnel.js +21 -14
- package/dist/model/generic-model.js +143 -135
- package/dist/model/heat-map.js +16 -9
- package/dist/model/horizontal-bar.js +18 -11
- package/dist/model/horizontal-group-bar.js +17 -10
- package/dist/model/index.js +93 -69
- package/dist/model/line-group.js +20 -13
- package/dist/model/line.js +19 -12
- package/dist/model/map-bubble.js +19 -12
- package/dist/model/map.js +19 -12
- package/dist/model/mirror.js +20 -13
- package/dist/model/pie.js +19 -12
- package/dist/model/ring.js +19 -12
- package/dist/model/scatter.js +17 -10
- package/dist/model/stacked-horizontal-bar.js +18 -11
- package/dist/model/table-element.js +12 -5
- package/dist/model/table.js +14 -7
- package/dist/model/tree-map.js +14 -7
- package/dist/model/trend.js +18 -11
- package/dist/model/user.js +7 -1
- package/dist/model/world-map-bubble.js +19 -12
- package/dist/model/world-map.js +19 -12
- package/dist/services/map-json.js +13 -7
- package/dist/settings/advance-bar-settings/data-settings.js +44 -36
- package/dist/settings/advance-bar-settings/index.js +20 -3
- package/dist/settings/advance-bar-settings/style-settings.js +74 -66
- package/dist/settings/bar-settings/data-settings.js +47 -39
- package/dist/settings/bar-settings/index.js +20 -3
- package/dist/settings/bar-settings/style-settings.js +60 -52
- package/dist/settings/basic-number-card/data-settings.js +57 -49
- package/dist/settings/basic-number-card/index.js +20 -3
- package/dist/settings/basic-number-card/style-settings.js +26 -18
- package/dist/settings/combination-settings/data-settings.js +63 -55
- package/dist/settings/combination-settings/index.js +20 -3
- package/dist/settings/combination-settings/style-settings.js +77 -69
- package/dist/settings/completeness-settings/callbacks/callbacks.js +27 -16
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +28 -21
- package/dist/settings/completeness-settings/data-settings/data-settings.js +32 -25
- package/dist/settings/completeness-settings/index.js +20 -3
- package/dist/settings/completeness-settings/style-settings.js +26 -19
- package/dist/settings/dashboard-settings/data-settings.js +51 -43
- package/dist/settings/dashboard-settings/index.js +13 -2
- package/dist/settings/data-settings.js +79 -72
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +19 -12
- package/dist/settings/funnel-settings/components/dnd-list.js +23 -15
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +40 -32
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +28 -20
- package/dist/settings/funnel-settings/data-settings.js +31 -23
- package/dist/settings/funnel-settings/index.js +20 -3
- package/dist/settings/funnel-settings/style-settings.js +19 -11
- package/dist/settings/heat-map-settings/data-settings.js +26 -18
- package/dist/settings/heat-map-settings/index.js +20 -3
- package/dist/settings/heat-map-settings/style-settings.js +26 -18
- package/dist/settings/horizontal-bar-settings/data-settings.js +19 -12
- package/dist/settings/horizontal-bar-settings/index.js +20 -3
- package/dist/settings/horizontal-bar-settings/style-settings.js +19 -12
- package/dist/settings/index.js +70 -52
- package/dist/settings/map-settings/components/location-field-selector.js +17 -10
- package/dist/settings/map-settings/components/map-level-selector.js +18 -11
- package/dist/settings/map-settings/components/map-province-city-selector.js +26 -19
- package/dist/settings/map-settings/index.js +20 -3
- package/dist/settings/map-settings/map-data-settings.js +30 -23
- package/dist/settings/map-settings/map-style-settings.js +34 -26
- package/dist/settings/mirror-settings/data-settings.js +34 -26
- package/dist/settings/mirror-settings/index.js +13 -2
- package/dist/settings/pie-settings/data-settings.js +41 -33
- package/dist/settings/pie-settings/index.js +20 -3
- package/dist/settings/pie-settings/style-settings.js +55 -47
- package/dist/settings/scatter/data-settings.js +34 -27
- package/dist/settings/scatter/index.js +12 -3
- package/dist/settings/stacks-settings/index.js +27 -19
- package/dist/settings/stacks-settings/stack-item-settings.js +27 -19
- package/dist/settings/style-settings.js +72 -64
- package/dist/settings/table-element-settings/components/data-filter.js +38 -30
- package/dist/settings/table-element-settings/data-settings.js +29 -21
- package/dist/settings/table-element-settings/index.js +13 -2
- package/dist/settings/table-settings/data-settings.js +119 -111
- package/dist/settings/table-settings/index.js +13 -2
- package/dist/settings/time-comparison-settings/data-settings.js +51 -43
- package/dist/settings/time-comparison-settings/index.js +20 -3
- package/dist/settings/time-comparison-settings/style-settings.js +53 -45
- package/dist/settings/trend-settings/data-settings.js +32 -24
- package/dist/settings/trend-settings/index.js +20 -3
- package/dist/settings/trend-settings/style-setting.js +25 -17
- package/dist/settings/widgets/axis-title-font-settings/index.js +17 -10
- package/dist/settings/widgets/basic-summary/index.js +63 -55
- package/dist/settings/widgets/chart-type/index.js +26 -18
- package/dist/settings/widgets/color-settings/index.js +80 -72
- package/dist/settings/widgets/common-data-settings.js +29 -21
- package/dist/settings/widgets/data-filter/index.js +43 -35
- package/dist/settings/widgets/data-sort.js +24 -16
- package/dist/settings/widgets/date-summary-item.js +32 -24
- package/dist/settings/widgets/display-values-settings/index.js +22 -14
- package/dist/settings/widgets/divider/index.js +16 -8
- package/dist/settings/widgets/font-settings/font-color-settings.js +19 -11
- package/dist/settings/widgets/font-settings/font-size-settings.js +22 -14
- package/dist/settings/widgets/font-settings/font-weight-settings.js +25 -17
- package/dist/settings/widgets/font-settings/index.js +27 -4
- package/dist/settings/widgets/group-by.js +59 -51
- package/dist/settings/widgets/min-max-setting.js +18 -10
- package/dist/settings/widgets/mininum-slice-percent.js +18 -10
- package/dist/settings/widgets/numeric-summary-item.js +31 -23
- package/dist/settings/widgets/select-line-type/index.js +17 -10
- package/dist/settings/widgets/select-table/index.js +16 -9
- package/dist/settings/widgets/select-view/index.js +28 -20
- package/dist/settings/widgets/stack.js +22 -14
- package/dist/settings/widgets/summary-method-setting.js +25 -17
- package/dist/settings/widgets/summary-settings.js +80 -72
- package/dist/settings/widgets/switch/index.js +15 -8
- package/dist/settings/widgets/text-horizontal-settings.js +23 -15
- package/dist/settings/widgets/time-picker.js +37 -29
- package/dist/settings/widgets/title-settings/index.js +37 -29
- package/dist/settings/widgets/title-settings/title-text.js +12 -5
- package/dist/settings/widgets/x-axios.js +1 -0
- package/dist/settings/widgets/y-axis-group-settings.js +71 -63
- package/dist/utils/cell-format-utils.js +28 -18
- package/dist/utils/cell-value-utils.js +12 -5
- package/dist/utils/chart-utils/base-utils.js +345 -337
- package/dist/utils/chart-utils/index.js +41 -28
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +85 -78
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -13
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +52 -45
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +39 -32
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +23 -16
- package/dist/utils/chart-utils/original-data-utils/index.js +57 -50
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +28 -21
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +97 -91
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +26 -19
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +38 -31
- package/dist/utils/chart-utils/sql-statistics-utils.js +240 -232
- package/dist/utils/chart.js +17 -9
- package/dist/utils/collaborator-manager.js +9 -3
- package/dist/utils/collaborator-utils.js +30 -18
- package/dist/utils/collaborator.js +13 -4
- package/dist/utils/color-utils.js +29 -18
- package/dist/utils/column-utils.js +92 -65
- package/dist/utils/common-utils.js +52 -27
- package/dist/utils/concurrency-manager.js +7 -1
- package/dist/utils/contexts.js +12 -5
- package/dist/utils/date-translate.js +19 -11
- package/dist/utils/digital-sign-utils.js +14 -7
- package/dist/utils/event-bus.js +7 -1
- package/dist/utils/hotkey.js +11 -5
- package/dist/utils/index.js +221 -54
- package/dist/utils/key-generator.js +9 -2
- package/dist/utils/map.js +31 -22
- package/dist/utils/object-utils.js +7 -1
- package/dist/utils/options-utils.js +16 -8
- package/dist/utils/row-record-utils.js +180 -168
- package/dist/utils/row-utils.js +38 -27
- package/dist/utils/search.js +32 -24
- package/dist/utils/sql/chart-data-sql.js +55 -49
- package/dist/utils/sql/column-2-sql-column.js +156 -146
- package/dist/utils/sql/index.js +27 -3
- package/dist/utils/trend-utils.js +47 -39
- package/dist/view/index.js +95 -89
- package/dist/view/title/index.js +23 -15
- package/dist/view/wrapper/area-group.js +47 -39
- package/dist/view/wrapper/area.js +45 -37
- package/dist/view/wrapper/bar-compare.js +41 -33
- package/dist/view/wrapper/bar-custom-stack.js +39 -31
- package/dist/view/wrapper/bar-group.js +48 -40
- package/dist/view/wrapper/bar-stack.js +51 -43
- package/dist/view/wrapper/bar.js +43 -35
- package/dist/view/wrapper/basic-number-card.js +26 -18
- package/dist/view/wrapper/chart-component.js +112 -104
- package/dist/view/wrapper/combination.js +55 -47
- package/dist/view/wrapper/completeness-group.js +38 -30
- package/dist/view/wrapper/completeness.js +36 -28
- package/dist/view/wrapper/dashboard.js +33 -25
- package/dist/view/wrapper/funnel.js +38 -30
- package/dist/view/wrapper/heat-map.js +64 -56
- package/dist/view/wrapper/horizontal-bar-group.js +55 -47
- package/dist/view/wrapper/horizontal-bar-stack.js +49 -41
- package/dist/view/wrapper/horizontal-bar.js +43 -35
- package/dist/view/wrapper/index.js +115 -107
- package/dist/view/wrapper/line-group.js +45 -37
- package/dist/view/wrapper/line.js +44 -36
- package/dist/view/wrapper/map-bubble.js +46 -38
- package/dist/view/wrapper/map-world-bubble.js +45 -37
- package/dist/view/wrapper/map-world.js +47 -39
- package/dist/view/wrapper/map.js +48 -40
- package/dist/view/wrapper/mirror.js +41 -33
- package/dist/view/wrapper/pie.js +47 -39
- package/dist/view/wrapper/ring.js +50 -42
- package/dist/view/wrapper/scatter.js +45 -37
- package/dist/view/wrapper/table/index.js +21 -13
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +57 -49
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +58 -50
- package/dist/view/wrapper/table/pivot-table-display-name.js +91 -83
- package/dist/view/wrapper/table/two-dimension-table.js +84 -76
- package/dist/view/wrapper/table-element/components/dataset-utils.js +36 -23
- package/dist/view/wrapper/table-element/components/formatter.js +105 -96
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +31 -22
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/formula-formatter.js +16 -9
- package/dist/view/wrapper/table-element/components/link-formatter.js +80 -73
- package/dist/view/wrapper/table-element/components/record.js +17 -10
- package/dist/view/wrapper/table-element/components/records-body.js +17 -9
- package/dist/view/wrapper/table-element/components/records-header/index.js +15 -7
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +16 -8
- package/dist/view/wrapper/table-element/components/records.js +29 -21
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +12 -5
- package/dist/view/wrapper/table-element/components/utils.js +15 -5
- package/dist/view/wrapper/table-element/components/value-display-utils.js +11 -4
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +13 -6
- package/dist/view/wrapper/table-element/index.js +26 -18
- package/dist/view/wrapper/treemap.js +41 -33
- package/dist/view/wrapper/trend.js +49 -41
- package/package.json +7 -2
|
@@ -1,20 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
exports.findIfColumnDataIsArray = findIfColumnDataIsArray;
|
|
9
|
+
var _shallowequal = _interopRequireDefault(require("shallowequal"));
|
|
10
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
|
+
var _slugid = _interopRequireDefault(require("slugid"));
|
|
12
|
+
var _dtableUtils = require("dtable-utils");
|
|
13
|
+
var _constants = require("../../constants");
|
|
14
|
+
var _cellFormatUtils = require("../cell-format-utils");
|
|
15
|
+
var _collaboratorUtils = require("../collaborator-utils");
|
|
16
|
+
var _columnUtils = require("../column-utils");
|
|
17
|
+
var _intl = _interopRequireDefault(require("../../intl"));
|
|
18
|
+
var _context = _interopRequireDefault(require("../../context"));
|
|
19
|
+
var _collaborator = require("../collaborator");
|
|
20
|
+
var _index = require("../index");
|
|
1
21
|
var _BaseUtils;
|
|
2
|
-
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import slugid from 'slugid';
|
|
5
|
-
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getMultipleOptionName, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isEmpty, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString, isArchiveView, getViewById, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP } from 'dtable-utils';
|
|
6
|
-
import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE, HORIZONTAL_BAR_CHART_TYPES, COMPLTETELESS_CHART_TYPES, CHART_STYLE_CONFIG_SETTING_KEYS, MAP_CHART_TYPES, DEFAULT_ITEM_COLOR } from '../../constants';
|
|
7
|
-
import { getClientFormulaDisplayString } from '../cell-format-utils';
|
|
8
|
-
import { getKnownCollaboratorByEmail, generateDefaultUser } from '../collaborator-utils';
|
|
9
|
-
import { getDateColumnFormat, getColumnByKey } from '../column-utils';
|
|
10
|
-
import intl from '../../intl';
|
|
11
|
-
import context from '../../context';
|
|
12
|
-
import { isValidCollaboratorEmail } from '../collaborator';
|
|
13
|
-
import { formatRowTotal, getFirstDayOfWeekForGroupby } from '../index';
|
|
14
|
-
export function findIfColumnDataIsArray(column) {
|
|
22
|
+
function findIfColumnDataIsArray(column) {
|
|
15
23
|
// link-formula may also be an array type column
|
|
16
|
-
let isGroupbyColumnDataAsAnArray = !!MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[column.type];
|
|
17
|
-
if (column.type === CellType.LINK_FORMULA) {
|
|
24
|
+
let isGroupbyColumnDataAsAnArray = !!_dtableUtils.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[column.type];
|
|
25
|
+
if (column.type === _dtableUtils.CellType.LINK_FORMULA) {
|
|
18
26
|
const {
|
|
19
27
|
result_type
|
|
20
28
|
} = column.data || {};
|
|
@@ -42,12 +50,12 @@ BaseUtils.updateSummaryValuePrecision = (result, summaryColumn, summaryValueKey)
|
|
|
42
50
|
if (enable_precision) {
|
|
43
51
|
result.forEach(item => {
|
|
44
52
|
if (format === 'percent') {
|
|
45
|
-
item[summaryValueKey] = parseFloat(getPrecisionNumber(item[summaryValueKey] * 100, {
|
|
53
|
+
item[summaryValueKey] = parseFloat((0, _dtableUtils.getPrecisionNumber)(item[summaryValueKey] * 100, {
|
|
46
54
|
enable_precision,
|
|
47
55
|
precision
|
|
48
56
|
})) / 100;
|
|
49
57
|
} else {
|
|
50
|
-
item[summaryValueKey] = parseFloat(getPrecisionNumber(item[summaryValueKey], {
|
|
58
|
+
item[summaryValueKey] = parseFloat((0, _dtableUtils.getPrecisionNumber)(item[summaryValueKey], {
|
|
51
59
|
enable_precision,
|
|
52
60
|
precision
|
|
53
61
|
}));
|
|
@@ -56,21 +64,21 @@ BaseUtils.updateSummaryValuePrecision = (result, summaryColumn, summaryValueKey)
|
|
|
56
64
|
}
|
|
57
65
|
};
|
|
58
66
|
BaseUtils.isCollaborator = column => {
|
|
59
|
-
return column.type === CellType.COLLABORATOR;
|
|
67
|
+
return column.type === _dtableUtils.CellType.COLLABORATOR;
|
|
60
68
|
};
|
|
61
69
|
// valid chart
|
|
62
70
|
BaseUtils.isValidCombinationChart = (config, table) => {
|
|
63
71
|
const summaryLeftColumnKey = config.y_axis_left_summary_column;
|
|
64
72
|
const summaryLeftType = config.y_axis_left_summary_type;
|
|
65
|
-
if (summaryLeftType === CHART_SUMMARY_TYPE.ADVANCED && !summaryLeftColumnKey) return false;
|
|
73
|
+
if (summaryLeftType === _constants.CHART_SUMMARY_TYPE.ADVANCED && !summaryLeftColumnKey) return false;
|
|
66
74
|
if (summaryLeftColumnKey) {
|
|
67
|
-
if (!getTableColumnByKey(table, summaryLeftColumnKey)) return false;
|
|
75
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, summaryLeftColumnKey)) return false;
|
|
68
76
|
}
|
|
69
77
|
const summaryRightColumnKey = config.y_axis_right_summary_column;
|
|
70
78
|
const summaryRightType = config.y_axis_right_summary_type;
|
|
71
|
-
if (summaryRightType === CHART_SUMMARY_TYPE.ADVANCED && !summaryRightColumnKey) return false;
|
|
79
|
+
if (summaryRightType === _constants.CHART_SUMMARY_TYPE.ADVANCED && !summaryRightColumnKey) return false;
|
|
72
80
|
if (summaryRightColumnKey) {
|
|
73
|
-
return getTableColumnByKey(table, summaryRightColumnKey);
|
|
81
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, summaryRightColumnKey);
|
|
74
82
|
}
|
|
75
83
|
return true;
|
|
76
84
|
};
|
|
@@ -83,39 +91,39 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
83
91
|
table_id,
|
|
84
92
|
type
|
|
85
93
|
} = config;
|
|
86
|
-
const table = getTableById(tables, table_id);
|
|
94
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
87
95
|
if (!table) return false;
|
|
88
96
|
|
|
89
97
|
// if table exists then it's a valid TABLE_ELEMENT chart
|
|
90
|
-
if (type === CHART_TYPE.TABLE_ELEMENT) {
|
|
98
|
+
if (type === _constants.CHART_TYPE.TABLE_ELEMENT) {
|
|
91
99
|
return true;
|
|
92
100
|
}
|
|
93
|
-
if (type === CHART_TYPE.SCATTER) {
|
|
101
|
+
if (type === _constants.CHART_TYPE.SCATTER) {
|
|
94
102
|
const {
|
|
95
103
|
column_groupby_column_key
|
|
96
104
|
} = config;
|
|
97
105
|
if (!column_groupby_column_key) return false;
|
|
98
106
|
}
|
|
99
|
-
if (config.type === CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
107
|
+
if (config.type === _constants.CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
100
108
|
const {
|
|
101
109
|
summary_type
|
|
102
110
|
} = config;
|
|
103
|
-
if (summary_type === CHART_Y_GROUP_TYPE.COUNT || !summary_type) return true;
|
|
111
|
+
if (summary_type === _constants.CHART_Y_GROUP_TYPE.COUNT || !summary_type) return true;
|
|
104
112
|
const numericColumnKey = config.numeric_column_key;
|
|
105
113
|
if (!numericColumnKey) return false;
|
|
106
|
-
return getTableColumnByKey(table, numericColumnKey);
|
|
114
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, numericColumnKey);
|
|
107
115
|
}
|
|
108
|
-
if (config.type === CHART_TYPE.DASHBOARD) {
|
|
116
|
+
if (config.type === _constants.CHART_TYPE.DASHBOARD) {
|
|
109
117
|
const targetColumnKey = config.target_value_column_key;
|
|
110
118
|
if (!targetColumnKey) return false;
|
|
111
119
|
const totalColumnKey = config.total_value_column_key;
|
|
112
120
|
if (!totalColumnKey) return false;
|
|
113
|
-
if (!getTableColumnByKey(table, targetColumnKey)) return false;
|
|
114
|
-
return getTableColumnByKey(table, totalColumnKey);
|
|
121
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, targetColumnKey)) return false;
|
|
122
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, totalColumnKey);
|
|
115
123
|
}
|
|
116
124
|
|
|
117
125
|
// completeness chart requires groupby_column_key, completed_column_key, and target_column_key
|
|
118
|
-
if (config.type === CHART_TYPE.COMPLETENESS || config.type === CHART_TYPE.COMPLETENESS_GROUP) {
|
|
126
|
+
if (config.type === _constants.CHART_TYPE.COMPLETENESS || config.type === _constants.CHART_TYPE.COMPLETENESS_GROUP) {
|
|
119
127
|
const {
|
|
120
128
|
groupby_column_key,
|
|
121
129
|
completed_column_key,
|
|
@@ -124,52 +132,52 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
124
132
|
if (!groupby_column_key) return false;
|
|
125
133
|
if (!completed_column_key) return false;
|
|
126
134
|
if (!target_column_key) return false;
|
|
127
|
-
if (!getTableColumnByKey(table, groupby_column_key)) return false;
|
|
128
|
-
if (!getTableColumnByKey(table, completed_column_key)) return false;
|
|
129
|
-
if (!getTableColumnByKey(table, target_column_key)) return false;
|
|
135
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key)) return false;
|
|
136
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, completed_column_key)) return false;
|
|
137
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, target_column_key)) return false;
|
|
130
138
|
return true;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
141
|
// if current chart is using "groupby_column_key" as key
|
|
134
142
|
// if groupby_column_key is null, still return false
|
|
135
143
|
let groupByColumnKey = config.groupby_column_key || config.x_axis_column_key || config.vertical_axis_column_key || config.columnKey || config.date_column_key;
|
|
136
|
-
if ([CHART_TYPE.BAR, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.COMBINATION].includes(config.type)) {
|
|
144
|
+
if ([_constants.CHART_TYPE.BAR, _constants.CHART_TYPE.BAR_GROUP, _constants.CHART_TYPE.BAR_CUSTOM, _constants.CHART_TYPE.BAR_STACK, _constants.CHART_TYPE.COMPARE_BAR, _constants.CHART_TYPE.LINE, _constants.CHART_TYPE.LINE_GROUP, _constants.CHART_TYPE.AREA, _constants.CHART_TYPE.AREA_GROUP, _constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.COMBINATION].includes(config.type)) {
|
|
137
145
|
groupByColumnKey = config.x_axis_column_key;
|
|
138
146
|
}
|
|
139
|
-
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(config.type)) {
|
|
147
|
+
if ([_constants.CHART_TYPE.HORIZONTAL_BAR, _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR, _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(config.type)) {
|
|
140
148
|
groupByColumnKey = config.vertical_axis_column_key;
|
|
141
149
|
}
|
|
142
|
-
if ([CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(config.type)) {
|
|
150
|
+
if ([_constants.CHART_TYPE.MAP, _constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(config.type)) {
|
|
143
151
|
groupByColumnKey = config.geo_column_key;
|
|
144
152
|
}
|
|
145
|
-
if ([CHART_TYPE.HEAT_MAP].includes(config.type)) {
|
|
153
|
+
if ([_constants.CHART_TYPE.HEAT_MAP].includes(config.type)) {
|
|
146
154
|
groupByColumnKey = config.time_column_key;
|
|
147
155
|
}
|
|
148
|
-
if ([CHART_TYPE.MIRROR].includes(config.type)) {
|
|
156
|
+
if ([_constants.CHART_TYPE.MIRROR].includes(config.type)) {
|
|
149
157
|
groupByColumnKey = config.column_key;
|
|
150
158
|
}
|
|
151
|
-
if ([CHART_TYPE.TREND].includes(config.type)) {
|
|
159
|
+
if ([_constants.CHART_TYPE.TREND].includes(config.type)) {
|
|
152
160
|
groupByColumnKey = config.date_column_key;
|
|
153
161
|
}
|
|
154
162
|
if (!groupByColumnKey) return false;
|
|
155
|
-
if (!getTableColumnByKey(table, groupByColumnKey)) return false;
|
|
156
|
-
if (type === CHART_TYPE.FUNNEL) {
|
|
157
|
-
const column = getColumnByKey(config.x_axis_column_key, table.columns);
|
|
158
|
-
if (!column || column.type !== CellType.SINGLE_SELECT) return false;
|
|
163
|
+
if (!(0, _dtableUtils.getTableColumnByKey)(table, groupByColumnKey)) return false;
|
|
164
|
+
if (type === _constants.CHART_TYPE.FUNNEL) {
|
|
165
|
+
const column = (0, _columnUtils.getColumnByKey)(config.x_axis_column_key, table.columns);
|
|
166
|
+
if (!column || column.type !== _dtableUtils.CellType.SINGLE_SELECT) return false;
|
|
159
167
|
}
|
|
160
|
-
if (type === CHART_TYPE.COMBINATION) {
|
|
168
|
+
if (type === _constants.CHART_TYPE.COMBINATION) {
|
|
161
169
|
const isExist = _BaseUtils.isValidCombinationChart(config, table);
|
|
162
170
|
if (!isExist) return false;
|
|
163
171
|
} else {
|
|
164
172
|
let summaryColumnKey = config.summary_column_key || config.y_axis_summary_column_key || config.horizontal_axis_column_key;
|
|
165
|
-
if ([CHART_TYPE.TABLE].includes(config.type) && config.column_groupby_multiple_numeric_column && (config === null || config === void 0 ? void 0 : config.summary_columns.length) > 0) {
|
|
173
|
+
if ([_constants.CHART_TYPE.TABLE].includes(config.type) && config.column_groupby_multiple_numeric_column && (config === null || config === void 0 ? void 0 : config.summary_columns.length) > 0) {
|
|
166
174
|
// "key" and "column_key" are both exists currently, "column_key" is defined in public component, to avoid bugs, better not to change "column_key" to "key"
|
|
167
175
|
summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
|
|
168
176
|
}
|
|
169
177
|
const summaryType = _BaseUtils.getSummaryType(config);
|
|
170
|
-
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
178
|
+
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
171
179
|
if (summaryColumnKey) {
|
|
172
|
-
return getTableColumnByKey(table, summaryColumnKey);
|
|
180
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, summaryColumnKey);
|
|
173
181
|
}
|
|
174
182
|
}
|
|
175
183
|
return true;
|
|
@@ -182,34 +190,34 @@ BaseUtils.getGroupColumn = (table, chart) => {
|
|
|
182
190
|
const {
|
|
183
191
|
type
|
|
184
192
|
} = config;
|
|
185
|
-
if (COMPLTETELESS_CHART_TYPES.includes(type)) {
|
|
186
|
-
return getTableColumnByKey(table, config.completed_column_key);
|
|
193
|
+
if (_constants.COMPLTETELESS_CHART_TYPES.includes(type)) {
|
|
194
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.completed_column_key);
|
|
187
195
|
}
|
|
188
|
-
if (HORIZONTAL_BAR_CHART_TYPES.includes(type)) {
|
|
189
|
-
return getTableColumnByKey(table, config.vertical_axis_column_key);
|
|
196
|
+
if (_constants.HORIZONTAL_BAR_CHART_TYPES.includes(type)) {
|
|
197
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.vertical_axis_column_key);
|
|
190
198
|
}
|
|
191
|
-
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
192
|
-
return getTableColumnByKey(table, config.groupby_column_key);
|
|
199
|
+
if (_constants.X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
200
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.groupby_column_key);
|
|
193
201
|
}
|
|
194
|
-
if (type === CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
195
|
-
return getTableColumnByKey(table, config.numeric_column_key);
|
|
202
|
+
if (type === _constants.CHART_TYPE.BASIC_NUMBER_CARD) {
|
|
203
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.numeric_column_key);
|
|
196
204
|
}
|
|
197
|
-
if ([CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
198
|
-
return getTableColumnByKey(table, config.geo_column_key);
|
|
205
|
+
if ([_constants.CHART_TYPE.WORLD_MAP, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
|
|
206
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.geo_column_key);
|
|
199
207
|
}
|
|
200
|
-
if (type === CHART_TYPE.MIRROR) {
|
|
201
|
-
return getTableColumnByKey(table, config.column_key);
|
|
208
|
+
if (type === _constants.CHART_TYPE.MIRROR) {
|
|
209
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.column_key);
|
|
202
210
|
}
|
|
203
|
-
if (type === CHART_TYPE.TREND) {
|
|
204
|
-
return getTableColumnByKey(table, config.date_column_key);
|
|
211
|
+
if (type === _constants.CHART_TYPE.TREND) {
|
|
212
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.date_column_key);
|
|
205
213
|
}
|
|
206
|
-
if (type === CHART_TYPE.HEAT_MAP) {
|
|
207
|
-
return getTableColumnByKey(table, config.time_column_key);
|
|
214
|
+
if (type === _constants.CHART_TYPE.HEAT_MAP) {
|
|
215
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.time_column_key);
|
|
208
216
|
}
|
|
209
|
-
if (MAP_CHART_TYPES.includes(type)) {
|
|
210
|
-
return getTableColumnByKey(table, config.geo_column_key);
|
|
217
|
+
if (_constants.MAP_CHART_TYPES.includes(type)) {
|
|
218
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.geo_column_key);
|
|
211
219
|
}
|
|
212
|
-
return getTableColumnByKey(table, config.x_axis_column_key);
|
|
220
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.x_axis_column_key);
|
|
213
221
|
};
|
|
214
222
|
BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
215
223
|
const {
|
|
@@ -218,19 +226,19 @@ BaseUtils.getColumnGroupColumn = (table, chart) => {
|
|
|
218
226
|
const {
|
|
219
227
|
type
|
|
220
228
|
} = config;
|
|
221
|
-
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
222
|
-
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
229
|
+
if (_constants.X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
230
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.column_groupby_column_key);
|
|
223
231
|
}
|
|
224
|
-
if ([CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.LINE_GROUP, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR, CHART_TYPE.AREA_GROUP, CHART_TYPE.COMPLETENESS, CHART_TYPE.COMPLETENESS_GROUP].includes(type)) {
|
|
225
|
-
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
232
|
+
if ([_constants.CHART_TYPE.BAR_GROUP, _constants.CHART_TYPE.BAR_STACK, _constants.CHART_TYPE.LINE_GROUP, _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR, _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR, _constants.CHART_TYPE.AREA_GROUP, _constants.CHART_TYPE.COMPLETENESS, _constants.CHART_TYPE.COMPLETENESS_GROUP].includes(type)) {
|
|
233
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.column_groupby_column_key);
|
|
226
234
|
}
|
|
227
|
-
if ([CHART_TYPE.MIRROR].includes(type)) {
|
|
228
|
-
return getTableColumnByKey(table, config.group_column_key);
|
|
235
|
+
if ([_constants.CHART_TYPE.MIRROR].includes(type)) {
|
|
236
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.group_column_key);
|
|
229
237
|
}
|
|
230
|
-
if (type === CHART_TYPE.SCATTER) {
|
|
231
|
-
return getTableColumnByKey(table, config.column_groupby_column_key);
|
|
238
|
+
if (type === _constants.CHART_TYPE.SCATTER) {
|
|
239
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.column_groupby_column_key);
|
|
232
240
|
}
|
|
233
|
-
return getTableColumnByKey(table, config.y_axis_summary_column_key);
|
|
241
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.y_axis_summary_column_key);
|
|
234
242
|
};
|
|
235
243
|
BaseUtils.getSummaryColumn = (table, chart) => {
|
|
236
244
|
const {
|
|
@@ -244,39 +252,39 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
244
252
|
horizontal_axis_column_key
|
|
245
253
|
} = config;
|
|
246
254
|
switch (type) {
|
|
247
|
-
case CHART_TYPE.COMPLETENESS:
|
|
248
|
-
case CHART_TYPE.COMPLETENESS_GROUP:
|
|
255
|
+
case _constants.CHART_TYPE.COMPLETENESS:
|
|
256
|
+
case _constants.CHART_TYPE.COMPLETENESS_GROUP:
|
|
249
257
|
{
|
|
250
|
-
return getTableColumnByKey(table, config.target_column_key);
|
|
258
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.target_column_key);
|
|
251
259
|
}
|
|
252
|
-
case CHART_TYPE.HORIZONTAL_BAR:
|
|
253
|
-
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
254
|
-
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
260
|
+
case _constants.CHART_TYPE.HORIZONTAL_BAR:
|
|
261
|
+
case _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
262
|
+
case _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
255
263
|
{
|
|
256
|
-
return getTableColumnByKey(table, horizontal_axis_column_key);
|
|
264
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, horizontal_axis_column_key);
|
|
257
265
|
}
|
|
258
|
-
case CHART_TYPE.BAR:
|
|
259
|
-
case CHART_TYPE.BAR_GROUP:
|
|
260
|
-
case CHART_TYPE.LINE:
|
|
261
|
-
case CHART_TYPE.LINE_GROUP:
|
|
262
|
-
case CHART_TYPE.AREA:
|
|
263
|
-
case CHART_TYPE.AREA_GROUP:
|
|
264
|
-
case CHART_TYPE.BAR_STACK:
|
|
266
|
+
case _constants.CHART_TYPE.BAR:
|
|
267
|
+
case _constants.CHART_TYPE.BAR_GROUP:
|
|
268
|
+
case _constants.CHART_TYPE.LINE:
|
|
269
|
+
case _constants.CHART_TYPE.LINE_GROUP:
|
|
270
|
+
case _constants.CHART_TYPE.AREA:
|
|
271
|
+
case _constants.CHART_TYPE.AREA_GROUP:
|
|
272
|
+
case _constants.CHART_TYPE.BAR_STACK:
|
|
265
273
|
{
|
|
266
|
-
return getTableColumnByKey(table, y_axis_summary_column_key);
|
|
274
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, y_axis_summary_column_key);
|
|
267
275
|
}
|
|
268
|
-
case CHART_TYPE.BASIC_NUMBER_CARD:
|
|
276
|
+
case _constants.CHART_TYPE.BASIC_NUMBER_CARD:
|
|
269
277
|
{
|
|
270
|
-
return getTableColumnByKey(table, numeric_column_key);
|
|
278
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, numeric_column_key);
|
|
271
279
|
}
|
|
272
|
-
case CHART_TYPE.SCATTER:
|
|
280
|
+
case _constants.CHART_TYPE.SCATTER:
|
|
273
281
|
{
|
|
274
|
-
return getTableColumnByKey(table, config.y_axis_column_key);
|
|
282
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, config.y_axis_column_key);
|
|
275
283
|
}
|
|
276
|
-
case CHART_TYPE.COMBINATION:
|
|
284
|
+
case _constants.CHART_TYPE.COMBINATION:
|
|
277
285
|
{
|
|
278
|
-
const summaryColumnLeft = getTableColumnByKey(table, config.y_axis_left_summary_column);
|
|
279
|
-
const summaryColumnRight = getTableColumnByKey(table, config.y_axis_right_summary_column);
|
|
286
|
+
const summaryColumnLeft = (0, _dtableUtils.getTableColumnByKey)(table, config.y_axis_left_summary_column);
|
|
287
|
+
const summaryColumnRight = (0, _dtableUtils.getTableColumnByKey)(table, config.y_axis_right_summary_column);
|
|
280
288
|
return {
|
|
281
289
|
summaryColumnLeft,
|
|
282
290
|
summaryColumnRight
|
|
@@ -284,7 +292,7 @@ BaseUtils.getSummaryColumn = (table, chart) => {
|
|
|
284
292
|
}
|
|
285
293
|
default:
|
|
286
294
|
{
|
|
287
|
-
return getTableColumnByKey(table, summary_column_key);
|
|
295
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
};
|
|
@@ -310,7 +318,7 @@ BaseUtils.getSummaryColumnsWithMethod = (table, chart) => {
|
|
|
310
318
|
summary_method
|
|
311
319
|
} = summaryItem;
|
|
312
320
|
return {
|
|
313
|
-
column: getTableColumnByKey(table, columnKey),
|
|
321
|
+
column: (0, _dtableUtils.getTableColumnByKey)(table, columnKey),
|
|
314
322
|
summary_method
|
|
315
323
|
};
|
|
316
324
|
});
|
|
@@ -319,7 +327,7 @@ BaseUtils.getGroupName = (tables, chart) => {
|
|
|
319
327
|
const {
|
|
320
328
|
config
|
|
321
329
|
} = chart;
|
|
322
|
-
const table = getTableById(tables, config.table_id);
|
|
330
|
+
const table = (0, _dtableUtils.getTableById)(tables, config.table_id);
|
|
323
331
|
const column = _BaseUtils.getGroupColumn(table, chart);
|
|
324
332
|
return column.name;
|
|
325
333
|
};
|
|
@@ -366,24 +374,24 @@ BaseUtils.getSummaryValueDisplayString = function (summaryColumn, summaryValue)
|
|
|
366
374
|
};
|
|
367
375
|
|
|
368
376
|
// The date returned by db carries T and Z, so that there is a time difference in data formatting
|
|
369
|
-
return getDateDisplayString(summaryValue.replace(/[T|Z]/g, ' '), format);
|
|
377
|
+
return (0, _dtableUtils.getDateDisplayString)(summaryValue.replace(/[T|Z]/g, ' '), format);
|
|
370
378
|
}
|
|
371
|
-
if (typeof summaryValue !== 'number') return formatRowTotal(summaryValue);
|
|
372
|
-
return getNumberDisplayString(summaryValue, data || DEFAULT_NUMBER_FORMAT_OBJECT);
|
|
379
|
+
if (typeof summaryValue !== 'number') return (0, _index.formatRowTotal)(summaryValue);
|
|
380
|
+
return (0, _dtableUtils.getNumberDisplayString)(summaryValue, data || _constants.DEFAULT_NUMBER_FORMAT_OBJECT);
|
|
373
381
|
};
|
|
374
382
|
BaseUtils.isNumericSummaryColumn = summaryColumn => {
|
|
375
383
|
if (!summaryColumn) return false;
|
|
376
384
|
const {
|
|
377
385
|
type
|
|
378
386
|
} = summaryColumn;
|
|
379
|
-
return type !== CellType.LINK && isNumericColumn(summaryColumn);
|
|
387
|
+
return type !== _dtableUtils.CellType.LINK && (0, _dtableUtils.isNumericColumn)(summaryColumn);
|
|
380
388
|
};
|
|
381
389
|
BaseUtils.isDateSummaryColumn = summaryColumn => {
|
|
382
390
|
if (!summaryColumn) return false;
|
|
383
391
|
const {
|
|
384
392
|
type
|
|
385
393
|
} = summaryColumn;
|
|
386
|
-
return type !== CellType.LINK && isDateColumn(summaryColumn);
|
|
394
|
+
return type !== _dtableUtils.CellType.LINK && (0, _dtableUtils.isDateColumn)(summaryColumn);
|
|
387
395
|
};
|
|
388
396
|
BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) => {
|
|
389
397
|
let {
|
|
@@ -393,14 +401,14 @@ BaseUtils.getSummaryValue = (_ref, currentValue, nextValue, isPivotCalculator) =
|
|
|
393
401
|
if (_BaseUtils.isDateSummaryColumn(summaryColumn)) {
|
|
394
402
|
if (summaryMethod === 'MAX') {
|
|
395
403
|
if (currentValue && nextValue) {
|
|
396
|
-
return
|
|
404
|
+
return (0, _dayjs.default)(currentValue).isBefore(nextValue) ? nextValue : currentValue;
|
|
397
405
|
}
|
|
398
406
|
if (!currentValue && nextValue) return nextValue;
|
|
399
407
|
return currentValue;
|
|
400
408
|
}
|
|
401
409
|
if (summaryMethod === 'MIN') {
|
|
402
410
|
if (currentValue && nextValue) {
|
|
403
|
-
return
|
|
411
|
+
return (0, _dayjs.default)(currentValue).isBefore(nextValue) ? currentValue : nextValue;
|
|
404
412
|
}
|
|
405
413
|
if (!currentValue && nextValue) return nextValue;
|
|
406
414
|
return currentValue;
|
|
@@ -426,7 +434,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
426
434
|
let {
|
|
427
435
|
columns
|
|
428
436
|
} = table;
|
|
429
|
-
let unStatisticalColumns = [CellType.LONG_TEXT, CellType.IMAGE, CellType.FILE, CellType.CHECKBOX];
|
|
437
|
+
let unStatisticalColumns = [_dtableUtils.CellType.LONG_TEXT, _dtableUtils.CellType.IMAGE, _dtableUtils.CellType.FILE, _dtableUtils.CellType.CHECKBOX];
|
|
430
438
|
return columns.filter(column => {
|
|
431
439
|
return unStatisticalColumns.indexOf(column.type) === -1;
|
|
432
440
|
});
|
|
@@ -434,7 +442,7 @@ BaseUtils.getStatisticColumns = table => {
|
|
|
434
442
|
BaseUtils.isChartEqual = (preChartElement, curChartElement) => {
|
|
435
443
|
const elementType = preChartElement.config.type;
|
|
436
444
|
if (elementType !== curChartElement.config.type) return false;
|
|
437
|
-
return
|
|
445
|
+
return (0, _shallowequal.default)(preChartElement.config, curChartElement.config);
|
|
438
446
|
};
|
|
439
447
|
BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
440
448
|
var _preChartElement$heig, _curChartElement$heig;
|
|
@@ -446,10 +454,10 @@ BaseUtils.isChartStyleChange = (preChartElement, curChartElement) => {
|
|
|
446
454
|
if ((preChartElement === null || preChartElement === void 0 ? void 0 : preChartElement.width_in_unit) !== (curChartElement === null || curChartElement === void 0 ? void 0 : curChartElement.width_in_unit)) return true;
|
|
447
455
|
const hasStyleConfig = preChartElement.style_config && curChartElement.style_config;
|
|
448
456
|
if (hasStyleConfig) {
|
|
449
|
-
const chartStyleConfigChanged = CHART_STYLE_CONFIG_SETTING_KEYS.some(key => preChartElement.style_config[key] !== curChartElement.style_config[key]);
|
|
457
|
+
const chartStyleConfigChanged = _constants.CHART_STYLE_CONFIG_SETTING_KEYS.some(key => preChartElement.style_config[key] !== curChartElement.style_config[key]);
|
|
450
458
|
return chartStyleConfigChanged;
|
|
451
459
|
}
|
|
452
|
-
return !CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
460
|
+
return !_constants.CHART_STYLE_SETTING_KEYS.every(key => preChartElement.config[key] === curChartElement.config[key]);
|
|
453
461
|
};
|
|
454
462
|
BaseUtils.isChartTypeChange = (preChartElement, curChartElement) => {
|
|
455
463
|
const elementType = preChartElement.config.type;
|
|
@@ -467,9 +475,9 @@ BaseUtils.isArchiveView = (chart, tables) => {
|
|
|
467
475
|
table_id,
|
|
468
476
|
view_id
|
|
469
477
|
} = chart;
|
|
470
|
-
const table = getTableById(tables, table_id);
|
|
471
|
-
const view = getViewById(table === null || table === void 0 ? void 0 : table.views, view_id);
|
|
472
|
-
return view && isArchiveView(view);
|
|
478
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
479
|
+
const view = (0, _dtableUtils.getViewById)(table === null || table === void 0 ? void 0 : table.views, view_id);
|
|
480
|
+
return view && (0, _dtableUtils.isArchiveView)(view);
|
|
473
481
|
};
|
|
474
482
|
BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
475
483
|
return preChartElement.config.sort_type !== curChartElement.config.sort_type;
|
|
@@ -477,7 +485,7 @@ BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
|
477
485
|
BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
478
486
|
const prevStyleConfig = prevElement && prevElement.style_config;
|
|
479
487
|
const currStyleConfig = currElement && currElement.style_config;
|
|
480
|
-
if ((prevStyleConfig === null || prevStyleConfig === void 0 ? void 0 : prevStyleConfig.display_goal_line) !== (currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.display_goal_line) && (!(currStyleConfig
|
|
488
|
+
if ((prevStyleConfig === null || prevStyleConfig === void 0 ? void 0 : prevStyleConfig.display_goal_line) !== (currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.display_goal_line) && (!(currStyleConfig !== null && currStyleConfig !== void 0 && currStyleConfig.goal_lable) || !(currStyleConfig !== null && currStyleConfig !== void 0 && currStyleConfig.goal_value))) {
|
|
481
489
|
return false;
|
|
482
490
|
}
|
|
483
491
|
if (!prevStyleConfig && !currStyleConfig) {
|
|
@@ -494,24 +502,24 @@ BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
|
|
|
494
502
|
border: currBorder,
|
|
495
503
|
title: currTitle
|
|
496
504
|
} = currStyleConfig;
|
|
497
|
-
return !
|
|
505
|
+
return !(0, _shallowequal.default)(prevBorder, currBorder) || !(0, _shallowequal.default)(prevTitle, currTitle);
|
|
498
506
|
};
|
|
499
507
|
BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
500
508
|
return !_BaseUtils.isChartEqual(prevProps.chart, currentProps.chart) ||
|
|
501
509
|
// chart attributes changed
|
|
502
|
-
!
|
|
510
|
+
!(0, _shallowequal.default)(prevProps.canvasStyle, currentProps.canvasStyle) ||
|
|
503
511
|
// canvasStyle
|
|
504
|
-
!
|
|
512
|
+
!(0, _shallowequal.default)(prevProps.groupbyColumn, currentProps.groupbyColumn) ||
|
|
505
513
|
// groupbyColumn's data、type changed or not exist
|
|
506
|
-
!
|
|
514
|
+
!(0, _shallowequal.default)(prevProps.columnGroupbyColumn, currentProps.columnGroupbyColumn) ||
|
|
507
515
|
// columnGroupbyColumn's data、type changed or not exist
|
|
508
|
-
!
|
|
516
|
+
!(0, _shallowequal.default)(prevProps.summaryColumn, currentProps.summaryColumn) ||
|
|
509
517
|
// summaryColumn's data、type changed or not exist
|
|
510
|
-
!
|
|
518
|
+
!(0, _shallowequal.default)(prevProps.globalTheme, currentProps.globalTheme) ||
|
|
511
519
|
// global theme changed
|
|
512
|
-
!
|
|
520
|
+
!(0, _shallowequal.default)(prevProps.chartColorTheme, currentProps.chartColorTheme) ||
|
|
513
521
|
// chart color theme changed
|
|
514
|
-
!
|
|
522
|
+
!(0, _shallowequal.default)(prevProps.resizeSignal, currentProps.resizeSignal) ||
|
|
515
523
|
// chart container resize changed
|
|
516
524
|
_BaseUtils._isChartDataChange(prevProps, currentProps) || _BaseUtils.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
517
525
|
};
|
|
@@ -528,7 +536,7 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
528
536
|
const {
|
|
529
537
|
result: oldData
|
|
530
538
|
} = currentProps;
|
|
531
|
-
if (chart.config.type === CHART_TYPE.COMBINATION) {
|
|
539
|
+
if (chart.config.type === _constants.CHART_TYPE.COMBINATION) {
|
|
532
540
|
return _BaseUtils._isCombinationDataChange(newData, oldData);
|
|
533
541
|
}
|
|
534
542
|
if (!newData && !oldData) return false;
|
|
@@ -547,14 +555,14 @@ BaseUtils._isChartDataChange = (prevProps, currentProps) => {
|
|
|
547
555
|
for (let j = 0; j < (newDataItemRows === null || newDataItemRows === void 0 ? void 0 : newDataItemRows.length) || 0; j++) {
|
|
548
556
|
let newDataItemRow = newDataItemRows[j];
|
|
549
557
|
let oldDataItemRow = oldDataItemRows[j];
|
|
550
|
-
if (!
|
|
558
|
+
if (!(0, _shallowequal.default)(newDataItemRow, oldDataItemRow)) return true;
|
|
551
559
|
}
|
|
552
560
|
}
|
|
553
561
|
return false;
|
|
554
562
|
};
|
|
555
563
|
BaseUtils.getColumn = (tables, tableId, columnKey) => {
|
|
556
|
-
const table = getTableById(tables, tableId);
|
|
557
|
-
return getTableColumnByKey(table, columnKey);
|
|
564
|
+
const table = (0, _dtableUtils.getTableById)(tables, tableId);
|
|
565
|
+
return (0, _dtableUtils.getTableColumnByKey)(table, columnKey);
|
|
558
566
|
};
|
|
559
567
|
BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) => {
|
|
560
568
|
if (!Array.isArray(dataList)) return [];
|
|
@@ -569,7 +577,7 @@ BaseUtils.formatEmptyName = (dataList, column_groupby_column_key, emptyName) =>
|
|
|
569
577
|
item.group_name = emptyName;
|
|
570
578
|
}
|
|
571
579
|
if (!item.slugId) {
|
|
572
|
-
item.slugId =
|
|
580
|
+
item.slugId = _slugid.default.nice();
|
|
573
581
|
}
|
|
574
582
|
if (!item.value) {
|
|
575
583
|
item.value = 0;
|
|
@@ -595,10 +603,10 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
595
603
|
const {
|
|
596
604
|
type: columnType
|
|
597
605
|
} = column || {};
|
|
598
|
-
const pieChartColorsLength = PIE_CHART_COLORS.length - 1;
|
|
606
|
+
const pieChartColorsLength = _constants.PIE_CHART_COLORS.length - 1;
|
|
599
607
|
const backgroundColor = [];
|
|
600
608
|
result.forEach((item, index) => {
|
|
601
|
-
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
609
|
+
if (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
602
610
|
let {
|
|
603
611
|
color
|
|
604
612
|
} = item;
|
|
@@ -607,7 +615,7 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
607
615
|
if (index > pieChartColorsLength) {
|
|
608
616
|
index = index % pieChartColorsLength;
|
|
609
617
|
}
|
|
610
|
-
backgroundColor.push(PIE_CHART_COLORS[index]);
|
|
618
|
+
backgroundColor.push(_constants.PIE_CHART_COLORS[index]);
|
|
611
619
|
}
|
|
612
620
|
});
|
|
613
621
|
return backgroundColor;
|
|
@@ -625,7 +633,7 @@ BaseUtils.getPieColor = (column, index, data, currentTheme, useColumnColor) => {
|
|
|
625
633
|
const selectedItem = columnData.options.find(item => {
|
|
626
634
|
return item.name === data.name.trim();
|
|
627
635
|
}) || {};
|
|
628
|
-
return selectedItem.color || DEFAULT_ITEM_COLOR;
|
|
636
|
+
return selectedItem.color || _constants.DEFAULT_ITEM_COLOR;
|
|
629
637
|
}
|
|
630
638
|
} else {
|
|
631
639
|
const pieChartColorsLength = colors.length - 1;
|
|
@@ -646,8 +654,8 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
646
654
|
groupby_column_key,
|
|
647
655
|
minimum_slice_percent
|
|
648
656
|
} = chart.config;
|
|
649
|
-
const table = getTableById(tables, table_id);
|
|
650
|
-
const column = getColumnByKey(groupby_column_key, table ? table.columns : []);
|
|
657
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
658
|
+
const column = (0, _columnUtils.getColumnByKey)(groupby_column_key, table ? table.columns : []);
|
|
651
659
|
let sum = data.reduce((total, currentValue) => {
|
|
652
660
|
return total += currentValue.value;
|
|
653
661
|
}, 0);
|
|
@@ -681,11 +689,11 @@ BaseUtils.formatPieChartData = (data, chart, tables, currentTheme, useColumnColo
|
|
|
681
689
|
filteredData.push({
|
|
682
690
|
name: '_Others',
|
|
683
691
|
value: filteredSum,
|
|
684
|
-
color: DEFAULT_ITEM_COLOR,
|
|
692
|
+
color: _constants.DEFAULT_ITEM_COLOR,
|
|
685
693
|
percent: String(Number.parseFloat(filteredSum / sum * 100).toFixed(1)) + '%',
|
|
686
694
|
rows
|
|
687
695
|
});
|
|
688
|
-
colorMap['_Others'] = DEFAULT_ITEM_COLOR;
|
|
696
|
+
colorMap['_Others'] = _constants.DEFAULT_ITEM_COLOR;
|
|
689
697
|
}
|
|
690
698
|
return {
|
|
691
699
|
data: filteredData,
|
|
@@ -703,14 +711,14 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
703
711
|
data: columnData
|
|
704
712
|
} = column;
|
|
705
713
|
let name = result[nameKey];
|
|
706
|
-
if (isEmpty(name)) {
|
|
707
|
-
result[colorKey] = result[colorKey] || DEFAULT_ITEM_COLOR;
|
|
714
|
+
if ((0, _dtableUtils.isEmpty)(name)) {
|
|
715
|
+
result[colorKey] = result[colorKey] || _constants.DEFAULT_ITEM_COLOR;
|
|
708
716
|
resolve(resultPromise);
|
|
709
717
|
return;
|
|
710
718
|
}
|
|
711
|
-
if (columnType === CellType.SINGLE_SELECT) {
|
|
712
|
-
const options = getColumnOptions(column);
|
|
713
|
-
let selectedOption = getOption(options, name);
|
|
719
|
+
if (columnType === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
720
|
+
const options = (0, _dtableUtils.getColumnOptions)(column);
|
|
721
|
+
let selectedOption = (0, _dtableUtils.getOption)(options, name);
|
|
714
722
|
let {
|
|
715
723
|
name: optionName,
|
|
716
724
|
color: optionColor,
|
|
@@ -721,80 +729,80 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
721
729
|
result[colorKey] = optionColor;
|
|
722
730
|
isNameField && (result.original_name = id);
|
|
723
731
|
} else {
|
|
724
|
-
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
732
|
+
result[colorKey] = _constants.DEFAULT_ITEM_COLOR;
|
|
725
733
|
}
|
|
726
|
-
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
727
|
-
const options = getColumnOptions(column);
|
|
734
|
+
} else if (columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
735
|
+
const options = (0, _dtableUtils.getColumnOptions)(column);
|
|
728
736
|
const optionIds = Array.isArray(name) ? name : [name];
|
|
729
|
-
const optionNames = getMultipleOptionName(options, optionIds);
|
|
737
|
+
const optionNames = (0, _dtableUtils.getMultipleOptionName)(options, optionIds);
|
|
730
738
|
if (optionNames) {
|
|
731
739
|
result[nameKey] = optionNames;
|
|
732
740
|
const firstOption = options.find(o => optionIds.includes(o.id));
|
|
733
|
-
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || DEFAULT_ITEM_COLOR;
|
|
741
|
+
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || _constants.DEFAULT_ITEM_COLOR;
|
|
734
742
|
isNameField && (result.original_name = optionIds);
|
|
735
743
|
} else {
|
|
736
|
-
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
744
|
+
result[colorKey] = _constants.DEFAULT_ITEM_COLOR;
|
|
737
745
|
}
|
|
738
|
-
} else if (columnType === CellType.COLLABORATOR) {
|
|
739
|
-
const users =
|
|
746
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
747
|
+
const users = _context.default.getCollaboratorsFromCache();
|
|
740
748
|
const user = users.find(user => user.email === name);
|
|
741
749
|
if (user) {
|
|
742
750
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
743
751
|
isNameField && (result.original_name = name);
|
|
744
752
|
resolve();
|
|
745
753
|
} else {
|
|
746
|
-
|
|
754
|
+
_context.default.queryUsers([name], users => {
|
|
747
755
|
const userEmail = name;
|
|
748
|
-
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
756
|
+
const user = users[userEmail] || (0, _collaboratorUtils.generateDefaultUser)(userEmail);
|
|
749
757
|
const userName = user.name || userEmail;
|
|
750
758
|
result[nameKey] = userName;
|
|
751
759
|
isNameField && (result.original_name = userEmail);
|
|
752
760
|
user.loaded = true;
|
|
753
|
-
|
|
761
|
+
_context.default.updateCollaboratorsCache(userEmail, user);
|
|
754
762
|
resolve();
|
|
755
763
|
});
|
|
756
764
|
}
|
|
757
765
|
return;
|
|
758
|
-
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
759
|
-
const users =
|
|
766
|
+
} else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
|
|
767
|
+
const users = _context.default.getCollaboratorsFromCache();
|
|
760
768
|
const user = users.find(user => user.email === name);
|
|
761
769
|
if (user) {
|
|
762
770
|
result[nameKey] = (user === null || user === void 0 ? void 0 : user.name) || name;
|
|
763
771
|
isNameField && (result.original_name = name);
|
|
764
772
|
resolve();
|
|
765
773
|
} else {
|
|
766
|
-
|
|
774
|
+
_context.default.queryUsers([name], users => {
|
|
767
775
|
const userEmail = name;
|
|
768
|
-
const user = users[userEmail] || generateDefaultUser(userEmail);
|
|
776
|
+
const user = users[userEmail] || (0, _collaboratorUtils.generateDefaultUser)(userEmail);
|
|
769
777
|
const userName = user.name || userEmail;
|
|
770
778
|
result[nameKey] = userName;
|
|
771
779
|
isNameField && (result.original_name = userEmail);
|
|
772
780
|
user.loaded = true;
|
|
773
|
-
|
|
781
|
+
_context.default.updateCollaboratorsCache(userEmail, user);
|
|
774
782
|
resolve();
|
|
775
783
|
});
|
|
776
784
|
}
|
|
777
785
|
return;
|
|
778
|
-
} else if (columnType === CellType.NUMBER) {
|
|
786
|
+
} else if (columnType === _dtableUtils.CellType.NUMBER) {
|
|
779
787
|
let valueNumber = parseFloat(name);
|
|
780
|
-
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
788
|
+
result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
|
|
781
789
|
isNameField && (result.original_name = name);
|
|
782
|
-
} else if (columnType === CellType.DATE) {
|
|
790
|
+
} else if (columnType === _dtableUtils.CellType.DATE) {
|
|
783
791
|
name = name + '';
|
|
784
792
|
if (name && name.split('-').length === 3) {
|
|
785
|
-
let format = getDateColumnFormat(column);
|
|
793
|
+
let format = (0, _columnUtils.getDateColumnFormat)(column);
|
|
786
794
|
let spaceIndex = format.indexOf(' ');
|
|
787
795
|
if (spaceIndex > -1) {
|
|
788
796
|
format = format.slice(0, spaceIndex);
|
|
789
797
|
}
|
|
790
|
-
result[nameKey] =
|
|
798
|
+
result[nameKey] = (0, _dayjs.default)(name).format(format);
|
|
791
799
|
}
|
|
792
|
-
} else if (columnType === CellType.LINK_FORMULA) {
|
|
800
|
+
} else if (columnType === _dtableUtils.CellType.LINK_FORMULA) {
|
|
793
801
|
// scatter only use number
|
|
794
802
|
if (isScatterChart) {
|
|
795
803
|
name.length && (name = name[0]);
|
|
796
804
|
let valueNumber = parseFloat(name);
|
|
797
|
-
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
805
|
+
result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
|
|
798
806
|
}
|
|
799
807
|
const {
|
|
800
808
|
array_data,
|
|
@@ -807,18 +815,18 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
807
815
|
};
|
|
808
816
|
// for linked formula, need to call recursively, using it's result as the result of the promise
|
|
809
817
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, linkedColumn, nameKey, colorKey, isScatterChart);
|
|
810
|
-
} else if (columnType === CellType.FORMULA) {
|
|
818
|
+
} else if (columnType === _dtableUtils.CellType.FORMULA) {
|
|
811
819
|
const {
|
|
812
820
|
result_type: resultType,
|
|
813
821
|
array_type: arrayType,
|
|
814
822
|
array_data: arrayData
|
|
815
823
|
} = columnData || {};
|
|
816
|
-
if (resultType === FORMULA_RESULT_TYPE.NUMBER) {
|
|
824
|
+
if (resultType === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
817
825
|
const valueNumber = parseFloat(name);
|
|
818
|
-
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
826
|
+
result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
|
|
819
827
|
isNameField && (result.original_name = name);
|
|
820
|
-
} else if (resultType === FORMULA_RESULT_TYPE.DATE || resultType === CellType.CTIME || resultType === CellType.MTIME) {
|
|
821
|
-
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
828
|
+
} else if (resultType === _dtableUtils.FORMULA_RESULT_TYPE.DATE || resultType === _dtableUtils.CellType.CTIME || resultType === _dtableUtils.CellType.MTIME) {
|
|
829
|
+
result[nameKey] = (0, _dtableUtils.getFormulaDisplayString)(name, columnData);
|
|
822
830
|
isNameField && (result.original_name = name);
|
|
823
831
|
} else if (arrayType && arrayData) {
|
|
824
832
|
const formulaArrayColumn = {
|
|
@@ -829,19 +837,19 @@ BaseUtils.updateTableViewListItemNameAndColor = async (result, column, nameKey,
|
|
|
829
837
|
resultPromise = _BaseUtils.updateTableViewListItemNameAndColor(result, formulaArrayColumn, nameKey, colorKey, isScatterChart, isNameField);
|
|
830
838
|
} else if (Array.isArray(name)) {
|
|
831
839
|
result[nameKey] = name.map(item => {
|
|
832
|
-
if (isValidCollaboratorEmail(item)) {
|
|
833
|
-
const collaborator = getKnownCollaboratorByEmail(item);
|
|
840
|
+
if ((0, _collaborator.isValidCollaboratorEmail)(item)) {
|
|
841
|
+
const collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(item);
|
|
834
842
|
return collaborator ? collaborator.name : item;
|
|
835
843
|
}
|
|
836
844
|
return item;
|
|
837
845
|
}).join(', ');
|
|
838
846
|
isNameField && (result.original_name = name.join(', '));
|
|
839
|
-
} else if (typeof name === 'string' && isValidCollaboratorEmail(name)) {
|
|
840
|
-
const collaborator = getKnownCollaboratorByEmail(name);
|
|
847
|
+
} else if (typeof name === 'string' && (0, _collaborator.isValidCollaboratorEmail)(name)) {
|
|
848
|
+
const collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(name);
|
|
841
849
|
result[nameKey] = collaborator ? collaborator.name : name;
|
|
842
850
|
isNameField && (result.original_name = name);
|
|
843
851
|
} else {
|
|
844
|
-
result[nameKey] = getFormulaDisplayString(name, columnData);
|
|
852
|
+
result[nameKey] = (0, _dtableUtils.getFormulaDisplayString)(name, columnData);
|
|
845
853
|
isNameField && (result.original_name = name);
|
|
846
854
|
}
|
|
847
855
|
}
|
|
@@ -868,8 +876,8 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
868
876
|
} = column;
|
|
869
877
|
const sortType = 'up';
|
|
870
878
|
const optionIdIndexMap = {};
|
|
871
|
-
const isPivotMultipleSelect = columnType === CellType.MULTIPLE_SELECT && isPivot;
|
|
872
|
-
if ([CellType.SINGLE_SELECT].includes(columnType) || isPivotMultipleSelect) {
|
|
879
|
+
const isPivotMultipleSelect = columnType === _dtableUtils.CellType.MULTIPLE_SELECT && isPivot;
|
|
880
|
+
if ([_dtableUtils.CellType.SINGLE_SELECT].includes(columnType) || isPivotMultipleSelect) {
|
|
873
881
|
const {
|
|
874
882
|
options
|
|
875
883
|
} = data || {};
|
|
@@ -877,7 +885,7 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
877
885
|
optionIdIndexMap[option.id] = index;
|
|
878
886
|
});
|
|
879
887
|
}
|
|
880
|
-
const isPivotLinkFormulaSingleAndMultipleSelect = columnType === CellType.LINK_FORMULA && [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT].includes(column.data.array_type) && isPivot;
|
|
888
|
+
const isPivotLinkFormulaSingleAndMultipleSelect = columnType === _dtableUtils.CellType.LINK_FORMULA && [_dtableUtils.CellType.SINGLE_SELECT, _dtableUtils.CellType.MULTIPLE_SELECT].includes(column.data.array_type) && isPivot;
|
|
881
889
|
if (isPivotLinkFormulaSingleAndMultipleSelect) {
|
|
882
890
|
var _column$data;
|
|
883
891
|
let {
|
|
@@ -901,14 +909,14 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
901
909
|
if (!next && next !== 0) {
|
|
902
910
|
return 1;
|
|
903
911
|
}
|
|
904
|
-
if (CHART_SUPPORT_SORT_COLUMNS.includes(columnType)) {
|
|
912
|
+
if (_constants.CHART_SUPPORT_SORT_COLUMNS.includes(columnType)) {
|
|
905
913
|
let realColumnType = columnType;
|
|
906
|
-
if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
|
|
914
|
+
if ([_dtableUtils.CellType.LINK_FORMULA, _dtableUtils.CellType.LINK].includes(columnType)) {
|
|
907
915
|
realColumnType = column.data.array_type;
|
|
908
916
|
}
|
|
909
917
|
switch (realColumnType) {
|
|
910
|
-
case CellType.NUMBER:
|
|
911
|
-
case CellType.RATE:
|
|
918
|
+
case _dtableUtils.CellType.NUMBER:
|
|
919
|
+
case _dtableUtils.CellType.RATE:
|
|
912
920
|
{
|
|
913
921
|
if (current) {
|
|
914
922
|
current = current - 0;
|
|
@@ -916,15 +924,15 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
916
924
|
if (next) {
|
|
917
925
|
next = next - 0;
|
|
918
926
|
}
|
|
919
|
-
return sortNumber(current, next, sortType);
|
|
927
|
+
return (0, _dtableUtils.sortNumber)(current, next, sortType);
|
|
920
928
|
}
|
|
921
|
-
case CellType.DATE:
|
|
922
|
-
case CellType.CTIME:
|
|
923
|
-
case CellType.MTIME:
|
|
929
|
+
case _dtableUtils.CellType.DATE:
|
|
930
|
+
case _dtableUtils.CellType.CTIME:
|
|
931
|
+
case _dtableUtils.CellType.MTIME:
|
|
924
932
|
{
|
|
925
|
-
return sortDate(current, next, sortType);
|
|
933
|
+
return (0, _dtableUtils.sortDate)(current, next, sortType);
|
|
926
934
|
}
|
|
927
|
-
case CellType.SINGLE_SELECT:
|
|
935
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
928
936
|
{
|
|
929
937
|
// key was used to sort "pivot columns" in pivot chart
|
|
930
938
|
const {
|
|
@@ -937,29 +945,29 @@ BaseUtils.sortCharts = (results, column, sortKey, isPivot) => {
|
|
|
937
945
|
} = nextResult || {};
|
|
938
946
|
const current = currentName || currentKey;
|
|
939
947
|
const next = nextName || nextKey;
|
|
940
|
-
return sortSingleSelect(current, next, {
|
|
948
|
+
return (0, _dtableUtils.sortSingleSelect)(current, next, {
|
|
941
949
|
sort_type: sortType,
|
|
942
950
|
option_id_index_map: optionIdIndexMap
|
|
943
951
|
});
|
|
944
952
|
}
|
|
945
|
-
case CellType.MULTIPLE_SELECT:
|
|
953
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
946
954
|
{
|
|
947
|
-
return sortSingleSelect(current, next, {
|
|
955
|
+
return (0, _dtableUtils.sortSingleSelect)(current, next, {
|
|
948
956
|
sort_type: sortType,
|
|
949
957
|
option_id_index_map: optionIdIndexMap
|
|
950
958
|
});
|
|
951
959
|
}
|
|
952
|
-
case CellType.FORMULA:
|
|
953
|
-
case CellType.LINK_FORMULA:
|
|
960
|
+
case _dtableUtils.CellType.FORMULA:
|
|
961
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
954
962
|
{
|
|
955
|
-
return sortFormula(current, next, sortType, {
|
|
963
|
+
return (0, _dtableUtils.sortFormula)(current, next, sortType, {
|
|
956
964
|
columnData: data,
|
|
957
965
|
value: {}
|
|
958
966
|
});
|
|
959
967
|
}
|
|
960
968
|
default:
|
|
961
969
|
{
|
|
962
|
-
return sortText(current, next, sortType);
|
|
970
|
+
return (0, _dtableUtils.sortText)(current, next, sortType);
|
|
963
971
|
}
|
|
964
972
|
}
|
|
965
973
|
}
|
|
@@ -974,8 +982,8 @@ BaseUtils.sortChartData = (charts, sort_key) => {
|
|
|
974
982
|
const {
|
|
975
983
|
value: next
|
|
976
984
|
} = nextResult;
|
|
977
|
-
if (isEmpty(current)) return -1;
|
|
978
|
-
if (isEmpty(next)) return 1;
|
|
985
|
+
if ((0, _dtableUtils.isEmpty)(current)) return -1;
|
|
986
|
+
if ((0, _dtableUtils.isEmpty)(next)) return 1;
|
|
979
987
|
if (sort_key === 'ascending') {
|
|
980
988
|
return current > next ? 1 : -1;
|
|
981
989
|
}
|
|
@@ -999,7 +1007,7 @@ BaseUtils.sortDataByKey = (data, key, sortType) => {
|
|
|
999
1007
|
if (!nextVal && nextVal !== 0) {
|
|
1000
1008
|
return 1;
|
|
1001
1009
|
}
|
|
1002
|
-
if (sortType === CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
1010
|
+
if (sortType === _constants.CHART_DATA_SORT_TYPE.ASCENDING) {
|
|
1003
1011
|
return currentVal > nextVal ? 1 : -1;
|
|
1004
1012
|
} else {
|
|
1005
1013
|
return currentVal > nextVal ? -1 : 1;
|
|
@@ -1025,7 +1033,7 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1025
1033
|
type,
|
|
1026
1034
|
config
|
|
1027
1035
|
} = chart;
|
|
1028
|
-
if (X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
1036
|
+
if (_constants.X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES.includes(type)) {
|
|
1029
1037
|
groupby_column_key = config.groupby_column_key;
|
|
1030
1038
|
} else {
|
|
1031
1039
|
groupby_column_key = config.x_axis_column_key;
|
|
@@ -1034,9 +1042,9 @@ BaseUtils.formatGroupsLabel = (results, chart, tables) => {
|
|
|
1034
1042
|
const {
|
|
1035
1043
|
table_id
|
|
1036
1044
|
} = config;
|
|
1037
|
-
const table = getTableById(tables, table_id);
|
|
1038
|
-
const groupbyColumn = getTableColumnByKey(table, groupby_column_key);
|
|
1039
|
-
const columnGroupbyColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
1045
|
+
const table = (0, _dtableUtils.getTableById)(tables, table_id);
|
|
1046
|
+
const groupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
|
|
1047
|
+
const columnGroupbyColumn = (0, _dtableUtils.getTableColumnByKey)(table, column_groupby_column_key);
|
|
1040
1048
|
results.forEach(item => {
|
|
1041
1049
|
const {
|
|
1042
1050
|
name,
|
|
@@ -1055,95 +1063,95 @@ BaseUtils.convertResultName = (result, column, name, nameKey, colorKey) => {
|
|
|
1055
1063
|
type: columnType,
|
|
1056
1064
|
data: columnData
|
|
1057
1065
|
} = column;
|
|
1058
|
-
if (columnType === CellType.SINGLE_SELECT) {
|
|
1059
|
-
const options = getColumnOptions(column);
|
|
1060
|
-
const selectedOption = getOption(options, name);
|
|
1066
|
+
if (columnType === _dtableUtils.CellType.SINGLE_SELECT) {
|
|
1067
|
+
const options = (0, _dtableUtils.getColumnOptions)(column);
|
|
1068
|
+
const selectedOption = (0, _dtableUtils.getOption)(options, name);
|
|
1061
1069
|
if (selectedOption) {
|
|
1062
1070
|
result[nameKey] = selectedOption.name;
|
|
1063
1071
|
result[colorKey] = selectedOption.color;
|
|
1064
1072
|
} else {
|
|
1065
|
-
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
1073
|
+
result[colorKey] = _constants.DEFAULT_ITEM_COLOR;
|
|
1066
1074
|
}
|
|
1067
|
-
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
1068
|
-
const options = getColumnOptions(column);
|
|
1075
|
+
} else if (columnType === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
1076
|
+
const options = (0, _dtableUtils.getColumnOptions)(column);
|
|
1069
1077
|
const optionIds = Array.isArray(name) ? name : [name];
|
|
1070
|
-
const optionNames = getMultipleOptionName(options, optionIds);
|
|
1078
|
+
const optionNames = (0, _dtableUtils.getMultipleOptionName)(options, optionIds);
|
|
1071
1079
|
if (optionNames) {
|
|
1072
1080
|
result[nameKey] = optionNames;
|
|
1073
1081
|
const firstOption = options.find(o => optionIds.includes(o.id));
|
|
1074
|
-
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || DEFAULT_ITEM_COLOR;
|
|
1082
|
+
result[colorKey] = (firstOption === null || firstOption === void 0 ? void 0 : firstOption.color) || _constants.DEFAULT_ITEM_COLOR;
|
|
1075
1083
|
} else {
|
|
1076
|
-
result[colorKey] = DEFAULT_ITEM_COLOR;
|
|
1084
|
+
result[colorKey] = _constants.DEFAULT_ITEM_COLOR;
|
|
1077
1085
|
}
|
|
1078
|
-
} else if (columnType === CellType.COLLABORATOR) {
|
|
1079
|
-
let collaborator = getKnownCollaboratorByEmail(name);
|
|
1086
|
+
} else if (columnType === _dtableUtils.CellType.COLLABORATOR) {
|
|
1087
|
+
let collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(name);
|
|
1080
1088
|
if (collaborator) {
|
|
1081
1089
|
result[nameKey] = collaborator.name;
|
|
1082
1090
|
}
|
|
1083
|
-
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
1091
|
+
} else if (columnType === _dtableUtils.CellType.CREATOR || columnType === _dtableUtils.CellType.LAST_MODIFIER) {
|
|
1084
1092
|
if (name === 'anonymous') {
|
|
1085
1093
|
result[nameKey] = name;
|
|
1086
1094
|
} else {
|
|
1087
|
-
const collaborator = getKnownCollaboratorByEmail(name);
|
|
1095
|
+
const collaborator = (0, _collaboratorUtils.getKnownCollaboratorByEmail)(name);
|
|
1088
1096
|
const collaboratorTemplate = {
|
|
1089
1097
|
loaded: false,
|
|
1090
1098
|
email: name,
|
|
1091
1099
|
name: name
|
|
1092
1100
|
};
|
|
1093
|
-
|
|
1101
|
+
_context.default.updateCollaboratorsCache(name, collaboratorTemplate);
|
|
1094
1102
|
if (!collaborator) {
|
|
1095
|
-
|
|
1096
|
-
const collaborator = emailUserMap && emailUserMap[name] || generateDefaultUser(name);
|
|
1103
|
+
_context.default.queryUsers([name], emailUserMap => {
|
|
1104
|
+
const collaborator = emailUserMap && emailUserMap[name] || (0, _collaboratorUtils.generateDefaultUser)(name);
|
|
1097
1105
|
const loadedCollaborator = {
|
|
1098
1106
|
...collaborator,
|
|
1099
1107
|
loaded: true
|
|
1100
1108
|
};
|
|
1101
|
-
|
|
1109
|
+
_context.default.updateCollaboratorsCache(name, loadedCollaborator);
|
|
1102
1110
|
result[nameKey] = name;
|
|
1103
1111
|
});
|
|
1104
1112
|
} else {
|
|
1105
1113
|
result[nameKey] = collaborator.name;
|
|
1106
1114
|
}
|
|
1107
1115
|
}
|
|
1108
|
-
} else if (columnType === CellType.NUMBER) {
|
|
1116
|
+
} else if (columnType === _dtableUtils.CellType.NUMBER) {
|
|
1109
1117
|
const valueNumber = parseFloat(name);
|
|
1110
|
-
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1111
|
-
} else if (columnType === CellType.DATE) {
|
|
1118
|
+
result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
|
|
1119
|
+
} else if (columnType === _dtableUtils.CellType.DATE) {
|
|
1112
1120
|
if (name && name.split('-').length === 3) {
|
|
1113
|
-
let format = getDateColumnFormat(column);
|
|
1121
|
+
let format = (0, _columnUtils.getDateColumnFormat)(column);
|
|
1114
1122
|
const spaceIndex = format.indexOf(' ');
|
|
1115
1123
|
if (spaceIndex > -1) {
|
|
1116
1124
|
format = format.slice(0, spaceIndex);
|
|
1117
1125
|
}
|
|
1118
|
-
result[nameKey] =
|
|
1126
|
+
result[nameKey] = (0, _dayjs.default)(name).format(format);
|
|
1119
1127
|
}
|
|
1120
|
-
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
1128
|
+
} else if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
1121
1129
|
const {
|
|
1122
1130
|
result_type,
|
|
1123
1131
|
array_type
|
|
1124
1132
|
} = columnData || {};
|
|
1125
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1133
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
1126
1134
|
const valueNumber = parseFloat(name);
|
|
1127
|
-
result[nameKey] = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, columnData) : name;
|
|
1128
|
-
} else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1129
|
-
if (COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(name)) {
|
|
1135
|
+
result[nameKey] = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, columnData) : name;
|
|
1136
|
+
} else if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
1137
|
+
if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(name)) {
|
|
1130
1138
|
result[nameKey] = name.map(email => {
|
|
1131
|
-
let user = array_type === CellType.COLLABORATOR ? getKnownCollaboratorByEmail(email) : getKnownCollaboratorByEmail(email);
|
|
1139
|
+
let user = array_type === _dtableUtils.CellType.COLLABORATOR ? (0, _collaboratorUtils.getKnownCollaboratorByEmail)(email) : (0, _collaboratorUtils.getKnownCollaboratorByEmail)(email);
|
|
1132
1140
|
return (user || {}).name;
|
|
1133
1141
|
});
|
|
1134
1142
|
}
|
|
1135
1143
|
}
|
|
1136
|
-
} else if (columnType === CellType.LINK) {
|
|
1137
|
-
result[nameKey] = getClientFormulaDisplayString([name], columnData) || null;
|
|
1144
|
+
} else if (columnType === _dtableUtils.CellType.LINK) {
|
|
1145
|
+
result[nameKey] = (0, _cellFormatUtils.getClientFormulaDisplayString)([name], columnData) || null;
|
|
1138
1146
|
}
|
|
1139
1147
|
};
|
|
1140
1148
|
// theme
|
|
1141
1149
|
BaseUtils.getCurrentTheme = themeName => {
|
|
1142
1150
|
if (themeName) {
|
|
1143
|
-
const currentColorTheme = STYLE_COLORS.find(item => item.name === themeName);
|
|
1151
|
+
const currentColorTheme = _constants.STYLE_COLORS.find(item => item.name === themeName);
|
|
1144
1152
|
return currentColorTheme;
|
|
1145
1153
|
}
|
|
1146
|
-
return STYLE_COLORS[0];
|
|
1154
|
+
return _constants.STYLE_COLORS[0];
|
|
1147
1155
|
};
|
|
1148
1156
|
BaseUtils.getSummaryExplanation = chart => {
|
|
1149
1157
|
const {
|
|
@@ -1153,43 +1161,43 @@ BaseUtils.getSummaryExplanation = chart => {
|
|
|
1153
1161
|
type
|
|
1154
1162
|
} = config;
|
|
1155
1163
|
switch (type) {
|
|
1156
|
-
case CHART_TYPE.PIE:
|
|
1157
|
-
case CHART_TYPE.LINE:
|
|
1158
|
-
case CHART_TYPE.LINE_GROUP:
|
|
1159
|
-
case CHART_TYPE.RING:
|
|
1164
|
+
case _constants.CHART_TYPE.PIE:
|
|
1165
|
+
case _constants.CHART_TYPE.LINE:
|
|
1166
|
+
case _constants.CHART_TYPE.LINE_GROUP:
|
|
1167
|
+
case _constants.CHART_TYPE.RING:
|
|
1160
1168
|
{
|
|
1161
1169
|
return {
|
|
1162
|
-
count:
|
|
1163
|
-
advanced:
|
|
1170
|
+
count: _intl.default.get('Count_the_number_of_records_in_each_group'),
|
|
1171
|
+
advanced: _intl.default.get('Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field')
|
|
1164
1172
|
};
|
|
1165
1173
|
}
|
|
1166
|
-
case CHART_TYPE.BAR:
|
|
1167
|
-
case CHART_TYPE.BAR_GROUP:
|
|
1174
|
+
case _constants.CHART_TYPE.BAR:
|
|
1175
|
+
case _constants.CHART_TYPE.BAR_GROUP:
|
|
1168
1176
|
{
|
|
1169
1177
|
return {
|
|
1170
|
-
count:
|
|
1171
|
-
advanced:
|
|
1178
|
+
count: _intl.default.get('Group_the_records_according_to_the_vertical_axis_and_count_the_records_in_each_group'),
|
|
1179
|
+
advanced: _intl.default.get('Group_the_records_according_to_the_vertical_axis_and_compute_the_sum_maximum_or_minimum_of_records_in_each_group_by_a_field')
|
|
1172
1180
|
};
|
|
1173
1181
|
}
|
|
1174
1182
|
default:
|
|
1175
1183
|
{
|
|
1176
1184
|
return {
|
|
1177
|
-
count:
|
|
1178
|
-
advanced:
|
|
1185
|
+
count: _intl.default.get('Count_the_records'),
|
|
1186
|
+
advanced: _intl.default.get('Compute_sum_max_min')
|
|
1179
1187
|
};
|
|
1180
1188
|
}
|
|
1181
1189
|
}
|
|
1182
1190
|
};
|
|
1183
1191
|
BaseUtils.getLabelFontSize = labelFontSize => {
|
|
1184
|
-
return isNumber(labelFontSize) ? labelFontSize : DEFAULT_LABEL_FONT_SIZE;
|
|
1192
|
+
return (0, _dtableUtils.isNumber)(labelFontSize) ? labelFontSize : _constants.DEFAULT_LABEL_FONT_SIZE;
|
|
1185
1193
|
};
|
|
1186
1194
|
BaseUtils.imEmptyChartResult = chartResult => {
|
|
1187
1195
|
return !chartResult || !chartResult.result && chartResult.result !== 0 || Array.isArray(chartResult.result) && chartResult.result.length === 0;
|
|
1188
1196
|
};
|
|
1189
1197
|
BaseUtils.getPrecisionNumber = (value, data) => {
|
|
1190
|
-
const valueString = getPrecisionNumber(value, data);
|
|
1198
|
+
const valueString = (0, _dtableUtils.getPrecisionNumber)(value, data);
|
|
1191
1199
|
const valueNumber = parseFloat(valueString);
|
|
1192
|
-
return isNumber(valueNumber) ? valueNumber : 0;
|
|
1200
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? valueNumber : 0;
|
|
1193
1201
|
};
|
|
1194
1202
|
BaseUtils.isValidCellValue = function (cellValue) {
|
|
1195
1203
|
let includeEmpty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -1201,7 +1209,7 @@ BaseUtils.convertConfig = config => {
|
|
|
1201
1209
|
const {
|
|
1202
1210
|
type
|
|
1203
1211
|
} = config;
|
|
1204
|
-
if (type === CHART_TYPE.HORIZONTAL_BAR || type === CHART_TYPE.HORIZONTAL_GROUP_BAR || type === CHART_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
1212
|
+
if (type === _constants.CHART_TYPE.HORIZONTAL_BAR || type === _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR || type === _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR) {
|
|
1205
1213
|
const {
|
|
1206
1214
|
vertical_axis_column_key,
|
|
1207
1215
|
vertical_axis_date_granularity,
|
|
@@ -1248,24 +1256,24 @@ BaseUtils.convertConfig = config => {
|
|
|
1248
1256
|
};
|
|
1249
1257
|
BaseUtils.getSummaryType = config => {
|
|
1250
1258
|
switch (config.type) {
|
|
1251
|
-
case CHART_TYPE.HORIZONTAL_BAR:
|
|
1252
|
-
case CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
1253
|
-
case CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1259
|
+
case _constants.CHART_TYPE.HORIZONTAL_BAR:
|
|
1260
|
+
case _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR:
|
|
1261
|
+
case _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR:
|
|
1254
1262
|
{
|
|
1255
1263
|
return config.horizontal_axis_summary_type;
|
|
1256
1264
|
}
|
|
1257
|
-
case CHART_TYPE.BAR:
|
|
1258
|
-
case CHART_TYPE.BAR_GROUP:
|
|
1259
|
-
case CHART_TYPE.BAR_STACK:
|
|
1260
|
-
case CHART_TYPE.LINE:
|
|
1261
|
-
case CHART_TYPE.LINE_GROUP:
|
|
1262
|
-
case CHART_TYPE.AREA:
|
|
1263
|
-
case CHART_TYPE.AREA_GROUP:
|
|
1264
|
-
case CHART_TYPE.SCATTER:
|
|
1265
|
+
case _constants.CHART_TYPE.BAR:
|
|
1266
|
+
case _constants.CHART_TYPE.BAR_GROUP:
|
|
1267
|
+
case _constants.CHART_TYPE.BAR_STACK:
|
|
1268
|
+
case _constants.CHART_TYPE.LINE:
|
|
1269
|
+
case _constants.CHART_TYPE.LINE_GROUP:
|
|
1270
|
+
case _constants.CHART_TYPE.AREA:
|
|
1271
|
+
case _constants.CHART_TYPE.AREA_GROUP:
|
|
1272
|
+
case _constants.CHART_TYPE.SCATTER:
|
|
1265
1273
|
{
|
|
1266
1274
|
return config.y_axis_summary_type;
|
|
1267
1275
|
}
|
|
1268
|
-
case CHART_TYPE.TABLE:
|
|
1276
|
+
case _constants.CHART_TYPE.TABLE:
|
|
1269
1277
|
default:
|
|
1270
1278
|
{
|
|
1271
1279
|
return config.summary_type;
|
|
@@ -1279,20 +1287,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1279
1287
|
data
|
|
1280
1288
|
} = column || {};
|
|
1281
1289
|
switch (type) {
|
|
1282
|
-
case CellType.TEXT:
|
|
1290
|
+
case _dtableUtils.CellType.TEXT:
|
|
1283
1291
|
{
|
|
1284
1292
|
return cellValue || null;
|
|
1285
1293
|
}
|
|
1286
|
-
case CellType.NUMBER:
|
|
1294
|
+
case _dtableUtils.CellType.NUMBER:
|
|
1287
1295
|
{
|
|
1288
1296
|
if (!cellValue && cellValue !== 0) {
|
|
1289
1297
|
return null;
|
|
1290
1298
|
}
|
|
1291
|
-
const number = getPrecisionNumber(cellValue, data);
|
|
1299
|
+
const number = (0, _dtableUtils.getPrecisionNumber)(cellValue, data);
|
|
1292
1300
|
let valueNumber = parseFloat(number);
|
|
1293
|
-
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : valueNumber;
|
|
1301
|
+
return (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, column.data) : valueNumber;
|
|
1294
1302
|
}
|
|
1295
|
-
case CellType.SINGLE_SELECT:
|
|
1303
|
+
case _dtableUtils.CellType.SINGLE_SELECT:
|
|
1296
1304
|
{
|
|
1297
1305
|
let isInvalidValue = data && data.options.findIndex(opt => opt.id === cellValue) < 0;
|
|
1298
1306
|
if (isInvalidValue) {
|
|
@@ -1300,20 +1308,20 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1300
1308
|
}
|
|
1301
1309
|
return cellValue;
|
|
1302
1310
|
}
|
|
1303
|
-
case CellType.DATE:
|
|
1304
|
-
case CellType.CTIME:
|
|
1305
|
-
case CellType.MTIME:
|
|
1311
|
+
case _dtableUtils.CellType.DATE:
|
|
1312
|
+
case _dtableUtils.CellType.CTIME:
|
|
1313
|
+
case _dtableUtils.CellType.MTIME:
|
|
1306
1314
|
{
|
|
1307
1315
|
if (!dateGranularity) {
|
|
1308
|
-
return getDateDisplayString(cellValue);
|
|
1316
|
+
return (0, _dtableUtils.getDateDisplayString)(cellValue);
|
|
1309
1317
|
}
|
|
1310
|
-
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1318
|
+
const firstDayOfWeek = (0, _index.getFirstDayOfWeekForGroupby)('base');
|
|
1311
1319
|
if (dateGranularity.toUpperCase() === 'QUARTER') {
|
|
1312
|
-
return DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1320
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, 'QUARTAR', firstDayOfWeek);
|
|
1313
1321
|
}
|
|
1314
|
-
return DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1322
|
+
return _dtableUtils.DateUtils.getDateByGranularity(cellValue, dateGranularity, firstDayOfWeek);
|
|
1315
1323
|
}
|
|
1316
|
-
case CellType.MULTIPLE_SELECT:
|
|
1324
|
+
case _dtableUtils.CellType.MULTIPLE_SELECT:
|
|
1317
1325
|
{
|
|
1318
1326
|
let options = data && data.options;
|
|
1319
1327
|
if (!Array.isArray(cellValue)) {
|
|
@@ -1322,18 +1330,18 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1322
1330
|
const newCellValue = cellValue.filter(id => options.findIndex(o => o.id === id) > -1);
|
|
1323
1331
|
return newCellValue.sort();
|
|
1324
1332
|
}
|
|
1325
|
-
case CellType.COLLABORATOR:
|
|
1333
|
+
case _dtableUtils.CellType.COLLABORATOR:
|
|
1326
1334
|
{
|
|
1327
1335
|
if (!Array.isArray(cellValue)) return [];
|
|
1328
|
-
return cellValue.filter(email => isValidCollaboratorEmail(email));
|
|
1336
|
+
return cellValue.filter(email => (0, _collaborator.isValidCollaboratorEmail)(email));
|
|
1329
1337
|
}
|
|
1330
|
-
case CellType.CREATOR:
|
|
1331
|
-
case CellType.LAST_MODIFIER:
|
|
1338
|
+
case _dtableUtils.CellType.CREATOR:
|
|
1339
|
+
case _dtableUtils.CellType.LAST_MODIFIER:
|
|
1332
1340
|
{
|
|
1333
1341
|
return cellValue ? cellValue : null;
|
|
1334
1342
|
}
|
|
1335
|
-
case CellType.LINK_FORMULA:
|
|
1336
|
-
case CellType.FORMULA:
|
|
1343
|
+
case _dtableUtils.CellType.LINK_FORMULA:
|
|
1344
|
+
case _dtableUtils.CellType.FORMULA:
|
|
1337
1345
|
{
|
|
1338
1346
|
if (!formulaRow) return '';
|
|
1339
1347
|
let formulaCellValue = formulaRow[key];
|
|
@@ -1341,34 +1349,34 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1341
1349
|
result_type,
|
|
1342
1350
|
array_type
|
|
1343
1351
|
} = data || {};
|
|
1344
|
-
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
1352
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
1345
1353
|
if (array_type === 'date' && (formulaCellValue === null || formulaCellValue === void 0 ? void 0 : formulaCellValue.length) === 1) {
|
|
1346
1354
|
const dateCellValue = formulaCellValue[0];
|
|
1347
|
-
if (!dateGranularity) return getDateDisplayString(dateCellValue);
|
|
1348
|
-
const firstDayOfWeek = getFirstDayOfWeekForGroupby('base');
|
|
1349
|
-
if (dateGranularity.toUpperCase() === 'QUARTER') return DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR', firstDayOfWeek);
|
|
1350
|
-
return DateUtils.getDateByGranularity(dateCellValue, dateGranularity, firstDayOfWeek);
|
|
1355
|
+
if (!dateGranularity) return (0, _dtableUtils.getDateDisplayString)(dateCellValue);
|
|
1356
|
+
const firstDayOfWeek = (0, _index.getFirstDayOfWeekForGroupby)('base');
|
|
1357
|
+
if (dateGranularity.toUpperCase() === 'QUARTER') return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, 'QUARTAR', firstDayOfWeek);
|
|
1358
|
+
return _dtableUtils.DateUtils.getDateByGranularity(dateCellValue, dateGranularity, firstDayOfWeek);
|
|
1351
1359
|
}
|
|
1352
|
-
return getFormulaDisplayString(formulaCellValue, data, {
|
|
1360
|
+
return (0, _dtableUtils.getFormulaDisplayString)(formulaCellValue, data, {
|
|
1353
1361
|
tables: value.tables
|
|
1354
1362
|
}) || null;
|
|
1355
1363
|
}
|
|
1356
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
1357
|
-
return getPrecisionNumber(formulaCellValue, data);
|
|
1364
|
+
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
1365
|
+
return (0, _dtableUtils.getPrecisionNumber)(formulaCellValue, data);
|
|
1358
1366
|
}
|
|
1359
1367
|
return formulaCellValue ? formulaCellValue + '' : null;
|
|
1360
1368
|
}
|
|
1361
|
-
case CellType.GEOLOCATION:
|
|
1369
|
+
case _dtableUtils.CellType.GEOLOCATION:
|
|
1362
1370
|
{
|
|
1363
1371
|
const {
|
|
1364
1372
|
geo_format
|
|
1365
1373
|
} = data || {};
|
|
1366
1374
|
if (geo_format === 'country_region' || geo_format === 'lng_lat' || !geoGranularity) {
|
|
1367
|
-
return getGeolocationDisplayString(cellValue, data);
|
|
1375
|
+
return (0, _dtableUtils.getGeolocationDisplayString)(cellValue, data);
|
|
1368
1376
|
}
|
|
1369
1377
|
return cellValue ? cellValue[geoGranularity] : null;
|
|
1370
1378
|
}
|
|
1371
|
-
case CellType.LINK:
|
|
1379
|
+
case _dtableUtils.CellType.LINK:
|
|
1372
1380
|
{
|
|
1373
1381
|
const linkCellValue = formulaRow && formulaRow[key];
|
|
1374
1382
|
if (!Array.isArray(linkCellValue)) {
|
|
@@ -1376,11 +1384,11 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
1376
1384
|
}
|
|
1377
1385
|
return linkCellValue.map(linkVal => linkVal.display_value);
|
|
1378
1386
|
}
|
|
1379
|
-
case CellType.CHECKBOX:
|
|
1387
|
+
case _dtableUtils.CellType.CHECKBOX:
|
|
1380
1388
|
{
|
|
1381
1389
|
return String(!!cellValue);
|
|
1382
1390
|
}
|
|
1383
|
-
case CellType.RATE:
|
|
1391
|
+
case _dtableUtils.CellType.RATE:
|
|
1384
1392
|
{
|
|
1385
1393
|
if (!cellValue) return null;
|
|
1386
1394
|
return cellValue + '';
|
|
@@ -1396,9 +1404,9 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1396
1404
|
let formula_rows = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1397
1405
|
let rowsLength = rows.length;
|
|
1398
1406
|
let total;
|
|
1399
|
-
if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1407
|
+
if (summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
1400
1408
|
total = rowsLength;
|
|
1401
|
-
} else if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1409
|
+
} else if (summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1402
1410
|
switch (summary_method) {
|
|
1403
1411
|
case 'Distinct_values':
|
|
1404
1412
|
{
|
|
@@ -1406,7 +1414,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1406
1414
|
let existMap = {};
|
|
1407
1415
|
rows.forEach(r => {
|
|
1408
1416
|
let num;
|
|
1409
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1417
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1410
1418
|
const formulaRow = formula_rows[r._id] || {};
|
|
1411
1419
|
num = formulaRow[summary_column_key];
|
|
1412
1420
|
num = Array.isArray(num) ? num[0] : num;
|
|
@@ -1435,14 +1443,14 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1435
1443
|
let validNumbersCount = 0;
|
|
1436
1444
|
rows.forEach(r => {
|
|
1437
1445
|
let num;
|
|
1438
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1446
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1439
1447
|
let formulaRow = formula_rows[r._id] || {};
|
|
1440
1448
|
num = formulaRow[summary_column_key];
|
|
1441
1449
|
num = Array.isArray(num) ? num[0] : num;
|
|
1442
1450
|
} else {
|
|
1443
1451
|
num = r[summary_column_key];
|
|
1444
1452
|
}
|
|
1445
|
-
if (isNumber(num)) {
|
|
1453
|
+
if ((0, _dtableUtils.isNumber)(num)) {
|
|
1446
1454
|
validNumbersCount++;
|
|
1447
1455
|
sum += num;
|
|
1448
1456
|
}
|
|
@@ -1460,7 +1468,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1460
1468
|
if (rowsLength > 0) {
|
|
1461
1469
|
let result = rows.reduce((current, next) => {
|
|
1462
1470
|
let currentValue, nextValue;
|
|
1463
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1471
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1464
1472
|
let currentFormulaRow = formula_rows[current._id];
|
|
1465
1473
|
let nextFormulaRow = formula_rows[next._id];
|
|
1466
1474
|
currentValue = currentFormulaRow && currentFormulaRow[summary_column_key];
|
|
@@ -1471,7 +1479,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1471
1479
|
currentValue = current[summary_column_key];
|
|
1472
1480
|
nextValue = next[summary_column_key];
|
|
1473
1481
|
}
|
|
1474
|
-
if (isEmpty(nextValue)) {
|
|
1482
|
+
if ((0, _dtableUtils.isEmpty)(nextValue)) {
|
|
1475
1483
|
return current;
|
|
1476
1484
|
}
|
|
1477
1485
|
let isNextGreater = currentValue < nextValue;
|
|
@@ -1481,7 +1489,7 @@ BaseUtils.getTotal = function (summary_column_key, summary_column_type, summary_
|
|
|
1481
1489
|
return isNextGreater ? next : current;
|
|
1482
1490
|
}
|
|
1483
1491
|
});
|
|
1484
|
-
if (FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1492
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[summary_column_type]) {
|
|
1485
1493
|
let formulaRow = formula_rows[result._id];
|
|
1486
1494
|
total = formulaRow && formulaRow[summary_column_key];
|
|
1487
1495
|
total = Array.isArray(total) ? total[0] : total;
|
|
@@ -1503,42 +1511,42 @@ BaseUtils.getFormattedValue = (value, column, summaryMethod) => {
|
|
|
1503
1511
|
if (!column) {
|
|
1504
1512
|
return value;
|
|
1505
1513
|
}
|
|
1506
|
-
if (summaryMethod === CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
|
|
1514
|
+
if (summaryMethod === _constants.CHART_SUMMARY_TYPE.DISTINCT_VALUES) {
|
|
1507
1515
|
return value;
|
|
1508
1516
|
}
|
|
1509
1517
|
const {
|
|
1510
1518
|
type,
|
|
1511
1519
|
data
|
|
1512
1520
|
} = column;
|
|
1513
|
-
if (isNumericColumn(column)) {
|
|
1514
|
-
return getNumberDisplayString(value, data);
|
|
1521
|
+
if ((0, _dtableUtils.isNumericColumn)(column)) {
|
|
1522
|
+
return (0, _dtableUtils.getNumberDisplayString)(value, data);
|
|
1515
1523
|
}
|
|
1516
|
-
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
1517
|
-
return getClientFormulaDisplayString(value, data);
|
|
1524
|
+
if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
1525
|
+
return (0, _cellFormatUtils.getClientFormulaDisplayString)(value, data);
|
|
1518
1526
|
}
|
|
1519
1527
|
return value;
|
|
1520
1528
|
};
|
|
1521
1529
|
BaseUtils.getSummaryResult = function (results, summaryMethod) {
|
|
1522
1530
|
let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
|
|
1523
|
-
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => isNumber(res)) : [];
|
|
1531
|
+
const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableUtils.isNumber)(res)) : [];
|
|
1524
1532
|
switch (summaryMethod) {
|
|
1525
|
-
case CHART_SUMMARY_TYPE.MAX:
|
|
1533
|
+
case _constants.CHART_SUMMARY_TYPE.MAX:
|
|
1526
1534
|
{
|
|
1527
1535
|
return _BaseUtils.getMax(numericResults);
|
|
1528
1536
|
}
|
|
1529
|
-
case CHART_SUMMARY_TYPE.MIN:
|
|
1537
|
+
case _constants.CHART_SUMMARY_TYPE.MIN:
|
|
1530
1538
|
{
|
|
1531
1539
|
return _BaseUtils.getMin(numericResults);
|
|
1532
1540
|
}
|
|
1533
|
-
case CHART_SUMMARY_TYPE.SUM:
|
|
1541
|
+
case _constants.CHART_SUMMARY_TYPE.SUM:
|
|
1534
1542
|
{
|
|
1535
1543
|
return _BaseUtils.getSum(numericResults, precision);
|
|
1536
1544
|
}
|
|
1537
|
-
case CHART_SUMMARY_TYPE.MEAN:
|
|
1545
|
+
case _constants.CHART_SUMMARY_TYPE.MEAN:
|
|
1538
1546
|
{
|
|
1539
1547
|
return _BaseUtils.getMean(numericResults, precision);
|
|
1540
1548
|
}
|
|
1541
|
-
case CHART_SUMMARY_TYPE.Distinct_values:
|
|
1549
|
+
case _constants.CHART_SUMMARY_TYPE.Distinct_values:
|
|
1542
1550
|
{
|
|
1543
1551
|
let count = 0;
|
|
1544
1552
|
let existMap = {};
|
|
@@ -1587,15 +1595,15 @@ BaseUtils.getMean = function (list) {
|
|
|
1587
1595
|
return Number.parseFloat((sum / list.length).toFixed(precision));
|
|
1588
1596
|
};
|
|
1589
1597
|
BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod, useDataDb, dbDateKey, valueKey) => {
|
|
1590
|
-
const currentTime =
|
|
1598
|
+
const currentTime = (0, _dayjs.default)();
|
|
1591
1599
|
const days = duration === 'days_30' ? 30 : 7;
|
|
1592
1600
|
// set date to start of the day
|
|
1593
1601
|
const formattedEndDate = currentTime.format('YYYY-MM-DD');
|
|
1594
1602
|
const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
|
|
1595
|
-
const formattedStartDate =
|
|
1596
|
-
const endDate =
|
|
1597
|
-
const middleDate =
|
|
1598
|
-
const startDate =
|
|
1603
|
+
const formattedStartDate = (0, _dayjs.default)(formattedMiddleDate).subtract(days, 'days').format('YYYY-MM-DD');
|
|
1604
|
+
const endDate = (0, _dayjs.default)(formattedEndDate);
|
|
1605
|
+
const middleDate = (0, _dayjs.default)(formattedMiddleDate);
|
|
1606
|
+
const startDate = (0, _dayjs.default)(formattedStartDate);
|
|
1599
1607
|
let compareValue = [];
|
|
1600
1608
|
let comparedValue = [];
|
|
1601
1609
|
if (useDataDb) {
|
|
@@ -1603,7 +1611,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1603
1611
|
const days2 = [];
|
|
1604
1612
|
for (let index = 0; index < result.length; index++) {
|
|
1605
1613
|
const item = result[index];
|
|
1606
|
-
const key =
|
|
1614
|
+
const key = (0, _dayjs.default)(item[dbDateKey]);
|
|
1607
1615
|
if (!key.isValid()) continue;
|
|
1608
1616
|
if (key >= startDate && key < middleDate) {
|
|
1609
1617
|
comparedValue.push(item[valueKey]);
|
|
@@ -1632,7 +1640,7 @@ BaseUtils.summaryDurationResult = (result, duration, summaryType, summaryMethod,
|
|
|
1632
1640
|
// }
|
|
1633
1641
|
// }
|
|
1634
1642
|
// }
|
|
1635
|
-
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1643
|
+
if (summaryType === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1636
1644
|
comparedValue = _BaseUtils.getSummaryResult(comparedValue, summaryMethod);
|
|
1637
1645
|
compareValue = _BaseUtils.getSummaryResult(compareValue, summaryMethod);
|
|
1638
1646
|
} else {
|
|
@@ -1658,13 +1666,13 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1658
1666
|
sqlColumnGroupbyColumnKey
|
|
1659
1667
|
} = chartSQLMap;
|
|
1660
1668
|
let newSqlRows = JSON.parse(JSON.stringify(sqlRows));
|
|
1661
|
-
if (config.summary_type === CHART_SUMMARY_TYPE.COUNT) {
|
|
1669
|
+
if (config.summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
|
|
1662
1670
|
// has column group
|
|
1663
1671
|
if (sqlColumnGroupbyColumnKey) {
|
|
1664
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1672
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.COLLABORATOR) {
|
|
1665
1673
|
return newSqlRows;
|
|
1666
1674
|
}
|
|
1667
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1675
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
1668
1676
|
return newSqlRows;
|
|
1669
1677
|
}
|
|
1670
1678
|
}
|
|
@@ -1690,7 +1698,7 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1690
1698
|
newSqlRows = Object.values(collaboratorsRowsMap);
|
|
1691
1699
|
}
|
|
1692
1700
|
}
|
|
1693
|
-
if (config.summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1701
|
+
if (config.summary_type === _constants.CHART_SUMMARY_TYPE.ADVANCED) {
|
|
1694
1702
|
let summarySQLColumnName2ColumnKeys;
|
|
1695
1703
|
if (summarySQLColumnName2ColumnKey) {
|
|
1696
1704
|
summarySQLColumnName2ColumnKeys = Object.keys(summarySQLColumnName2ColumnKey);
|
|
@@ -1703,10 +1711,10 @@ BaseUtils.formatedTableSqlRowsByCollaboratorAndMultiple = (chart, sqlRows, chart
|
|
|
1703
1711
|
|
|
1704
1712
|
// has column group
|
|
1705
1713
|
if (sqlColumnGroupbyColumnKey) {
|
|
1706
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1714
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.COLLABORATOR) {
|
|
1707
1715
|
return newSqlRows;
|
|
1708
1716
|
}
|
|
1709
|
-
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1717
|
+
if ((columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
1710
1718
|
return newSqlRows;
|
|
1711
1719
|
}
|
|
1712
1720
|
|
|
@@ -1848,16 +1856,16 @@ BaseUtils.getDateGranularityByType = chart => {
|
|
|
1848
1856
|
const {
|
|
1849
1857
|
type
|
|
1850
1858
|
} = chart;
|
|
1851
|
-
if ([CHART_TYPE.AREA_GROUP, CHART_TYPE.AREA, CHART_TYPE.BAR, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_STACK, CHART_TYPE.COMPARE_BAR, CHART_TYPE.COMBINATION, CHART_TYPE.LINE_GROUP, CHART_TYPE.LINE].includes(type)) {
|
|
1859
|
+
if ([_constants.CHART_TYPE.AREA_GROUP, _constants.CHART_TYPE.AREA, _constants.CHART_TYPE.BAR, _constants.CHART_TYPE.BAR_CUSTOM, _constants.CHART_TYPE.BAR_GROUP, _constants.CHART_TYPE.BAR_STACK, _constants.CHART_TYPE.COMPARE_BAR, _constants.CHART_TYPE.COMBINATION, _constants.CHART_TYPE.LINE_GROUP, _constants.CHART_TYPE.LINE].includes(type)) {
|
|
1852
1860
|
return chart['x_axis_date_granularity'];
|
|
1853
1861
|
}
|
|
1854
|
-
if ([CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER, CHART_TYPE.TREND].includes(type)) {
|
|
1862
|
+
if ([_constants.CHART_TYPE.COMPLETENESS_GROUP, _constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.TREND].includes(type)) {
|
|
1855
1863
|
return chart['date_granularity'];
|
|
1856
1864
|
}
|
|
1857
|
-
if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1865
|
+
if ([_constants.CHART_TYPE.HORIZONTAL_BAR, _constants.CHART_TYPE.HORIZONTAL_GROUP_BAR, _constants.CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(type)) {
|
|
1858
1866
|
return chart['vertical_axis_date_granularity'];
|
|
1859
1867
|
}
|
|
1860
|
-
if ([CHART_TYPE.PIE, CHART_TYPE.RING, CHART_TYPE.TABLE, CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1868
|
+
if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING, _constants.CHART_TYPE.TABLE, _constants.CHART_TYPE.TREE_MAP].includes(type)) {
|
|
1861
1869
|
return chart['groupby_date_granularity'];
|
|
1862
1870
|
}
|
|
1863
1871
|
return null;
|
|
@@ -1908,13 +1916,13 @@ BaseUtils.isCollaboratorColumnOrMultipleColumn = columnMap => {
|
|
|
1908
1916
|
columnGroupbyColumn,
|
|
1909
1917
|
groupbyColumn
|
|
1910
1918
|
} = columnMap || {};
|
|
1911
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.COLLABORATOR) {
|
|
1919
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === _dtableUtils.CellType.COLLABORATOR) {
|
|
1912
1920
|
return true;
|
|
1913
1921
|
}
|
|
1914
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.MULTIPLE_SELECT) {
|
|
1922
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === _dtableUtils.CellType.MULTIPLE_SELECT) {
|
|
1915
1923
|
return true;
|
|
1916
1924
|
}
|
|
1917
|
-
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === CellType.LINK_FORMULA && [CellType.MULTIPLE_SELECT, CellType.COLLABORATOR].includes(groupbyColumn === null || groupbyColumn === void 0 ? void 0 : (_groupbyColumn$data = groupbyColumn.data) === null || _groupbyColumn$data === void 0 ? void 0 : _groupbyColumn$data.array_type)) {
|
|
1925
|
+
if (columnGroupbyColumn && groupbyColumn && (groupbyColumn === null || groupbyColumn === void 0 ? void 0 : groupbyColumn.type) === _dtableUtils.CellType.LINK_FORMULA && [_dtableUtils.CellType.MULTIPLE_SELECT, _dtableUtils.CellType.COLLABORATOR].includes(groupbyColumn === null || groupbyColumn === void 0 ? void 0 : (_groupbyColumn$data = groupbyColumn.data) === null || _groupbyColumn$data === void 0 ? void 0 : _groupbyColumn$data.array_type)) {
|
|
1918
1926
|
return true;
|
|
1919
1927
|
}
|
|
1920
1928
|
return false;
|
|
@@ -1928,10 +1936,10 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1928
1936
|
} = chart.config;
|
|
1929
1937
|
if (!column_groupby_multiple_numeric_column) {
|
|
1930
1938
|
if (groupColumn) {
|
|
1931
|
-
if ([CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1939
|
+
if ([_dtableUtils.CellType.SINGLE_SELECT].includes(groupColumn.type)) {
|
|
1932
1940
|
data.forEach(item => {
|
|
1933
1941
|
const option = groupColumn.data.options.find(option => option.name === item[groupKey]);
|
|
1934
|
-
if (option
|
|
1942
|
+
if (option !== null && option !== void 0 && option.id) {
|
|
1935
1943
|
item['group_name_id'] = option.id;
|
|
1936
1944
|
item['oldName'] = item.name;
|
|
1937
1945
|
item.name = item['group_name_id'];
|
|
@@ -1951,4 +1959,4 @@ BaseUtils.sortDataByGroupName = function (data, groupKey, groupColumn) {
|
|
|
1951
1959
|
}
|
|
1952
1960
|
return data;
|
|
1953
1961
|
};
|
|
1954
|
-
|
|
1962
|
+
var _default = exports.default = BaseUtils;
|