@gingkoo/pandora-metabase 1.0.117 → 1.0.119
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/lib/cjs/common/Portal/index.js +0 -2
- package/lib/cjs/common/SplitView/index.d.ts +0 -4
- package/lib/cjs/common/SplitView/index.js +0 -10
- package/lib/cjs/components/dialog/custom-column/config.js +4 -48
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/cjs/components/dialog/custom-column/index.js +2 -4
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +2 -3
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/cjs/components/dialog/custom-editor/index.js +2 -7
- package/lib/cjs/components/dialog/diff-viewer/index copy.js +1 -16
- package/lib/cjs/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/cjs/components/dialog/expression/date-format.js +2 -8
- package/lib/cjs/components/dialog/expression/index.d.ts +0 -3
- package/lib/cjs/components/dialog/expression/index.js +2 -83
- package/lib/cjs/components/dialog/formula/index.js +1 -30
- package/lib/cjs/components/dialog/formula/utils.js +2 -10
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +109 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +43 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/cjs/components/dialog/formula-list/index.js +966 -509
- package/lib/cjs/components/dialog/formula-list/index.less +724 -0
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/cjs/components/dialog/formula-list/utils.js +117 -112
- package/lib/cjs/components/dialog/select-column/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-column/index.js +4 -15
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-column-multiple/index.js +6 -45
- package/lib/cjs/components/dialog/select-join/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-join/index.js +0 -6
- package/lib/cjs/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column/index.js +7 -21
- package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +5 -35
- package/lib/cjs/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/cjs/components/dialog/select-permission-table/index.js +0 -6
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +3 -3
- package/lib/cjs/components/dialog/select-summarize/index.js +105 -18
- package/lib/cjs/components/dialog/select-summarize/index.less +23 -0
- package/lib/cjs/components/dialog/select-table/index.d.ts +0 -6
- package/lib/cjs/components/dialog/select-table/index.js +1 -9
- package/lib/cjs/components/metabase/index.js +72 -86
- package/lib/cjs/components/metabase/index.less +14 -7
- package/lib/cjs/components/modules/components/Wrapper.js +1 -1
- package/lib/cjs/components/modules/components/header.js +2 -2
- package/lib/cjs/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/cjs/components/modules/components/meta-icon.js +2 -47
- package/lib/cjs/components/modules/custom-column.js +3 -29
- package/lib/cjs/components/modules/enum/filter-enum.js +9 -88
- package/lib/cjs/components/modules/filter.js +2 -20
- package/lib/cjs/components/modules/index.d.ts +4 -2
- package/lib/cjs/components/modules/index.js +24 -1
- package/lib/cjs/components/modules/join-data.js +13 -291
- package/lib/cjs/components/modules/row-limit.js +0 -1
- package/lib/cjs/components/modules/sort.js +1 -61
- package/lib/cjs/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/cjs/components/modules/summarize/group-by.js +231 -76
- package/lib/cjs/components/modules/summarize/select-index.js +96 -46
- package/lib/cjs/components/modules/table-data.js +11 -64
- package/lib/cjs/components/popup.js +26 -32
- package/lib/cjs/hooks/patch.d.ts +1 -0
- package/lib/cjs/hooks/patch.js +104 -6
- package/lib/cjs/hooks/patch2.js +3 -165
- package/lib/cjs/hooks/use-provider.js +0 -3
- package/lib/cjs/hooks/use-state.js +55 -135
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/locale/en.js +5 -0
- package/lib/cjs/locale/index.js +1 -4
- package/lib/cjs/locale/zh.js +5 -0
- package/lib/cjs/sql-formula.js +0 -1
- package/lib/cjs/store/enum.d.ts +6 -6
- package/lib/cjs/store/enum.js +0 -13
- package/lib/cjs/store/helper.d.ts +2 -1
- package/lib/cjs/store/helper.js +15 -225
- package/lib/cjs/store/types.d.ts +45 -67
- package/lib/cjs/store/types.js +3 -49
- package/lib/cjs/types.d.ts +1 -0
- package/lib/cjs/utils/cookies.js +0 -3
- package/lib/cjs/utils/event.js +1 -1
- package/lib/cjs/utils/helper-dom.d.ts +1 -0
- package/lib/cjs/utils/helper-dom.js +17 -10
- package/lib/cjs/utils/helper.js +1 -24
- package/lib/cjs/utils/keydown.js +4 -7
- package/lib/cjs/utils/platform.d.ts +0 -9
- package/lib/cjs/utils/platform.js +0 -10
- package/lib/cjs/utils/selection.js +0 -6
- package/lib/cjs/utils/storage.d.ts +0 -9
- package/lib/cjs/utils/storage.js +1 -11
- package/lib/cjs/utils/transformSql.d.ts +5 -0
- package/lib/cjs/utils/transformSql.js +42 -113
- package/lib/cjs/utils.d.ts +1 -6
- package/lib/cjs/utils.js +115 -255
- package/lib/es/common/Portal/index.js +0 -2
- package/lib/es/common/SplitView/index.d.ts +0 -4
- package/lib/es/common/SplitView/index.js +0 -10
- package/lib/es/components/dialog/custom-column/config.js +4 -48
- package/lib/es/components/dialog/custom-column/expression-editor.js +3 -14
- package/lib/es/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
- package/lib/es/components/dialog/custom-column/expressions/suggest.js +2 -43
- package/lib/es/components/dialog/custom-column/expressions/tokenizer.js +8 -65
- package/lib/es/components/dialog/custom-column/index.js +2 -4
- package/lib/es/components/dialog/custom-column/tokenized-expression.js +1 -3
- package/lib/es/components/dialog/custom-column/tokenizedI-input.js +1 -1
- package/lib/es/components/dialog/custom-editor/index.js +1 -7
- package/lib/es/components/dialog/diff-viewer/index copy.js +1 -15
- package/lib/es/components/dialog/expression/date-format-picker.js +2 -20
- package/lib/es/components/dialog/expression/date-format.js +2 -8
- package/lib/es/components/dialog/expression/index.d.ts +0 -3
- package/lib/es/components/dialog/expression/index.js +2 -82
- package/lib/es/components/dialog/formula/index.js +0 -30
- package/lib/es/components/dialog/formula/utils.js +2 -10
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +102 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +9 -0
- package/lib/es/components/dialog/formula-list/LogicGroup.js +36 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/es/components/dialog/formula-list/index.js +965 -509
- package/lib/es/components/dialog/formula-list/index.less +724 -0
- package/lib/es/components/dialog/formula-list/utils.d.ts +0 -7
- package/lib/es/components/dialog/formula-list/utils.js +117 -112
- package/lib/es/components/dialog/index.js +3 -3
- package/lib/es/components/dialog/select-column/index.d.ts +0 -6
- package/lib/es/components/dialog/select-column/index.js +4 -14
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-column-multiple/index.js +7 -47
- package/lib/es/components/dialog/select-join/index.d.ts +0 -5
- package/lib/es/components/dialog/select-join/index.js +0 -5
- package/lib/es/components/dialog/select-join-column/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column/index.js +7 -20
- package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +0 -8
- package/lib/es/components/dialog/select-join-column-multiple/index.js +5 -34
- package/lib/es/components/dialog/select-permission-table/index.d.ts +0 -5
- package/lib/es/components/dialog/select-permission-table/index.js +0 -5
- package/lib/es/components/dialog/select-summarize/index.d.ts +3 -3
- package/lib/es/components/dialog/select-summarize/index.js +106 -18
- package/lib/es/components/dialog/select-summarize/index.less +23 -0
- package/lib/es/components/dialog/select-table/index.d.ts +0 -6
- package/lib/es/components/dialog/select-table/index.js +1 -8
- package/lib/es/components/metabase/index.js +72 -87
- package/lib/es/components/metabase/index.less +14 -7
- package/lib/es/components/modules/components/Wrapper.js +1 -1
- package/lib/es/components/modules/components/header.js +2 -2
- package/lib/es/components/modules/components/meta-icon.d.ts +0 -3
- package/lib/es/components/modules/components/meta-icon.js +2 -46
- package/lib/es/components/modules/custom-column.js +3 -29
- package/lib/es/components/modules/enum/filter-enum.js +9 -88
- package/lib/es/components/modules/filter.js +2 -19
- package/lib/es/components/modules/index.d.ts +4 -2
- package/lib/es/components/modules/index.js +24 -1
- package/lib/es/components/modules/join-data.js +13 -291
- package/lib/es/components/modules/row-limit.js +0 -1
- package/lib/es/components/modules/sort.js +1 -61
- package/lib/es/components/modules/summarize/group-by.d.ts +0 -5
- package/lib/es/components/modules/summarize/group-by.js +233 -78
- package/lib/es/components/modules/summarize/select-index.js +96 -46
- package/lib/es/components/modules/table-data.js +11 -64
- package/lib/es/components/popup.js +27 -33
- package/lib/es/hooks/patch.d.ts +1 -0
- package/lib/es/hooks/patch.js +103 -5
- package/lib/es/hooks/patch2.js +2 -164
- package/lib/es/hooks/use-provider.js +0 -3
- package/lib/es/hooks/use-state.js +55 -135
- package/lib/es/index.js +0 -14
- package/lib/es/locale/en.js +5 -0
- package/lib/es/locale/index.js +1 -4
- package/lib/es/locale/zh.js +5 -0
- package/lib/es/sql-formula.js +0 -1
- package/lib/es/store/enum.d.ts +6 -6
- package/lib/es/store/enum.js +0 -13
- package/lib/es/store/helper.d.ts +2 -1
- package/lib/es/store/helper.js +13 -224
- package/lib/es/store/types.d.ts +45 -67
- package/lib/es/store/types.js +3 -49
- package/lib/es/types.d.ts +1 -0
- package/lib/es/types.js +1 -18
- package/lib/es/utils/cookies.js +0 -3
- package/lib/es/utils/event.js +1 -1
- package/lib/es/utils/helper-dom.d.ts +1 -0
- package/lib/es/utils/helper-dom.js +16 -9
- package/lib/es/utils/helper.js +1 -24
- package/lib/es/utils/keydown.js +4 -7
- package/lib/es/utils/platform.d.ts +0 -9
- package/lib/es/utils/platform.js +0 -10
- package/lib/es/utils/selection.js +0 -6
- package/lib/es/utils/storage.d.ts +0 -9
- package/lib/es/utils/storage.js +1 -10
- package/lib/es/utils/transformSql.d.ts +5 -0
- package/lib/es/utils/transformSql.js +42 -112
- package/lib/es/utils.d.ts +1 -6
- package/lib/es/utils.js +116 -255
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
4
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
7
|
var _excluded = ["notExistsToolbar", "toolbar"],
|
|
7
8
|
_excluded2 = ["subToolbar", "notExistsColumns", "showFields", "isExit", "toolbar"];
|
|
@@ -11,7 +12,6 @@ import React, { useEffect, useState, useMemo, useRef, forwardRef } from 'react';
|
|
|
11
12
|
import './index.less';
|
|
12
13
|
import { FieldString, FieldNumber, FfPlus } from '@gingkoo/pandora-icons';
|
|
13
14
|
import cx from 'classnames';
|
|
14
|
-
// import './index.less';
|
|
15
15
|
import Metabase from '../../../index';
|
|
16
16
|
import { __ } from '../../../locale';
|
|
17
17
|
import isEqual from 'lodash/isEqual';
|
|
@@ -31,22 +31,25 @@ import { useStore, Provider } from '../../../hooks/use-provider';
|
|
|
31
31
|
import ItemName from '../../modules/components/item-name';
|
|
32
32
|
import DiffViewer from '../diff-viewer';
|
|
33
33
|
import storage from '../../../utils/storage';
|
|
34
|
+
import { getTopLayerZIndex } from '../../../utils/helper-dom';
|
|
35
|
+
import CaseWhenGroup from './CaseWhenGroup';
|
|
36
|
+
import LogicGroup from './LogicGroup';
|
|
37
|
+
var CASE_FIXED_OPERATORS = ['case', 'when', 'then', 'else', 'end'];
|
|
38
|
+
var LOGIC_FIXED_OPERATORS = ['(', ')'];
|
|
39
|
+
var LOGIC_REQUIRED_OPERATORS = ['(', ')'];
|
|
34
40
|
var FormulaList = forwardRef(function (props, ref) {
|
|
35
|
-
var _storage$_metabaseCop
|
|
36
|
-
// 响应 storage._metabaseCopyItems 变化,保证粘贴按钮能实时显示
|
|
41
|
+
var _storage$_metabaseCop;
|
|
37
42
|
var _useState = useState((storage === null || storage === void 0 || (_storage$_metabaseCop = storage._metabaseCopyItems) === null || _storage$_metabaseCop === void 0 ? void 0 : _storage$_metabaseCop.length) || 0),
|
|
38
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
44
|
checkedItemsCount = _useState2[0],
|
|
40
45
|
setCheckedItemsCount = _useState2[1];
|
|
41
46
|
useEffect(function () {
|
|
42
47
|
var _storage$_metabaseCop3;
|
|
43
|
-
// 监听 _metabaseCopyItems 变化(自定义事件)
|
|
44
48
|
var handler = function handler() {
|
|
45
49
|
var _storage$_metabaseCop2;
|
|
46
50
|
setCheckedItemsCount((storage === null || storage === void 0 || (_storage$_metabaseCop2 = storage._metabaseCopyItems) === null || _storage$_metabaseCop2 === void 0 ? void 0 : _storage$_metabaseCop2.length) || 0);
|
|
47
51
|
};
|
|
48
52
|
window.addEventListener('sqb-checked-items-changed', handler);
|
|
49
|
-
// 初始化
|
|
50
53
|
setCheckedItemsCount((storage === null || storage === void 0 || (_storage$_metabaseCop3 = storage._metabaseCopyItems) === null || _storage$_metabaseCop3 === void 0 ? void 0 : _storage$_metabaseCop3.length) || 0);
|
|
51
54
|
return function () {
|
|
52
55
|
window.removeEventListener('sqb-checked-items-changed', handler);
|
|
@@ -68,7 +71,96 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
68
71
|
showPreview = _props$showPreview === void 0 ? true : _props$showPreview,
|
|
69
72
|
check = props.check,
|
|
70
73
|
_props$_type = props._type,
|
|
71
|
-
_type = _props$_type === void 0 ? 'filter' : _props$_type
|
|
74
|
+
_type = _props$_type === void 0 ? 'filter' : _props$_type,
|
|
75
|
+
_props$embedded = props.embedded,
|
|
76
|
+
embedded = _props$embedded === void 0 ? false : _props$embedded,
|
|
77
|
+
_props$enableCopy = props.enableCopy,
|
|
78
|
+
enableCopy = _props$enableCopy === void 0 ? true : _props$enableCopy,
|
|
79
|
+
parentPopupChannel = props.parentPopupChannel;
|
|
80
|
+
var parentPopupLockCountRef = useRef(0);
|
|
81
|
+
var parentPopupUnlockTimerRef = useRef(null);
|
|
82
|
+
var setParentClosable = function setParentClosable(closable) {
|
|
83
|
+
if (!parentPopupChannel) return;
|
|
84
|
+
if (parentPopupChannel === 'secondary') {
|
|
85
|
+
store.setClosable2(closable);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
store.setClosable(closable);
|
|
89
|
+
};
|
|
90
|
+
var lockParentPopup = function lockParentPopup() {
|
|
91
|
+
if (!parentPopupChannel) return;
|
|
92
|
+
if (parentPopupUnlockTimerRef.current) {
|
|
93
|
+
window.clearTimeout(parentPopupUnlockTimerRef.current);
|
|
94
|
+
parentPopupUnlockTimerRef.current = null;
|
|
95
|
+
}
|
|
96
|
+
parentPopupLockCountRef.current += 1;
|
|
97
|
+
if (parentPopupLockCountRef.current === 1) {
|
|
98
|
+
setParentClosable(false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var unlockParentPopup = function unlockParentPopup() {
|
|
102
|
+
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
103
|
+
if (!parentPopupChannel) return;
|
|
104
|
+
var runUnlock = function runUnlock() {
|
|
105
|
+
parentPopupUnlockTimerRef.current = null;
|
|
106
|
+
parentPopupLockCountRef.current = Math.max(0, parentPopupLockCountRef.current - 1);
|
|
107
|
+
if (parentPopupLockCountRef.current === 0) {
|
|
108
|
+
setParentClosable(true);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (delay > 0) {
|
|
112
|
+
if (parentPopupUnlockTimerRef.current) {
|
|
113
|
+
window.clearTimeout(parentPopupUnlockTimerRef.current);
|
|
114
|
+
}
|
|
115
|
+
parentPopupUnlockTimerRef.current = window.setTimeout(runUnlock, delay);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
runUnlock();
|
|
119
|
+
};
|
|
120
|
+
var openChildModal = function openChildModal(options) {
|
|
121
|
+
var _options$zIndex, _modalInstance;
|
|
122
|
+
var lockDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 120;
|
|
123
|
+
if (parentPopupChannel) {
|
|
124
|
+
lockParentPopup();
|
|
125
|
+
}
|
|
126
|
+
var modalZIndex = (_options$zIndex = options.zIndex) !== null && _options$zIndex !== void 0 ? _options$zIndex : getTopLayerZIndex() + 1;
|
|
127
|
+
var closed = false;
|
|
128
|
+
var modalInstance;
|
|
129
|
+
var releaseParentPopup = function releaseParentPopup() {
|
|
130
|
+
if (!parentPopupChannel || closed) return;
|
|
131
|
+
closed = true;
|
|
132
|
+
unlockParentPopup(lockDelay);
|
|
133
|
+
};
|
|
134
|
+
modalInstance = Modal2.openModal(_objectSpread(_objectSpread({
|
|
135
|
+
zIndex: modalZIndex
|
|
136
|
+
}, options), {}, {
|
|
137
|
+
onClose: function onClose() {
|
|
138
|
+
var _options$onClose;
|
|
139
|
+
releaseParentPopup();
|
|
140
|
+
(_options$onClose = options.onClose) === null || _options$onClose === void 0 || _options$onClose.call(options);
|
|
141
|
+
}
|
|
142
|
+
}));
|
|
143
|
+
var originalClose = (_modalInstance = modalInstance) === null || _modalInstance === void 0 || (_modalInstance = _modalInstance.close) === null || _modalInstance === void 0 ? void 0 : _modalInstance.bind(modalInstance);
|
|
144
|
+
if (originalClose) {
|
|
145
|
+
modalInstance.close = function () {
|
|
146
|
+
releaseParentPopup();
|
|
147
|
+
return originalClose.apply(void 0, arguments);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return modalInstance;
|
|
151
|
+
};
|
|
152
|
+
useEffect(function () {
|
|
153
|
+
return function () {
|
|
154
|
+
if (parentPopupUnlockTimerRef.current) {
|
|
155
|
+
window.clearTimeout(parentPopupUnlockTimerRef.current);
|
|
156
|
+
parentPopupUnlockTimerRef.current = null;
|
|
157
|
+
}
|
|
158
|
+
if (parentPopupLockCountRef.current > 0) {
|
|
159
|
+
parentPopupLockCountRef.current = 0;
|
|
160
|
+
setParentClosable(true);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}, [parentPopupChannel]);
|
|
72
164
|
var mergedTypes = useMemo(function () {
|
|
73
165
|
var map = new Map();
|
|
74
166
|
[].concat(_toConsumableArray(_customTypes), _toConsumableArray(otherTypes)).forEach(function (item) {
|
|
@@ -90,15 +182,12 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
90
182
|
return map;
|
|
91
183
|
}, [otherTypes]);
|
|
92
184
|
var caseList = value || [];
|
|
93
|
-
// const [caseList, setCaseListState] = useState<AtomsItem[]>(cloneDeep(value));
|
|
94
185
|
var caseListRef = useRef(caseList);
|
|
95
|
-
var isSettingCaseList = useRef(false);
|
|
96
186
|
var operatorList = useMemo(function () {
|
|
97
187
|
if (store.operatorList.length > 0) {
|
|
98
188
|
return store.operatorList;
|
|
99
|
-
} else {
|
|
100
|
-
return __operatorList;
|
|
101
189
|
}
|
|
190
|
+
return __operatorList;
|
|
102
191
|
}, [store.operatorList]);
|
|
103
192
|
var _useState3 = useState(''),
|
|
104
193
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
@@ -109,6 +198,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
109
198
|
previewMode = _useState6[0],
|
|
110
199
|
setPreviewMode = _useState6[1];
|
|
111
200
|
var _useState7 = useState(function () {
|
|
201
|
+
if (!enableCopy) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
112
204
|
if (store.copyType.includes(FormulaTypeEnum.ALL)) {
|
|
113
205
|
return true;
|
|
114
206
|
}
|
|
@@ -117,34 +209,221 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
117
209
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
118
210
|
isCopy = _useState8[0],
|
|
119
211
|
setIsCopy = _useState8[1];
|
|
120
|
-
// const [formulaList, setFunctionList] = useState<{ [params: string]: FormulaTemplatesItem }>(
|
|
121
|
-
// );
|
|
122
212
|
var formulaList = useMemo(function () {
|
|
123
213
|
return getObjTem(store.formulaTemplates);
|
|
124
214
|
}, [store.formulaTemplates]);
|
|
125
|
-
useEffect(function () {
|
|
126
|
-
setOldCode(getPreviewStr(caseList));
|
|
127
|
-
}, []);
|
|
128
215
|
var _useState9 = useState(''),
|
|
129
216
|
_useState0 = _slicedToArray(_useState9, 2),
|
|
130
217
|
filterVal = _useState0[0],
|
|
131
218
|
setFilterVal = _useState0[1];
|
|
132
219
|
var setCaseList = function setCaseList(data) {
|
|
133
|
-
var quotes = data.map(function (v
|
|
134
|
-
if (v !== null && v !== void 0 && v.quotes)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return v === null || v === void 0 ? void 0 : v.fieldName;
|
|
138
|
-
} else {
|
|
139
|
-
return v.val;
|
|
140
|
-
}
|
|
220
|
+
var quotes = data.map(function (v) {
|
|
221
|
+
if (v !== null && v !== void 0 && v.quotes) return v.quotes;
|
|
222
|
+
if (v !== null && v !== void 0 && v.fieldName) return v.fieldName;
|
|
223
|
+
return v === null || v === void 0 ? void 0 : v.val;
|
|
141
224
|
}).join(' ');
|
|
142
|
-
isSettingCaseList.current = true;
|
|
143
|
-
// setCaseListState(data);
|
|
144
225
|
caseList = data;
|
|
145
226
|
caseListRef.current = data;
|
|
146
227
|
onChange === null || onChange === void 0 || onChange(data, quotes);
|
|
147
228
|
};
|
|
229
|
+
var updateAtomAt = function updateAtomAt(index, nextItem) {
|
|
230
|
+
var nextList = caseList.slice();
|
|
231
|
+
nextList[index] = nextItem;
|
|
232
|
+
setCaseList(nextList);
|
|
233
|
+
};
|
|
234
|
+
function getItemDisplayText(v) {
|
|
235
|
+
if (!v) return '';
|
|
236
|
+
if (v.quotes) return v.quotes;
|
|
237
|
+
if (v.fieldName) return v.fieldName;
|
|
238
|
+
if (v.type === AtomsTypeEnum.FORMULA) {
|
|
239
|
+
return v.name ? getQuotes(v, v.args, formulaList) : '';
|
|
240
|
+
}
|
|
241
|
+
if (v.type === AtomsTypeEnum.CASE_WHEN) {
|
|
242
|
+
var caseValueText = (v.caseValue || []).map(function (item) {
|
|
243
|
+
return getItemDisplayText(item);
|
|
244
|
+
}).join(' ');
|
|
245
|
+
var branchText = (v.branches || []).map(function (branch) {
|
|
246
|
+
var whenText = (branch.when || []).map(function (item) {
|
|
247
|
+
return getItemDisplayText(item);
|
|
248
|
+
}).join(' ');
|
|
249
|
+
var thenText = (branch.then || []).map(function (item) {
|
|
250
|
+
return getItemDisplayText(item);
|
|
251
|
+
}).join(' ');
|
|
252
|
+
return "when ".concat(whenText, " then ").concat(thenText).trim();
|
|
253
|
+
}).join(' ');
|
|
254
|
+
var elseText = (v.elseValue || []).length ? " else ".concat((v.elseValue || []).map(function (item) {
|
|
255
|
+
return getItemDisplayText(item);
|
|
256
|
+
}).join(' ')) : '';
|
|
257
|
+
return "case ".concat(caseValueText, " ").concat(branchText).concat(elseText, " end").replace(/\s+/g, ' ').trim();
|
|
258
|
+
}
|
|
259
|
+
if (v.type === AtomsTypeEnum.AND_OR) {
|
|
260
|
+
var listText = (v.list || []).map(function (item) {
|
|
261
|
+
return getItemDisplayText(item);
|
|
262
|
+
}).join(' ');
|
|
263
|
+
return "".concat(v.operator || 'and', " ( ").concat(listText, " )").replace(/\s+/g, ' ').trim();
|
|
264
|
+
}
|
|
265
|
+
if (Array.isArray(v.val)) {
|
|
266
|
+
return v.val.join(', ');
|
|
267
|
+
}
|
|
268
|
+
return v.val || '';
|
|
269
|
+
}
|
|
270
|
+
var getPreviewStr = function getPreviewStr() {
|
|
271
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
272
|
+
return data.map(function (v) {
|
|
273
|
+
if (v.type === AtomsTypeEnum.OPERATOR && (v.val === 'and' || v.val === 'or')) {
|
|
274
|
+
return "\r".concat(v.val, "\r");
|
|
275
|
+
}
|
|
276
|
+
if (v.type === AtomsTypeEnum.OPERATOR && (v.val === '(' || v.val === ')')) {
|
|
277
|
+
return "".concat(v.val);
|
|
278
|
+
}
|
|
279
|
+
return getItemDisplayText(v);
|
|
280
|
+
}).join(' ');
|
|
281
|
+
};
|
|
282
|
+
useEffect(function () {
|
|
283
|
+
setOldCode(getPreviewStr(caseList));
|
|
284
|
+
}, []);
|
|
285
|
+
var renderTokenContent = function renderTokenContent(children) {
|
|
286
|
+
return _jsx("span", {
|
|
287
|
+
className: 'Sqb-TokenContent',
|
|
288
|
+
children: children
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
var renderNestedFormulaList = function renderNestedFormulaList(list, onNestedChange) {
|
|
292
|
+
return _jsx("div", {
|
|
293
|
+
className: 'Sqb-NestedFormulaList',
|
|
294
|
+
children: _jsx(FormulaList, {
|
|
295
|
+
ref: ref,
|
|
296
|
+
embedded: true,
|
|
297
|
+
value: list,
|
|
298
|
+
data: data,
|
|
299
|
+
exitData: exitData,
|
|
300
|
+
onChange: function onChange(atoms) {
|
|
301
|
+
return onNestedChange(atoms);
|
|
302
|
+
},
|
|
303
|
+
customTypes: _customTypes,
|
|
304
|
+
otherTypes: otherTypes,
|
|
305
|
+
isCustom: isCustom,
|
|
306
|
+
showPreview: false,
|
|
307
|
+
check: check,
|
|
308
|
+
_type: _type,
|
|
309
|
+
parentPopupChannel: parentPopupChannel
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var renderCaseWhenEditor = function renderCaseWhenEditor(value, index) {
|
|
314
|
+
return _jsx(CaseWhenGroup, {
|
|
315
|
+
caseValueContent: renderNestedFormulaList(value.caseValue || [], function (nextList) {
|
|
316
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
317
|
+
caseValue: nextList
|
|
318
|
+
}));
|
|
319
|
+
}),
|
|
320
|
+
branches: (value.branches || []).map(function (branch, branchIndex) {
|
|
321
|
+
return {
|
|
322
|
+
key: "case-".concat(index, "-branch-").concat(branchIndex),
|
|
323
|
+
whenContent: renderNestedFormulaList(branch.when || [], function (nextList) {
|
|
324
|
+
var nextBranches = (value.branches || []).slice();
|
|
325
|
+
nextBranches[branchIndex] = _objectSpread(_objectSpread({}, branch), {}, {
|
|
326
|
+
when: nextList
|
|
327
|
+
});
|
|
328
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
329
|
+
branches: nextBranches
|
|
330
|
+
}));
|
|
331
|
+
}),
|
|
332
|
+
thenContent: renderNestedFormulaList(branch.then || [], function (nextList) {
|
|
333
|
+
var nextBranches = (value.branches || []).slice();
|
|
334
|
+
nextBranches[branchIndex] = _objectSpread(_objectSpread({}, branch), {}, {
|
|
335
|
+
then: nextList
|
|
336
|
+
});
|
|
337
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
338
|
+
branches: nextBranches
|
|
339
|
+
}));
|
|
340
|
+
}),
|
|
341
|
+
onAddAfter: function onAddAfter(e) {
|
|
342
|
+
e.stopPropagation();
|
|
343
|
+
var nextBranches = (value.branches || []).slice();
|
|
344
|
+
nextBranches.splice(branchIndex + 1, 0, {
|
|
345
|
+
when: [{
|
|
346
|
+
val: '',
|
|
347
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
348
|
+
}],
|
|
349
|
+
then: [{
|
|
350
|
+
val: '',
|
|
351
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
352
|
+
}]
|
|
353
|
+
});
|
|
354
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
355
|
+
branches: nextBranches
|
|
356
|
+
}));
|
|
357
|
+
},
|
|
358
|
+
onDelete: function onDelete(e) {
|
|
359
|
+
e.stopPropagation();
|
|
360
|
+
var nextBranches = (value.branches || []).filter(function (_, currentIndex) {
|
|
361
|
+
return currentIndex !== branchIndex;
|
|
362
|
+
});
|
|
363
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
364
|
+
branches: nextBranches
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
}),
|
|
369
|
+
elseContent: value.elseValue ? renderNestedFormulaList(value.elseValue || [], function (nextList) {
|
|
370
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
371
|
+
elseValue: nextList
|
|
372
|
+
}));
|
|
373
|
+
}) : undefined,
|
|
374
|
+
onAddBranch: function onAddBranch(e) {
|
|
375
|
+
e.stopPropagation();
|
|
376
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
377
|
+
branches: [].concat(_toConsumableArray(value.branches || []), [{
|
|
378
|
+
when: [{
|
|
379
|
+
val: '',
|
|
380
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
381
|
+
}],
|
|
382
|
+
then: [{
|
|
383
|
+
val: '',
|
|
384
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
385
|
+
}]
|
|
386
|
+
}])
|
|
387
|
+
}));
|
|
388
|
+
},
|
|
389
|
+
onAddElse: function onAddElse(e) {
|
|
390
|
+
e.stopPropagation();
|
|
391
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
392
|
+
elseValue: [{
|
|
393
|
+
val: '',
|
|
394
|
+
type: AtomsTypeEnum.UNKNOWN
|
|
395
|
+
}]
|
|
396
|
+
}));
|
|
397
|
+
},
|
|
398
|
+
onRemoveElse: function onRemoveElse(e) {
|
|
399
|
+
e.stopPropagation();
|
|
400
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
401
|
+
elseValue: undefined
|
|
402
|
+
}));
|
|
403
|
+
},
|
|
404
|
+
onDeleteCase: function onDeleteCase(e) {
|
|
405
|
+
return handleDel(e, index);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
var renderAndOrEditor = function renderAndOrEditor(value, index) {
|
|
410
|
+
return _jsx(LogicGroup, {
|
|
411
|
+
operator: value.operator || 'and',
|
|
412
|
+
onToggleOperator: function onToggleOperator() {
|
|
413
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
414
|
+
operator: value.operator === 'or' ? 'and' : 'or'
|
|
415
|
+
}));
|
|
416
|
+
},
|
|
417
|
+
content: renderNestedFormulaList(value.list || [], function (nextList) {
|
|
418
|
+
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
419
|
+
list: nextList
|
|
420
|
+
}));
|
|
421
|
+
}),
|
|
422
|
+
onDelete: function onDelete(e) {
|
|
423
|
+
return handleDel(e, index);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
};
|
|
148
427
|
var _useState1 = useState(-1),
|
|
149
428
|
_useState10 = _slicedToArray(_useState1, 2),
|
|
150
429
|
ind = _useState10[0],
|
|
@@ -162,56 +441,194 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
162
441
|
isCheck = _useState14[0],
|
|
163
442
|
setIsCheck = _useState14[1];
|
|
164
443
|
var myInstanceIdRef = useRef(Math.random().toString(36).slice(2));
|
|
165
|
-
var _useState15 = useState(
|
|
444
|
+
var _useState15 = useState(null),
|
|
166
445
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var _useState17 = useState(window.
|
|
446
|
+
hoveredCaseGroupKey = _useState16[0],
|
|
447
|
+
setHoveredCaseGroupKey = _useState16[1];
|
|
448
|
+
var _useState17 = useState(!!window.__sqb_selection_active__),
|
|
170
449
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
var _useState19 = useState(
|
|
450
|
+
globalSelectionActive = _useState18[0],
|
|
451
|
+
setGlobalSelectionActive = _useState18[1];
|
|
452
|
+
var _useState19 = useState(window.__sqb_selection_owner__ || null),
|
|
174
453
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
var _useState21 = useState(
|
|
454
|
+
globalSelectionOwner = _useState20[0],
|
|
455
|
+
setGlobalSelectionOwner = _useState20[1];
|
|
456
|
+
var _useState21 = useState([]),
|
|
178
457
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
458
|
+
selectedIndices = _useState22[0],
|
|
459
|
+
setSelectedIndices = _useState22[1];
|
|
460
|
+
var _useState23 = useState(null),
|
|
461
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
462
|
+
hoveredCopyIndex = _useState24[0],
|
|
463
|
+
setHoveredCopyIndex = _useState24[1];
|
|
464
|
+
var getCaseGroupEnd = function getCaseGroupEnd(list, startIndex) {
|
|
465
|
+
var depth = 0;
|
|
466
|
+
for (var index = startIndex; index < list.length; index++) {
|
|
467
|
+
var item = list[index];
|
|
468
|
+
if (item.type !== AtomsTypeEnum.OPERATOR) continue;
|
|
469
|
+
if (item.val === 'case') depth += 1;
|
|
470
|
+
if (item.val === 'end') {
|
|
471
|
+
depth -= 1;
|
|
472
|
+
if (depth === 0) {
|
|
473
|
+
return index;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
186
476
|
}
|
|
187
|
-
|
|
188
|
-
|
|
477
|
+
return startIndex;
|
|
478
|
+
};
|
|
479
|
+
var getLogicGroupIndices = function getLogicGroupIndices(list, startIndex) {
|
|
480
|
+
var _list, _list2;
|
|
481
|
+
var prevItem = list[startIndex - 1];
|
|
482
|
+
var currentItem = list[startIndex];
|
|
483
|
+
if (!currentItem) return [];
|
|
484
|
+
if (currentItem.type === AtomsTypeEnum.OPERATOR && ['and', 'or'].includes(currentItem.val) && ((_list = list[startIndex + 1]) === null || _list === void 0 ? void 0 : _list.type) === AtomsTypeEnum.OPERATOR && ((_list2 = list[startIndex + 1]) === null || _list2 === void 0 ? void 0 : _list2.val) === '(') {
|
|
485
|
+
var depth = 0;
|
|
486
|
+
var _indices = [];
|
|
487
|
+
for (var index = startIndex; index < list.length; index++) {
|
|
488
|
+
var item = list[index];
|
|
489
|
+
_indices.push(index);
|
|
490
|
+
if ((item === null || item === void 0 ? void 0 : item.type) !== AtomsTypeEnum.OPERATOR) continue;
|
|
491
|
+
if (item.val === '(') depth += 1;
|
|
492
|
+
if (item.val === ')') {
|
|
493
|
+
depth -= 1;
|
|
494
|
+
if (depth === 0) {
|
|
495
|
+
return _indices;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return _indices;
|
|
500
|
+
}
|
|
501
|
+
if (currentItem.type === AtomsTypeEnum.OPERATOR) return [];
|
|
502
|
+
if ((prevItem === null || prevItem === void 0 ? void 0 : prevItem.type) === AtomsTypeEnum.OPERATOR && ['and', 'or'].includes((prevItem === null || prevItem === void 0 ? void 0 : prevItem.val) || '')) {
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
var indices = [startIndex];
|
|
506
|
+
var cursor = startIndex;
|
|
507
|
+
while (cursor + 2 < list.length) {
|
|
508
|
+
var operatorItem = list[cursor + 1];
|
|
509
|
+
var nextItem = list[cursor + 2];
|
|
510
|
+
if ((operatorItem === null || operatorItem === void 0 ? void 0 : operatorItem.type) !== AtomsTypeEnum.OPERATOR || !['and', 'or'].includes((operatorItem === null || operatorItem === void 0 ? void 0 : operatorItem.val) || '') || !nextItem || nextItem.type === AtomsTypeEnum.OPERATOR) {
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
indices.push(cursor + 1, cursor + 2);
|
|
514
|
+
cursor += 2;
|
|
515
|
+
}
|
|
516
|
+
return indices.length >= 3 ? indices : [];
|
|
517
|
+
};
|
|
518
|
+
var renderGroups = useMemo(function () {
|
|
519
|
+
var groups = [];
|
|
520
|
+
var index = 0;
|
|
521
|
+
while (index < caseList.length) {
|
|
522
|
+
var item = caseList[index];
|
|
523
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === AtomsTypeEnum.OPERATOR && (item === null || item === void 0 ? void 0 : item.val) === 'case') {
|
|
524
|
+
var endIndex = getCaseGroupEnd(caseList, index);
|
|
525
|
+
groups.push({
|
|
526
|
+
type: 'caseWhen',
|
|
527
|
+
indices: Array.from({
|
|
528
|
+
length: endIndex - index + 1
|
|
529
|
+
}, function (_, offset) {
|
|
530
|
+
return index + offset;
|
|
531
|
+
})
|
|
532
|
+
});
|
|
533
|
+
index = endIndex + 1;
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
var logicIndices = getLogicGroupIndices(caseList, index);
|
|
537
|
+
if (logicIndices.length > 0) {
|
|
538
|
+
groups.push({
|
|
539
|
+
type: 'logic',
|
|
540
|
+
indices: logicIndices
|
|
541
|
+
});
|
|
542
|
+
index = logicIndices[logicIndices.length - 1] + 1;
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
groups.push({
|
|
546
|
+
type: 'single',
|
|
547
|
+
indices: [index]
|
|
548
|
+
});
|
|
549
|
+
index += 1;
|
|
550
|
+
}
|
|
551
|
+
return groups;
|
|
189
552
|
}, [caseList]);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
553
|
+
var getCaseGroupRows = function getCaseGroupRows(indices) {
|
|
554
|
+
var rows = [];
|
|
555
|
+
var currentRow = [];
|
|
556
|
+
var depth = 0;
|
|
557
|
+
indices.forEach(function (itemIndex) {
|
|
558
|
+
var item = caseList[itemIndex];
|
|
559
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === AtomsTypeEnum.OPERATOR) {
|
|
560
|
+
if (item.val === 'case') {
|
|
561
|
+
if (depth === 0) {
|
|
562
|
+
if (currentRow.length > 0) rows.push(currentRow);
|
|
563
|
+
currentRow = [itemIndex];
|
|
564
|
+
depth = 1;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
depth += 1;
|
|
568
|
+
}
|
|
569
|
+
if (depth === 1 && (item.val === 'when' || item.val === 'else')) {
|
|
570
|
+
if (currentRow.length > 0) rows.push(currentRow);
|
|
571
|
+
currentRow = [itemIndex];
|
|
572
|
+
return;
|
|
201
573
|
}
|
|
202
|
-
if (
|
|
203
|
-
|
|
574
|
+
if (item.val === 'end') {
|
|
575
|
+
depth -= 1;
|
|
576
|
+
if (depth === 0) {
|
|
577
|
+
if (currentRow.length > 0) rows.push(currentRow);
|
|
578
|
+
rows.push([itemIndex]);
|
|
579
|
+
currentRow = [];
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
204
582
|
}
|
|
205
|
-
return v.val;
|
|
206
583
|
}
|
|
207
|
-
|
|
584
|
+
currentRow.push(itemIndex);
|
|
585
|
+
});
|
|
586
|
+
if (currentRow.length > 0) {
|
|
587
|
+
rows.push(currentRow);
|
|
588
|
+
}
|
|
589
|
+
return rows;
|
|
590
|
+
};
|
|
591
|
+
var isFixedCaseOperator = function isFixedCaseOperator(item) {
|
|
592
|
+
return item.type === AtomsTypeEnum.OPERATOR && CASE_FIXED_OPERATORS.includes(item.val || '');
|
|
593
|
+
};
|
|
594
|
+
var isFixedLogicOperator = function isFixedLogicOperator(item) {
|
|
595
|
+
return item.type === AtomsTypeEnum.OPERATOR && LOGIC_FIXED_OPERATORS.includes(item.val || '');
|
|
596
|
+
};
|
|
597
|
+
var isRequiredLogicOperator = function isRequiredLogicOperator(item) {
|
|
598
|
+
return item.type === AtomsTypeEnum.OPERATOR && LOGIC_REQUIRED_OPERATORS.includes(item.val || '');
|
|
599
|
+
};
|
|
600
|
+
var canDeleteItem = function canDeleteItem(item, groupType) {
|
|
601
|
+
if (groupType === 'logic') {
|
|
602
|
+
return !isRequiredLogicOperator(item);
|
|
603
|
+
}
|
|
604
|
+
return !isFixedCaseOperator(item);
|
|
208
605
|
};
|
|
606
|
+
var canShowInsertArrows = function canShowInsertArrows(item, groupType) {
|
|
607
|
+
if (groupType === 'caseWhen') {
|
|
608
|
+
return !isFixedCaseOperator(item);
|
|
609
|
+
}
|
|
610
|
+
if (groupType === 'logic') {
|
|
611
|
+
return !isRequiredLogicOperator(item);
|
|
612
|
+
}
|
|
613
|
+
return !(item.type === AtomsTypeEnum.OPERATOR && ['case', 'end'].includes(item.val));
|
|
614
|
+
};
|
|
615
|
+
useEffect(function () {
|
|
616
|
+
var _errorInfo = validateExpressionIntegrity(caseList);
|
|
617
|
+
setErrorInfo(_errorInfo);
|
|
618
|
+
}, [caseList]);
|
|
209
619
|
function closePopup() {
|
|
210
620
|
store.setPopup({
|
|
211
621
|
visible: false
|
|
212
622
|
});
|
|
213
623
|
}
|
|
214
|
-
|
|
624
|
+
var getSelectTriggerProps = function getSelectTriggerProps() {
|
|
625
|
+
return {
|
|
626
|
+
clickToClose: true,
|
|
627
|
+
style: {
|
|
628
|
+
zIndex: getTopLayerZIndex() + 1
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
};
|
|
215
632
|
var selectOperator = function selectOperator(props) {
|
|
216
633
|
var triggerElement = props.triggerElement,
|
|
217
634
|
ind = props.ind,
|
|
@@ -227,9 +644,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
227
644
|
},
|
|
228
645
|
showSearch: true,
|
|
229
646
|
trigger: trigger,
|
|
230
|
-
triggerProps:
|
|
231
|
-
clickToClose: true
|
|
232
|
-
},
|
|
647
|
+
triggerProps: getSelectTriggerProps(),
|
|
233
648
|
virtualListProps: {
|
|
234
649
|
threshold: null
|
|
235
650
|
},
|
|
@@ -246,6 +661,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
246
661
|
onVisibleChange: function onVisibleChange(visible) {
|
|
247
662
|
if (visible) {
|
|
248
663
|
setFilterVal('');
|
|
664
|
+
lockParentPopup();
|
|
665
|
+
} else {
|
|
666
|
+
unlockParentPopup(300);
|
|
249
667
|
}
|
|
250
668
|
},
|
|
251
669
|
value: '',
|
|
@@ -259,7 +677,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
259
677
|
},
|
|
260
678
|
value: filterVal,
|
|
261
679
|
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
262
|
-
// size='large'
|
|
263
680
|
onChange: function onChange(val) {
|
|
264
681
|
setFilterVal(val);
|
|
265
682
|
}
|
|
@@ -277,7 +694,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
277
694
|
})]
|
|
278
695
|
});
|
|
279
696
|
};
|
|
280
|
-
// 字段
|
|
281
697
|
function handleField(e, i, val) {
|
|
282
698
|
store.setPopup({
|
|
283
699
|
visible: true,
|
|
@@ -288,7 +704,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
288
704
|
multiple: false,
|
|
289
705
|
value: [val],
|
|
290
706
|
theme: ColumnsPopupThemeEnum.skyBlue,
|
|
291
|
-
onSelect: function onSelect(fields
|
|
707
|
+
onSelect: function onSelect(fields) {
|
|
292
708
|
var _caseList = caseList.slice();
|
|
293
709
|
_caseList[i] = fields[0];
|
|
294
710
|
setCaseList(_caseList);
|
|
@@ -297,7 +713,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
297
713
|
})
|
|
298
714
|
});
|
|
299
715
|
}
|
|
300
|
-
// 常量
|
|
301
716
|
var handleConstant = function handleConstant(val, i) {
|
|
302
717
|
var _caseList = caseList.slice();
|
|
303
718
|
var currentItem = _caseList[i];
|
|
@@ -317,7 +732,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
317
732
|
_caseList = insertTemplateAt(oldVal, val, _caseList, i);
|
|
318
733
|
setCaseList(_caseList);
|
|
319
734
|
};
|
|
320
|
-
// 表达式
|
|
321
735
|
function handleExpression(e, i, val) {
|
|
322
736
|
store.setPopup({
|
|
323
737
|
visible: true,
|
|
@@ -338,7 +752,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
338
752
|
})
|
|
339
753
|
});
|
|
340
754
|
}
|
|
341
|
-
// 删除
|
|
342
755
|
function handleDel(e, index) {
|
|
343
756
|
e.stopPropagation();
|
|
344
757
|
var _caseList = caseList.slice();
|
|
@@ -346,13 +759,21 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
346
759
|
setCaseList(_caseList);
|
|
347
760
|
closePopup();
|
|
348
761
|
}
|
|
349
|
-
|
|
762
|
+
function handleDelItems(e, indices) {
|
|
763
|
+
e.stopPropagation();
|
|
764
|
+
if (!indices.length) return;
|
|
765
|
+
var indexSet = new Set(indices);
|
|
766
|
+
var _caseList = caseList.filter(function (_, itemIndex) {
|
|
767
|
+
return !indexSet.has(itemIndex);
|
|
768
|
+
});
|
|
769
|
+
setCaseList(_caseList);
|
|
770
|
+
closePopup();
|
|
771
|
+
}
|
|
350
772
|
function initPaste() {
|
|
351
773
|
var isDispatch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
352
774
|
setSelectedIndices([]);
|
|
353
775
|
setLocalItem([]);
|
|
354
776
|
setIsCheck(false);
|
|
355
|
-
//有些事不需要通知别的过滤器重置勾选状态
|
|
356
777
|
if (isDispatch) {
|
|
357
778
|
window.dispatchEvent(new CustomEvent('sqb-check-active', {
|
|
358
779
|
detail: {
|
|
@@ -361,11 +782,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
361
782
|
}));
|
|
362
783
|
}
|
|
363
784
|
}
|
|
364
|
-
// 粘贴到末尾并清除勾选
|
|
365
785
|
function handlePaste() {
|
|
366
786
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
367
787
|
var _caseList = caseList.slice();
|
|
368
|
-
// determine items to paste (selected items have priority)
|
|
369
788
|
var itemsToPaste = storage._metabaseCopyItems || [];
|
|
370
789
|
itemsToPaste = changeCopyField(itemsToPaste, data);
|
|
371
790
|
if (itemsToPaste.length) {
|
|
@@ -378,13 +797,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
378
797
|
}
|
|
379
798
|
initPaste();
|
|
380
799
|
}
|
|
381
|
-
// 将值存在 localStorage
|
|
382
800
|
function setLocalItem(next) {
|
|
383
801
|
var _caseList = caseList.slice();
|
|
384
|
-
// determine items to paste (selected items have priority)
|
|
385
802
|
var itemsToPaste = [];
|
|
386
803
|
if (next.length > 0) {
|
|
387
|
-
// paste all selected items
|
|
388
804
|
itemsToPaste = next.map(function (i) {
|
|
389
805
|
return _caseList[i] ? cloneDeep(_caseList[i]) : null;
|
|
390
806
|
}).filter(Boolean);
|
|
@@ -406,11 +822,33 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
406
822
|
});
|
|
407
823
|
setSelectedIndices(next);
|
|
408
824
|
setLocalItem(next);
|
|
409
|
-
// const active = next.length > 0;
|
|
410
825
|
}
|
|
826
|
+
function toggleSelectGroup(indices, checked) {
|
|
827
|
+
var next = selectedIndices.slice();
|
|
828
|
+
if (checked) {
|
|
829
|
+
indices.forEach(function (index) {
|
|
830
|
+
if (!next.includes(index)) next.push(index);
|
|
831
|
+
});
|
|
832
|
+
} else {
|
|
833
|
+
var indexSet = new Set(indices);
|
|
834
|
+
next = next.filter(function (index) {
|
|
835
|
+
return !indexSet.has(index);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
next = next.sort(function (a, b) {
|
|
839
|
+
return a - b;
|
|
840
|
+
});
|
|
841
|
+
setSelectedIndices(next);
|
|
842
|
+
setLocalItem(next);
|
|
843
|
+
}
|
|
844
|
+
var isGroupSelected = function isGroupSelected(indices) {
|
|
845
|
+
return indices.length > 0 && indices.every(function (index) {
|
|
846
|
+
return selectedIndices.includes(index);
|
|
847
|
+
});
|
|
848
|
+
};
|
|
411
849
|
var copyAll = function copyAll() {
|
|
412
850
|
_setIsCheck(true);
|
|
413
|
-
var allIndices = caseList.map(function (
|
|
851
|
+
var allIndices = caseList.map(function (_, i) {
|
|
414
852
|
return i;
|
|
415
853
|
});
|
|
416
854
|
setSelectedIndices(allIndices);
|
|
@@ -419,11 +857,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
419
857
|
var delSelect = function delSelect() {
|
|
420
858
|
Modal.confirm({
|
|
421
859
|
title: __('metabase.prompt'),
|
|
422
|
-
// 提示
|
|
423
860
|
content: __('customColumn.confirmDelete'),
|
|
424
|
-
// 确认删除吗
|
|
425
861
|
onOk: function () {
|
|
426
|
-
var _onOk = _asyncToGenerator(
|
|
862
|
+
var _onOk = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
427
863
|
var selectedIndexSet, _caseList;
|
|
428
864
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
429
865
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -448,7 +884,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
448
884
|
onCancel: function onCancel() {}
|
|
449
885
|
});
|
|
450
886
|
};
|
|
451
|
-
// 开启关闭勾选,清除别的过滤器勾选
|
|
452
887
|
var _setIsCheck = function _setIsCheck(val) {
|
|
453
888
|
initPaste();
|
|
454
889
|
setIsCheck(val);
|
|
@@ -466,7 +901,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
466
901
|
window.removeEventListener('sqb-check-active', onCheckActive);
|
|
467
902
|
};
|
|
468
903
|
}, []);
|
|
469
|
-
// 添加
|
|
470
904
|
var addOperator = function addOperator(type, index, position) {
|
|
471
905
|
var _caseList = caseList.slice() || [];
|
|
472
906
|
var _ind = index;
|
|
@@ -486,14 +920,59 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
486
920
|
_caseList.splice(index + 1, 0, temItem);
|
|
487
921
|
_ind = index + 1;
|
|
488
922
|
} else {
|
|
489
|
-
//替换
|
|
490
923
|
_caseList.splice(index, 1, temItem);
|
|
491
924
|
_ind = index;
|
|
492
925
|
}
|
|
493
926
|
setCaseList(_caseList);
|
|
494
927
|
return _ind < 0 ? 0 : _ind;
|
|
495
928
|
};
|
|
496
|
-
|
|
929
|
+
var getItemNameProps = function getItemNameProps(v) {
|
|
930
|
+
if (v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.EXISTS) {
|
|
931
|
+
return {
|
|
932
|
+
isError: isExistsError(v.notExists, store.existsError)
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
if (v.type === AtomsTypeEnum.SUB_QUERY) {
|
|
936
|
+
return {
|
|
937
|
+
isError: isExistsError(v.subQuery, store.existsError)
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
if (v.type === AtomsTypeEnum.FIELD) {
|
|
941
|
+
return {
|
|
942
|
+
isError: isError(v, data)
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
if (v.type === AtomsTypeEnum.CONSTANT) {
|
|
946
|
+
return {
|
|
947
|
+
isError: !!(v.id || v.val) && !getConstantLabel(store.constantList, v.id || v.val),
|
|
948
|
+
message: '常量丢失'
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
if (otherTypeMap.has(String(v.type))) {
|
|
952
|
+
var currentOtherType = otherTypeMap.get(String(v.type));
|
|
953
|
+
var listSource = (currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.list) || [];
|
|
954
|
+
return {
|
|
955
|
+
isError: !!(v.id || v.val) && !getConstantLabel(listSource, v.id || v.val),
|
|
956
|
+
message: "".concat(currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.label, "\u4E22\u5931")
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
if (v.type === AtomsTypeEnum.EXPRESSION) {
|
|
960
|
+
return {
|
|
961
|
+
isError: isError(v, data)
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
if (v.type === AtomsTypeEnum.FORMULA) {
|
|
965
|
+
var formulaMissing = formulaIsError(v, formulaList);
|
|
966
|
+
return {
|
|
967
|
+
isError: isError(v, data) || formulaMissing,
|
|
968
|
+
message: formulaMissing ? '公式丢失' : ''
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
return {
|
|
972
|
+
isError: false,
|
|
973
|
+
message: ''
|
|
974
|
+
};
|
|
975
|
+
};
|
|
497
976
|
var showNotExists = function showNotExists(i) {
|
|
498
977
|
var _caseList$i, _caseList$i2;
|
|
499
978
|
var _store$preProps = store.preProps,
|
|
@@ -502,23 +981,22 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
502
981
|
other = _objectWithoutProperties(_store$preProps, _excluded);
|
|
503
982
|
var _value = ((_caseList$i = caseList[i]) === null || _caseList$i === void 0 ? void 0 : _caseList$i.notExists) || [];
|
|
504
983
|
var oldList = cloneDeep(((_caseList$i2 = caseList[i]) === null || _caseList$i2 === void 0 ? void 0 : _caseList$i2.notExists) || []);
|
|
984
|
+
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
505
985
|
var _toolbar = notExistsToolbar || toolbar;
|
|
506
|
-
|
|
507
|
-
|
|
986
|
+
var o = openChildModal({
|
|
987
|
+
zIndex: childModalZIndex,
|
|
508
988
|
title: caseList[i].type,
|
|
509
|
-
transparentMask:
|
|
989
|
+
transparentMask: false,
|
|
510
990
|
content: _jsx(_Fragment, {
|
|
511
991
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
992
|
+
popupZIndex: childModalZIndex + 1,
|
|
512
993
|
notExistsColumns: exitData,
|
|
513
|
-
// showFields={false}
|
|
514
994
|
isExit: true,
|
|
515
|
-
// showSubquery={subShowSubquery}
|
|
516
995
|
toolbar: _toolbar,
|
|
517
996
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
518
997
|
value: cloneDeep(_value),
|
|
519
998
|
onOk: function onOk(newList) {
|
|
520
999
|
try {
|
|
521
|
-
// 子查询未改变不做操作
|
|
522
1000
|
if (isEqual(newList, oldList)) {
|
|
523
1001
|
o.close();
|
|
524
1002
|
return;
|
|
@@ -532,18 +1010,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
532
1010
|
onChange === null || onChange === void 0 || onChange(caseList, '');
|
|
533
1011
|
setCaseList(_toConsumableArray(caseList));
|
|
534
1012
|
o.close();
|
|
535
|
-
} catch (e) {
|
|
536
|
-
console.warn(e);
|
|
537
|
-
} finally {
|
|
1013
|
+
} catch (e) {} finally {
|
|
538
1014
|
o.close();
|
|
539
1015
|
}
|
|
540
1016
|
}
|
|
541
1017
|
}))
|
|
542
|
-
})
|
|
543
|
-
onClose: function onClose() {}
|
|
1018
|
+
})
|
|
544
1019
|
});
|
|
545
1020
|
};
|
|
546
|
-
// 子查询 窗口
|
|
547
1021
|
var showSubQuery = function showSubQuery(i) {
|
|
548
1022
|
var _caseList$i3, _caseList$i4;
|
|
549
1023
|
var _store$preProps2 = store.preProps,
|
|
@@ -555,12 +1029,15 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
555
1029
|
other = _objectWithoutProperties(_store$preProps2, _excluded2);
|
|
556
1030
|
var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
|
|
557
1031
|
var oldList = cloneDeep(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
|
|
1032
|
+
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
558
1033
|
var _toolbar = subToolbar || toolbar;
|
|
559
|
-
var o =
|
|
1034
|
+
var o = openChildModal({
|
|
1035
|
+
zIndex: childModalZIndex,
|
|
560
1036
|
title: __('SqlQueryBuilder.subquery'),
|
|
561
|
-
transparentMask:
|
|
1037
|
+
transparentMask: false,
|
|
562
1038
|
content: _jsx(_Fragment, {
|
|
563
1039
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
1040
|
+
popupZIndex: childModalZIndex + 1,
|
|
564
1041
|
isExit: true,
|
|
565
1042
|
isSubquery: true,
|
|
566
1043
|
notExistsColumns: exitData,
|
|
@@ -570,7 +1047,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
570
1047
|
value: cloneDeep(_value),
|
|
571
1048
|
onOk: function onOk(newList) {
|
|
572
1049
|
try {
|
|
573
|
-
// 子查询未改变不做操作
|
|
574
1050
|
if (isEqual(newList, oldList)) {
|
|
575
1051
|
o.close();
|
|
576
1052
|
return;
|
|
@@ -584,15 +1060,12 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
584
1060
|
onChange === null || onChange === void 0 || onChange(caseList, '');
|
|
585
1061
|
setCaseList(_toConsumableArray(caseList));
|
|
586
1062
|
o.close();
|
|
587
|
-
} catch (e) {
|
|
588
|
-
console.warn(e);
|
|
589
|
-
} finally {
|
|
1063
|
+
} catch (e) {} finally {
|
|
590
1064
|
o.close();
|
|
591
1065
|
}
|
|
592
1066
|
}
|
|
593
1067
|
}))
|
|
594
|
-
})
|
|
595
|
-
onClose: function onClose() {}
|
|
1068
|
+
})
|
|
596
1069
|
});
|
|
597
1070
|
};
|
|
598
1071
|
function selectConstant(e) {
|
|
@@ -617,7 +1090,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
617
1090
|
})
|
|
618
1091
|
});
|
|
619
1092
|
}
|
|
620
|
-
// 函数弹窗
|
|
621
1093
|
var showFunction = function showFunction(e, i) {
|
|
622
1094
|
var _value = caseList[i];
|
|
623
1095
|
var o = Modal2.openModal({
|
|
@@ -654,317 +1126,275 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
654
1126
|
onClose: function onClose() {}
|
|
655
1127
|
});
|
|
656
1128
|
};
|
|
657
|
-
|
|
658
|
-
var itemDom = function itemDom(v, index) {
|
|
1129
|
+
var itemDom = function itemDom(v, index, groupType) {
|
|
659
1130
|
var type = v.type;
|
|
660
1131
|
if (v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.EXISTS) {
|
|
661
|
-
return
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
1132
|
+
return {
|
|
1133
|
+
className: 'purple-name',
|
|
1134
|
+
onClick: function onClick() {
|
|
1135
|
+
return showNotExists(index);
|
|
1136
|
+
},
|
|
1137
|
+
node: _jsxs(_Fragment, {
|
|
1138
|
+
children: [v.type, " ( * )", renderDeleteIcon(v, index, groupType)]
|
|
1139
|
+
})
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
if (v.type === AtomsTypeEnum.SUB_QUERY) {
|
|
1143
|
+
return {
|
|
1144
|
+
className: 'purple-name',
|
|
1145
|
+
onClick: function onClick() {
|
|
1146
|
+
return showSubQuery(index);
|
|
1147
|
+
},
|
|
1148
|
+
node: _jsxs(_Fragment, {
|
|
1149
|
+
children: [v.label || __('SqlQueryBuilder.subquery'), renderDeleteIcon(v, index, groupType)]
|
|
1150
|
+
})
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
if (type === AtomsTypeEnum.FIELD) {
|
|
1154
|
+
return {
|
|
1155
|
+
className: cx({
|
|
1156
|
+
notSelected: !(v !== null && v !== void 0 && v.fieldName)
|
|
1157
|
+
}),
|
|
1158
|
+
onClick: function onClick(e) {
|
|
1159
|
+
return handleField(e, index, v);
|
|
1160
|
+
},
|
|
1161
|
+
node: _jsxs(_Fragment, {
|
|
1162
|
+
children: [!(v !== null && v !== void 0 && v.fieldName) && __('customColumn.selectField'), v.fieldName, renderDeleteIcon(v, index, groupType)]
|
|
1163
|
+
})
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
if (type === AtomsTypeEnum.INPUT_STRING) {
|
|
1167
|
+
return {
|
|
1168
|
+
className: 'notSelected',
|
|
1169
|
+
node: _jsxs(_Fragment, {
|
|
1170
|
+
children: [_jsx(FieldString, {}), _jsx(Input, {
|
|
1171
|
+
className: ':sqb-Custom-input',
|
|
1172
|
+
value: v.val,
|
|
1173
|
+
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
1174
|
+
size: 'large',
|
|
1175
|
+
onChange: function onChange(val) {
|
|
1176
|
+
handleConstant(val, index);
|
|
1177
|
+
}
|
|
1178
|
+
}), renderDeleteIcon(v, index, groupType)]
|
|
1179
|
+
})
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
if (type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
1183
|
+
return {
|
|
1184
|
+
className: 'notSelected',
|
|
1185
|
+
node: _jsxs(_Fragment, {
|
|
1186
|
+
children: [_jsx(FieldNumber, {}), _jsx(InputNumber, {
|
|
1187
|
+
className: ':sqb-Custom-input',
|
|
1188
|
+
value: v.val,
|
|
1189
|
+
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
1190
|
+
size: 'large',
|
|
1191
|
+
onChange: function onChange(val) {
|
|
1192
|
+
handleConstant(val, index);
|
|
1193
|
+
}
|
|
1194
|
+
}), renderDeleteIcon(v, index, groupType)]
|
|
1195
|
+
})
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
if (type === AtomsTypeEnum.OPERATOR) {
|
|
1199
|
+
if (isFixedCaseOperator(v)) {
|
|
1200
|
+
return {
|
|
1201
|
+
raw: true,
|
|
1202
|
+
node: _jsx("span", {
|
|
1203
|
+
className: 'Sqb-CaseKeyword',
|
|
1204
|
+
children: v.val
|
|
1205
|
+
})
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
if (groupType === 'logic' && isFixedLogicOperator(v)) {
|
|
1209
|
+
return {
|
|
1210
|
+
raw: true,
|
|
1211
|
+
node: _jsx("span", {
|
|
1212
|
+
className: 'Sqb-CaseKeyword',
|
|
1213
|
+
children: v.val
|
|
1214
|
+
})
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
if (groupType === 'logic' && ['and', 'or'].includes(v.val)) {
|
|
1218
|
+
var nextLogicOperator = v.val === 'and' ? 'or' : 'and';
|
|
1219
|
+
return {
|
|
1220
|
+
className: cx({
|
|
1221
|
+
'logic-operator': true,
|
|
1222
|
+
'logic-and': v.val === 'and',
|
|
1223
|
+
'logic-or': v.val === 'or'
|
|
707
1224
|
}),
|
|
708
|
-
onClick: function onClick(
|
|
709
|
-
|
|
1225
|
+
onClick: function onClick() {
|
|
1226
|
+
handleConstant(nextLogicOperator, index);
|
|
710
1227
|
},
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
})
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
// 输入框
|
|
725
|
-
return _jsxs("div", {
|
|
726
|
-
className: cx("Sqb-TableName notSelected "),
|
|
727
|
-
children: [_jsx(FieldString, {}), _jsx(Input, {
|
|
728
|
-
className: ':Sqb-Custom-input',
|
|
1228
|
+
node: renderTokenContent(v.val)
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
className: cx('operator-trigger', {
|
|
1233
|
+
notSelected: !v.val,
|
|
1234
|
+
'flow-operator': ['case', 'when', 'then', 'else', 'end'].includes(v.val),
|
|
1235
|
+
'logic-operator': ['and', 'or'].includes(v.val),
|
|
1236
|
+
'logic-and': v.val === 'and',
|
|
1237
|
+
'logic-or': v.val === 'or'
|
|
1238
|
+
}),
|
|
1239
|
+
node: _jsx(Select, {
|
|
1240
|
+
triggerProps: getSelectTriggerProps(),
|
|
729
1241
|
value: v.val,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
}
|
|
735
|
-
}), _jsx("span", {
|
|
736
|
-
className: 'item-del',
|
|
737
|
-
style: {
|
|
738
|
-
fontSize: 0
|
|
739
|
-
},
|
|
740
|
-
onClick: function onClick(e) {
|
|
741
|
-
return handleDel(e, index);
|
|
1242
|
+
triggerElement: function triggerElement() {
|
|
1243
|
+
return renderTokenContent(_jsxs(_Fragment, {
|
|
1244
|
+
children: [!v.val && __('customColumn.selectOperator'), v.val, renderDeleteIcon(v, index)]
|
|
1245
|
+
}));
|
|
742
1246
|
},
|
|
743
|
-
children: _jsx(CloseIcon, {})
|
|
744
|
-
})]
|
|
745
|
-
});
|
|
746
|
-
} else if (type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
747
|
-
// 输入框
|
|
748
|
-
return _jsxs("div", {
|
|
749
|
-
className: cx("Sqb-TableName notSelected "),
|
|
750
|
-
children: [_jsx(FieldNumber, {}), _jsx(InputNumber, {
|
|
751
|
-
className: ':sqb-Custom-input',
|
|
752
|
-
value: v.val,
|
|
753
|
-
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
754
|
-
size: 'large',
|
|
755
1247
|
onChange: function onChange(val) {
|
|
756
1248
|
handleConstant(val, index);
|
|
757
|
-
}
|
|
758
|
-
}), _jsx("span", {
|
|
759
|
-
className: 'item-del',
|
|
760
|
-
style: {
|
|
761
|
-
fontSize: 0
|
|
762
|
-
},
|
|
763
|
-
onClick: function onClick(e) {
|
|
764
|
-
return handleDel(e, index);
|
|
765
1249
|
},
|
|
766
|
-
children:
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
triggerProps: {
|
|
773
|
-
clickToClose: true
|
|
774
|
-
},
|
|
775
|
-
value: v.val,
|
|
776
|
-
triggerElement: function triggerElement(value) {
|
|
777
|
-
return _jsxs("div", {
|
|
778
|
-
className: cx("Sqb-TableName Sqb-TableName-OPERATOR", {
|
|
779
|
-
notSelected: !v.val
|
|
780
|
-
}),
|
|
781
|
-
children: [!v.val && __('customColumn.selectOperator'), v.val, _jsx("span", {
|
|
782
|
-
className: 'item-del',
|
|
783
|
-
style: {
|
|
784
|
-
fontSize: 0
|
|
785
|
-
},
|
|
786
|
-
onClick: function onClick(e) {
|
|
787
|
-
return handleDel(e, index);
|
|
788
|
-
},
|
|
789
|
-
children: _jsx(CloseIcon, {})
|
|
790
|
-
})]
|
|
791
|
-
});
|
|
792
|
-
},
|
|
793
|
-
onChange: function onChange(val) {
|
|
794
|
-
handleConstant(val, index);
|
|
795
|
-
},
|
|
796
|
-
children: operatorList.map(function (option, index) {
|
|
797
|
-
return _jsx(Select.Option, {
|
|
798
|
-
value: option,
|
|
799
|
-
children: option
|
|
800
|
-
}, index + '' + ind);
|
|
1250
|
+
children: operatorList.map(function (option, optionIndex) {
|
|
1251
|
+
return _jsx(Select.Option, {
|
|
1252
|
+
value: option,
|
|
1253
|
+
children: option
|
|
1254
|
+
}, optionIndex + '' + ind);
|
|
1255
|
+
})
|
|
801
1256
|
})
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
return
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
children: [getConstantLabel(store.constantList, v.id || v.val, v.val) || __('SqlQueryBuilder.pickConstant'),
|
|
816
|
-
className: 'item-del',
|
|
817
|
-
style: {
|
|
818
|
-
fontSize: 0
|
|
819
|
-
},
|
|
820
|
-
onClick: function onClick(e) {
|
|
821
|
-
return handleDel(e, index);
|
|
822
|
-
},
|
|
823
|
-
children: _jsx(CloseIcon, {})
|
|
824
|
-
})]
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
if (type === AtomsTypeEnum.CONSTANT) {
|
|
1260
|
+
return {
|
|
1261
|
+
className: cx({
|
|
1262
|
+
notSelected: !v.val
|
|
1263
|
+
}),
|
|
1264
|
+
attrs: {
|
|
1265
|
+
'v-index': index,
|
|
1266
|
+
'v-val': v.id || v.val
|
|
1267
|
+
},
|
|
1268
|
+
onClick: selectConstant,
|
|
1269
|
+
node: _jsxs(_Fragment, {
|
|
1270
|
+
children: [getConstantLabel(store.constantList, v.id || v.val, v.val) || __('SqlQueryBuilder.pickConstant'), renderDeleteIcon(v, index, groupType)]
|
|
825
1271
|
})
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
if (otherTypeMap.has(String(type))) {
|
|
829
1275
|
var currentOtherType = otherTypeMap.get(String(type));
|
|
830
1276
|
var listSource = (currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.list) || [];
|
|
831
|
-
return
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
children: [getConstantLabel(listSource, v.id || v.val, v.val) || "\u8BF7\u9009\u62E9".concat(currentOtherType.label),
|
|
843
|
-
className: 'item-del',
|
|
844
|
-
style: {
|
|
845
|
-
fontSize: 0
|
|
846
|
-
},
|
|
847
|
-
onClick: function onClick(e) {
|
|
848
|
-
return handleDel(e, index);
|
|
849
|
-
},
|
|
850
|
-
children: _jsx(CloseIcon, {})
|
|
851
|
-
})]
|
|
1277
|
+
return {
|
|
1278
|
+
className: cx({
|
|
1279
|
+
notSelected: !v.val
|
|
1280
|
+
}),
|
|
1281
|
+
attrs: {
|
|
1282
|
+
'v-index': index,
|
|
1283
|
+
'v-val': v.id || v.val,
|
|
1284
|
+
'v-type': type
|
|
1285
|
+
},
|
|
1286
|
+
onClick: selectConstant,
|
|
1287
|
+
node: _jsxs(_Fragment, {
|
|
1288
|
+
children: [getConstantLabel(listSource, v.id || v.val, v.val) || "\u8BF7\u9009\u62E9".concat(currentOtherType.label), renderDeleteIcon(v, index, groupType)]
|
|
852
1289
|
})
|
|
853
|
-
}
|
|
854
|
-
}
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
if (type === AtomsTypeEnum.EXPRESSION) {
|
|
855
1293
|
if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
856
|
-
var
|
|
857
|
-
var
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
setCaseList(
|
|
1294
|
+
var _nextList$index$quote;
|
|
1295
|
+
var nextList = caseList.slice();
|
|
1296
|
+
nextList[index].rhs = [nextList[index].rhs[0]];
|
|
1297
|
+
nextList[index].quotes = (_nextList$index$quote = nextList[index].quotes.split(' || ')) === null || _nextList$index$quote === void 0 ? void 0 : _nextList$index$quote[0];
|
|
1298
|
+
setCaseList(nextList);
|
|
861
1299
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
},
|
|
872
|
-
children: [v.quotes ? v.quotes : __('customColumn.selectExpression'), _jsx("span", {
|
|
873
|
-
className: 'item-del',
|
|
874
|
-
style: {
|
|
875
|
-
fontSize: 0
|
|
876
|
-
},
|
|
877
|
-
onClick: function onClick(e) {
|
|
878
|
-
return handleDel(e, index);
|
|
879
|
-
},
|
|
880
|
-
children: _jsx(CloseIcon, {})
|
|
881
|
-
})]
|
|
1300
|
+
return {
|
|
1301
|
+
className: cx('purple-name', {
|
|
1302
|
+
notSelected: !v.quotes
|
|
1303
|
+
}),
|
|
1304
|
+
onClick: function onClick(e) {
|
|
1305
|
+
return handleExpression(e, index, v);
|
|
1306
|
+
},
|
|
1307
|
+
node: _jsxs(_Fragment, {
|
|
1308
|
+
children: [v.quotes ? v.quotes : __('customColumn.selectExpression'), renderDeleteIcon(v, index, groupType)]
|
|
882
1309
|
})
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
return
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
if (type === AtomsTypeEnum.CASE_WHEN) {
|
|
1313
|
+
return {
|
|
1314
|
+
raw: true,
|
|
1315
|
+
node: renderCaseWhenEditor(v, index)
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
if (type === AtomsTypeEnum.AND_OR) {
|
|
1319
|
+
return {
|
|
1320
|
+
raw: true,
|
|
1321
|
+
node: renderAndOrEditor(v, index)
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
if (type === AtomsTypeEnum.FORMULA) {
|
|
1325
|
+
return {
|
|
1326
|
+
className: 'gray-name',
|
|
1327
|
+
onClick: function onClick(e) {
|
|
1328
|
+
return showFunction(e, index);
|
|
1329
|
+
},
|
|
1330
|
+
node: _jsxs(_Fragment, {
|
|
1331
|
+
children: [v.name ? getQuotes(v, v.args, formulaList) : __('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
|
|
1332
|
+
})
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
if (type === AtomsTypeEnum.SELECT) {
|
|
1336
|
+
return {
|
|
1337
|
+
className: cx('operator-trigger', {
|
|
1338
|
+
notSelected: !v.val,
|
|
1339
|
+
'flow-operator': v.val === 'caseWhen',
|
|
1340
|
+
'logic-operator': v.val === 'andOr'
|
|
1341
|
+
}),
|
|
1342
|
+
node: _jsx(Select, {
|
|
1343
|
+
triggerProps: getSelectTriggerProps(),
|
|
1344
|
+
multiple: v.multiple,
|
|
1345
|
+
value: v.val,
|
|
1346
|
+
triggerElement: function triggerElement() {
|
|
1347
|
+
return renderTokenContent(_jsxs(_Fragment, {
|
|
1348
|
+
children: [!v.val && __('customColumn.selectOperator'), v.val, !v.fixed && renderDeleteIcon(v, index, groupType)]
|
|
1349
|
+
}));
|
|
893
1350
|
},
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
},
|
|
902
|
-
|
|
903
|
-
})]
|
|
1351
|
+
onChange: function onChange(val) {
|
|
1352
|
+
handleConstant(val, index);
|
|
1353
|
+
},
|
|
1354
|
+
children: v.options.map(function (option, optionIndex) {
|
|
1355
|
+
return _jsx(Select.Option, {
|
|
1356
|
+
value: option.value,
|
|
1357
|
+
children: option.label
|
|
1358
|
+
}, optionIndex + '' + ind);
|
|
1359
|
+
})
|
|
904
1360
|
})
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
return
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
value: v.val,
|
|
914
|
-
triggerElement: function triggerElement(value) {
|
|
915
|
-
return _jsxs("div", {
|
|
916
|
-
className: cx("Sqb-TableName Sqb-TableName-OPERATOR", {
|
|
917
|
-
notSelected: !v.val
|
|
918
|
-
}),
|
|
919
|
-
children: [!v.val && __('customColumn.selectOperator'), v.val, !v.fixed && _jsx("span", {
|
|
920
|
-
className: 'item-del',
|
|
921
|
-
style: {
|
|
922
|
-
fontSize: 0
|
|
923
|
-
},
|
|
924
|
-
onClick: function onClick(e) {
|
|
925
|
-
return handleDel(e, index);
|
|
926
|
-
},
|
|
927
|
-
children: _jsx(CloseIcon, {})
|
|
928
|
-
})]
|
|
929
|
-
});
|
|
930
|
-
},
|
|
931
|
-
onChange: function onChange(val) {
|
|
932
|
-
handleConstant(val, index);
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
if (groupType === 'logic') {
|
|
1364
|
+
return {
|
|
1365
|
+
className: cx('gray-name', 'notSelected'),
|
|
1366
|
+
style: {
|
|
1367
|
+
minWidth: 44,
|
|
1368
|
+
justifyContent: 'center'
|
|
933
1369
|
},
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1370
|
+
node: selectOperator({
|
|
1371
|
+
triggerElement: function triggerElement() {
|
|
1372
|
+
return renderTokenContent(_jsx(AddIcon, {}));
|
|
1373
|
+
},
|
|
1374
|
+
ind: index,
|
|
1375
|
+
position: ''
|
|
939
1376
|
})
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
return {
|
|
1380
|
+
className: cx({
|
|
1381
|
+
notSelected: true
|
|
1382
|
+
}),
|
|
1383
|
+
node: selectOperator({
|
|
943
1384
|
triggerElement: function triggerElement() {
|
|
944
|
-
return _jsxs(
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
}),
|
|
948
|
-
children: [__('customColumn.selectCustomInput'), _jsx("span", {
|
|
949
|
-
className: 'item-del',
|
|
950
|
-
style: {
|
|
951
|
-
fontSize: 0
|
|
952
|
-
},
|
|
953
|
-
onClick: function onClick(e) {
|
|
954
|
-
return handleDel(e, index);
|
|
955
|
-
},
|
|
956
|
-
children: _jsx(CloseIcon, {})
|
|
957
|
-
})]
|
|
958
|
-
});
|
|
1385
|
+
return renderTokenContent(_jsxs(_Fragment, {
|
|
1386
|
+
children: [__('customColumn.selectCustomInput'), renderDeleteIcon(v, index, groupType)]
|
|
1387
|
+
}));
|
|
959
1388
|
},
|
|
960
1389
|
ind: index,
|
|
961
1390
|
position: ''
|
|
962
|
-
})
|
|
963
|
-
}
|
|
1391
|
+
})
|
|
1392
|
+
};
|
|
964
1393
|
};
|
|
965
1394
|
var copyDom = function copyDom() {
|
|
966
1395
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
967
1396
|
var positioned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1397
|
+
if (embedded) return null;
|
|
968
1398
|
if (!isCopy || selectedIndices.length === 0 && checkedItemsCount === 0) return null;
|
|
969
1399
|
return _jsx("div", {
|
|
970
1400
|
className: cx('Sqb-Filter-item-copy', {
|
|
@@ -992,10 +1422,147 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
992
1422
|
})
|
|
993
1423
|
});
|
|
994
1424
|
};
|
|
1425
|
+
var renderItemShell = function renderItemShell(v, i, groupType, extraClassName) {
|
|
1426
|
+
var showCheckbox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1427
|
+
var itemContent = itemDom(v, i, groupType);
|
|
1428
|
+
var isCompositeAtom = v.type === AtomsTypeEnum.CASE_WHEN || v.type === AtomsTypeEnum.AND_OR;
|
|
1429
|
+
var isPassiveCaseKeyword = groupType === 'caseWhen' && isFixedCaseOperator(v) || groupType === 'logic' && isFixedLogicOperator(v);
|
|
1430
|
+
return _jsx(React.Fragment, {
|
|
1431
|
+
children: _jsxs("div", {
|
|
1432
|
+
className: cx('Sqb-Filter-item', _defineProperty({
|
|
1433
|
+
hover: ind === i && hoveredCopyIndex !== i,
|
|
1434
|
+
'item-fixed': v.fixed || false,
|
|
1435
|
+
'item-selected': isCheck,
|
|
1436
|
+
'item-composite': isCompositeAtom,
|
|
1437
|
+
'group-child': groupType !== 'single',
|
|
1438
|
+
'group-flow-child': groupType === 'caseWhen',
|
|
1439
|
+
'group-logic-child': groupType === 'logic'
|
|
1440
|
+
}, extraClassName || '', !!extraClassName)),
|
|
1441
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
1442
|
+
if (isCheck || isPassiveCaseKeyword) return;
|
|
1443
|
+
setInd(i);
|
|
1444
|
+
},
|
|
1445
|
+
onMouseLeave: function onMouseLeave() {
|
|
1446
|
+
if (isCheck || isPassiveCaseKeyword) return;
|
|
1447
|
+
setInd(-1);
|
|
1448
|
+
},
|
|
1449
|
+
children: [copyDom(i), canShowInsertArrows(v, groupType) && selectOperator({
|
|
1450
|
+
triggerElement: function triggerElement() {
|
|
1451
|
+
return _jsx("div", {
|
|
1452
|
+
className: 'left-arrow',
|
|
1453
|
+
"v-index": i,
|
|
1454
|
+
"v-type": 'before',
|
|
1455
|
+
onClick: function onClick() {
|
|
1456
|
+
if (!selectedIndices.length) addOperator(AtomsTypeEnum.UNKNOWN, i, 'before');
|
|
1457
|
+
},
|
|
1458
|
+
children: _jsx("img", {
|
|
1459
|
+
src: arrow
|
|
1460
|
+
})
|
|
1461
|
+
});
|
|
1462
|
+
},
|
|
1463
|
+
ind: i,
|
|
1464
|
+
position: 'before',
|
|
1465
|
+
trigger: 'hover'
|
|
1466
|
+
}), !embedded && showCheckbox && v.type !== AtomsTypeEnum.UNKNOWN && _jsx(Checkbox, {
|
|
1467
|
+
className: 'item-check',
|
|
1468
|
+
checked: selectedIndices.includes(i),
|
|
1469
|
+
disabled: globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
|
|
1470
|
+
onChange: function onChange(e) {
|
|
1471
|
+
var _e$target$checked, _e$target;
|
|
1472
|
+
return toggleSelect(i, (_e$target$checked = e === null || e === void 0 || (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.checked) !== null && _e$target$checked !== void 0 ? _e$target$checked : !selectedIndices.includes(i));
|
|
1473
|
+
}
|
|
1474
|
+
}), _jsx("div", {
|
|
1475
|
+
style: {
|
|
1476
|
+
pointerEvents: isCheck || store.isMetabaseCopy ? 'none' : 'auto'
|
|
1477
|
+
},
|
|
1478
|
+
className: cx({
|
|
1479
|
+
openCheck: isCheck
|
|
1480
|
+
}),
|
|
1481
|
+
children: _jsx(ItemName, _objectSpread(_objectSpread({}, getItemNameProps(v)), {}, {
|
|
1482
|
+
children: itemContent.raw ? itemContent.node : _jsx("div", _objectSpread(_objectSpread({
|
|
1483
|
+
className: cx('Sqb-TableName', itemContent.className),
|
|
1484
|
+
onClick: itemContent.onClick,
|
|
1485
|
+
style: itemContent.style
|
|
1486
|
+
}, itemContent.attrs || {}), {}, {
|
|
1487
|
+
children: itemContent.node
|
|
1488
|
+
}))
|
|
1489
|
+
}))
|
|
1490
|
+
}), canShowInsertArrows(v, groupType) && selectOperator({
|
|
1491
|
+
triggerElement: function triggerElement(value) {
|
|
1492
|
+
return _jsx("div", {
|
|
1493
|
+
className: 'right-arrow',
|
|
1494
|
+
"v-index": i,
|
|
1495
|
+
"v-type": 'after',
|
|
1496
|
+
onClick: function onClick() {
|
|
1497
|
+
addOperator(AtomsTypeEnum.UNKNOWN, i, 'after');
|
|
1498
|
+
},
|
|
1499
|
+
children: _jsx("img", {
|
|
1500
|
+
src: arrow
|
|
1501
|
+
})
|
|
1502
|
+
});
|
|
1503
|
+
},
|
|
1504
|
+
ind: i,
|
|
1505
|
+
position: 'after',
|
|
1506
|
+
trigger: 'hover'
|
|
1507
|
+
})]
|
|
1508
|
+
})
|
|
1509
|
+
}, i);
|
|
1510
|
+
};
|
|
1511
|
+
var renderCaseSection = function renderCaseSection(itemIndices, groupType, sectionClassName) {
|
|
1512
|
+
return itemIndices.map(function (itemIndex) {
|
|
1513
|
+
return renderItemShell(caseList[itemIndex], itemIndex, groupType, "case-row-item ".concat(sectionClassName), false);
|
|
1514
|
+
});
|
|
1515
|
+
};
|
|
1516
|
+
var renderDeleteIcon = function renderDeleteIcon(item, index, groupType) {
|
|
1517
|
+
if (!canDeleteItem(item, groupType)) return null;
|
|
1518
|
+
return _jsx("span", {
|
|
1519
|
+
className: 'item-del',
|
|
1520
|
+
style: {
|
|
1521
|
+
fontSize: 0
|
|
1522
|
+
},
|
|
1523
|
+
onClick: function onClick(e) {
|
|
1524
|
+
return handleDel(e, index);
|
|
1525
|
+
},
|
|
1526
|
+
children: _jsx(CloseIcon, {})
|
|
1527
|
+
});
|
|
1528
|
+
};
|
|
1529
|
+
var renderCaseRecoverButton = function renderCaseRecoverButton(onClick, className, label) {
|
|
1530
|
+
return _jsxs("button", {
|
|
1531
|
+
type: 'button',
|
|
1532
|
+
className: cx('Sqb-CaseRecover', className),
|
|
1533
|
+
onClick: onClick,
|
|
1534
|
+
children: [_jsx(FfPlus, {}), _jsx("span", {
|
|
1535
|
+
children: label
|
|
1536
|
+
})]
|
|
1537
|
+
});
|
|
1538
|
+
};
|
|
1539
|
+
var renderGroupInsertArrow = function renderGroupInsertArrow(index, position) {
|
|
1540
|
+
return selectOperator({
|
|
1541
|
+
triggerElement: function triggerElement() {
|
|
1542
|
+
return _jsx("div", {
|
|
1543
|
+
className: position === 'before' ? 'left-arrow' : 'right-arrow',
|
|
1544
|
+
"v-index": index,
|
|
1545
|
+
"v-type": position,
|
|
1546
|
+
onClick: function onClick() {
|
|
1547
|
+
if (position === 'before' && selectedIndices.length) return;
|
|
1548
|
+
addOperator(AtomsTypeEnum.UNKNOWN, index, position);
|
|
1549
|
+
},
|
|
1550
|
+
children: _jsx("img", {
|
|
1551
|
+
src: arrow
|
|
1552
|
+
})
|
|
1553
|
+
});
|
|
1554
|
+
},
|
|
1555
|
+
ind: index,
|
|
1556
|
+
position: position,
|
|
1557
|
+
trigger: 'hover'
|
|
1558
|
+
});
|
|
1559
|
+
};
|
|
995
1560
|
return _jsx(_Fragment, {
|
|
996
1561
|
children: _jsxs("div", {
|
|
997
|
-
className:
|
|
998
|
-
|
|
1562
|
+
className: cx('Sqb-NotebookCell', {
|
|
1563
|
+
'Sqb-NotebookCell--embedded': embedded
|
|
1564
|
+
}),
|
|
1565
|
+
children: [!embedded && isCopy && caseList.length > 0 && _jsxs(Space, {
|
|
999
1566
|
size: 'small',
|
|
1000
1567
|
direction: 'vertical',
|
|
1001
1568
|
className: cx('item-isCheck', {
|
|
@@ -1034,75 +1601,8 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1034
1601
|
},
|
|
1035
1602
|
children: "\u6E05\u9664\u590D\u5236"
|
|
1036
1603
|
})]
|
|
1037
|
-
}),
|
|
1038
|
-
return
|
|
1039
|
-
children: _jsxs("div", {
|
|
1040
|
-
className: cx('Sqb-Filter-item', {
|
|
1041
|
-
hover: ind === i && hoveredCopyIndex !== i,
|
|
1042
|
-
'item-fixed': v.fixed || false,
|
|
1043
|
-
'item-selected': isCheck
|
|
1044
|
-
}),
|
|
1045
|
-
onMouseEnter: function onMouseEnter(e) {
|
|
1046
|
-
if (isCheck) return;
|
|
1047
|
-
setInd(i);
|
|
1048
|
-
},
|
|
1049
|
-
onMouseLeave: function onMouseLeave() {
|
|
1050
|
-
if (isCheck) return;
|
|
1051
|
-
setInd(-1);
|
|
1052
|
-
},
|
|
1053
|
-
children: [copyDom(i), selectOperator({
|
|
1054
|
-
triggerElement: function triggerElement() {
|
|
1055
|
-
return _jsx("div", {
|
|
1056
|
-
className: 'left-arrow',
|
|
1057
|
-
"v-index": i,
|
|
1058
|
-
"v-type": 'before',
|
|
1059
|
-
onClick: function onClick() {
|
|
1060
|
-
if (!selectedIndices.length) addOperator(AtomsTypeEnum.UNKNOWN, i, 'before');
|
|
1061
|
-
},
|
|
1062
|
-
children: _jsx("img", {
|
|
1063
|
-
src: arrow
|
|
1064
|
-
})
|
|
1065
|
-
});
|
|
1066
|
-
},
|
|
1067
|
-
ind: i,
|
|
1068
|
-
position: 'before',
|
|
1069
|
-
trigger: 'hover'
|
|
1070
|
-
}), v.type !== AtomsTypeEnum.UNKNOWN && _jsx(Checkbox, {
|
|
1071
|
-
className: 'item-check',
|
|
1072
|
-
checked: selectedIndices.includes(i),
|
|
1073
|
-
disabled: globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
|
|
1074
|
-
onChange: function onChange(e) {
|
|
1075
|
-
var _e$target$checked, _e$target;
|
|
1076
|
-
return toggleSelect(i, (_e$target$checked = e === null || e === void 0 || (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.checked) !== null && _e$target$checked !== void 0 ? _e$target$checked : !selectedIndices.includes(i));
|
|
1077
|
-
}
|
|
1078
|
-
}), _jsx("div", {
|
|
1079
|
-
style: {
|
|
1080
|
-
pointerEvents: isCheck || store.isMetabaseCopy ? 'none' : 'auto'
|
|
1081
|
-
},
|
|
1082
|
-
className: cx('Sqb-Filter-item-content', {
|
|
1083
|
-
openCheck: isCheck
|
|
1084
|
-
}),
|
|
1085
|
-
children: itemDom(v, i)
|
|
1086
|
-
}), selectOperator({
|
|
1087
|
-
triggerElement: function triggerElement(value) {
|
|
1088
|
-
return _jsx("div", {
|
|
1089
|
-
className: 'right-arrow',
|
|
1090
|
-
"v-index": i,
|
|
1091
|
-
"v-type": 'after',
|
|
1092
|
-
onClick: function onClick() {
|
|
1093
|
-
addOperator(AtomsTypeEnum.UNKNOWN, i, 'after');
|
|
1094
|
-
},
|
|
1095
|
-
children: _jsx("img", {
|
|
1096
|
-
src: arrow
|
|
1097
|
-
})
|
|
1098
|
-
});
|
|
1099
|
-
},
|
|
1100
|
-
ind: i,
|
|
1101
|
-
position: 'after',
|
|
1102
|
-
trigger: 'hover'
|
|
1103
|
-
})]
|
|
1104
|
-
}, i)
|
|
1105
|
-
}, i);
|
|
1604
|
+
}), caseList.map(function (item, itemIndex) {
|
|
1605
|
+
return renderItemShell(item, itemIndex, 'single');
|
|
1106
1606
|
}), Array.from(caseList).length < 1 && selectOperator({
|
|
1107
1607
|
triggerElement: function triggerElement() {
|
|
1108
1608
|
return _jsx("div", {
|
|
@@ -1113,7 +1613,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1113
1613
|
ind: -1,
|
|
1114
1614
|
position: 'add',
|
|
1115
1615
|
trigger: 'click'
|
|
1116
|
-
}), copyDom(-1, false), showPreview && _jsx("div", {
|
|
1616
|
+
}), !embedded && copyDom(-1, false), !embedded && showPreview && _jsx("div", {
|
|
1117
1617
|
className: cx("mb-2 font-bold uppercase tracking-wider preview-box"),
|
|
1118
1618
|
style: {
|
|
1119
1619
|
fontSize: 12,
|
|
@@ -1156,54 +1656,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1156
1656
|
isSqlError: errorInfo.isError
|
|
1157
1657
|
}),
|
|
1158
1658
|
children: caseList.map(function (v, i) {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
}, i);
|
|
1164
|
-
} else if (v !== null && v !== void 0 && v.fieldName) {
|
|
1165
|
-
return _jsx("span", {
|
|
1166
|
-
className: 'mr-1',
|
|
1167
|
-
children: v === null || v === void 0 ? void 0 : v.fieldName
|
|
1168
|
-
}, i);
|
|
1169
|
-
} else {
|
|
1170
|
-
if (v.type === AtomsTypeEnum.OPERATOR && (v.val === 'and' || v.val === 'or')) {
|
|
1171
|
-
return _jsxs("span", {
|
|
1172
|
-
className: 'mr-1',
|
|
1173
|
-
children: [_jsx("br", {}), v.val, _jsx("br", {})]
|
|
1174
|
-
}, i);
|
|
1175
|
-
}
|
|
1176
|
-
if (v.type === AtomsTypeEnum.OPERATOR) {
|
|
1177
|
-
if (v.val === '(' || v.val === ')') {
|
|
1178
|
-
return _jsx("span", {
|
|
1179
|
-
className: cx('mr-1', {
|
|
1180
|
-
error: errorInfo.isBracket
|
|
1181
|
-
}),
|
|
1182
|
-
children: v.val
|
|
1183
|
-
}, i);
|
|
1184
|
-
}
|
|
1185
|
-
if (v.val === 'case' || v.val === 'end' || v.val === 'when' || v.val === 'then') {
|
|
1186
|
-
return _jsx("span", {
|
|
1187
|
-
className: cx('mr-1', {
|
|
1188
|
-
error: errorInfo.isCase
|
|
1189
|
-
}),
|
|
1190
|
-
children: v.val
|
|
1191
|
-
}, i);
|
|
1192
|
-
}
|
|
1193
|
-
if (v.val === 'over') {
|
|
1194
|
-
return _jsx("span", {
|
|
1195
|
-
className: cx('mr-1', {
|
|
1196
|
-
error: errorInfo.isOver
|
|
1197
|
-
}),
|
|
1198
|
-
children: v.val
|
|
1199
|
-
}, i);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
return _jsx("span", {
|
|
1203
|
-
className: 'mr-1',
|
|
1204
|
-
children: v.val
|
|
1205
|
-
}, i);
|
|
1206
|
-
}
|
|
1659
|
+
return _jsx("span", {
|
|
1660
|
+
className: 'mr-1',
|
|
1661
|
+
children: getItemDisplayText(v)
|
|
1662
|
+
}, i);
|
|
1207
1663
|
})
|
|
1208
1664
|
}), _jsx("div", {
|
|
1209
1665
|
className: 'errorMsg mt-2',
|