@seafile/sdoc-editor 0.3.24 → 0.3.26-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/seafile-api.js +20 -0
- package/dist/basic-sdk/editor/sdoc-editor.js +20 -2
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/constants/menus-config.js +6 -1
- package/dist/basic-sdk/extension/core/utils/index.js +1 -1
- package/dist/basic-sdk/extension/plugins/chart/chart-components/base-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/column-setting.js +119 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/data-sort-setting.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/date-granularities.js +55 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/dtable-select-setting.js +86 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/geolocation-granularities.js +97 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-item.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-items.js +87 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/include-empty-setting.js +35 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-field-setting.js +64 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-method-setting.js +61 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-type-setting.js +74 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/x-axis-group-setting.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/y-axis-group-settings.js +182 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/index.js +28 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/style.css +52 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/table-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/index.js +27 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/style.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.css +22 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.js +50 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.css +24 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.js +115 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/base-utils.js +349 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/dtable-utils.js +147 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/histogram-bar-utils.js +84 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/date-constants.js +9 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/geolocation-constants.js +11 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/index.js +109 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/special-column-types.js +7 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/summary-constants.js +18 -0
- package/dist/basic-sdk/extension/plugins/chart/helpers.js +82 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.css +55 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.js +55 -0
- package/dist/basic-sdk/extension/plugins/chart/index.js +12 -0
- package/dist/basic-sdk/extension/plugins/chart/menu/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/model.js +33 -0
- package/dist/basic-sdk/extension/plugins/chart/plugin.js +20 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.css +26 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.js +284 -0
- package/dist/basic-sdk/extension/plugins/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/link/hover/index.js +3 -1
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +4 -3
- package/dist/basic-sdk/extension/render/custom-element.js +10 -4
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +2 -1
- package/dist/basic-sdk/socket/socket-client.js +3 -0
- package/dist/components/doc-operations/more-operations.js +21 -12
- package/dist/constants/index.js +3 -0
- package/dist/context.js +40 -0
- package/package.json +7 -1
- package/public/locales/en/sdoc-editor.json +34 -1
- package/public/locales/zh_CN/sdoc-editor.json +35 -1
- package/public/media/{sdoc-editor-font.css → iconfont.css} +10 -10
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -2
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import ColumnSetting from './column-setting';
|
|
4
|
+
import SummaryMethodSetting from './summary-method-setting';
|
|
5
|
+
class GroupbyNumericItem extends Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.getSummaryColumn = columnKey => {
|
|
9
|
+
const {
|
|
10
|
+
columns
|
|
11
|
+
} = this.props;
|
|
12
|
+
return columns.find(item => item.key === columnKey);
|
|
13
|
+
};
|
|
14
|
+
this.onToggleExpand = () => {
|
|
15
|
+
this.setState({
|
|
16
|
+
isExpand: !this.state.isExpand
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.onSelectedColumnChanged = option => {
|
|
20
|
+
const column = option.value;
|
|
21
|
+
const {
|
|
22
|
+
groupbyNumericItem,
|
|
23
|
+
index
|
|
24
|
+
} = this.props;
|
|
25
|
+
const {
|
|
26
|
+
column_key
|
|
27
|
+
} = groupbyNumericItem;
|
|
28
|
+
if (column.key === column_key) return;
|
|
29
|
+
const setting = {
|
|
30
|
+
column_key: column.key
|
|
31
|
+
};
|
|
32
|
+
this.props.updateGroupBySetting(setting, index);
|
|
33
|
+
};
|
|
34
|
+
this.onDeleteNumericColumnItem = () => {
|
|
35
|
+
const {
|
|
36
|
+
index
|
|
37
|
+
} = this.props;
|
|
38
|
+
this.props.onDeleteNumericItem(index);
|
|
39
|
+
};
|
|
40
|
+
this.updateSetting = setting => {
|
|
41
|
+
const {
|
|
42
|
+
index
|
|
43
|
+
} = this.props;
|
|
44
|
+
this.props.updateGroupBySetting(setting, index);
|
|
45
|
+
};
|
|
46
|
+
this.state = {
|
|
47
|
+
isExpand: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const {
|
|
52
|
+
index,
|
|
53
|
+
groupbyNumericItem
|
|
54
|
+
} = this.props;
|
|
55
|
+
const {
|
|
56
|
+
isExpand
|
|
57
|
+
} = this.state;
|
|
58
|
+
const itemIcon = "dtable-font dtable-icon-".concat(isExpand ? 'drop-down' : 'right-slide', " expand-icon");
|
|
59
|
+
const itemLabel = this.props.t('Numeric_column') + (index + 1);
|
|
60
|
+
const deleteIcon = 'dtable-font dtable-icon-fork-number delete-icon';
|
|
61
|
+
const summaryContentClass = "".concat(isExpand ? 'expanded' : 'collapsed', "-numeric-summary-content");
|
|
62
|
+
const {
|
|
63
|
+
column_key: summaryColumnKey,
|
|
64
|
+
summary_method: summaryMethod
|
|
65
|
+
} = groupbyNumericItem;
|
|
66
|
+
const summaryColumn = this.getSummaryColumn(summaryColumnKey);
|
|
67
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
style: {
|
|
69
|
+
paddingBottom: isExpand ? '14px' : '7px'
|
|
70
|
+
},
|
|
71
|
+
className: "numeric-summary-item"
|
|
72
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "summary-item-info"
|
|
74
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "item-title"
|
|
76
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
77
|
+
className: itemIcon,
|
|
78
|
+
onClick: this.onToggleExpand
|
|
79
|
+
}), /*#__PURE__*/React.createElement("label", {
|
|
80
|
+
className: "title"
|
|
81
|
+
}, itemLabel)), /*#__PURE__*/React.createElement("span", {
|
|
82
|
+
className: "item-control"
|
|
83
|
+
}, index !== 0 && /*#__PURE__*/React.createElement("i", {
|
|
84
|
+
className: deleteIcon,
|
|
85
|
+
onClick: this.onDeleteNumericColumnItem
|
|
86
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: summaryContentClass
|
|
88
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: "summary-filed-setting__column mt-1"
|
|
90
|
+
}, /*#__PURE__*/React.createElement(ColumnSetting, {
|
|
91
|
+
columns: this.props.columns,
|
|
92
|
+
activeColumnKey: summaryColumnKey,
|
|
93
|
+
specifiedColumnType: 'number',
|
|
94
|
+
onSelectedColumnChanged: this.onSelectedColumnChanged,
|
|
95
|
+
noOptionsMessage: () => {
|
|
96
|
+
return /*#__PURE__*/React.createElement("span", null, this.props.t('No_options'));
|
|
97
|
+
}
|
|
98
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
className: "summary-filed-setting__summary_method mt-1"
|
|
100
|
+
}, /*#__PURE__*/React.createElement(SummaryMethodSetting, {
|
|
101
|
+
summaryColumn: summaryColumn,
|
|
102
|
+
settingKey: 'summary_method',
|
|
103
|
+
settingValue: summaryMethod,
|
|
104
|
+
updateSetting: this.updateSetting
|
|
105
|
+
}))));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export default withTranslation('sdoc-editor')(GroupbyNumericItem);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import GroupbyNumericItem from './groupby-numeric-item';
|
|
5
|
+
import DtableUtils from '../../chart-utils/common-utils/dtable-utils';
|
|
6
|
+
const SETTING_KEY = 'column_groupby_numeric_columns';
|
|
7
|
+
class GroupbyNumericItems extends Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.getNumericColumns = () => {
|
|
11
|
+
const {
|
|
12
|
+
columns
|
|
13
|
+
} = this.props;
|
|
14
|
+
if (!columns || columns.length === 0) return [];
|
|
15
|
+
return columns.filter(column => {
|
|
16
|
+
return DtableUtils.isNumericColumn(column);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.onAddNumericColumn = () => {
|
|
20
|
+
const item = {
|
|
21
|
+
column_key: '',
|
|
22
|
+
summary_method: ''
|
|
23
|
+
};
|
|
24
|
+
const {
|
|
25
|
+
groupbyNumericItems
|
|
26
|
+
} = this.props;
|
|
27
|
+
let newItems = [];
|
|
28
|
+
if (groupbyNumericItems && Array.isArray(groupbyNumericItems)) {
|
|
29
|
+
newItems = groupbyNumericItems.concat(item);
|
|
30
|
+
} else {
|
|
31
|
+
newItems = [item];
|
|
32
|
+
}
|
|
33
|
+
this.props.updateSetting({
|
|
34
|
+
[SETTING_KEY]: newItems
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
this.onDeleteNumericItem = index => {
|
|
38
|
+
const {
|
|
39
|
+
groupbyNumericItems
|
|
40
|
+
} = this.props;
|
|
41
|
+
const newItems = groupbyNumericItems.filter((item, idx) => idx !== index - 1);
|
|
42
|
+
this.props.updateSetting({
|
|
43
|
+
[SETTING_KEY]: newItems
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
this.updateGroupBySetting = (setting, index) => {
|
|
47
|
+
const {
|
|
48
|
+
groupbyNumericItems
|
|
49
|
+
} = this.props;
|
|
50
|
+
const newItems = groupbyNumericItems.map((item, idx) => {
|
|
51
|
+
if (idx === index - 1) {
|
|
52
|
+
item = _objectSpread(_objectSpread({}, item), setting);
|
|
53
|
+
}
|
|
54
|
+
return item;
|
|
55
|
+
});
|
|
56
|
+
this.props.updateSetting({
|
|
57
|
+
[SETTING_KEY]: newItems
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const {
|
|
63
|
+
groupbyNumericItems = []
|
|
64
|
+
} = this.props;
|
|
65
|
+
const numericColumns = this.getNumericColumns();
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
className: "numeric-summary-item-wrapper"
|
|
68
|
+
}, groupbyNumericItems && Array.isArray(groupbyNumericItems) && groupbyNumericItems.length > 0 && groupbyNumericItems.map((item, index) => {
|
|
69
|
+
return /*#__PURE__*/React.createElement(GroupbyNumericItem, {
|
|
70
|
+
key: index,
|
|
71
|
+
index: index + 1,
|
|
72
|
+
columns: this.props.columns,
|
|
73
|
+
groupbyNumericItem: item,
|
|
74
|
+
onDeleteNumericItem: this.onDeleteNumericItem,
|
|
75
|
+
updateGroupBySetting: this.updateGroupBySetting
|
|
76
|
+
});
|
|
77
|
+
}), numericColumns.length > 0 && /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "operation-control",
|
|
79
|
+
onClick: this.onAddNumericColumn
|
|
80
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "dtable-font dtable-icon-add-table add-icon"
|
|
82
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
83
|
+
className: "add-description"
|
|
84
|
+
}, this.props.t('Add_new_numeric_column'))));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export default withTranslation('sdoc-editor')(GroupbyNumericItems);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import ToggleSetting from '../toggle-setting';
|
|
4
|
+
class IncludeEmptySetting extends React.Component {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.onToggleIncludeEmpty = () => {
|
|
8
|
+
const {
|
|
9
|
+
settingValue,
|
|
10
|
+
settingKey
|
|
11
|
+
} = this.props;
|
|
12
|
+
const setting = {
|
|
13
|
+
[settingKey]: !settingValue
|
|
14
|
+
};
|
|
15
|
+
this.props.updateSetting(setting);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const {
|
|
20
|
+
settingValue
|
|
21
|
+
} = this.props;
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
className: "mt-1"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(ToggleSetting, {
|
|
25
|
+
label: this.props.t('Including_empty_cell'),
|
|
26
|
+
isChecked: settingValue,
|
|
27
|
+
handleToggleChange: this.onToggleIncludeEmpty
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
IncludeEmptySetting.defaultProps = {
|
|
32
|
+
settingKey: 'x_axis_include_empty',
|
|
33
|
+
settingValue: false
|
|
34
|
+
};
|
|
35
|
+
export default withTranslation('sdoc-editor')(IncludeEmptySetting);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import ColumnSetting from './column-setting';
|
|
4
|
+
import SummaryMethodSetting from './summary-method-setting';
|
|
5
|
+
class SummaryFieldSetting extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.getSummaryColumn = () => {
|
|
9
|
+
const {
|
|
10
|
+
summaryColumnKey,
|
|
11
|
+
columns
|
|
12
|
+
} = this.props;
|
|
13
|
+
return columns.find(column => column.key === summaryColumnKey);
|
|
14
|
+
};
|
|
15
|
+
this.onSelectedColumnChanged = option => {
|
|
16
|
+
const {
|
|
17
|
+
key: columnKey
|
|
18
|
+
} = option.value;
|
|
19
|
+
const {
|
|
20
|
+
summaryColumnSettingKey
|
|
21
|
+
} = this.props;
|
|
22
|
+
const newSetting = {
|
|
23
|
+
[summaryColumnSettingKey]: columnKey
|
|
24
|
+
};
|
|
25
|
+
this.props.updateSetting(newSetting);
|
|
26
|
+
};
|
|
27
|
+
this.updateSetting = setting => {
|
|
28
|
+
this.props.updateSetting(setting);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
const {
|
|
33
|
+
summaryColumnKey,
|
|
34
|
+
summaryMethod,
|
|
35
|
+
summaryMethodSettingKey,
|
|
36
|
+
specifiedColumnType
|
|
37
|
+
} = this.props;
|
|
38
|
+
const summaryColumn = this.getSummaryColumn();
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: "summary-filed-setting"
|
|
41
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: "summary-filed-setting__column mt-14"
|
|
43
|
+
}, /*#__PURE__*/React.createElement("label", null, this.props.t('Numeric_column')), /*#__PURE__*/React.createElement(ColumnSetting, {
|
|
44
|
+
columns: this.props.columns,
|
|
45
|
+
activeColumnKey: summaryColumnKey,
|
|
46
|
+
specifiedColumnType: specifiedColumnType,
|
|
47
|
+
onSelectedColumnChanged: this.onSelectedColumnChanged,
|
|
48
|
+
noOptionsMessage: () => {
|
|
49
|
+
return /*#__PURE__*/React.createElement("span", null, this.props.t('No_options'));
|
|
50
|
+
}
|
|
51
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "summary-filed-setting__summary_method mt-14"
|
|
53
|
+
}, /*#__PURE__*/React.createElement(SummaryMethodSetting, {
|
|
54
|
+
summaryColumn: summaryColumn,
|
|
55
|
+
settingKey: summaryMethodSettingKey,
|
|
56
|
+
settingValue: summaryMethod,
|
|
57
|
+
updateSetting: this.updateSetting
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
SummaryFieldSetting.defaultProps = {
|
|
62
|
+
specifiedColumnType: 'number'
|
|
63
|
+
};
|
|
64
|
+
export default withTranslation('sdoc-editor')(SummaryFieldSetting);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import DTableSelect from './dtable-select-setting';
|
|
4
|
+
import { STATISTICS_COUNT_SHOW } from '../../constants';
|
|
5
|
+
import { DATE_COLUMN_TYPES } from '../../constants/special-column-types';
|
|
6
|
+
import { SUMMARY_METHOD, DATE_COLUMN_SUMMARY_METHOD } from '../../constants/summary-constants';
|
|
7
|
+
class SummaryMethodSetting extends Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.getSummaryMethodsOptions = () => {
|
|
11
|
+
return SUMMARY_METHOD.map(method => {
|
|
12
|
+
return {
|
|
13
|
+
value: method,
|
|
14
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
15
|
+
className: 'select-module select-module-name'
|
|
16
|
+
}, this.props.t(STATISTICS_COUNT_SHOW[method]))
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
this.getActiveMethodOption = (method, summaryMethodsOptions) => {
|
|
21
|
+
return summaryMethodsOptions.find(m => m.value === method) || summaryMethodsOptions[0];
|
|
22
|
+
};
|
|
23
|
+
this.onSelectSummaryMethod = summaryMethodOption => {
|
|
24
|
+
const {
|
|
25
|
+
settingKey,
|
|
26
|
+
settingValue: summaryMethod
|
|
27
|
+
} = this.props;
|
|
28
|
+
const newSummaryMethod = summaryMethodOption.value;
|
|
29
|
+
if (newSummaryMethod === summaryMethod) return;
|
|
30
|
+
const newSetting = {
|
|
31
|
+
[settingKey]: newSummaryMethod
|
|
32
|
+
};
|
|
33
|
+
this.props.updateSetting(newSetting);
|
|
34
|
+
};
|
|
35
|
+
this.summaryMethodsOptions = this.getSummaryMethodsOptions();
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const {
|
|
39
|
+
summaryColumn,
|
|
40
|
+
settingValue: summaryMethod
|
|
41
|
+
} = this.props;
|
|
42
|
+
const activeMethodOption = this.getActiveMethodOption(summaryMethod, this.summaryMethodsOptions);
|
|
43
|
+
let summaryMethodOptions = this.summaryMethodsOptions;
|
|
44
|
+
if (activeMethodOption && summaryColumn && DATE_COLUMN_TYPES.includes(summaryColumn.type)) {
|
|
45
|
+
summaryMethodOptions = summaryMethodOptions.filter(option => {
|
|
46
|
+
return DATE_COLUMN_SUMMARY_METHOD.includes(option.value);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: "filed-summary_method"
|
|
51
|
+
}, /*#__PURE__*/React.createElement("label", null, this.props.t('Summary_method')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
52
|
+
value: activeMethodOption,
|
|
53
|
+
onChange: this.onSelectSummaryMethod,
|
|
54
|
+
options: summaryMethodOptions
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
SummaryMethodSetting.defaultProps = {
|
|
59
|
+
settingKey: 'y_axis_summary_method'
|
|
60
|
+
};
|
|
61
|
+
export default withTranslation('sdoc-editor')(SummaryMethodSetting);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import DTableSelect from './dtable-select-setting';
|
|
4
|
+
import { STATISTICS_COUNT_SHOW } from '../../constants';
|
|
5
|
+
import { GROUP_TYPES } from '../../constants/summary-constants';
|
|
6
|
+
const GROUP_TYPES_CONFIG = [{
|
|
7
|
+
type: GROUP_TYPES.COUNT,
|
|
8
|
+
name: 'count',
|
|
9
|
+
explanation: 'Count_the_number_of_records_in_each_group'
|
|
10
|
+
}, {
|
|
11
|
+
type: GROUP_TYPES.SINGLE_NUMERIC_COLUMN,
|
|
12
|
+
name: 'advanced',
|
|
13
|
+
explanation: 'Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_a_field'
|
|
14
|
+
}, {
|
|
15
|
+
type: GROUP_TYPES.MULTIPLE_NUMERIC_COLUMN,
|
|
16
|
+
name: 'Summarize_multiple_fields',
|
|
17
|
+
explanation: 'Compute_the_sum_maximum_or_minimum_value_of_records_in_each_group_by_multiple_fields'
|
|
18
|
+
}];
|
|
19
|
+
class SummaryTypeSettings extends React.Component {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
22
|
+
this.getGroupTypeOptions = () => {
|
|
23
|
+
let groupTypes = GROUP_TYPES_CONFIG;
|
|
24
|
+
const {
|
|
25
|
+
supportSummaryTypes
|
|
26
|
+
} = this.props;
|
|
27
|
+
if (supportSummaryTypes && supportSummaryTypes.length > 0) {
|
|
28
|
+
groupTypes = GROUP_TYPES_CONFIG.filter(item => supportSummaryTypes.includes(item.type));
|
|
29
|
+
}
|
|
30
|
+
return groupTypes.map(item => {
|
|
31
|
+
return {
|
|
32
|
+
value: item.type,
|
|
33
|
+
label: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: 'select-module select-module-name'
|
|
35
|
+
}, this.props.t(STATISTICS_COUNT_SHOW[item.name] || item.name)), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "summary-type-explanation"
|
|
37
|
+
}, this.props.t(item.explanation)))
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
this.getActiveGroupTypeOption = () => {
|
|
42
|
+
const {
|
|
43
|
+
settingValue
|
|
44
|
+
} = this.props;
|
|
45
|
+
if (!settingValue) return null;
|
|
46
|
+
return this.groupTypeOptions.find(item => item.value === settingValue);
|
|
47
|
+
};
|
|
48
|
+
this.onChangeGroupType = option => {
|
|
49
|
+
const {
|
|
50
|
+
settingKey,
|
|
51
|
+
settingValue
|
|
52
|
+
} = this.props;
|
|
53
|
+
if (settingValue === option.value) return;
|
|
54
|
+
const newSetting = {
|
|
55
|
+
[settingKey]: option.value
|
|
56
|
+
};
|
|
57
|
+
this.props.updateSetting(newSetting);
|
|
58
|
+
};
|
|
59
|
+
this.groupTypeOptions = this.getGroupTypeOptions();
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
const activeValue = this.getActiveGroupTypeOption();
|
|
63
|
+
return /*#__PURE__*/React.createElement(DTableSelect, {
|
|
64
|
+
classNamePrefix: "chart-summary-types",
|
|
65
|
+
value: activeValue,
|
|
66
|
+
options: this.groupTypeOptions,
|
|
67
|
+
onChange: this.onChangeGroupType
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
SummaryTypeSettings.defaultProps = {
|
|
72
|
+
settingKey: 'y_axis_summary_type'
|
|
73
|
+
};
|
|
74
|
+
export default withTranslation('sdoc-editor')(SummaryTypeSettings);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import IncludeEmptySetting from './include-empty-setting';
|
|
3
|
+
import ColumnSetting from './column-setting';
|
|
4
|
+
import DateGranularities from './date-granularities';
|
|
5
|
+
import GeolocationGranlarities from './geolocation-granularities';
|
|
6
|
+
import { DATE_COLUMN_TYPES, GEOLOCATION_COLUMN_OPTIONS } from '../../constants/special-column-types';
|
|
7
|
+
import { DEFAULT_DATE_GRANULARITY } from '../../constants/date-constants';
|
|
8
|
+
import { DEFAULT_GEOLOCATION_GRANULARITY_MAP } from '../../constants/geolocation-constants';
|
|
9
|
+
import { GROUP_TYPES } from '../../constants/summary-constants';
|
|
10
|
+
import { STAT_TYPE } from '../../constants';
|
|
11
|
+
class XAxisGroupSettings extends Component {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.getDefaultGeolocationGranularity = groupbyColumnKey => {
|
|
15
|
+
const groupbyColumn = this.getGroupbyColumn(groupbyColumnKey);
|
|
16
|
+
const {
|
|
17
|
+
geo_format
|
|
18
|
+
} = groupbyColumn.data || {};
|
|
19
|
+
return DEFAULT_GEOLOCATION_GRANULARITY_MAP[geo_format];
|
|
20
|
+
};
|
|
21
|
+
this.onSelectedColumnChanged = columnOption => {
|
|
22
|
+
const {
|
|
23
|
+
key,
|
|
24
|
+
type
|
|
25
|
+
} = columnOption.value;
|
|
26
|
+
const {
|
|
27
|
+
statItem
|
|
28
|
+
} = this.props;
|
|
29
|
+
let {
|
|
30
|
+
x_axis_column_key: groupbyColumnKey,
|
|
31
|
+
x_axis_date_granularity: groupbyDateGranularity,
|
|
32
|
+
x_axis_geolocation_granularity: groupbyGeolocationGranularity,
|
|
33
|
+
y_axis_summary_type: summaryType
|
|
34
|
+
} = statItem;
|
|
35
|
+
if (key !== 'Groupby_null') {
|
|
36
|
+
groupbyColumnKey = key;
|
|
37
|
+
if (type === 'date') {
|
|
38
|
+
groupbyDateGranularity = DEFAULT_DATE_GRANULARITY;
|
|
39
|
+
} else if (type === 'geolocation') {
|
|
40
|
+
groupbyGeolocationGranularity = this.getDefaultGeolocationGranularity(groupbyColumnKey);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
groupbyColumnKey = null;
|
|
44
|
+
groupbyDateGranularity = null;
|
|
45
|
+
groupbyGeolocationGranularity = null;
|
|
46
|
+
}
|
|
47
|
+
summaryType = summaryType ? summaryType : GROUP_TYPES.COUNT;
|
|
48
|
+
const setting = {
|
|
49
|
+
x_axis_column_key: groupbyColumnKey,
|
|
50
|
+
x_axis_date_granularity: groupbyDateGranularity,
|
|
51
|
+
x_axis_geolocation_granularity: groupbyGeolocationGranularity,
|
|
52
|
+
y_axis_summary_type: summaryType
|
|
53
|
+
};
|
|
54
|
+
this.props.updateSetting(setting);
|
|
55
|
+
};
|
|
56
|
+
this.getGroupbyColumn = groupbyColumnKey => {
|
|
57
|
+
const {
|
|
58
|
+
columns
|
|
59
|
+
} = this.props;
|
|
60
|
+
if (!columns || columns.length === 0) return null;
|
|
61
|
+
const groupbyColumn = columns.find(column => column.key === groupbyColumnKey);
|
|
62
|
+
return groupbyColumn;
|
|
63
|
+
};
|
|
64
|
+
this.updateSetting = settingItem => {
|
|
65
|
+
this.props.updateSetting(settingItem);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
const {
|
|
70
|
+
statItem,
|
|
71
|
+
columns,
|
|
72
|
+
renderIncludeEmpty
|
|
73
|
+
} = this.props;
|
|
74
|
+
const {
|
|
75
|
+
x_axis_column_key: groupbyColumnKey,
|
|
76
|
+
x_axis_date_granularity,
|
|
77
|
+
x_axis_geolocation_granularity,
|
|
78
|
+
x_axis_include_empty,
|
|
79
|
+
type
|
|
80
|
+
} = statItem;
|
|
81
|
+
const groupbyColumn = this.getGroupbyColumn(groupbyColumnKey);
|
|
82
|
+
const {
|
|
83
|
+
type: groupbyColumnType
|
|
84
|
+
} = groupbyColumn || {};
|
|
85
|
+
const isDateType = [STAT_TYPE.COMPARE_BAR].includes(type) ? 'date' : false;
|
|
86
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: "sdoc-chart-setting-item"
|
|
88
|
+
}, /*#__PURE__*/React.createElement("label", null, this.props.label), /*#__PURE__*/React.createElement(ColumnSetting, {
|
|
89
|
+
columns: columns,
|
|
90
|
+
activeColumnKey: groupbyColumnKey,
|
|
91
|
+
onSelectedColumnChanged: this.onSelectedColumnChanged,
|
|
92
|
+
specifiedColumnType: isDateType || ''
|
|
93
|
+
}), DATE_COLUMN_TYPES.includes(groupbyColumnType) && /*#__PURE__*/React.createElement(DateGranularities, {
|
|
94
|
+
settingKey: 'x_axis_date_granularity',
|
|
95
|
+
settingValue: x_axis_date_granularity,
|
|
96
|
+
updateSetting: this.updateSetting
|
|
97
|
+
}), GEOLOCATION_COLUMN_OPTIONS.includes(groupbyColumnType) && /*#__PURE__*/React.createElement(GeolocationGranlarities, {
|
|
98
|
+
settingKey: 'x_axis_geolocation_granularity',
|
|
99
|
+
settingValue: x_axis_geolocation_granularity,
|
|
100
|
+
updateSetting: this.updateSetting
|
|
101
|
+
}), renderIncludeEmpty && /*#__PURE__*/React.createElement(IncludeEmptySetting, {
|
|
102
|
+
settingKey: 'x_axis_include_empty',
|
|
103
|
+
settingValue: x_axis_include_empty,
|
|
104
|
+
updateSetting: this.updateSetting
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export default XAxisGroupSettings;
|