sea-chart 0.0.8 → 0.0.10
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/assets/css/time-picker.css +9 -0
- package/dist/components/color-popover/color-rules/color-rule.js +175 -0
- package/dist/components/color-popover/color-rules/index.js +79 -0
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +214 -0
- package/dist/components/color-popover/color-rules/rule-filters/index.css +210 -0
- package/dist/components/color-popover/color-rules/rule-filters/index.js +89 -0
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +70 -0
- package/dist/components/color-popover/color-rules-popover.css +165 -0
- package/dist/components/color-popover/color-rules-popover.js +210 -0
- package/dist/components/color-popover/color-selector-popover.js +68 -0
- package/dist/components/common-add-tool/index.css +21 -0
- package/dist/components/common-add-tool/index.js +22 -0
- package/dist/components/dtable-popover/index.js +92 -0
- package/dist/components/types-dialog/index.js +1 -1
- package/dist/constants/color-rules.js +11 -0
- package/dist/constants/common-constants.js +6 -0
- package/dist/constants/geolocation.js +14 -1
- package/dist/constants/index.js +41 -6
- package/dist/constants/key-codes.js +102 -0
- package/dist/constants/regions.js +2106 -0
- package/dist/constants/style.js +18 -0
- package/dist/constants/table.js +4 -0
- package/dist/constants/type.js +3 -1
- package/dist/context.js +20 -1
- package/dist/editor/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/intl.js +4 -4
- package/dist/locale/lang/de.js +3 -1
- package/dist/locale/lang/en.js +39 -2
- package/dist/locale/lang/es.js +3 -1
- package/dist/locale/lang/fr.js +3 -1
- package/dist/locale/lang/pt.js +3 -1
- package/dist/locale/lang/ru.js +3 -1
- package/dist/locale/lang/zh_CN.js +47 -9
- package/dist/model/bar-custom.js +39 -0
- package/dist/model/bar-stack.js +1 -0
- package/dist/model/index.js +20 -18
- package/dist/settings/advance-bar-settings/data-settings.js +2 -0
- package/dist/settings/advance-bar-settings/style-settings.js +25 -4
- package/dist/settings/bar-settings/data-settings.js +6 -2
- package/dist/settings/bar-settings/style-settings.js +11 -20
- package/dist/settings/basic-number-card/data-settings.js +4 -2
- package/dist/settings/combination-settings/data-settings.js +2 -0
- package/dist/settings/dashboard-settings/data-settings.js +4 -2
- package/dist/settings/data-settings.js +1 -0
- package/dist/settings/horizontal-bar-settings/data-settings.js +2 -2
- package/dist/settings/horizontal-bar-settings/style-settings.js +3 -2
- package/dist/settings/index.css +8 -0
- package/dist/settings/index.js +41 -26
- package/dist/settings/pie-settings/data-settings.js +2 -0
- package/dist/settings/stacks-settings/index.css +72 -0
- package/dist/settings/stacks-settings/index.js +180 -0
- package/dist/settings/stacks-settings/stack-item-settings.js +80 -0
- package/dist/settings/style-settings.js +15 -13
- package/dist/settings/table-settings/data-settings.js +27 -9
- package/dist/settings/time-comparison-settings/data-settings.js +9 -5
- package/dist/settings/time-comparison-settings/style-settings.js +14 -42
- package/dist/settings/widgets/basic-summary/index.js +18 -8
- package/dist/settings/widgets/color-settings/color-use-type-selector.js +367 -0
- package/dist/settings/widgets/color-settings/index.css +212 -0
- package/dist/settings/widgets/common-data-settings.js +25 -2
- package/dist/settings/widgets/display-values-settings/index.css +1 -0
- package/dist/settings/widgets/display-values-settings/index.js +2 -2
- package/dist/settings/widgets/group-by.js +33 -4
- package/dist/settings/widgets/numeric-summary-item.js +9 -10
- package/dist/settings/widgets/select-table/index.js +1 -1
- package/dist/settings/widgets/select-view/index.css +4 -0
- package/dist/settings/widgets/select-view/index.js +47 -0
- package/dist/settings/widgets/summary-method-setting.js +2 -2
- package/dist/settings/widgets/summary-settings.js +3 -3
- package/dist/settings/widgets/switch/index.css +1 -0
- package/dist/settings/widgets/time-picker.js +4 -4
- package/dist/settings/widgets/y-axis-group-settings.js +4 -4
- package/dist/utils/cell-format-utils.js +56 -1
- package/dist/utils/cell-value-utils.js +10 -0
- package/dist/utils/chart-utils/base-utils.js +1168 -0
- package/dist/utils/chart-utils/index.js +68 -0
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +487 -0
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +34 -0
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +270 -0
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +142 -0
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +201 -0
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +62 -0
- package/dist/utils/chart-utils/original-data-utils/index.js +125 -0
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +144 -0
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +714 -0
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +73 -0
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +100 -0
- package/dist/utils/chart-utils/sql-statistics-utils.js +1213 -0
- package/dist/utils/collaborator.js +41 -0
- package/dist/utils/color-utils.js +123 -0
- package/dist/utils/column-utils.js +181 -2
- package/dist/utils/common-utils.js +18 -0
- package/dist/utils/index.js +5 -5
- package/dist/utils/map.js +102 -0
- package/dist/utils/options-utils.js +1 -9
- package/dist/utils/row-utils.js +124 -0
- package/dist/utils/{chart-data-sql.js → sql/chart-data-sql.js} +182 -61
- package/dist/utils/{column-2-sql-column.js → sql/column-2-sql-column.js} +5 -4
- package/dist/utils/sql/index.js +3 -0
- package/dist/utils/trend-utils.js +127 -0
- package/dist/view/index.js +32 -19
- package/dist/view/wrapper/area.js +11 -8
- package/dist/view/wrapper/bar-custom.js +178 -0
- package/dist/view/wrapper/bar-group.js +69 -12
- package/dist/view/wrapper/bar.js +27 -11
- package/dist/view/wrapper/basic-number-card.js +6 -4
- package/dist/view/wrapper/chart-component.js +28 -4
- package/dist/view/wrapper/combination.js +12 -10
- package/dist/view/wrapper/compare.js +272 -0
- package/dist/view/wrapper/dashboard.js +5 -3
- package/dist/view/wrapper/horizontal-bar-group.js +10 -7
- package/dist/view/wrapper/horizontal-bar.js +8 -6
- package/dist/view/wrapper/index.js +23 -11
- package/dist/view/wrapper/line-group.js +41 -21
- package/dist/view/wrapper/line.js +41 -28
- package/dist/view/wrapper/pie.js +11 -8
- package/dist/view/wrapper/ring.js +13 -10
- package/dist/view/wrapper/table/index.css +35 -0
- package/dist/view/wrapper/table/index.js +33 -17
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +18 -10
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +11 -7
- package/dist/view/wrapper/table/two-dimension-table.js +24 -16
- package/dist/view/wrapper/treemap.js +9 -6
- package/package.json +6 -4
- package/dist/settings/widgets/label-color.js +0 -30
- package/dist/utils/chart-utils.js +0 -1803
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import intl from '../../../intl';
|
|
4
|
+
import RuleFilters from './rule-filters';
|
|
5
|
+
import ColorSelectorPopover from '../color-selector-popover';
|
|
6
|
+
import CommonAddTool from '../../common-add-tool';
|
|
7
|
+
class ColorRule extends Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.onColorPopoverToggle = event => {
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
13
|
+
this.setState({
|
|
14
|
+
isColorPopoverShow: !this.state.isColorPopoverShow
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
this.hideColorPopover = () => {
|
|
18
|
+
this.setState({
|
|
19
|
+
isColorPopoverShow: false
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
this.onSelectColor = color => {
|
|
23
|
+
const {
|
|
24
|
+
rule,
|
|
25
|
+
ruleIndex
|
|
26
|
+
} = this.props;
|
|
27
|
+
const updatedRule = Object.assign({}, rule, {
|
|
28
|
+
color
|
|
29
|
+
});
|
|
30
|
+
this.props.updateRule(ruleIndex, updatedRule);
|
|
31
|
+
};
|
|
32
|
+
this.deleteRule = e => {
|
|
33
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
const {
|
|
36
|
+
ruleIndex
|
|
37
|
+
} = this.props;
|
|
38
|
+
this.props.deleteRule(ruleIndex);
|
|
39
|
+
};
|
|
40
|
+
this.addFilter = () => {
|
|
41
|
+
const {
|
|
42
|
+
colorRuleTypes,
|
|
43
|
+
rule
|
|
44
|
+
} = this.props;
|
|
45
|
+
const {
|
|
46
|
+
filters
|
|
47
|
+
} = rule;
|
|
48
|
+
const defaultFilter = this.props.generateDefaultFilter(colorRuleTypes[0]);
|
|
49
|
+
if (!defaultFilter || filters.length >= 8) return;
|
|
50
|
+
let updatedFilters = [...filters];
|
|
51
|
+
updatedFilters.push(defaultFilter);
|
|
52
|
+
this.updateFilters(updatedFilters);
|
|
53
|
+
};
|
|
54
|
+
this.updateFilter = (filterIndex, updatedFilter) => {
|
|
55
|
+
const {
|
|
56
|
+
rule
|
|
57
|
+
} = this.props;
|
|
58
|
+
const {
|
|
59
|
+
filters
|
|
60
|
+
} = rule;
|
|
61
|
+
let updatedFilters = [...filters];
|
|
62
|
+
updatedFilters[filterIndex] = updatedFilter;
|
|
63
|
+
this.updateFilters(updatedFilters);
|
|
64
|
+
};
|
|
65
|
+
this.modifyFilterConjunction = filterConjunction => {
|
|
66
|
+
const {
|
|
67
|
+
rule,
|
|
68
|
+
ruleIndex
|
|
69
|
+
} = this.props;
|
|
70
|
+
const updatedRule = Object.assign({}, rule, {
|
|
71
|
+
filter_conjunction: filterConjunction
|
|
72
|
+
});
|
|
73
|
+
this.props.updateRule(ruleIndex, updatedRule);
|
|
74
|
+
};
|
|
75
|
+
this.updateFilters = filters => {
|
|
76
|
+
const {
|
|
77
|
+
rule,
|
|
78
|
+
ruleIndex
|
|
79
|
+
} = this.props;
|
|
80
|
+
if (filters.length === 0) {
|
|
81
|
+
this.props.deleteRule(ruleIndex);
|
|
82
|
+
} else {
|
|
83
|
+
const updatedRule = Object.assign({}, rule, {
|
|
84
|
+
filters
|
|
85
|
+
});
|
|
86
|
+
this.props.updateRule(ruleIndex, updatedRule);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.onMouseDown = e => {
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
92
|
+
};
|
|
93
|
+
this.state = {
|
|
94
|
+
isColorPopoverShow: false
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
const {
|
|
99
|
+
labelColorConfigs,
|
|
100
|
+
colorRuleTypes,
|
|
101
|
+
rule,
|
|
102
|
+
isEditing,
|
|
103
|
+
ruleIndex,
|
|
104
|
+
ruleName
|
|
105
|
+
} = this.props;
|
|
106
|
+
const {
|
|
107
|
+
color,
|
|
108
|
+
filter_conjunction,
|
|
109
|
+
filters
|
|
110
|
+
} = rule;
|
|
111
|
+
const target = "row-color-rule-".concat(ruleIndex);
|
|
112
|
+
const selectedColorConfig = this.props.getColorConfigByColor(color);
|
|
113
|
+
const ruleTitle = ruleName || intl.get('Define_rule');
|
|
114
|
+
const canAddFilter = filters.length < 8;
|
|
115
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
116
|
+
className: classnames('statistic-color-rule-item', {
|
|
117
|
+
'editing': isEditing
|
|
118
|
+
})
|
|
119
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
className: "d-flex justify-content-between pr-4"
|
|
121
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
className: "statistic-color-rule-title",
|
|
123
|
+
onClick: () => this.props.setEditingRuleIndex(ruleIndex)
|
|
124
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
125
|
+
ref: ref => this.rowColorRule = ref,
|
|
126
|
+
className: "statistic-color-rule-dropdown",
|
|
127
|
+
style: {
|
|
128
|
+
backgroundColor: color
|
|
129
|
+
},
|
|
130
|
+
onMouseDown: this.onMouseDown,
|
|
131
|
+
onClick: this.onColorPopoverToggle,
|
|
132
|
+
id: target
|
|
133
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
134
|
+
className: "dtable-font dtable-icon-drop-down",
|
|
135
|
+
style: {
|
|
136
|
+
color: selectedColorConfig.text_color
|
|
137
|
+
}
|
|
138
|
+
}), this.state.isColorPopoverShow && /*#__PURE__*/React.createElement(ColorSelectorPopover, {
|
|
139
|
+
placement: "bottom-start",
|
|
140
|
+
hideArrow: false,
|
|
141
|
+
target: target,
|
|
142
|
+
selectedColor: color,
|
|
143
|
+
colorConfigs: labelColorConfigs,
|
|
144
|
+
toggle: this.hideColorPopover,
|
|
145
|
+
onSelectColor: this.onSelectColor
|
|
146
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
className: classnames('statistic-color-rule-name text-truncate', {
|
|
148
|
+
'invalid': !!ruleName
|
|
149
|
+
}),
|
|
150
|
+
title: ruleTitle
|
|
151
|
+
}, ruleTitle)), /*#__PURE__*/React.createElement("span", {
|
|
152
|
+
className: "statistic-delete-color-rule"
|
|
153
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
154
|
+
className: "dtable-font dtable-icon-delete",
|
|
155
|
+
onClick: this.deleteRule
|
|
156
|
+
}))), isEditing && /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
className: "statistic-color-rule-filters-wrapper"
|
|
158
|
+
}, /*#__PURE__*/React.createElement(RuleFilters, {
|
|
159
|
+
filterTypes: colorRuleTypes,
|
|
160
|
+
filters: rule.filters,
|
|
161
|
+
filterConjunction: filter_conjunction,
|
|
162
|
+
getFilterConfigByType: this.props.getFilterConfigByType,
|
|
163
|
+
modifyConjunction: this.modifyFilterConjunction,
|
|
164
|
+
updateFilters: this.updateFilters
|
|
165
|
+
}), /*#__PURE__*/React.createElement(CommonAddTool, {
|
|
166
|
+
className: classnames('statistic-btn-add-color-rule-filter', {
|
|
167
|
+
'disabled': !canAddFilter
|
|
168
|
+
}),
|
|
169
|
+
callBack: this.addFilter,
|
|
170
|
+
footerName: intl.get('Add_condition'),
|
|
171
|
+
addIconClassName: "popover-add-icon"
|
|
172
|
+
})));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export default ColorRule;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import ColorRule from './color-rule';
|
|
3
|
+
class ColorRules extends Component {
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.setEditingRuleIndex = editingRuleIndex => {
|
|
7
|
+
if (this.state.editingRuleIndex === editingRuleIndex) {
|
|
8
|
+
this.setState({
|
|
9
|
+
editingRuleIndex: -1
|
|
10
|
+
});
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
this.setState({
|
|
14
|
+
editingRuleIndex
|
|
15
|
+
}, () => {
|
|
16
|
+
this.props.resetPopoverPosition();
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.updateRule = (ruleIndex, updatedRule) => {
|
|
20
|
+
const {
|
|
21
|
+
rules
|
|
22
|
+
} = this.props;
|
|
23
|
+
const isAddingFilter = updatedRule.filters.length > rules[ruleIndex].filters.length;
|
|
24
|
+
let updatedRules = [...rules];
|
|
25
|
+
updatedRules[ruleIndex] = updatedRule;
|
|
26
|
+
this.props.updateRules({
|
|
27
|
+
colorRules: updatedRules,
|
|
28
|
+
callback: () => {
|
|
29
|
+
isAddingFilter && this.props.resetPopoverPosition();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.deleteRule = ruleIndex => {
|
|
34
|
+
const {
|
|
35
|
+
rules
|
|
36
|
+
} = this.props;
|
|
37
|
+
let updatedRules = [...rules];
|
|
38
|
+
updatedRules.splice(ruleIndex, 1);
|
|
39
|
+
this.props.updateRules({
|
|
40
|
+
colorRules: updatedRules
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
this.state = {
|
|
44
|
+
editingRuleIndex: -1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
rules,
|
|
50
|
+
labelColorConfigs,
|
|
51
|
+
colorRuleTypes,
|
|
52
|
+
rulesName
|
|
53
|
+
} = this.props;
|
|
54
|
+
const {
|
|
55
|
+
editingRuleIndex
|
|
56
|
+
} = this.state;
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: "statistic-color-rules"
|
|
59
|
+
}, rules.map((rule, ruleIndex) => {
|
|
60
|
+
const isEditing = editingRuleIndex === ruleIndex;
|
|
61
|
+
return /*#__PURE__*/React.createElement(ColorRule, {
|
|
62
|
+
key: "statistic-color-rule-".concat(ruleIndex),
|
|
63
|
+
ruleIndex: ruleIndex,
|
|
64
|
+
rule: rule,
|
|
65
|
+
labelColorConfigs: labelColorConfigs,
|
|
66
|
+
colorRuleTypes: colorRuleTypes,
|
|
67
|
+
isEditing: isEditing,
|
|
68
|
+
ruleName: rulesName[ruleIndex],
|
|
69
|
+
setEditingRuleIndex: this.setEditingRuleIndex,
|
|
70
|
+
getColorConfigByColor: this.props.getColorConfigByColor,
|
|
71
|
+
getFilterConfigByType: this.props.getFilterConfigByType,
|
|
72
|
+
generateDefaultFilter: this.props.generateDefaultFilter,
|
|
73
|
+
updateRule: this.updateRule,
|
|
74
|
+
deleteRule: this.deleteRule
|
|
75
|
+
});
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default ColorRules;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import intl from '../../../../intl';
|
|
3
|
+
import DTableCustomizeSelect from "dtable-ui-component/lib/DTableCustomizeSelect";
|
|
4
|
+
import NumberInput from './number-input';
|
|
5
|
+
import { COLOR_RULE_FILTER_TYPE_MAP, EMPTY_PREDICATE } from '../../../../constants/color-rules';
|
|
6
|
+
const INPUT_CMP_TYPE_MAP = {
|
|
7
|
+
NUMBER: 'number'
|
|
8
|
+
};
|
|
9
|
+
class Filter extends React.Component {
|
|
10
|
+
constructor(_props) {
|
|
11
|
+
super(_props);
|
|
12
|
+
this.initSelectOptions = props => {
|
|
13
|
+
const {
|
|
14
|
+
filter
|
|
15
|
+
} = props;
|
|
16
|
+
const {
|
|
17
|
+
filterPredicateList
|
|
18
|
+
} = this.props.getFilterConfigByType(filter.filter_type);
|
|
19
|
+
this.predicateOptions = filterPredicateList ? filterPredicateList.map(predicate => {
|
|
20
|
+
if (EMPTY_PREDICATE.includes(predicate)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
value: predicate,
|
|
25
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "select-option-name"
|
|
27
|
+
}, intl.get(predicate))
|
|
28
|
+
};
|
|
29
|
+
}).filter(Boolean) : [];
|
|
30
|
+
};
|
|
31
|
+
this.onDeleteFilter = event => {
|
|
32
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
33
|
+
const {
|
|
34
|
+
index
|
|
35
|
+
} = this.props;
|
|
36
|
+
this.props.deleteFilter(index);
|
|
37
|
+
};
|
|
38
|
+
this.onSelectConjunction = filterConjunction => {
|
|
39
|
+
if (filterConjunction === this.props.filterConjunction) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.props.modifyConjunction(filterConjunction);
|
|
43
|
+
};
|
|
44
|
+
this.onSelectFilterBy = filterType => {
|
|
45
|
+
const {
|
|
46
|
+
index,
|
|
47
|
+
filter
|
|
48
|
+
} = this.props;
|
|
49
|
+
if (filter.filter_type === filterType) return;
|
|
50
|
+
const {
|
|
51
|
+
filterPredicateList
|
|
52
|
+
} = this.props.getFilterConfigByType(filter.filter_type);
|
|
53
|
+
if (!filterPredicateList) return;
|
|
54
|
+
const updatedFilter = Object.assign({}, filter, {
|
|
55
|
+
filter_type: filterType,
|
|
56
|
+
filter_predicate: filterPredicateList[0]
|
|
57
|
+
});
|
|
58
|
+
this.props.updateFilter(index, updatedFilter);
|
|
59
|
+
};
|
|
60
|
+
this.onSelectPredicate = predicate => {
|
|
61
|
+
const {
|
|
62
|
+
index,
|
|
63
|
+
filter
|
|
64
|
+
} = this.props;
|
|
65
|
+
if (filter.filter_predicate === predicate) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const updatedFilter = Object.assign({}, filter, {
|
|
69
|
+
filter_predicate: predicate
|
|
70
|
+
});
|
|
71
|
+
this.props.updateFilter(index, updatedFilter);
|
|
72
|
+
};
|
|
73
|
+
this.onNumberFilterTermChanged = newFilterTerm => {
|
|
74
|
+
const {
|
|
75
|
+
index,
|
|
76
|
+
filter
|
|
77
|
+
} = this.props;
|
|
78
|
+
if (newFilterTerm === filter.filter_term) return;
|
|
79
|
+
const newFilter = Object.assign({}, filter, {
|
|
80
|
+
filter_term: newFilterTerm
|
|
81
|
+
});
|
|
82
|
+
this.props.updateFilter(index, newFilter);
|
|
83
|
+
};
|
|
84
|
+
this.getInputComponent = type => {
|
|
85
|
+
const {
|
|
86
|
+
filter
|
|
87
|
+
} = this.props;
|
|
88
|
+
const {
|
|
89
|
+
filter_term
|
|
90
|
+
} = filter;
|
|
91
|
+
switch (type) {
|
|
92
|
+
case INPUT_CMP_TYPE_MAP.NUMBER:
|
|
93
|
+
{
|
|
94
|
+
const number = filter_term || filter_term === 0 ? filter_term : '';
|
|
95
|
+
return /*#__PURE__*/React.createElement(NumberInput, {
|
|
96
|
+
value: number,
|
|
97
|
+
onChange: this.onNumberFilterTermChanged
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
{
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
this.renderConjunction = () => {
|
|
107
|
+
const {
|
|
108
|
+
index,
|
|
109
|
+
filterConjunction,
|
|
110
|
+
conjunctionOptions
|
|
111
|
+
} = this.props;
|
|
112
|
+
switch (index) {
|
|
113
|
+
case 0:
|
|
114
|
+
{
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
case 1:
|
|
118
|
+
{
|
|
119
|
+
const selectedConjunction = conjunctionOptions.find(option => option.value === filterConjunction);
|
|
120
|
+
return /*#__PURE__*/React.createElement(DTableCustomizeSelect, {
|
|
121
|
+
value: selectedConjunction,
|
|
122
|
+
options: conjunctionOptions,
|
|
123
|
+
onSelectOption: this.onSelectConjunction
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
{
|
|
128
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
129
|
+
className: "selected-conjunction-show"
|
|
130
|
+
}, intl.get(filterConjunction));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
this.renderFilterTerm = () => {
|
|
135
|
+
const {
|
|
136
|
+
filter
|
|
137
|
+
} = this.props;
|
|
138
|
+
const {
|
|
139
|
+
filter_type,
|
|
140
|
+
filter_predicate
|
|
141
|
+
} = filter;
|
|
142
|
+
|
|
143
|
+
// predicate is empty or not empty
|
|
144
|
+
if (EMPTY_PREDICATE.includes(filter_predicate)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
switch (filter_type) {
|
|
148
|
+
case COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE:
|
|
149
|
+
{
|
|
150
|
+
return this.getInputComponent(INPUT_CMP_TYPE_MAP.NUMBER);
|
|
151
|
+
}
|
|
152
|
+
default:
|
|
153
|
+
{
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
this.initSelectOptions(_props);
|
|
159
|
+
}
|
|
160
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
161
|
+
const {
|
|
162
|
+
filter
|
|
163
|
+
} = this.props;
|
|
164
|
+
if (nextProps.filter !== filter) {
|
|
165
|
+
this.initSelectOptions(nextProps);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
shouldComponentUpdate(nextProps) {
|
|
169
|
+
const currentProps = this.props;
|
|
170
|
+
const shouldUpdated = nextProps.index !== currentProps.index || nextProps.filter !== currentProps.filter || nextProps.filterConjunction !== currentProps.filterConjunction;
|
|
171
|
+
return shouldUpdated;
|
|
172
|
+
}
|
|
173
|
+
render() {
|
|
174
|
+
const {
|
|
175
|
+
filterTypeOptions,
|
|
176
|
+
filter
|
|
177
|
+
} = this.props;
|
|
178
|
+
const {
|
|
179
|
+
filter_type,
|
|
180
|
+
filter_predicate
|
|
181
|
+
} = filter;
|
|
182
|
+
const selectedFilterType = filterTypeOptions.find(option => option.value === filter_type);
|
|
183
|
+
const selectedPredicate = this.predicateOptions.find(option => option.value === filter_predicate);
|
|
184
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
185
|
+
className: "filter-item"
|
|
186
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
187
|
+
className: "delete-filter",
|
|
188
|
+
onClick: this.onDeleteFilter
|
|
189
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
190
|
+
className: "dtable-font dtable-icon-fork-number"
|
|
191
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
192
|
+
className: "condition"
|
|
193
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
className: "filter-conjunction"
|
|
195
|
+
}, this.renderConjunction()), /*#__PURE__*/React.createElement("div", {
|
|
196
|
+
className: "filter-container"
|
|
197
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
198
|
+
className: "filter-column"
|
|
199
|
+
}, /*#__PURE__*/React.createElement(DTableCustomizeSelect, {
|
|
200
|
+
value: selectedFilterType,
|
|
201
|
+
options: filterTypeOptions,
|
|
202
|
+
onSelectOption: this.onSelectFilterBy
|
|
203
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
204
|
+
className: "filter-predicate ml-2"
|
|
205
|
+
}, /*#__PURE__*/React.createElement(DTableCustomizeSelect, {
|
|
206
|
+
value: selectedPredicate,
|
|
207
|
+
options: this.predicateOptions,
|
|
208
|
+
onSelectOption: this.onSelectPredicate
|
|
209
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
210
|
+
className: "filter-term ml-2"
|
|
211
|
+
}, this.renderFilterTerm()))));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export default Filter;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
.statistic-color-rule-filters {
|
|
2
|
+
min-height: 120px;
|
|
3
|
+
max-height: 100%;
|
|
4
|
+
padding: 8px 15px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.statistic-color-rule-filters .selected-option {
|
|
8
|
+
align-self: stretch;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.statistic-color-rule-filters .filter-item {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
padding: .25rem 12px .25rem 12px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.statistic-color-rule-filters .filter-item .condition {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex: 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.statistic-color-rule-filters .filter-item .condition>div {
|
|
23
|
+
margin-left: .5rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.statistic-color-rule-filters .filter-item .condition>div:first-child {
|
|
27
|
+
margin-left: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.statistic-color-rule-filters .filter-item .filter-term {
|
|
31
|
+
max-width: 300px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.statistic-color-rule-filters .filter-item .dtable-font {
|
|
35
|
+
font-size: 12px;
|
|
36
|
+
color: #747474;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.statistic-color-rule-filters .filter-item .dtable-font:hover {
|
|
40
|
+
color: #000;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.statistic-color-rule-filters .filter-conjunction {
|
|
44
|
+
width: 72px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.statistic-color-rule-filters .filter-conjunction-readonly {
|
|
48
|
+
width: 52px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.statistic-color-rule-filters .filter-container {
|
|
52
|
+
width : calc(100% - 72px);
|
|
53
|
+
display: flex;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.statistic-color-rule-filters .selected-option-show {
|
|
57
|
+
width: calc(100% - 20px);
|
|
58
|
+
height: 20px;
|
|
59
|
+
line-height: 20px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.statistic-color-rule-filters .selected-option {
|
|
63
|
+
width: auto;
|
|
64
|
+
overflow-x: auto;
|
|
65
|
+
background-color: #f5f5f5;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.statistic-color-rule-filters .dtable-icon-drop-down {
|
|
69
|
+
margin-left: .5rem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.statistic-color-rule-filters .selected-conjunction-show {
|
|
73
|
+
padding: 0 10px;
|
|
74
|
+
color: #999;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.statistic-color-rule-filters .filter-column {
|
|
78
|
+
max-width: 150px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.filter-column .option:hover .filter-header-icon .dtable-font {
|
|
82
|
+
color: #fff;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.statistic-color-rule-filters .filter-term input {
|
|
86
|
+
display: flex;
|
|
87
|
+
width: 100%;
|
|
88
|
+
height: 30px;
|
|
89
|
+
background-color: #ffffff;
|
|
90
|
+
padding-left: 8px;
|
|
91
|
+
padding-right: 8px;
|
|
92
|
+
outline: none;
|
|
93
|
+
border-radius: 3px;
|
|
94
|
+
font-size: 0.875rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.statistic-color-rule-filters .custom-select:hover,
|
|
98
|
+
.statistic-color-rule-filters .filter-term input:hover {
|
|
99
|
+
border-color: rgb(179, 179, 179);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.statistic-color-rule-filters .filter-term input.disabled:hover {
|
|
103
|
+
border-color: rgba(0, 40, 100, 0.12);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.statistic-color-rule-filters .filter-term input:hover:focus {
|
|
107
|
+
border-color: #1991eb;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.statistic-color-rule-filters .filter-term input:focus {
|
|
111
|
+
color: #495057;
|
|
112
|
+
background-color: #fff;
|
|
113
|
+
border-color: #1991eb;
|
|
114
|
+
outline: 0;
|
|
115
|
+
box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.statistic-color-rule-filters .filter-term .date-picker-container input:focus {
|
|
119
|
+
color: #495057;
|
|
120
|
+
background-color: #fff;
|
|
121
|
+
border: 1px solid #fff;
|
|
122
|
+
outline: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.statistic-color-rule-filters .filter-term .date-picker-container table tr {
|
|
126
|
+
height: 30px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.statistic-color-rule-filters .filter-term input[type='checkbox'] {
|
|
130
|
+
width: inherit;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.statistic-color-rule-filters .filter-term input[type='checkbox']:focus {
|
|
134
|
+
border: 0;
|
|
135
|
+
box-shadow: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.filter-term .filter-rate-list {
|
|
139
|
+
display: flex;
|
|
140
|
+
padding: 0 5px;
|
|
141
|
+
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.statistic-color-rule-filters .delete-filter {
|
|
145
|
+
width: 12px;
|
|
146
|
+
height: 20px;
|
|
147
|
+
margin-right: 14px;
|
|
148
|
+
text-align: center;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.statistic-color-rule-filters .delete-filter:hover {
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.statistic-color-rule-filters .delete-filter .dtable-icon-fork-number {
|
|
156
|
+
display: inline-block;
|
|
157
|
+
font-size: 12px;
|
|
158
|
+
color: #949494;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.statistic-color-rule-filters .popover-add-tool {
|
|
162
|
+
border-top: none;
|
|
163
|
+
color: #555555;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.statistic-color-rule-filters .popover-add-tool .popover-add-icon {
|
|
167
|
+
margin-right: 14px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.statistic-color-rule-filters .option-group {
|
|
171
|
+
max-height: 360px;
|
|
172
|
+
overflow: auto;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.statistic-color-rule-filters .filter-item .dtable-icon-fork-number:hover {
|
|
176
|
+
color: #5a5a5a;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.statistic-color-rule-filters .filter-container-readonly .selected-option-show,
|
|
180
|
+
.statistic-color-rule-filters .filter-conjunction-readonly .selected-option-show {
|
|
181
|
+
width: 100%;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.statistic-color-rule-filters .selected-option-show .remove-container {
|
|
185
|
+
display: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.filter-header-icon {
|
|
189
|
+
display: inline-block;
|
|
190
|
+
padding: 0 0.3125rem;
|
|
191
|
+
margin-left: -0.3125rem;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.filter-header-icon .dtable-font {
|
|
195
|
+
font-size: 14px;
|
|
196
|
+
color: #aaa;
|
|
197
|
+
cursor: default;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.statistic-color-rule-filters .custom-select,
|
|
201
|
+
.statistic-color-rule-filters .filter-term,
|
|
202
|
+
.statistic-color-rule-filters .filter-term input,
|
|
203
|
+
.statistic-color-rule-filters .filter-item .condition>div,
|
|
204
|
+
.statistic-color-rule-filters .filter-item .filter-term input:focus {
|
|
205
|
+
height: 30px;
|
|
206
|
+
line-height: 30px;
|
|
207
|
+
background-color: #f5f5f5;
|
|
208
|
+
border-color: rgba(0, 40, 100, 0.12);
|
|
209
|
+
box-shadow: unset;
|
|
210
|
+
}
|