dtable-statistic 4.3.3 → 4.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/api/dtable-db-api.js +3 -10
- package/es/calculator/base-calculator.js +12 -20
- package/es/calculator/basic-chart-calculator.js +65 -72
- package/es/calculator/combination-calculator.js +57 -64
- package/es/calculator/compare-bar-calculator.js +26 -33
- package/es/calculator/completeness-calculator.js +30 -37
- package/es/calculator/copy-value.js +1 -7
- package/es/calculator/dashboard-calculator.js +13 -20
- package/es/calculator/heat-map-calculator.js +18 -25
- package/es/calculator/horizontal-bar-calculator.js +8 -15
- package/es/calculator/index.js +35 -42
- package/es/calculator/map-calculator.js +22 -29
- package/es/calculator/mirror-calculator.js +20 -27
- package/es/calculator/number-card-calculator.js +10 -17
- package/es/calculator/pivot-table-calculator.js +58 -65
- package/es/calculator/scatter-calculator.js +14 -21
- package/es/calculator/thread-manager.js +1 -7
- package/es/calculator/trend-calculator.js +22 -29
- package/es/calculator/workers/basic-chart-calculator-worker.js +76 -83
- package/es/calculator/workers/calculator.worker.js +30 -33
- package/es/calculator/workers/card-calculator-worker.js +13 -19
- package/es/calculator/workers/combination-calculator-worker.js +46 -53
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +22 -29
- package/es/calculator/workers/completeness-calculator-worker.js +34 -41
- package/es/calculator/workers/dashboard-calculator-worker.js +18 -24
- package/es/calculator/workers/mirror-calculator-worker.js +22 -29
- package/es/calculator/workers/pivot-table-calculator-worker.js +77 -84
- package/es/calculator/workers/scatter-calculator-worker.js +20 -27
- package/es/calculator/workers/trend-calculator-worker.js +27 -34
- package/es/calculator/world-map-calculator.js +17 -24
- package/es/components/common-add-tool.js +5 -12
- package/es/components/dialog/chart-addition-edit-dialog.js +12 -20
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +101 -108
- package/es/components/dialog/color-theme-dialog.js +15 -22
- package/es/components/dialog/delete-confirmation-dialog.js +11 -18
- package/es/components/dialog/enlarged-chart-dialog.js +20 -28
- package/es/components/dialog/new-table-dialog.js +16 -23
- package/es/components/dialog/new-view-dialog.js +14 -21
- package/es/components/dialog/rename-view-dialog.js +14 -22
- package/es/components/dialog/statistic-record-dialog/index.js +37 -45
- package/es/components/dialog/statistic-types-dialog/index.js +14 -22
- package/es/components/dialog/table-select-dialog.js +15 -23
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +41 -49
- package/es/components/dtable-popover.js +12 -19
- package/es/components/dtable-search-input.js +13 -21
- package/es/components/dtable-select.js +15 -21
- package/es/components/icon.js +4 -11
- package/es/components/index.js +11 -76
- package/es/components/loading.js +3 -10
- package/es/components/modal-portal.js +5 -12
- package/es/components/popover/color-rules/color-rule.js +25 -33
- package/es/components/popover/color-rules/index.js +6 -14
- package/es/components/popover/color-rules/rule-filters/filter.js +27 -34
- package/es/components/popover/color-rules/rule-filters/index.js +17 -25
- package/es/components/popover/color-rules/rule-filters/number-input.js +9 -17
- package/es/components/popover/color-rules-popover.js +24 -32
- package/es/components/popover/color-selector-popover.js +10 -17
- package/es/components/seatable-radio/index.js +9 -16
- package/es/components/select/index.js +2 -9
- package/es/components/select/option-group.js +19 -27
- package/es/components/select/option.js +6 -14
- package/es/components/select/select.js +17 -25
- package/es/components/toast/alert.js +24 -31
- package/es/components/toast/index.js +3 -10
- package/es/components/toast/toast.js +12 -20
- package/es/components/toast/toastManager.js +9 -17
- package/es/components/toast/toaster.js +6 -14
- package/es/constants/color-rules.js +6 -12
- package/es/constants/dtable-select-style.js +4 -9
- package/es/constants/event-types.js +4 -10
- package/es/constants/index.js +67 -96
- package/es/constants/key-codes.js +0 -2
- package/es/constants/map.js +2 -8
- package/es/constants/model.js +20 -26
- package/es/constants/regions.js +3 -8
- package/es/constants/zIndexes.js +1 -7
- package/es/custom-g2.js +208 -236
- package/es/dashboard.js +50 -58
- package/es/desktop-dashboard.js +47 -55
- package/es/index.js +3 -6
- package/es/locale/index.js +10 -13
- package/es/locale/lang/de.js +1 -7
- package/es/locale/lang/en.js +1 -7
- package/es/locale/lang/fr.js +1 -7
- package/es/locale/lang/zh_CN.js +1 -7
- package/es/mobile-dashboard.js +38 -46
- package/es/model/bar-group.js +11 -19
- package/es/model/bar.js +10 -18
- package/es/model/base-model.js +2 -9
- package/es/model/basic-number-card.js +8 -16
- package/es/model/collaborators.js +2 -9
- package/es/model/combination.js +12 -20
- package/es/model/compare-bar.js +16 -24
- package/es/model/completeness-group.js +8 -16
- package/es/model/completeness.js +5 -13
- package/es/model/custom-bar.js +6 -14
- package/es/model/dashboard.js +6 -14
- package/es/model/generic-model.js +133 -141
- package/es/model/heat-map.js +11 -19
- package/es/model/horizontal-bar-group.js +10 -18
- package/es/model/horizontal-bar.js +10 -18
- package/es/model/index.js +53 -185
- package/es/model/map.js +15 -23
- package/es/model/mirror.js +13 -21
- package/es/model/pie.js +10 -18
- package/es/model/ring.js +11 -19
- package/es/model/scatter.js +6 -14
- package/es/model/statistic-dashboard.js +2 -9
- package/es/model/table.js +10 -18
- package/es/model/trend.js +12 -20
- package/es/model/world-map.js +13 -21
- package/es/service/chart-service.js +7 -14
- package/es/service/dashboard-service.js +34 -41
- package/es/service/map-json.js +8 -14
- package/es/stat-editor/chart-name-editor.js +8 -15
- package/es/stat-editor/index.js +16 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +21 -29
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +49 -57
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +4 -11
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +43 -51
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +23 -31
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +37 -45
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +19 -27
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +26 -34
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +47 -55
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +22 -30
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +27 -35
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +24 -32
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +33 -41
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +22 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +27 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +46 -54
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +23 -31
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +26 -34
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +77 -85
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +21 -29
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +73 -81
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +16 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +19 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +18 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +49 -57
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +47 -55
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +11 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +45 -53
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +9 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +20 -28
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +30 -38
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +50 -58
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +17 -25
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +47 -55
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +11 -19
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +12 -19
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +62 -70
- package/es/stat-editor/stat-settings/map/map-level.js +13 -20
- package/es/stat-editor/stat-settings/map/map-province-city.js +20 -27
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +20 -28
- package/es/stat-editor/stat-settings/public-setting/calender.js +22 -29
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +6 -13
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +9 -16
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +13 -21
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +11 -19
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +27 -35
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +8 -15
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +18 -26
- package/es/stat-list/chart-preview.js +20 -28
- package/es/stat-list/index.js +27 -35
- package/es/stat-view/area-chart.js +43 -50
- package/es/stat-view/bar-chart.js +47 -54
- package/es/stat-view/base-chart.js +24 -32
- package/es/stat-view/basic-number-card.js +19 -26
- package/es/stat-view/combination-chart.js +49 -56
- package/es/stat-view/compare-chart.js +39 -46
- package/es/stat-view/completeness-chart.js +28 -35
- package/es/stat-view/custom-bar.js +31 -38
- package/es/stat-view/dashboard-chart.js +15 -22
- package/es/stat-view/heat-map.js +43 -50
- package/es/stat-view/horizontal-bar-chart.js +51 -58
- package/es/stat-view/index.js +73 -80
- package/es/stat-view/line-chart.js +39 -46
- package/es/stat-view/map.js +33 -40
- package/es/stat-view/mirror.js +21 -28
- package/es/stat-view/pie-chart.js +29 -36
- package/es/stat-view/pivot-table/index.js +32 -39
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +31 -39
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +29 -37
- package/es/stat-view/pivot-table/pivot-table-display-name.js +46 -54
- package/es/stat-view/pivot-table/two-dimension-table.js +62 -70
- package/es/stat-view/ring-chart.js +38 -45
- package/es/stat-view/scatter-chart.js +30 -37
- package/es/stat-view/treemap-chart.js +37 -44
- package/es/stat-view/trend-chart.js +32 -39
- package/es/stat-view/world-map.js +33 -40
- package/es/tabs/index.js +32 -40
- package/es/tabs/tab.js +26 -34
- package/es/utils/basic-chart-utils.js +2 -9
- package/es/utils/cell-format.js +14 -22
- package/es/utils/cell-value.js +7 -14
- package/es/utils/collaborator.js +4 -13
- package/es/utils/color-utils.js +18 -29
- package/es/utils/column-utils.js +18 -29
- package/es/utils/column.js +4 -11
- package/es/utils/common-utils.js +41 -65
- package/es/utils/date-format.js +2 -8
- package/es/utils/export-table-utils.js +82 -91
- package/es/utils/index.js +11 -100
- package/es/utils/map.js +26 -36
- package/es/utils/model.js +6 -14
- package/es/utils/object.js +6 -15
- package/es/utils/pivot-table.js +16 -23
- package/es/utils/row-utils.js +23 -33
- package/es/utils/search.js +21 -29
- package/es/utils/sql-utils.js +65 -75
- package/es/utils/stat-utils.js +60 -66
- package/es/utils/trend-utils.js +32 -40
- package/package.json +1 -1
package/es/utils/map.js
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getRegionScaleOffsets = exports.getGeoGranularityByLevel = exports.fixMapGeoGranularity = exports.fixGeoGranularity = void 0;
|
|
7
|
-
var _constants = require("../constants");
|
|
8
|
-
var _map = require("../constants/map");
|
|
9
|
-
var _regions = require("../constants/regions");
|
|
1
|
+
import { GEOLOCATION_GRANULARITY, STAT_TYPE } from '../constants';
|
|
2
|
+
import { MAP_LEVEL, MUNICIPALITIES } from '../constants/map';
|
|
3
|
+
import { regions } from '../constants/regions';
|
|
10
4
|
const COUNTY_SCALE_WIDTH = 5.95;
|
|
11
5
|
const COUNTY_SCALE_HEIGHT = 4.37;
|
|
12
|
-
const getGeoGranularityByLevel = mapLevel => {
|
|
6
|
+
export const getGeoGranularityByLevel = mapLevel => {
|
|
13
7
|
switch (mapLevel) {
|
|
14
|
-
case
|
|
8
|
+
case MAP_LEVEL.PROVINCE:
|
|
15
9
|
{
|
|
16
|
-
return
|
|
10
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
17
11
|
}
|
|
18
|
-
case
|
|
12
|
+
case MAP_LEVEL.CITY:
|
|
19
13
|
{
|
|
20
|
-
return
|
|
14
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
21
15
|
}
|
|
22
16
|
default:
|
|
23
17
|
{
|
|
24
18
|
// default as 'country'
|
|
25
|
-
return
|
|
19
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
26
20
|
}
|
|
27
21
|
}
|
|
28
22
|
};
|
|
29
|
-
|
|
30
|
-
const fixGeoGranularity = _ref => {
|
|
23
|
+
export const fixGeoGranularity = _ref => {
|
|
31
24
|
let {
|
|
32
25
|
mapLevel,
|
|
33
26
|
mapLocation
|
|
34
27
|
} = _ref;
|
|
35
|
-
if (!mapLevel || mapLevel ===
|
|
36
|
-
return
|
|
28
|
+
if (!mapLevel || mapLevel === MAP_LEVEL.COUNTRY || !mapLocation) {
|
|
29
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
// e.g. Beijing
|
|
@@ -41,32 +34,31 @@ const fixGeoGranularity = _ref => {
|
|
|
41
34
|
province: provinceName,
|
|
42
35
|
city: cityName
|
|
43
36
|
} = mapLocation;
|
|
44
|
-
if (provinceName &&
|
|
45
|
-
return
|
|
37
|
+
if (provinceName && MUNICIPALITIES.includes(provinceName)) {
|
|
38
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
// e.g. HongKong
|
|
49
|
-
const selectedProvince = provinceName &&
|
|
42
|
+
const selectedProvince = provinceName && regions.find(province => province.name === provinceName);
|
|
50
43
|
if (selectedProvince && selectedProvince.disable_drill_down) {
|
|
51
|
-
return
|
|
44
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
52
45
|
}
|
|
53
46
|
const cities = selectedProvince && selectedProvince.cities;
|
|
54
47
|
const selectedCity = cities && cityName && cities.find(city => city.name === cityName);
|
|
55
|
-
if (mapLevel ===
|
|
56
|
-
return
|
|
48
|
+
if (mapLevel === MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
|
|
49
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
57
50
|
}
|
|
58
51
|
|
|
59
52
|
// others
|
|
60
53
|
return getGeoGranularityByLevel(mapLevel);
|
|
61
54
|
};
|
|
62
|
-
|
|
63
|
-
const fixMapGeoGranularity = chart => {
|
|
55
|
+
export const fixMapGeoGranularity = chart => {
|
|
64
56
|
const {
|
|
65
57
|
type,
|
|
66
58
|
map_level,
|
|
67
59
|
map_location
|
|
68
60
|
} = chart;
|
|
69
|
-
if (type !==
|
|
61
|
+
if (type !== STAT_TYPE.MAP && type !== STAT_TYPE.MAP_BUBBLE) {
|
|
70
62
|
return chart.geolocation_granularity;
|
|
71
63
|
}
|
|
72
64
|
return fixGeoGranularity({
|
|
@@ -74,27 +66,26 @@ const fixMapGeoGranularity = chart => {
|
|
|
74
66
|
mapLocation: map_location
|
|
75
67
|
});
|
|
76
68
|
};
|
|
77
|
-
|
|
78
|
-
const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
69
|
+
export const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
79
70
|
const countryScaleOffsets = {
|
|
80
71
|
scale_w: COUNTY_SCALE_WIDTH,
|
|
81
72
|
scale_h: COUNTY_SCALE_HEIGHT
|
|
82
73
|
};
|
|
83
74
|
switch (mapLevel) {
|
|
84
|
-
case
|
|
75
|
+
case MAP_LEVEL.PROVINCE:
|
|
85
76
|
{
|
|
86
77
|
const provinceName = mapLocation && mapLocation.province;
|
|
87
|
-
const province = provinceName &&
|
|
78
|
+
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
88
79
|
if (!province) return countryScaleOffsets;
|
|
89
80
|
return {
|
|
90
81
|
scale_w: province.scale_w,
|
|
91
82
|
scale_h: province.scale_h
|
|
92
83
|
};
|
|
93
84
|
}
|
|
94
|
-
case
|
|
85
|
+
case MAP_LEVEL.CITY:
|
|
95
86
|
{
|
|
96
87
|
const provinceName = mapLocation && mapLocation.province;
|
|
97
|
-
const province = provinceName &&
|
|
88
|
+
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
98
89
|
const cities = province && province.cities;
|
|
99
90
|
const cityName = mapLocation.city;
|
|
100
91
|
const city = cityName && Array.isArray(cities) && cities.find(city => city.name === cityName);
|
|
@@ -110,5 +101,4 @@ const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
|
110
101
|
return countryScaleOffsets;
|
|
111
102
|
}
|
|
112
103
|
}
|
|
113
|
-
};
|
|
114
|
-
exports.getRegionScaleOffsets = getRegionScaleOffsets;
|
|
104
|
+
};
|
package/es/utils/model.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getChartConfigValueFromKeys = exports.getChartConfigValueFromKey = void 0;
|
|
7
|
-
var _object = require("./object");
|
|
8
|
-
const getChartConfigValueFromKey = (key, object) => {
|
|
9
|
-
if (!(0, _object.hasOwnProperty)(object, key)) {
|
|
1
|
+
import { hasOwnProperty } from './object';
|
|
2
|
+
export const getChartConfigValueFromKey = (key, object) => {
|
|
3
|
+
if (!hasOwnProperty(object, key)) {
|
|
10
4
|
return null;
|
|
11
5
|
}
|
|
12
6
|
return object[key];
|
|
13
7
|
};
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const existKey = keys.find(key => (0, _object.hasOwnProperty)(object, key));
|
|
8
|
+
export const getChartConfigValueFromKeys = (keys, object) => {
|
|
9
|
+
const existKey = keys.find(key => hasOwnProperty(object, key));
|
|
17
10
|
return existKey ? object[existKey] : null;
|
|
18
|
-
};
|
|
19
|
-
exports.getChartConfigValueFromKeys = getChartConfigValueFromKeys;
|
|
11
|
+
};
|
package/es/utils/object.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSameObject = exports.isEmptyObject = exports.hasOwnProperty = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
const isSameObject = (a, b) => {
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
export const isSameObject = (a, b) => {
|
|
9
3
|
let k;
|
|
10
4
|
for (k in a) {
|
|
11
5
|
if (a.hasOwnProperty(k)) {
|
|
12
|
-
if (typeof a[k] === 'function' && typeof b[k] === 'function' ||
|
|
6
|
+
if (typeof a[k] === 'function' && typeof b[k] === 'function' || isValidElement(a[k]) && isValidElement(b[k])) {
|
|
13
7
|
continue;
|
|
14
8
|
}
|
|
15
9
|
if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
|
|
@@ -24,12 +18,9 @@ const isSameObject = (a, b) => {
|
|
|
24
18
|
}
|
|
25
19
|
return true;
|
|
26
20
|
};
|
|
27
|
-
|
|
28
|
-
const isEmptyObject = obj => {
|
|
21
|
+
export const isEmptyObject = obj => {
|
|
29
22
|
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
30
23
|
};
|
|
31
|
-
|
|
32
|
-
const hasOwnProperty = (obj, prop) => {
|
|
24
|
+
export const hasOwnProperty = (obj, prop) => {
|
|
33
25
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
34
|
-
};
|
|
35
|
-
exports.hasOwnProperty = hasOwnProperty;
|
|
26
|
+
};
|
package/es/utils/pivot-table.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getPivotTableSummaryTotal = void 0;
|
|
7
|
-
var _dtableStore = require("dtable-store");
|
|
8
|
-
var _constants = require("../constants");
|
|
1
|
+
import { FORMULA_COLUMN_TYPES_MAP, isNumber } from 'dtable-store';
|
|
2
|
+
import { STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP } from '../constants';
|
|
9
3
|
const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) => {
|
|
10
4
|
if (!isSqlQuery) {
|
|
11
|
-
if (
|
|
5
|
+
if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
12
6
|
const cellValue = formulaRow[columnKey];
|
|
13
7
|
return Array.isArray(cellValue) ? cellValue[0] : cellValue;
|
|
14
8
|
}
|
|
@@ -16,15 +10,15 @@ const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isS
|
|
|
16
10
|
}
|
|
17
11
|
return row[sqlKey];
|
|
18
12
|
};
|
|
19
|
-
const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) => {
|
|
20
|
-
if (summaryType ===
|
|
13
|
+
export const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) => {
|
|
14
|
+
if (summaryType === STATISTICS_COUNT_TYPE.COUNT) {
|
|
21
15
|
return rows.length;
|
|
22
16
|
}
|
|
23
|
-
if (summaryType !==
|
|
17
|
+
if (summaryType !== STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
24
18
|
return 0;
|
|
25
19
|
}
|
|
26
20
|
switch (summaryMethod) {
|
|
27
|
-
case
|
|
21
|
+
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
28
22
|
{
|
|
29
23
|
let count = 0;
|
|
30
24
|
let existMap = {};
|
|
@@ -45,28 +39,28 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
|
|
|
45
39
|
});
|
|
46
40
|
return count;
|
|
47
41
|
}
|
|
48
|
-
case
|
|
49
|
-
case
|
|
42
|
+
case SUMMARY_METHOD_MAP.Sum:
|
|
43
|
+
case SUMMARY_METHOD_MAP.Mean:
|
|
50
44
|
{
|
|
51
45
|
let sum = 0;
|
|
52
46
|
let validNumbersCount = 0;
|
|
53
47
|
rows.forEach(row => {
|
|
54
48
|
const formulaRow = formulaRows && formulaRows[row._id];
|
|
55
49
|
let cellValue = getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
|
|
56
|
-
if (
|
|
50
|
+
if (isNumber(cellValue)) {
|
|
57
51
|
validNumbersCount++;
|
|
58
52
|
sum += cellValue;
|
|
59
53
|
}
|
|
60
54
|
});
|
|
61
|
-
if (summaryMethod ===
|
|
55
|
+
if (summaryMethod === SUMMARY_METHOD_MAP.Sum) {
|
|
62
56
|
sum = Number.parseFloat(sum.toFixed(8));
|
|
63
|
-
} else if (summaryMethod ===
|
|
57
|
+
} else if (summaryMethod === SUMMARY_METHOD_MAP.Mean) {
|
|
64
58
|
sum = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
65
59
|
}
|
|
66
60
|
return sum;
|
|
67
61
|
}
|
|
68
|
-
case
|
|
69
|
-
case
|
|
62
|
+
case SUMMARY_METHOD_MAP.Max:
|
|
63
|
+
case SUMMARY_METHOD_MAP.Min:
|
|
70
64
|
{
|
|
71
65
|
if (rows.length === 0) {
|
|
72
66
|
return 0;
|
|
@@ -80,7 +74,7 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
|
|
|
80
74
|
return current;
|
|
81
75
|
}
|
|
82
76
|
let isNextGreater = currentValue < nextValue;
|
|
83
|
-
if (summaryMethod ===
|
|
77
|
+
if (summaryMethod === SUMMARY_METHOD_MAP.Min) {
|
|
84
78
|
return isNextGreater ? current : next;
|
|
85
79
|
} else {
|
|
86
80
|
return isNextGreater ? next : current;
|
|
@@ -94,5 +88,4 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
|
|
|
94
88
|
return 0;
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
|
-
};
|
|
98
|
-
exports.getPivotTableSummaryTotal = getPivotTableSummaryTotal;
|
|
91
|
+
};
|
package/es/utils/row-utils.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCellValue = getCellValue;
|
|
7
|
-
exports.isValidRow = exports.isEmptyGeolocationCell = exports.getFormattedLabel = void 0;
|
|
8
|
-
var _dtableStore = require("dtable-store");
|
|
9
|
-
var _utils = require("../utils");
|
|
10
|
-
const isEmptyGeolocationCell = (cellValue, format) => {
|
|
1
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, isNumber, getNumberDisplayString } from 'dtable-store';
|
|
2
|
+
import { getClientFormulaDisplayString } from '../utils';
|
|
3
|
+
export const isEmptyGeolocationCell = (cellValue, format) => {
|
|
11
4
|
if (!cellValue) return null;
|
|
12
5
|
if (format === 'lng_lat') {
|
|
13
6
|
return (cellValue.lng || cellValue.lng === 0) && (cellValue.lat || cellValue.lat === 0);
|
|
@@ -17,32 +10,30 @@ const isEmptyGeolocationCell = (cellValue, format) => {
|
|
|
17
10
|
}
|
|
18
11
|
return cellValue.province;
|
|
19
12
|
};
|
|
20
|
-
|
|
21
|
-
const isValidRow = (row, formulaRow, column, includeEmpty) => {
|
|
13
|
+
export const isValidRow = (row, formulaRow, column, includeEmpty) => {
|
|
22
14
|
const {
|
|
23
15
|
type: columnType,
|
|
24
16
|
key: columnKey
|
|
25
17
|
} = column;
|
|
26
|
-
if (includeEmpty || columnType ===
|
|
27
|
-
if (columnType ===
|
|
18
|
+
if (includeEmpty || columnType === CellType.CHECKBOX) return true;
|
|
19
|
+
if (columnType === CellType.GEOLOCATION) {
|
|
28
20
|
const {
|
|
29
21
|
geo_format
|
|
30
22
|
} = column.data;
|
|
31
23
|
return isEmptyGeolocationCell(row[columnKey], geo_format);
|
|
32
24
|
}
|
|
33
25
|
let cellValue = row[columnKey];
|
|
34
|
-
if (
|
|
26
|
+
if (FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === CellType.LINK) {
|
|
35
27
|
cellValue = formulaRow ? formulaRow[columnKey] : null;
|
|
36
28
|
}
|
|
37
29
|
return cellValue || cellValue === 0;
|
|
38
30
|
};
|
|
39
|
-
|
|
40
|
-
const getFormattedLabel = (column, name, collaborators) => {
|
|
31
|
+
export const getFormattedLabel = (column, name, collaborators) => {
|
|
41
32
|
let {
|
|
42
33
|
type: columnType,
|
|
43
34
|
data: columnData
|
|
44
35
|
} = column;
|
|
45
|
-
if (columnType ===
|
|
36
|
+
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
46
37
|
let options = columnData ? columnData.options : [];
|
|
47
38
|
let selectedOption = options.find(o => {
|
|
48
39
|
let id = name;
|
|
@@ -57,7 +48,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
57
48
|
if (selectedOption) {
|
|
58
49
|
return optionName;
|
|
59
50
|
}
|
|
60
|
-
} else if (columnType ===
|
|
51
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
61
52
|
let collaborator = collaborators.find(item => {
|
|
62
53
|
let email = name;
|
|
63
54
|
if (Array.isArray(name)) {
|
|
@@ -68,7 +59,7 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
68
59
|
if (collaborator) {
|
|
69
60
|
return collaborator.name;
|
|
70
61
|
}
|
|
71
|
-
} else if (columnType ===
|
|
62
|
+
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
72
63
|
if (name === 'anonymous') {
|
|
73
64
|
return name;
|
|
74
65
|
} else {
|
|
@@ -77,25 +68,25 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
77
68
|
return collaborator.name;
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
|
-
} else if (columnType ===
|
|
81
|
-
return
|
|
71
|
+
} else if (columnType === CellType.LINK) {
|
|
72
|
+
return getClientFormulaDisplayString(Array.isArray(name) ? name : [name], columnData, {
|
|
82
73
|
collaborators
|
|
83
74
|
});
|
|
84
|
-
} else if (columnType ===
|
|
75
|
+
} else if (columnType === CellType.CHECKBOX) {
|
|
85
76
|
return name === 'true' ? 'Checked' : 'Unchecked';
|
|
86
|
-
} else if (
|
|
77
|
+
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
87
78
|
const {
|
|
88
79
|
result_type,
|
|
89
80
|
array_type
|
|
90
81
|
} = columnData || {};
|
|
91
|
-
if (!name && !
|
|
92
|
-
if (result_type ===
|
|
82
|
+
if (!name && !isNumber(name)) return '';
|
|
83
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
93
84
|
const valueNumber = parseFloat(name);
|
|
94
|
-
return
|
|
85
|
+
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : name;
|
|
95
86
|
}
|
|
96
|
-
if (result_type ===
|
|
97
|
-
if (
|
|
98
|
-
if ([
|
|
87
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
88
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
89
|
+
if ([CellType.CREATOR, CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
|
|
99
90
|
return name;
|
|
100
91
|
}
|
|
101
92
|
const collaborator = collaborators.find(item => {
|
|
@@ -116,14 +107,13 @@ const getFormattedLabel = (column, name, collaborators) => {
|
|
|
116
107
|
}
|
|
117
108
|
return name;
|
|
118
109
|
};
|
|
119
|
-
|
|
120
|
-
function getCellValue(row, formulaRow, column) {
|
|
110
|
+
export function getCellValue(row, formulaRow, column) {
|
|
121
111
|
if (!column) return null;
|
|
122
112
|
const {
|
|
123
113
|
type,
|
|
124
114
|
key
|
|
125
115
|
} = column;
|
|
126
|
-
if (
|
|
116
|
+
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
127
117
|
const cellValue = formulaRow && formulaRow[key];
|
|
128
118
|
if (Array.isArray(cellValue)) {
|
|
129
119
|
return cellValue[0];
|
package/es/utils/search.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.searchRows = void 0;
|
|
8
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
var _dtableStore = require("dtable-store");
|
|
10
|
-
var _column = require("./column");
|
|
11
|
-
const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableStore.CellType.DATE, _dtableStore.CellType.TEXT, _dtableStore.CellType.LONG_TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.URL, _dtableStore.CellType.EMAIL, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.MULTIPLE_SELECT, _dtableStore.CellType.LAST_MODIFIER, _dtableStore.CellType.CREATOR, _dtableStore.CellType.COLLABORATOR, _dtableStore.CellType.LINK, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.AUTO_NUMBER, _dtableStore.CellType.GEOLOCATION, _dtableStore.CellType.DURATION];
|
|
12
|
-
const searchRows = (rows, columns, val, processRow) => {
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { CellType, getNumberDisplayString, getMultipleOptionName, getCollaboratorsName, getGeolocationDisplayString } from 'dtable-store';
|
|
3
|
+
import { getSelectColumnOptions } from './column';
|
|
4
|
+
const SUPPORT_SEARCH_COLUMN_TYPES = [CellType.DATE, CellType.TEXT, CellType.LONG_TEXT, CellType.NUMBER, CellType.URL, CellType.EMAIL, CellType.SINGLE_SELECT, CellType.CTIME, CellType.MTIME, CellType.MULTIPLE_SELECT, CellType.LAST_MODIFIER, CellType.CREATOR, CellType.COLLABORATOR, CellType.LINK, CellType.FORMULA, CellType.LINK_FORMULA, CellType.AUTO_NUMBER, CellType.GEOLOCATION, CellType.DURATION];
|
|
5
|
+
export const searchRows = (rows, columns, val, processRow) => {
|
|
13
6
|
let dtableCollaborators = window.app.collaboratorsCache || [];
|
|
14
7
|
let collaborators = window.app.state.collaborators;
|
|
15
8
|
let searchResult = [];
|
|
@@ -25,20 +18,20 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
25
18
|
const cellValue = row[columnKey];
|
|
26
19
|
if (cellValue) {
|
|
27
20
|
let text;
|
|
28
|
-
if (columnType ===
|
|
21
|
+
if (columnType === CellType.LONG_TEXT) {
|
|
29
22
|
text = cellValue.text;
|
|
30
|
-
} else if (columnType ===
|
|
31
|
-
text =
|
|
32
|
-
} else if (columnType ===
|
|
33
|
-
const options =
|
|
23
|
+
} else if (columnType === CellType.NUMBER || columnType === CellType.DURATION) {
|
|
24
|
+
text = getNumberDisplayString(cellValue, column.data);
|
|
25
|
+
} else if (columnType === CellType.SINGLE_SELECT) {
|
|
26
|
+
const options = getSelectColumnOptions(column);
|
|
34
27
|
const option = options.find(option => option.id === cellValue);
|
|
35
28
|
text = option ? option.name : '';
|
|
36
|
-
} else if (columnType ===
|
|
37
|
-
const options =
|
|
38
|
-
text =
|
|
39
|
-
} else if (columnType ===
|
|
40
|
-
text =
|
|
41
|
-
} else if (columnType ===
|
|
29
|
+
} else if (columnType === CellType.MULTIPLE_SELECT) {
|
|
30
|
+
const options = getSelectColumnOptions(column);
|
|
31
|
+
text = getMultipleOptionName(options, cellValue);
|
|
32
|
+
} else if (columnType === CellType.COLLABORATOR) {
|
|
33
|
+
text = getCollaboratorsName(collaborators, cellValue);
|
|
34
|
+
} else if (columnType === CellType.LAST_MODIFIER || columnType === CellType.CREATOR) {
|
|
42
35
|
if (cellValue === 'anonymous') {
|
|
43
36
|
text = cellValue;
|
|
44
37
|
} else {
|
|
@@ -50,10 +43,10 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
50
43
|
text = collaborator.name;
|
|
51
44
|
}
|
|
52
45
|
}
|
|
53
|
-
} else if (columnType ===
|
|
54
|
-
text =
|
|
55
|
-
} else if (columnType ===
|
|
56
|
-
text = (
|
|
46
|
+
} else if (columnType === CellType.GEOLOCATION) {
|
|
47
|
+
text = getGeolocationDisplayString(cellValue, column.data);
|
|
48
|
+
} else if (columnType === CellType.CTIME || columnType === CellType.MTIME) {
|
|
49
|
+
text = dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss');
|
|
57
50
|
} else {
|
|
58
51
|
text = cellValue;
|
|
59
52
|
}
|
|
@@ -69,5 +62,4 @@ const searchRows = (rows, columns, val, processRow) => {
|
|
|
69
62
|
}
|
|
70
63
|
});
|
|
71
64
|
return searchResult;
|
|
72
|
-
};
|
|
73
|
-
exports.searchRows = searchRows;
|
|
65
|
+
};
|