sea-chart 1.1.21 → 1.1.22-alpha.2
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/components/data-process-setter/data-setting-header.js +11 -0
- package/dist/components/data-process-setter/hide-column-setter.js +79 -0
- package/dist/components/data-process-setter/index.js +4 -0
- package/dist/components/data-process-setter/sort-setter.js +75 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +60 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover.css +38 -0
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +208 -0
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +71 -0
- package/dist/components/popover/sort-popover/sort-popover.css +83 -0
- package/dist/components/popover/sort-popover/sort-popover.js +290 -0
- package/dist/components/types-dialog/index.js +5 -2
- package/dist/constants/common-constants.js +3 -1
- package/dist/constants/index.js +1 -1
- package/dist/constants/type-image.js +2 -1
- package/dist/constants/type.js +5 -3
- package/dist/context.js +1 -1
- package/dist/locale/lang/de.js +17 -2
- package/dist/locale/lang/en.js +16 -1
- package/dist/locale/lang/es.js +16 -1
- package/dist/locale/lang/fr.js +17 -2
- package/dist/locale/lang/pt.js +16 -1
- package/dist/locale/lang/ru.js +16 -1
- package/dist/locale/lang/zh_CN.js +16 -1
- package/dist/model/index.js +3 -1
- package/dist/model/table-element.js +22 -0
- package/dist/settings/data-settings.js +5 -0
- package/dist/settings/table-element-settings/components/data-filter.css +17 -0
- package/dist/settings/table-element-settings/components/data-filter.js +89 -0
- package/dist/settings/table-element-settings/data-settings.js +100 -0
- package/dist/settings/table-element-settings/index.css +190 -0
- package/dist/settings/table-element-settings/index.js +2 -0
- package/dist/settings/widgets/chart-type/index.js +3 -1
- package/dist/settings/widgets/common-data-settings.js +1 -0
- package/dist/settings/widgets/data-filter/index.css +1 -1
- package/dist/utils/chart-utils/base-utils.js +7 -1
- package/dist/utils/chart-utils/index.js +5 -5
- package/dist/utils/chart-utils/original-data-utils/index.js +2 -2
- package/dist/utils/chart-utils/sql-statistics-utils.js +10 -4
- package/dist/utils/chart.js +9 -1
- package/dist/utils/hotkey.js +5 -0
- package/dist/utils/row-utils.js +10 -1
- package/dist/utils/sql/chart-data-sql.js +4 -0
- package/dist/utils/sql/column-2-sql-column.js +4 -0
- package/dist/view/index.css +5 -1
- package/dist/view/index.js +56 -14
- package/dist/view/wrapper/bar-group.js +1 -1
- package/dist/view/wrapper/index.js +7 -0
- package/dist/view/wrapper/table-element/components/dataset-utils.js +123 -0
- package/dist/view/wrapper/table-element/components/formatter.js +309 -0
- package/dist/view/wrapper/table-element/components/formula-formatter.js +36 -0
- package/dist/view/wrapper/table-element/components/link-formatter.js +269 -0
- package/dist/view/wrapper/table-element/components/record.js +67 -0
- package/dist/view/wrapper/table-element/components/records-body.js +117 -0
- package/dist/view/wrapper/table-element/components/records-header/index.js +41 -0
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +51 -0
- package/dist/view/wrapper/table-element/components/records.js +117 -0
- package/dist/view/wrapper/table-element/components/resize-column-handle/index.css +11 -0
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +48 -0
- package/dist/view/wrapper/table-element/components/value-display-utils.js +13 -0
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.css +12 -0
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +36 -0
- package/dist/view/wrapper/table-element/css/index.css +239 -0
- package/dist/view/wrapper/table-element/index.js +101 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Label } from 'reactstrap';
|
|
3
|
+
import intl from '../../intl';
|
|
4
|
+
function DataSettingHeader() {
|
|
5
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
6
|
+
className: "setting-item data-setting"
|
|
7
|
+
}, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement("div", {
|
|
8
|
+
className: "d-flex align-items-center"
|
|
9
|
+
}, /*#__PURE__*/React.createElement("span", null, intl.get('Data_settings')))));
|
|
10
|
+
}
|
|
11
|
+
export default DataSettingHeader;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import HideColumnPopover from '../popover/hide-column-popover/hide-column-popover';
|
|
3
|
+
import intl from '../../intl';
|
|
4
|
+
class HideColumnSetter extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.onHideColumnToggle = () => {
|
|
8
|
+
const {
|
|
9
|
+
isShowHideColumnSetter
|
|
10
|
+
} = this.state;
|
|
11
|
+
if (isShowHideColumnSetter) {
|
|
12
|
+
const {
|
|
13
|
+
shownColumnKeys
|
|
14
|
+
} = this.state;
|
|
15
|
+
this.props.onSettingUpdate(shownColumnKeys);
|
|
16
|
+
}
|
|
17
|
+
this.setState({
|
|
18
|
+
isShowHideColumnSetter: !isShowHideColumnSetter
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
this.modifyHiddenColumns = shownColumnKeys => {
|
|
22
|
+
this.setState({
|
|
23
|
+
shownColumnKeys
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.state = {
|
|
27
|
+
isShowHideColumnSetter: false,
|
|
28
|
+
shownColumnKeys: props.shownColumnKeys || []
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
32
|
+
const {
|
|
33
|
+
shownColumnKeys
|
|
34
|
+
} = nextProps;
|
|
35
|
+
if (shownColumnKeys !== this.props.shownColumnKeys) {
|
|
36
|
+
this.setState({
|
|
37
|
+
isShowHideColumnSetter: false,
|
|
38
|
+
shownColumnKeys
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
const {
|
|
44
|
+
columns,
|
|
45
|
+
wrapperClass
|
|
46
|
+
} = this.props;
|
|
47
|
+
if (!columns) return null;
|
|
48
|
+
const {
|
|
49
|
+
shownColumnKeys
|
|
50
|
+
} = this.state;
|
|
51
|
+
const shown_column_keys = shownColumnKeys || [];
|
|
52
|
+
const hiddenColumns = columns.filter(column => !shown_column_keys.includes(column.key));
|
|
53
|
+
const hiddenColumnsLength = hiddenColumns.length;
|
|
54
|
+
let message = intl.get('hide_columns');
|
|
55
|
+
if (hiddenColumnsLength === 1) {
|
|
56
|
+
message = intl.get('1_hidden_column');
|
|
57
|
+
} else if (hiddenColumnsLength > 1) {
|
|
58
|
+
message = hiddenColumnsLength + ' ' + intl.get('Hidden_columns');
|
|
59
|
+
}
|
|
60
|
+
let settingClass = wrapperClass || '';
|
|
61
|
+
settingClass = settingClass && hiddenColumnsLength > 0 ? settingClass + ' active' : settingClass;
|
|
62
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
className: "setting-item ".concat(settingClass ? '' : 'mb-1')
|
|
64
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
className: "mr-2 filters-setting-btn",
|
|
66
|
+
onClick: this.onHideColumnToggle
|
|
67
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
68
|
+
className: "dtable-font dtable-icon-hide mr-2",
|
|
69
|
+
id: "dtable-hidden-column-popover"
|
|
70
|
+
}), /*#__PURE__*/React.createElement("span", null, message)), this.state.isShowHideColumnSetter && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HideColumnPopover, {
|
|
71
|
+
columns: columns,
|
|
72
|
+
target: 'dtable-hidden-column-popover',
|
|
73
|
+
shownColumnKeys: shownColumnKeys,
|
|
74
|
+
modifyHiddenColumns: this.modifyHiddenColumns,
|
|
75
|
+
onPopoverToggle: this.onHideColumnToggle
|
|
76
|
+
})));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default HideColumnSetter;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { getValidSorts } from 'dtable-utils';
|
|
3
|
+
import SortPopover from '../../components/popover/sort-popover/sort-popover';
|
|
4
|
+
import { isEnter, isSpace } from '../../utils/hotkey';
|
|
5
|
+
import intl from '../../intl';
|
|
6
|
+
class SortSetter extends Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.onSortToggle = () => {
|
|
10
|
+
this.setState({
|
|
11
|
+
isSortPopoverShow: !this.state.isSortPopoverShow
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
this.onKeyDown = e => {
|
|
15
|
+
e.stopPropagation();
|
|
16
|
+
if (isEnter(e) || isSpace(e)) this.onSortToggle();
|
|
17
|
+
};
|
|
18
|
+
this.update = update => {
|
|
19
|
+
const {
|
|
20
|
+
sorts
|
|
21
|
+
} = update || {};
|
|
22
|
+
this.props.onSortsChange(sorts);
|
|
23
|
+
};
|
|
24
|
+
this.state = {
|
|
25
|
+
isSortPopoverShow: false
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
const {
|
|
30
|
+
sorts,
|
|
31
|
+
columns,
|
|
32
|
+
isNeedSubmit,
|
|
33
|
+
wrapperClass
|
|
34
|
+
} = this.props;
|
|
35
|
+
if (!columns) return null;
|
|
36
|
+
const validSorts = getValidSorts(sorts || [], columns);
|
|
37
|
+
const sortsLength = validSorts ? validSorts.length : 0;
|
|
38
|
+
let sortMessage = intl.get('Sort');
|
|
39
|
+
if (sortsLength === 1) {
|
|
40
|
+
sortMessage = intl.get('1_Sort');
|
|
41
|
+
} else if (sortsLength > 1) {
|
|
42
|
+
sortMessage = isNeedSubmit ? intl.get('Sorts') : intl.get('Sorts');
|
|
43
|
+
sortMessage = sortsLength + ' ' + sortMessage;
|
|
44
|
+
}
|
|
45
|
+
let labelClass = wrapperClass || '';
|
|
46
|
+
labelClass = labelClass && sortsLength > 0 ? labelClass + ' active' : labelClass;
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "setting-item ".concat(labelClass ? '' : 'mb-1')
|
|
49
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: "mr-2 setting-item-btn filters-setting-btn ".concat(labelClass),
|
|
51
|
+
onClick: this.onSortToggle,
|
|
52
|
+
role: "button",
|
|
53
|
+
onKeyDown: this.onKeyDown,
|
|
54
|
+
title: sortMessage,
|
|
55
|
+
"aria-label": sortMessage,
|
|
56
|
+
tabIndex: 0
|
|
57
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
className: "dtable-font dtable-icon-sort mr-2",
|
|
60
|
+
id: this.props.target
|
|
61
|
+
}), /*#__PURE__*/React.createElement("span", null, sortMessage))), this.state.isSortPopoverShow && /*#__PURE__*/React.createElement(SortPopover, {
|
|
62
|
+
target: this.props.target,
|
|
63
|
+
isNeedSubmit: isNeedSubmit,
|
|
64
|
+
columns: columns,
|
|
65
|
+
onSortComponentToggle: this.onSortToggle,
|
|
66
|
+
update: this.update,
|
|
67
|
+
sorts: sorts
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
SortSetter.defaultProps = {
|
|
72
|
+
target: 'dtable-sort-popover',
|
|
73
|
+
isNeedSubmit: false
|
|
74
|
+
};
|
|
75
|
+
export default SortSetter;
|
package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _DTableSwitch from "dtable-ui-component/lib/DTableSwitch";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
class HideColumnItem extends React.PureComponent {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.onUpdateFieldSetting = event => {
|
|
7
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
8
|
+
const value = event.target.checked;
|
|
9
|
+
const {
|
|
10
|
+
setting
|
|
11
|
+
} = this.state;
|
|
12
|
+
if (setting.isChecked === value) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const newSetting = Object.assign({}, setting, {
|
|
16
|
+
isChecked: value
|
|
17
|
+
});
|
|
18
|
+
this.setState({
|
|
19
|
+
setting: newSetting
|
|
20
|
+
}, () => {
|
|
21
|
+
this.props.onUpdateFieldSetting(newSetting);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
this.state = {
|
|
25
|
+
setting: null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
29
|
+
if (JSON.stringify(nextProps.setting) !== JSON.stringify(prevState.setting)) {
|
|
30
|
+
return {
|
|
31
|
+
setting: nextProps.setting
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const {
|
|
38
|
+
setting
|
|
39
|
+
} = this.state;
|
|
40
|
+
const {
|
|
41
|
+
readonly
|
|
42
|
+
} = this.props;
|
|
43
|
+
const placeholder = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
44
|
+
className: "dtable-font ".concat(setting.columnIcon)
|
|
45
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
className: "text-truncate"
|
|
47
|
+
}, setting.columnName));
|
|
48
|
+
return /*#__PURE__*/React.createElement(_DTableSwitch, {
|
|
49
|
+
checked: setting.isChecked,
|
|
50
|
+
disabled: readonly,
|
|
51
|
+
placeholder: placeholder,
|
|
52
|
+
onChange: this.onUpdateFieldSetting,
|
|
53
|
+
switchClassName: "dropdown-item"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
HideColumnItem.defaultProps = {
|
|
58
|
+
readonly: false
|
|
59
|
+
};
|
|
60
|
+
export default HideColumnItem;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.hidden-column-popover .custom-switch .custom-switch-description {
|
|
2
|
+
width: 192px;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding-right: 5px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.hidden-column-popover .custom-switch .dtable-font {
|
|
10
|
+
transform: scale(0.8);
|
|
11
|
+
display: inline-block;
|
|
12
|
+
line-height: 24px;
|
|
13
|
+
margin-right: 8px;
|
|
14
|
+
color: #666;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.hidden-column-popover .custom-switch .custom-switch-indicator {
|
|
18
|
+
width: 22px;
|
|
19
|
+
height: 12px;
|
|
20
|
+
border-radius: 6px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.hidden-column-popover .custom-switch .custom-switch-input:checked ~ .custom-switch-indicator:before {
|
|
24
|
+
left: 12px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.hidden-column-popover .custom-switch .custom-switch-indicator:before {
|
|
28
|
+
content: "";
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 1px;
|
|
31
|
+
width: 8px;
|
|
32
|
+
height: 8px;
|
|
33
|
+
left: 1px;
|
|
34
|
+
background: #fff;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
transition: .3s left;
|
|
37
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .4);
|
|
38
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// import intl from 'react-intl-universal';
|
|
3
|
+
import { UncontrolledPopover } from 'reactstrap';
|
|
4
|
+
import isHotkey from 'is-hotkey';
|
|
5
|
+
import { COLUMNS_ICON_CONFIG } from 'dtable-utils';
|
|
6
|
+
import intl from '../../../intl';
|
|
7
|
+
import { getEventClassName } from '../../../utils';
|
|
8
|
+
import HideColumnItem from './hide-column-popover-widgets/hide-column-item';
|
|
9
|
+
import './hide-column-popover.css';
|
|
10
|
+
class HideColumnPopover extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.hidePopover = e => {
|
|
14
|
+
if (this.popoverRef && !getEventClassName(e).includes('popover') && !this.popoverRef.contains(e.target)) {
|
|
15
|
+
this.props.onPopoverToggle(e);
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
this.onHotKey = e => {
|
|
22
|
+
if (isHotkey('esc', e)) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
this.props.onPopoverToggle();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
this.onChooseAllColumns = () => {
|
|
28
|
+
const {
|
|
29
|
+
columns
|
|
30
|
+
} = this.props;
|
|
31
|
+
let shownColumnKeys = [];
|
|
32
|
+
const {
|
|
33
|
+
fieldSettings
|
|
34
|
+
} = this.state;
|
|
35
|
+
const newFieldSettings = fieldSettings.map(setting => {
|
|
36
|
+
setting.isChecked = true;
|
|
37
|
+
shownColumnKeys.push(setting.key);
|
|
38
|
+
return setting;
|
|
39
|
+
});
|
|
40
|
+
shownColumnKeys.unshift(columns[0].key);
|
|
41
|
+
this.setState({
|
|
42
|
+
fieldSettings: newFieldSettings
|
|
43
|
+
}, () => {
|
|
44
|
+
this.props.modifyHiddenColumns(shownColumnKeys);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
this.onHideAllColumns = () => {
|
|
48
|
+
const {
|
|
49
|
+
columns
|
|
50
|
+
} = this.props;
|
|
51
|
+
const newFieldSettings = this.state.fieldSettings.map(setting => {
|
|
52
|
+
setting.isChecked = false;
|
|
53
|
+
return setting;
|
|
54
|
+
});
|
|
55
|
+
// table page cannot hide first column
|
|
56
|
+
const shownColumnKeys = [columns[0].key];
|
|
57
|
+
this.setState({
|
|
58
|
+
fieldSettings: newFieldSettings
|
|
59
|
+
}, () => {
|
|
60
|
+
this.props.modifyHiddenColumns(shownColumnKeys);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
this.onUpdateFieldSetting = columnSetting => {
|
|
64
|
+
const {
|
|
65
|
+
columns
|
|
66
|
+
} = this.props;
|
|
67
|
+
const {
|
|
68
|
+
fieldSettings
|
|
69
|
+
} = this.state;
|
|
70
|
+
let shownColumnKeys = [];
|
|
71
|
+
const newFieldSettings = fieldSettings.map(setting => {
|
|
72
|
+
if (setting.key === columnSetting.key) {
|
|
73
|
+
setting = columnSetting;
|
|
74
|
+
}
|
|
75
|
+
if (setting.isChecked) {
|
|
76
|
+
shownColumnKeys.push(setting.key);
|
|
77
|
+
}
|
|
78
|
+
return setting;
|
|
79
|
+
});
|
|
80
|
+
// table page cannot hide first column
|
|
81
|
+
if (!shownColumnKeys.includes(columns[0].key)) {
|
|
82
|
+
shownColumnKeys.unshift(columns[0].key);
|
|
83
|
+
}
|
|
84
|
+
this.setState({
|
|
85
|
+
fieldSettings: newFieldSettings
|
|
86
|
+
}, () => {
|
|
87
|
+
this.props.modifyHiddenColumns(shownColumnKeys);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.onPopoverInsideClick = e => {
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
};
|
|
93
|
+
this.onChangeSearch = event => {
|
|
94
|
+
let {
|
|
95
|
+
searchVal
|
|
96
|
+
} = this.state;
|
|
97
|
+
if (searchVal === event.target.value) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
searchVal = event.target.value;
|
|
101
|
+
this.setState({
|
|
102
|
+
searchVal
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
this.getFilteredColumns = () => {
|
|
106
|
+
let {
|
|
107
|
+
searchVal,
|
|
108
|
+
fieldSettings
|
|
109
|
+
} = this.state;
|
|
110
|
+
searchVal = searchVal.toLowerCase();
|
|
111
|
+
if (!searchVal) {
|
|
112
|
+
return fieldSettings;
|
|
113
|
+
}
|
|
114
|
+
return fieldSettings.filter(setting => {
|
|
115
|
+
return setting.columnName.toLowerCase().includes(searchVal);
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
this.state = {
|
|
119
|
+
fieldSettings: [],
|
|
120
|
+
searchVal: ''
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
componentDidMount() {
|
|
124
|
+
document.addEventListener('click', this.hidePopover, true);
|
|
125
|
+
document.addEventListener('keydown', this.onHotKey);
|
|
126
|
+
}
|
|
127
|
+
componentWillUnmount() {
|
|
128
|
+
document.removeEventListener('click', this.hidePopover, true);
|
|
129
|
+
document.removeEventListener('keydown', this.onHotKey);
|
|
130
|
+
}
|
|
131
|
+
static getDerivedStateFromProps(nextProps, preState) {
|
|
132
|
+
const {
|
|
133
|
+
columns,
|
|
134
|
+
shownColumnKeys
|
|
135
|
+
} = nextProps;
|
|
136
|
+
let fieldSettings = columns.map(column => {
|
|
137
|
+
return {
|
|
138
|
+
key: column.key,
|
|
139
|
+
isChecked: shownColumnKeys.includes(column.key),
|
|
140
|
+
columnName: column.name,
|
|
141
|
+
columnIcon: COLUMNS_ICON_CONFIG[column.type]
|
|
142
|
+
};
|
|
143
|
+
});
|
|
144
|
+
// table page cannot hide first column
|
|
145
|
+
fieldSettings.shift();
|
|
146
|
+
return {
|
|
147
|
+
fieldSettings: fieldSettings
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
render() {
|
|
151
|
+
const {
|
|
152
|
+
target,
|
|
153
|
+
readonly
|
|
154
|
+
} = this.props;
|
|
155
|
+
const fieldSettings = this.getFilteredColumns();
|
|
156
|
+
const isEmpty = fieldSettings.length === 0 ? true : false;
|
|
157
|
+
return /*#__PURE__*/React.createElement(UncontrolledPopover, {
|
|
158
|
+
placement: "auto-start",
|
|
159
|
+
isOpen: true,
|
|
160
|
+
target: target,
|
|
161
|
+
fade: false,
|
|
162
|
+
hideArrow: true,
|
|
163
|
+
className: "hidden-column-popover",
|
|
164
|
+
boundariesElement: document.body
|
|
165
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
ref: ref => this.popoverRef = ref,
|
|
167
|
+
onClick: this.onPopoverInsideClick
|
|
168
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
169
|
+
className: "field-settings ".concat(isEmpty ? 'empty' : '')
|
|
170
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "search-column"
|
|
172
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
173
|
+
className: "form-control",
|
|
174
|
+
type: "text",
|
|
175
|
+
placeholder: intl.get('Search_column'),
|
|
176
|
+
value: this.state.searchVal,
|
|
177
|
+
onChange: this.onChangeSearch
|
|
178
|
+
})), isEmpty && /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
className: "empty-hidden-columns-container"
|
|
180
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: "empty-hidden-columns-list"
|
|
182
|
+
}, intl.get('No_columns_available_to_be_hidden'))), !isEmpty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
className: "field-settings-body",
|
|
184
|
+
style: {
|
|
185
|
+
maxHeight: window.innerHeight - 200 + 'px'
|
|
186
|
+
}
|
|
187
|
+
}, fieldSettings.map(setting => {
|
|
188
|
+
return /*#__PURE__*/React.createElement(HideColumnItem, {
|
|
189
|
+
key: setting.key,
|
|
190
|
+
setting: setting,
|
|
191
|
+
onUpdateFieldSetting: this.onUpdateFieldSetting,
|
|
192
|
+
readonly: readonly
|
|
193
|
+
});
|
|
194
|
+
})), !this.state.searchVal && !readonly && /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: "field-settings-header"
|
|
196
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
className: "hide-all px-2",
|
|
198
|
+
onClick: this.onHideAllColumns
|
|
199
|
+
}, intl.get('Hide_all')), /*#__PURE__*/React.createElement("div", {
|
|
200
|
+
className: "show-all px-2",
|
|
201
|
+
onClick: this.onChooseAllColumns
|
|
202
|
+
}, intl.get('Show_all')))))));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
HideColumnPopover.defaultProps = {
|
|
206
|
+
readonly: false
|
|
207
|
+
};
|
|
208
|
+
export default HideColumnPopover;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SORT_TYPE, isValidSort } from 'dtable-utils';
|
|
2
|
+
export const SORT_OPERATION = {
|
|
3
|
+
ADD_SORT: 'add_sort',
|
|
4
|
+
DELETE_SORT: 'delete_sort',
|
|
5
|
+
MODIFY_SORT_COLUMN: 'modify_sort_column',
|
|
6
|
+
MODIFY_SORT_TYPE: 'modify_sort_type'
|
|
7
|
+
};
|
|
8
|
+
export const getDisplaySorts = (sorts, columns) => {
|
|
9
|
+
if (!Array.isArray(sorts) || !Array.isArray(columns)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return sorts.filter(sort => !sort.column_key || isValidSort(sort, columns));
|
|
13
|
+
};
|
|
14
|
+
export const isSortsEmpty = sorts => {
|
|
15
|
+
return !sorts || sorts.length === 0;
|
|
16
|
+
};
|
|
17
|
+
export const execSortsOperation = (action, payload) => {
|
|
18
|
+
const {
|
|
19
|
+
sorts: updatedSorts
|
|
20
|
+
} = payload;
|
|
21
|
+
switch (action) {
|
|
22
|
+
case SORT_OPERATION.ADD_SORT:
|
|
23
|
+
{
|
|
24
|
+
const newSort = {
|
|
25
|
+
column_key: null,
|
|
26
|
+
sort_type: SORT_TYPE.UP
|
|
27
|
+
};
|
|
28
|
+
updatedSorts.push(newSort);
|
|
29
|
+
return updatedSorts;
|
|
30
|
+
}
|
|
31
|
+
case SORT_OPERATION.DELETE_SORT:
|
|
32
|
+
{
|
|
33
|
+
const {
|
|
34
|
+
index
|
|
35
|
+
} = payload;
|
|
36
|
+
updatedSorts.splice(index, 1);
|
|
37
|
+
return updatedSorts;
|
|
38
|
+
}
|
|
39
|
+
case SORT_OPERATION.MODIFY_SORT_COLUMN:
|
|
40
|
+
{
|
|
41
|
+
const {
|
|
42
|
+
index,
|
|
43
|
+
column_key
|
|
44
|
+
} = payload;
|
|
45
|
+
const newSort = {
|
|
46
|
+
column_key: column_key,
|
|
47
|
+
sort_type: SORT_TYPE.UP
|
|
48
|
+
};
|
|
49
|
+
updatedSorts[index] = newSort;
|
|
50
|
+
return updatedSorts;
|
|
51
|
+
}
|
|
52
|
+
case SORT_OPERATION.MODIFY_SORT_TYPE:
|
|
53
|
+
{
|
|
54
|
+
const {
|
|
55
|
+
index,
|
|
56
|
+
sort_type
|
|
57
|
+
} = payload;
|
|
58
|
+
const updatedSort = updatedSorts[index];
|
|
59
|
+
const newSort = {
|
|
60
|
+
column_key: updatedSort.column_key,
|
|
61
|
+
sort_type: sort_type
|
|
62
|
+
};
|
|
63
|
+
updatedSorts[index] = newSort;
|
|
64
|
+
return updatedSorts;
|
|
65
|
+
}
|
|
66
|
+
default:
|
|
67
|
+
{
|
|
68
|
+
return updatedSorts;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
.sort-popover .popover {
|
|
2
|
+
max-width: none;
|
|
3
|
+
min-width: 400px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sort-popover .sorts-list {
|
|
7
|
+
min-height: 120px;
|
|
8
|
+
max-height: 100%;
|
|
9
|
+
padding: 15px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sort-popover .sorts-list .option-group {
|
|
13
|
+
overflow: auto;
|
|
14
|
+
max-height: 360px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sort-popover .empty-sorts-container {
|
|
18
|
+
min-height: 80px;
|
|
19
|
+
padding: 16px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sorts-list .sort-item {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
padding: 0.25rem 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.sort-item .condition {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex: 1 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sort-item .condition > div {
|
|
34
|
+
height: 38px;
|
|
35
|
+
line-height: 38px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sort-item .sort-column {
|
|
39
|
+
width: 150px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sort-item .sort-predicate {
|
|
43
|
+
width: 130px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sorts-list .delete-sort {
|
|
47
|
+
width: 12px;
|
|
48
|
+
height: 20px;
|
|
49
|
+
margin-right: 14px;
|
|
50
|
+
text-align: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sorts-list .empty-sorts-list {
|
|
54
|
+
color: #666666;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.delete-sort .dtable-icon-fork-number {
|
|
58
|
+
display: inline-block;
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
color: #999;
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.sorts-list .delete-sort .dtable-icon-fork-number:hover {
|
|
65
|
+
color: #555555;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sort-popover .popover-add-tool {
|
|
69
|
+
border-top: none;
|
|
70
|
+
color: #666666;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sort-popover .popover-add-tool .popover-add-icon {
|
|
74
|
+
margin-right: 14px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.sort-popover .sort-popover-footer {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: flex-end;
|
|
81
|
+
padding: 1rem;
|
|
82
|
+
border-top: 1px solid #e9ecef;
|
|
83
|
+
}
|