@gingkoo/pandora-metabase 1.0.158-alpha.2 → 1.0.158-alpha.21
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/SplitView/index.js +2 -2
- package/lib/cjs/components/dialog/column-type-label/index.d.ts +8 -0
- package/lib/cjs/components/dialog/column-type-label/index.js +22 -0
- package/lib/cjs/components/dialog/column-type-label/index.less +17 -0
- package/lib/cjs/components/dialog/custom-column/config.js +2 -2
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +1 -1
- package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -2
- package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +2 -2
- package/lib/cjs/components/dialog/custom-column/index.js +2 -2
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +6 -6
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +8 -8
- package/lib/cjs/components/dialog/custom-editor/index.js +4 -4
- package/lib/cjs/components/dialog/expression/date-format-picker.js +1 -1
- package/lib/cjs/components/dialog/expression/index.js +4 -4
- package/lib/cjs/components/dialog/formula/index.js +55 -14
- package/lib/cjs/components/dialog/formula/index.less +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +5 -1
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +3 -4
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +138 -214
- package/lib/cjs/components/dialog/formula-list/LogicGroup.js +55 -39
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/cjs/components/dialog/formula-list/index.js +414 -321
- package/lib/cjs/components/dialog/formula-list/index.less +1012 -1105
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +16 -2
- package/lib/cjs/components/dialog/formula-list/utils.js +650 -131
- package/lib/cjs/components/dialog/select-column/index.js +10 -4
- package/lib/cjs/components/dialog/select-column/index.less +6 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +12 -9
- package/lib/cjs/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column/index.js +9 -5
- package/lib/cjs/components/dialog/select-join-column/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +10 -6
- package/lib/cjs/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/cjs/components/dialog/select-permission-table/index.js +1 -1
- package/lib/cjs/components/dialog/select-summarize/index.js +2 -2
- package/lib/cjs/components/dialog/select-table/index.js +5 -5
- package/lib/cjs/components/icons.js +1 -1
- package/lib/cjs/components/metabase/index.js +129 -60
- package/lib/cjs/components/metabase/index.less +28 -29
- package/lib/cjs/components/modules/components/Wrapper.js +2 -2
- package/lib/cjs/components/modules/components/header.d.ts +2 -1
- package/lib/cjs/components/modules/components/header.js +7 -3
- package/lib/cjs/components/modules/components/item-wrapper.js +1 -1
- package/lib/cjs/components/modules/components/meta-icon.js +3 -5
- package/lib/cjs/components/modules/custom-column.js +7 -4
- package/lib/cjs/components/modules/filter.js +2 -2
- package/lib/cjs/components/modules/join-data.js +100 -21
- package/lib/cjs/components/modules/sort.js +6 -3
- package/lib/cjs/components/modules/summarize/group-by.js +10 -6
- package/lib/cjs/components/modules/summarize/select-index.js +12 -5
- package/lib/cjs/components/modules/table-data.js +50 -16
- package/lib/cjs/components/popup.js +7 -7
- package/lib/cjs/components/right-click-menu.js +3 -3
- package/lib/cjs/components/sql-syntax-confirm.d.ts +14 -0
- package/lib/cjs/components/sql-syntax-confirm.js +149 -0
- package/lib/cjs/enum.d.ts +1 -0
- package/lib/cjs/enum.js +16 -0
- package/lib/cjs/hooks/patch.js +1 -1
- package/lib/cjs/hooks/patch2.js +1 -1
- package/lib/cjs/hooks/use-state.js +118 -111
- package/lib/cjs/hooks/winsize.js +1 -1
- package/lib/cjs/index.d.ts +4 -2
- package/lib/cjs/index.js +14 -6
- package/lib/cjs/locale/en.js +35 -0
- package/lib/cjs/locale/zh.js +35 -0
- package/lib/cjs/prompt.d.ts +3 -0
- package/lib/cjs/prompt.js +262 -0
- package/lib/cjs/store/enum.d.ts +50 -0
- package/lib/cjs/store/enum.js +56 -2
- package/lib/cjs/store/helper.js +2 -2
- package/lib/cjs/store/types.d.ts +9 -52
- package/lib/cjs/store/types.js +25 -54
- package/lib/cjs/types.d.ts +6 -0
- package/lib/cjs/utils/event.js +3 -3
- package/lib/cjs/utils/helper.js +1 -1
- package/lib/cjs/utils/keydown.js +2 -2
- package/lib/cjs/utils/selection.js +1 -1
- package/lib/cjs/utils/storage.js +2 -2
- package/lib/cjs/utils/transformSql.d.ts +44 -1
- package/lib/cjs/utils/transformSql.js +1042 -29
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +82 -43
- package/lib/cjs/validate.d.ts +2 -0
- package/lib/cjs/validate.js +42 -0
- package/lib/es/components/dialog/column-type-label/index.d.ts +8 -0
- package/lib/es/components/dialog/column-type-label/index.js +16 -0
- package/lib/es/components/dialog/column-type-label/index.less +17 -0
- package/lib/es/components/dialog/expression/index.js +1 -1
- package/lib/es/components/dialog/formula/index.js +53 -12
- package/lib/es/components/dialog/formula/index.less +7 -0
- package/lib/es/components/dialog/formula/utils.js +5 -1
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +3 -4
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +141 -217
- package/lib/es/components/dialog/formula-list/LogicGroup.js +54 -38
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
- package/lib/es/components/dialog/formula-list/index.js +409 -316
- package/lib/es/components/dialog/formula-list/index.less +1012 -1105
- package/lib/es/components/dialog/formula-list/utils.d.ts +16 -2
- package/lib/es/components/dialog/formula-list/utils.js +646 -126
- package/lib/es/components/dialog/select-column/index.js +7 -1
- package/lib/es/components/dialog/select-column/index.less +6 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +9 -6
- package/lib/es/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/es/components/dialog/select-join-column/index.js +7 -3
- package/lib/es/components/dialog/select-join-column/index.less +10 -0
- package/lib/es/components/dialog/select-join-column-multiple/index.js +7 -3
- package/lib/es/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/es/components/metabase/index.js +126 -57
- package/lib/es/components/metabase/index.less +28 -29
- package/lib/es/components/modules/components/header.d.ts +2 -1
- package/lib/es/components/modules/components/header.js +6 -2
- package/lib/es/components/modules/components/meta-icon.js +2 -4
- package/lib/es/components/modules/custom-column.js +4 -1
- package/lib/es/components/modules/join-data.js +98 -19
- package/lib/es/components/modules/sort.js +4 -1
- package/lib/es/components/modules/summarize/group-by.js +5 -1
- package/lib/es/components/modules/summarize/select-index.js +8 -1
- package/lib/es/components/modules/table-data.js +47 -13
- package/lib/es/components/sql-syntax-confirm.d.ts +14 -0
- package/lib/es/components/sql-syntax-confirm.js +142 -0
- package/lib/es/enum.d.ts +1 -0
- package/lib/es/enum.js +1 -0
- package/lib/es/hooks/use-state.js +112 -105
- package/lib/es/index.d.ts +4 -2
- package/lib/es/index.js +8 -6
- package/lib/es/locale/en.js +35 -0
- package/lib/es/locale/zh.js +35 -0
- package/lib/es/prompt.d.ts +3 -0
- package/lib/es/prompt.js +3 -0
- package/lib/es/store/enum.d.ts +50 -0
- package/lib/es/store/enum.js +55 -1
- package/lib/es/store/types.d.ts +9 -52
- package/lib/es/store/types.js +2 -53
- package/lib/es/types.d.ts +6 -0
- package/lib/es/utils/transformSql.d.ts +44 -1
- package/lib/es/utils/transformSql.js +1038 -25
- package/lib/es/utils.d.ts +3 -1
- package/lib/es/utils.js +76 -37
- package/lib/es/validate.d.ts +2 -0
- package/lib/es/validate.js +1 -0
- package/package.json +31 -1
- package/lib/cjs/components/dialog/diff-viewer/index copy.d.ts +0 -10
- package/lib/cjs/components/dialog/diff-viewer/index copy.js +0 -139
- package/lib/es/components/dialog/diff-viewer/index copy.d.ts +0 -10
- package/lib/es/components/dialog/diff-viewer/index copy.js +0 -132
|
@@ -13,7 +13,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import React, { useEffect, useState, useMemo, useRef, forwardRef } from 'react';
|
|
15
15
|
import './index.less';
|
|
16
|
-
import { FieldString, FieldNumber, FfPlus, FullscreenOExpand } from '@gingkoo/pandora-icons';
|
|
16
|
+
import { FieldString, FieldNumber, Tags, FfPlus, FullscreenOExpand } from '@gingkoo/pandora-icons';
|
|
17
17
|
import cx from 'classnames';
|
|
18
18
|
import Metabase from '../../../index';
|
|
19
19
|
import { __ } from '../../../locale';
|
|
@@ -23,11 +23,11 @@ import { AtomsTypeEnum, FormulaTypeEnum } from '../../../store/types';
|
|
|
23
23
|
import { ColumnsPopupThemeEnum } from '../../../store/enum';
|
|
24
24
|
import { Select, Input, Modal2, Modal, InputNumber, Space, Button, Checkbox, Tooltip, Toast, Editor } from '@gingkoo/pandora';
|
|
25
25
|
import cloneDeep from 'lodash/cloneDeep';
|
|
26
|
-
import { buildSqlQuery, getAtomDisplayText,
|
|
26
|
+
import { buildSqlQuery, getAtomDisplayText, getFieldReferenceError, changeCopyField, isExistsError, normalizeAndOrStructure, normalizeLegacySummarizeForSave, splitByUnion, syncAtomQuotes } from '../../../utils';
|
|
27
27
|
import Formula from '../formula';
|
|
28
28
|
import { AddIcon, CloseIcon, UpArrowIcon } from '../../icons';
|
|
29
29
|
import { Expression, SelectColumnMultiple, SelectTable } from '../../dialog';
|
|
30
|
-
import { customTypes, operatorList as __operatorList, insertTemplateAt, getTemplateItem, validateExpressionIntegrity, getConstantLabel, normalizeExpressionAtoms } from './utils';
|
|
30
|
+
import { customTypes, operatorList as __operatorList, insertTemplateAt, getTemplateItem, getInputListValues, isInputListType, validateExpressionIntegrity, getConstantLabel, normalizeExpressionAtoms, normalizeOperatorList, findNestedMetaIssue, isOk } from './utils';
|
|
31
31
|
import SelectList from '../../dialog/select-list';
|
|
32
32
|
import arrow from './arrow.svg';
|
|
33
33
|
import { useStore, Provider } from '../../../hooks/use-provider';
|
|
@@ -798,16 +798,16 @@ var ADD_TRIGGER_STYLE = {
|
|
|
798
798
|
display: 'inline-flex',
|
|
799
799
|
alignItems: 'center',
|
|
800
800
|
justifyContent: 'center',
|
|
801
|
-
minHeight:
|
|
802
|
-
minWidth:
|
|
803
|
-
padding: '
|
|
801
|
+
minHeight: 24,
|
|
802
|
+
minWidth: 24,
|
|
803
|
+
padding: '0 8px',
|
|
804
804
|
border: '1px solid transparent',
|
|
805
|
-
borderRadius:
|
|
805
|
+
borderRadius: 4,
|
|
806
806
|
boxSizing: 'border-box',
|
|
807
807
|
color: '#fff',
|
|
808
808
|
backgroundColor: 'rgb(147, 161, 171)',
|
|
809
|
-
fontSize:
|
|
810
|
-
lineHeight: '
|
|
809
|
+
fontSize: 12,
|
|
810
|
+
lineHeight: '20px',
|
|
811
811
|
cursor: 'pointer'
|
|
812
812
|
};
|
|
813
813
|
var ZOOM_FOOTER_BUTTON_STYLE = {
|
|
@@ -841,55 +841,41 @@ var FORMULA_LIST_ZOOM_BUTTON_STYLE = {
|
|
|
841
841
|
cursor: 'pointer',
|
|
842
842
|
lineHeight: 0
|
|
843
843
|
};
|
|
844
|
-
var TOKEN_BASE_STYLE = {
|
|
845
|
-
display: 'inline-flex',
|
|
846
|
-
alignItems: 'center',
|
|
847
|
-
minHeight: 28,
|
|
848
|
-
padding: '4px 7px',
|
|
849
|
-
border: '1px solid transparent',
|
|
850
|
-
borderRadius: 5,
|
|
851
|
-
boxSizing: 'border-box',
|
|
852
|
-
fontSize: 13,
|
|
853
|
-
lineHeight: '18px',
|
|
854
|
-
cursor: 'pointer'
|
|
855
|
-
};
|
|
856
|
-
var TOKEN_PALETTE = {
|
|
857
|
-
blue: 'rgb(80, 158, 227)',
|
|
858
|
-
purple: 'rgb(113, 114, 173)',
|
|
859
|
-
gray: 'rgb(147, 161, 171)',
|
|
860
|
-
green: 'rgb(136, 191, 77)'
|
|
861
|
-
};
|
|
862
844
|
var createUnknownAtom = function createUnknownAtom() {
|
|
863
845
|
return {
|
|
864
846
|
val: '',
|
|
865
847
|
type: AtomsTypeEnum.UNKNOWN
|
|
866
848
|
};
|
|
867
849
|
};
|
|
868
|
-
var
|
|
869
|
-
|
|
870
|
-
var
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
} else if (names.includes(' gray-name ')) {
|
|
874
|
-
color = TOKEN_PALETTE.gray;
|
|
875
|
-
} else if (names.includes(' green-name ')) {
|
|
876
|
-
color = TOKEN_PALETTE.green;
|
|
877
|
-
}
|
|
878
|
-
var selectedStyle = _objectSpread(_objectSpread({}, TOKEN_BASE_STYLE), {}, {
|
|
879
|
-
color: '#fff',
|
|
880
|
-
backgroundColor: color
|
|
850
|
+
var copySourceMap = new Map();
|
|
851
|
+
var syncCopyClipboard = function syncCopyClipboard() {
|
|
852
|
+
var merged = [];
|
|
853
|
+
copySourceMap.forEach(function (items) {
|
|
854
|
+
merged.push.apply(merged, _toConsumableArray(items));
|
|
881
855
|
});
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
856
|
+
storage._metabaseCopyItems = merged;
|
|
857
|
+
window.dispatchEvent(new CustomEvent('sqb-checked-items-changed'));
|
|
858
|
+
};
|
|
859
|
+
var setCopySource = function setCopySource(owner, items) {
|
|
860
|
+
if (!items.length) {
|
|
861
|
+
copySourceMap["delete"](owner);
|
|
862
|
+
} else {
|
|
863
|
+
copySourceMap.set(owner, items);
|
|
864
|
+
}
|
|
865
|
+
syncCopyClipboard();
|
|
866
|
+
};
|
|
867
|
+
var clearAllCopySources = function clearAllCopySources() {
|
|
868
|
+
copySourceMap.clear();
|
|
869
|
+
syncCopyClipboard();
|
|
870
|
+
};
|
|
871
|
+
var createCaseWhenBranch = function createCaseWhenBranch() {
|
|
872
|
+
return {
|
|
873
|
+
whenAtoms: [createUnknownAtom()],
|
|
874
|
+
thenAtoms: [createUnknownAtom()]
|
|
875
|
+
};
|
|
890
876
|
};
|
|
891
877
|
var FormulaList = forwardRef(function (props, ref) {
|
|
892
|
-
var _storage$_metabaseCop, _store$preProps, _store$preProps2;
|
|
878
|
+
var _storage$_metabaseCop, _ref9, _store$preProps, _store$preProps2;
|
|
893
879
|
var _useState13 = useState((storage === null || storage === void 0 || (_storage$_metabaseCop = storage._metabaseCopyItems) === null || _storage$_metabaseCop === void 0 ? void 0 : _storage$_metabaseCop.length) || 0),
|
|
894
880
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
895
881
|
checkedItemsCount = _useState14[0],
|
|
@@ -931,7 +917,17 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
931
917
|
_props$enableZoom = props.enableZoom,
|
|
932
918
|
enableZoom = _props$enableZoom === void 0 ? true : _props$enableZoom,
|
|
933
919
|
parentPopupChannel = props.parentPopupChannel,
|
|
934
|
-
|
|
920
|
+
pairBracketsProp = props.pairBrackets,
|
|
921
|
+
onAddSql = props.onAddSql,
|
|
922
|
+
_props$checkActive = props.checkActive,
|
|
923
|
+
checkActive = _props$checkActive === void 0 ? false : _props$checkActive,
|
|
924
|
+
_props$forceChecked = props.forceChecked,
|
|
925
|
+
forceChecked = _props$forceChecked === void 0 ? false : _props$forceChecked;
|
|
926
|
+
var pairBrackets = (_ref9 = pairBracketsProp !== null && pairBracketsProp !== void 0 ? pairBracketsProp : store.pairBrackets) !== null && _ref9 !== void 0 ? _ref9 : false;
|
|
927
|
+
var _useState15 = useState(false),
|
|
928
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
929
|
+
isCheck = _useState16[0],
|
|
930
|
+
setIsCheck = _useState16[1];
|
|
935
931
|
var parentPopupLockCountRef = useRef(0);
|
|
936
932
|
var parentPopupUnlockTimerRef = useRef(null);
|
|
937
933
|
var setParentClosable = function setParentClosable(closable) {
|
|
@@ -1067,19 +1063,19 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1067
1063
|
var hasFormulaDiffAction = Boolean(store.showFormulaDiff && store.hasFormulaDiffCode);
|
|
1068
1064
|
var operatorList = useMemo(function () {
|
|
1069
1065
|
if (store.operatorList.length > 0) {
|
|
1070
|
-
return store.operatorList;
|
|
1066
|
+
return normalizeOperatorList(store.operatorList, pairBrackets);
|
|
1071
1067
|
}
|
|
1072
|
-
return __operatorList;
|
|
1073
|
-
}, [store.operatorList]);
|
|
1074
|
-
var _useState15 = useState(false),
|
|
1075
|
-
_useState16 = _slicedToArray(_useState15, 2),
|
|
1076
|
-
sqlLoading = _useState16[0],
|
|
1077
|
-
setSqlLoading = _useState16[1];
|
|
1068
|
+
return normalizeOperatorList(__operatorList, pairBrackets);
|
|
1069
|
+
}, [store.operatorList, pairBrackets]);
|
|
1078
1070
|
var _useState17 = useState(false),
|
|
1079
1071
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
var _useState19 = useState(
|
|
1072
|
+
sqlLoading = _useState18[0],
|
|
1073
|
+
setSqlLoading = _useState18[1];
|
|
1074
|
+
var _useState19 = useState(false),
|
|
1075
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
1076
|
+
diffLoading = _useState20[0],
|
|
1077
|
+
setDiffLoading = _useState20[1];
|
|
1078
|
+
var _useState21 = useState(function () {
|
|
1083
1079
|
if (!enableCopy) {
|
|
1084
1080
|
return false;
|
|
1085
1081
|
}
|
|
@@ -1088,25 +1084,25 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1088
1084
|
}
|
|
1089
1085
|
return store.copyType.includes(_type);
|
|
1090
1086
|
}),
|
|
1091
|
-
|
|
1092
|
-
isCopy =
|
|
1093
|
-
setIsCopy =
|
|
1087
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
1088
|
+
isCopy = _useState22[0],
|
|
1089
|
+
setIsCopy = _useState22[1];
|
|
1094
1090
|
var formulaList = useMemo(function () {
|
|
1095
1091
|
return getObjTem(store.formulaTemplates);
|
|
1096
1092
|
}, [store.formulaTemplates]);
|
|
1097
|
-
var
|
|
1098
|
-
|
|
1099
|
-
filterVal =
|
|
1100
|
-
setFilterVal =
|
|
1093
|
+
var _useState23 = useState(''),
|
|
1094
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
1095
|
+
filterVal = _useState24[0],
|
|
1096
|
+
setFilterVal = _useState24[1];
|
|
1101
1097
|
function getSelectDisplayText(item) {
|
|
1102
1098
|
var displayField = item.displayField || 'value';
|
|
1103
1099
|
var getOptionText = function getOptionText(value) {
|
|
1104
|
-
var
|
|
1100
|
+
var _ref0, _option$displayField;
|
|
1105
1101
|
var option = (item.options || []).find(function (currentOption) {
|
|
1106
1102
|
return currentOption.value === value;
|
|
1107
1103
|
});
|
|
1108
1104
|
if (!option) return value || '';
|
|
1109
|
-
return String((
|
|
1105
|
+
return String((_ref0 = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref0 !== void 0 ? _ref0 : '');
|
|
1110
1106
|
};
|
|
1111
1107
|
if (Array.isArray(item.val)) {
|
|
1112
1108
|
return item.val.map(function (currentValue) {
|
|
@@ -1209,6 +1205,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1209
1205
|
if (v.type === AtomsTypeEnum.SELECT) {
|
|
1210
1206
|
return getSelectDisplayText(v);
|
|
1211
1207
|
}
|
|
1208
|
+
if (isInputListType(v.type)) {
|
|
1209
|
+
return getInputListValues(v.val).join(', ');
|
|
1210
|
+
}
|
|
1212
1211
|
if (Array.isArray(v.val)) {
|
|
1213
1212
|
return v.val.join(', ');
|
|
1214
1213
|
}
|
|
@@ -1227,7 +1226,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1227
1226
|
var nextItem = _objectSpread(_objectSpread({}, item), {}, {
|
|
1228
1227
|
caseAtoms: [],
|
|
1229
1228
|
whenClauses: [],
|
|
1230
|
-
elseAtoms:
|
|
1229
|
+
elseAtoms: item.elseAtoms
|
|
1231
1230
|
});
|
|
1232
1231
|
visited.set(item, nextItem);
|
|
1233
1232
|
nextItem.caseAtoms = (item.caseAtoms || []).map(function (currentItem) {
|
|
@@ -1288,13 +1287,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1288
1287
|
setCaseList(nextList);
|
|
1289
1288
|
};
|
|
1290
1289
|
var getFormulaSqlText = function getFormulaSqlText(result) {
|
|
1291
|
-
var
|
|
1290
|
+
var _ref1, _result$sql;
|
|
1292
1291
|
if (typeof result === 'string') return result;
|
|
1293
1292
|
if (!result) return '';
|
|
1294
|
-
return String((
|
|
1293
|
+
return String((_ref1 = (_result$sql = result.sql) !== null && _result$sql !== void 0 ? _result$sql : result.code) !== null && _ref1 !== void 0 ? _ref1 : '');
|
|
1295
1294
|
};
|
|
1296
1295
|
var getFormulaDiffData = function getFormulaDiffData(result) {
|
|
1297
|
-
var _result$oldCode,
|
|
1296
|
+
var _result$oldCode, _ref10, _result$newCode;
|
|
1298
1297
|
if (typeof result === 'string') {
|
|
1299
1298
|
return {
|
|
1300
1299
|
oldCode: '',
|
|
@@ -1309,7 +1308,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1309
1308
|
}
|
|
1310
1309
|
return {
|
|
1311
1310
|
oldCode: String((_result$oldCode = result.oldCode) !== null && _result$oldCode !== void 0 ? _result$oldCode : ''),
|
|
1312
|
-
newCode: String((
|
|
1311
|
+
newCode: String((_ref10 = (_result$newCode = result.newCode) !== null && _result$newCode !== void 0 ? _result$newCode : result.code) !== null && _ref10 !== void 0 ? _ref10 : '')
|
|
1313
1312
|
};
|
|
1314
1313
|
};
|
|
1315
1314
|
var normalizeFormulaValueForOutput = function normalizeFormulaValueForOutput() {
|
|
@@ -1331,7 +1330,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1331
1330
|
var parseFormulaSql = (_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.parseFormulaSql;
|
|
1332
1331
|
var parseFormulaSqlStream = (_store$preProps2 = store.preProps) === null || _store$preProps2 === void 0 ? void 0 : _store$preProps2.parseFormulaSqlStream;
|
|
1333
1332
|
var resolvedAddSql = onAddSql || typeof parseFormulaSql === 'function' || typeof parseFormulaSqlStream === 'function' ? (function () {
|
|
1334
|
-
var
|
|
1333
|
+
var _ref11 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee7(sqlOrResult, availableTables, tableScope) {
|
|
1335
1334
|
var result;
|
|
1336
1335
|
return _regeneratorRuntime.wrap(function (_context7) {
|
|
1337
1336
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -1387,11 +1386,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1387
1386
|
}, _callee7);
|
|
1388
1387
|
}));
|
|
1389
1388
|
return function (_x5, _x6, _x7) {
|
|
1390
|
-
return
|
|
1389
|
+
return _ref11.apply(this, arguments);
|
|
1391
1390
|
};
|
|
1392
1391
|
}()) : undefined;
|
|
1393
1392
|
var showFormulaSql = function () {
|
|
1394
|
-
var
|
|
1393
|
+
var _ref12 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee8() {
|
|
1395
1394
|
var result, sql, _t1;
|
|
1396
1395
|
return _regeneratorRuntime.wrap(function (_context8) {
|
|
1397
1396
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -1452,7 +1451,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1452
1451
|
}, _callee8, null, [[2, 5, 6, 7]]);
|
|
1453
1452
|
}));
|
|
1454
1453
|
return function showFormulaSql() {
|
|
1455
|
-
return
|
|
1454
|
+
return _ref12.apply(this, arguments);
|
|
1456
1455
|
};
|
|
1457
1456
|
}();
|
|
1458
1457
|
var previewFormulaConfig = function previewFormulaConfig(result) {
|
|
@@ -1539,11 +1538,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1539
1538
|
});
|
|
1540
1539
|
},
|
|
1541
1540
|
defaultAvailableTables: data,
|
|
1542
|
-
streamParser: typeof parseFormulaSqlStream === 'function' ? function (
|
|
1543
|
-
var sql =
|
|
1544
|
-
messages =
|
|
1545
|
-
availableTables =
|
|
1546
|
-
tableScope =
|
|
1541
|
+
streamParser: typeof parseFormulaSqlStream === 'function' ? function (_ref13, handlers) {
|
|
1542
|
+
var sql = _ref13.sql,
|
|
1543
|
+
messages = _ref13.messages,
|
|
1544
|
+
availableTables = _ref13.availableTables,
|
|
1545
|
+
tableScope = _ref13.tableScope;
|
|
1547
1546
|
return parseFormulaSqlStream({
|
|
1548
1547
|
sql: sql,
|
|
1549
1548
|
messages: messages,
|
|
@@ -1563,7 +1562,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1563
1562
|
});
|
|
1564
1563
|
};
|
|
1565
1564
|
var showFormulaDiff = function () {
|
|
1566
|
-
var
|
|
1565
|
+
var _ref14 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee9() {
|
|
1567
1566
|
var result, _getFormulaDiffData, oldCode, newCode, _t10;
|
|
1568
1567
|
return _regeneratorRuntime.wrap(function (_context9) {
|
|
1569
1568
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1617,7 +1616,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1617
1616
|
}, _callee9, null, [[2, 5, 6, 7]]);
|
|
1618
1617
|
}));
|
|
1619
1618
|
return function showFormulaDiff() {
|
|
1620
|
-
return
|
|
1619
|
+
return _ref14.apply(this, arguments);
|
|
1621
1620
|
};
|
|
1622
1621
|
}();
|
|
1623
1622
|
var renderTokenContent = function renderTokenContent(children) {
|
|
@@ -1632,16 +1631,16 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1632
1631
|
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
1633
1632
|
var modalInstance;
|
|
1634
1633
|
var CaseWhenZoomEditor = function CaseWhenZoomEditor() {
|
|
1635
|
-
var
|
|
1634
|
+
var _useState25 = useState(function () {
|
|
1636
1635
|
return cloneDeep(value);
|
|
1637
1636
|
}),
|
|
1638
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
1639
|
-
draftValue = _useState24[0],
|
|
1640
|
-
setDraftValue = _useState24[1];
|
|
1641
|
-
var _useState25 = useState(null),
|
|
1642
1637
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
1643
|
-
|
|
1644
|
-
|
|
1638
|
+
draftValue = _useState26[0],
|
|
1639
|
+
setDraftValue = _useState26[1];
|
|
1640
|
+
var _useState27 = useState(null),
|
|
1641
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
1642
|
+
activeZoomRegionKey = _useState28[0],
|
|
1643
|
+
setActiveZoomRegionKey = _useState28[1];
|
|
1645
1644
|
var updateDraftValue = function updateDraftValue(nextValue) {
|
|
1646
1645
|
setDraftValue(withSyncedQuotes(nextValue));
|
|
1647
1646
|
};
|
|
@@ -1660,7 +1659,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1660
1659
|
className: 'Sqb-NotebookCell Sqb-FormulaListZoomEditor-cell',
|
|
1661
1660
|
children: _jsx(CaseWhenGroup, {
|
|
1662
1661
|
showTools: false,
|
|
1663
|
-
useBranchScrollInner: true,
|
|
1664
1662
|
caseRegionKey: 'case-zoom-case',
|
|
1665
1663
|
elseRegionKey: 'case-zoom-else',
|
|
1666
1664
|
activeRegionKey: activeZoomRegionKey,
|
|
@@ -1669,7 +1667,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1669
1667
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1670
1668
|
caseAtoms: nextList
|
|
1671
1669
|
}));
|
|
1672
|
-
}),
|
|
1670
|
+
}, index),
|
|
1673
1671
|
whenClauses: (draftValue.whenClauses || []).map(function (branch, branchIndex) {
|
|
1674
1672
|
return {
|
|
1675
1673
|
key: "case-zoom-".concat(branchIndex),
|
|
@@ -1682,7 +1680,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1682
1680
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1683
1681
|
whenClauses: nextWhenClauses
|
|
1684
1682
|
}));
|
|
1685
|
-
}),
|
|
1683
|
+
}, index),
|
|
1686
1684
|
thenContent: renderNestedFormulaList(branch.thenAtoms || [], function (nextList) {
|
|
1687
1685
|
var nextWhenClauses = (draftValue.whenClauses || []).slice();
|
|
1688
1686
|
nextWhenClauses[branchIndex] = _objectSpread(_objectSpread({}, branch), {}, {
|
|
@@ -1691,20 +1689,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1691
1689
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1692
1690
|
whenClauses: nextWhenClauses
|
|
1693
1691
|
}));
|
|
1694
|
-
}),
|
|
1692
|
+
}, index),
|
|
1695
1693
|
onAddAfter: function onAddAfter(event) {
|
|
1696
1694
|
event.stopPropagation();
|
|
1697
1695
|
var nextWhenClauses = (draftValue.whenClauses || []).slice();
|
|
1698
|
-
nextWhenClauses.splice(branchIndex + 1, 0,
|
|
1699
|
-
whenAtoms: [{
|
|
1700
|
-
val: '',
|
|
1701
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1702
|
-
}],
|
|
1703
|
-
thenAtoms: [{
|
|
1704
|
-
val: '',
|
|
1705
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1706
|
-
}]
|
|
1707
|
-
});
|
|
1696
|
+
nextWhenClauses.splice(branchIndex + 1, 0, createCaseWhenBranch());
|
|
1708
1697
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1709
1698
|
whenClauses: nextWhenClauses
|
|
1710
1699
|
}));
|
|
@@ -1721,35 +1710,18 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1721
1710
|
}
|
|
1722
1711
|
};
|
|
1723
1712
|
}),
|
|
1724
|
-
elseContent:
|
|
1713
|
+
elseContent: renderNestedFormulaList(draftValue.elseAtoms || [], function (nextList) {
|
|
1725
1714
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1726
1715
|
elseAtoms: nextList
|
|
1727
1716
|
}));
|
|
1728
|
-
})
|
|
1717
|
+
}, index),
|
|
1729
1718
|
onAddBranch: function onAddBranch(event) {
|
|
1730
1719
|
event.stopPropagation();
|
|
1731
1720
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1732
|
-
whenClauses: [].concat(_toConsumableArray(draftValue.whenClauses || []), [
|
|
1733
|
-
whenAtoms: [{
|
|
1734
|
-
val: '',
|
|
1735
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1736
|
-
}],
|
|
1737
|
-
thenAtoms: [{
|
|
1738
|
-
val: '',
|
|
1739
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1740
|
-
}]
|
|
1741
|
-
}])
|
|
1742
|
-
}));
|
|
1743
|
-
},
|
|
1744
|
-
onAddElse: function onAddElse(event) {
|
|
1745
|
-
event.stopPropagation();
|
|
1746
|
-
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
1747
|
-
elseAtoms: [{
|
|
1748
|
-
val: '',
|
|
1749
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1750
|
-
}]
|
|
1721
|
+
whenClauses: [].concat(_toConsumableArray(draftValue.whenClauses || []), [createCaseWhenBranch()])
|
|
1751
1722
|
}));
|
|
1752
1723
|
},
|
|
1724
|
+
canClearElse: !!(draftValue.elseAtoms && draftValue.elseAtoms.length),
|
|
1753
1725
|
onRemoveElse: function onRemoveElse(event) {
|
|
1754
1726
|
event.stopPropagation();
|
|
1755
1727
|
updateDraftValue(_objectSpread(_objectSpread({}, draftValue), {}, {
|
|
@@ -1796,12 +1768,12 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1796
1768
|
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
1797
1769
|
var modalInstance;
|
|
1798
1770
|
var FormulaListZoomEditor = function FormulaListZoomEditor() {
|
|
1799
|
-
var
|
|
1771
|
+
var _useState29 = useState(function () {
|
|
1800
1772
|
return cloneDeep(caseList || []);
|
|
1801
1773
|
}),
|
|
1802
|
-
|
|
1803
|
-
draftList =
|
|
1804
|
-
setDraftList =
|
|
1774
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
1775
|
+
draftList = _useState30[0],
|
|
1776
|
+
setDraftList = _useState30[1];
|
|
1805
1777
|
var updateDraftList = function updateDraftList(nextList) {
|
|
1806
1778
|
setDraftList(nextList.map(function (item) {
|
|
1807
1779
|
return withSyncedQuotes(item);
|
|
@@ -1868,10 +1840,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1868
1840
|
onClose: function onClose() {}
|
|
1869
1841
|
});
|
|
1870
1842
|
};
|
|
1871
|
-
var renderNestedFormulaList = function renderNestedFormulaList(list, onNestedChange) {
|
|
1843
|
+
var renderNestedFormulaList = function renderNestedFormulaList(list, onNestedChange, atomIndex) {
|
|
1872
1844
|
var hasNestedCaseWhen = list.some(function (item) {
|
|
1873
1845
|
return (item === null || item === void 0 ? void 0 : item.type) === AtomsTypeEnum.CASE_WHEN;
|
|
1874
1846
|
});
|
|
1847
|
+
var nestedForced = forceChecked || typeof atomIndex === 'number' && selectedIndices.includes(atomIndex);
|
|
1875
1848
|
return _jsx("div", {
|
|
1876
1849
|
className: cx('Sqb-NestedFormulaList', {
|
|
1877
1850
|
'Sqb-NestedFormulaList--hasCaseWhen': hasNestedCaseWhen
|
|
@@ -1891,6 +1864,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1891
1864
|
showPreview: false,
|
|
1892
1865
|
check: check,
|
|
1893
1866
|
_type: _type,
|
|
1867
|
+
enableCopy: isCopy,
|
|
1868
|
+
checkActive: isCheck || checkActive,
|
|
1869
|
+
forceChecked: nestedForced,
|
|
1894
1870
|
enableZoom: false,
|
|
1895
1871
|
parentPopupChannel: parentPopupChannel
|
|
1896
1872
|
})
|
|
@@ -1905,7 +1881,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1905
1881
|
return _jsx(CaseWhenGroup, {
|
|
1906
1882
|
readonly: snapshotMode,
|
|
1907
1883
|
isNested: embedded,
|
|
1908
|
-
useBranchScrollInner: !embedded,
|
|
1909
1884
|
caseRegionKey: caseRegionKey,
|
|
1910
1885
|
elseRegionKey: elseRegionKey,
|
|
1911
1886
|
activeRegionKey: hoveredCaseGroupKey,
|
|
@@ -1914,7 +1889,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1914
1889
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1915
1890
|
caseAtoms: nextList
|
|
1916
1891
|
}));
|
|
1917
|
-
}),
|
|
1892
|
+
}, index),
|
|
1918
1893
|
whenClauses: whenClauses.map(function (branch, branchIndex) {
|
|
1919
1894
|
return {
|
|
1920
1895
|
key: "case-".concat(index, "-branch-").concat(branchIndex),
|
|
@@ -1927,7 +1902,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1927
1902
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1928
1903
|
whenClauses: nextWhenClauses
|
|
1929
1904
|
}));
|
|
1930
|
-
}),
|
|
1905
|
+
}, index),
|
|
1931
1906
|
thenContent: renderNestedFormulaList(branch.thenAtoms || [], function (nextList) {
|
|
1932
1907
|
var nextWhenClauses = whenClauses.slice();
|
|
1933
1908
|
nextWhenClauses[branchIndex] = _objectSpread(_objectSpread({}, branch), {}, {
|
|
@@ -1936,20 +1911,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1936
1911
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1937
1912
|
whenClauses: nextWhenClauses
|
|
1938
1913
|
}));
|
|
1939
|
-
}),
|
|
1914
|
+
}, index),
|
|
1940
1915
|
onAddAfter: function onAddAfter(e) {
|
|
1941
1916
|
e.stopPropagation();
|
|
1942
1917
|
var nextWhenClauses = whenClauses.slice();
|
|
1943
|
-
nextWhenClauses.splice(branchIndex + 1, 0,
|
|
1944
|
-
whenAtoms: [{
|
|
1945
|
-
val: '',
|
|
1946
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1947
|
-
}],
|
|
1948
|
-
thenAtoms: [{
|
|
1949
|
-
val: '',
|
|
1950
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1951
|
-
}]
|
|
1952
|
-
});
|
|
1918
|
+
nextWhenClauses.splice(branchIndex + 1, 0, createCaseWhenBranch());
|
|
1953
1919
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1954
1920
|
whenClauses: nextWhenClauses
|
|
1955
1921
|
}));
|
|
@@ -1966,35 +1932,18 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1966
1932
|
}
|
|
1967
1933
|
};
|
|
1968
1934
|
}),
|
|
1969
|
-
elseContent:
|
|
1935
|
+
elseContent: renderNestedFormulaList(elseAtoms || [], function (nextList) {
|
|
1970
1936
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1971
1937
|
elseAtoms: nextList
|
|
1972
1938
|
}));
|
|
1973
|
-
})
|
|
1939
|
+
}, index),
|
|
1974
1940
|
onAddBranch: function onAddBranch(e) {
|
|
1975
1941
|
e.stopPropagation();
|
|
1976
1942
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1977
|
-
whenClauses: [].concat(_toConsumableArray(whenClauses), [
|
|
1978
|
-
whenAtoms: [{
|
|
1979
|
-
val: '',
|
|
1980
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1981
|
-
}],
|
|
1982
|
-
thenAtoms: [{
|
|
1983
|
-
val: '',
|
|
1984
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1985
|
-
}]
|
|
1986
|
-
}])
|
|
1987
|
-
}));
|
|
1988
|
-
},
|
|
1989
|
-
onAddElse: function onAddElse(e) {
|
|
1990
|
-
e.stopPropagation();
|
|
1991
|
-
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
1992
|
-
elseAtoms: [{
|
|
1993
|
-
val: '',
|
|
1994
|
-
type: AtomsTypeEnum.UNKNOWN
|
|
1995
|
-
}]
|
|
1943
|
+
whenClauses: [].concat(_toConsumableArray(whenClauses), [createCaseWhenBranch()])
|
|
1996
1944
|
}));
|
|
1997
1945
|
},
|
|
1946
|
+
canClearElse: !!(elseAtoms && elseAtoms.length),
|
|
1998
1947
|
onRemoveElse: function onRemoveElse(e) {
|
|
1999
1948
|
e.stopPropagation();
|
|
2000
1949
|
updateAtomAt(index, _objectSpread(_objectSpread({}, value), {}, {
|
|
@@ -2025,7 +1974,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2025
1974
|
atoms: nextList
|
|
2026
1975
|
});
|
|
2027
1976
|
updateItems(nextItems);
|
|
2028
|
-
})
|
|
1977
|
+
}, index)
|
|
2029
1978
|
};
|
|
2030
1979
|
}),
|
|
2031
1980
|
onChangeOperator: function onChangeOperator(itemIndex, operator) {
|
|
@@ -2076,22 +2025,19 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2076
2025
|
}
|
|
2077
2026
|
});
|
|
2078
2027
|
};
|
|
2079
|
-
var
|
|
2080
|
-
|
|
2081
|
-
ind =
|
|
2082
|
-
setInd =
|
|
2028
|
+
var _useState31 = useState(-1),
|
|
2029
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
2030
|
+
ind = _useState32[0],
|
|
2031
|
+
setInd = _useState32[1];
|
|
2083
2032
|
var filterCustomType = store.filterCustomType;
|
|
2084
2033
|
var _ref = useRef(null);
|
|
2085
|
-
var
|
|
2034
|
+
var _useState33 = useState({
|
|
2086
2035
|
isError: false
|
|
2087
2036
|
}),
|
|
2088
|
-
_useState32 = _slicedToArray(_useState31, 2),
|
|
2089
|
-
errorInfo = _useState32[0],
|
|
2090
|
-
setErrorInfo = _useState32[1];
|
|
2091
|
-
var _useState33 = useState(false),
|
|
2092
2037
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
2093
|
-
|
|
2094
|
-
|
|
2038
|
+
errorInfo = _useState34[0],
|
|
2039
|
+
setErrorInfo = _useState34[1];
|
|
2040
|
+
var inCheckMode = isCheck || checkActive || forceChecked;
|
|
2095
2041
|
var myInstanceIdRef = useRef(Math.random().toString(36).slice(2));
|
|
2096
2042
|
var _useState35 = useState(null),
|
|
2097
2043
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
@@ -2113,6 +2059,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2113
2059
|
_useState44 = _slicedToArray(_useState43, 2),
|
|
2114
2060
|
hoveredCopyIndex = _useState44[0],
|
|
2115
2061
|
setHoveredCopyIndex = _useState44[1];
|
|
2062
|
+
useEffect(function () {
|
|
2063
|
+
if (!forceChecked) return;
|
|
2064
|
+
setSelectedIndices(function (current) {
|
|
2065
|
+
return current.length ? [] : current;
|
|
2066
|
+
});
|
|
2067
|
+
setCopySource(myInstanceIdRef.current, []);
|
|
2068
|
+
}, [forceChecked]);
|
|
2116
2069
|
var getCaseGroupEnd = function getCaseGroupEnd(list, startIndex) {
|
|
2117
2070
|
var depth = 0;
|
|
2118
2071
|
for (var index = startIndex; index < list.length; index++) {
|
|
@@ -2387,8 +2340,32 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2387
2340
|
var _caseList = caseList.slice();
|
|
2388
2341
|
var currentItem = _caseList[i];
|
|
2389
2342
|
var oldVal = _caseList[i].val;
|
|
2390
|
-
var oldType =
|
|
2343
|
+
var oldType = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) || '';
|
|
2344
|
+
var isOperatorItem = oldType === AtomsTypeEnum.OPERATOR;
|
|
2391
2345
|
var otherTypeConfig = otherTypeMap.get(String(oldType));
|
|
2346
|
+
if (pairBrackets && oldType === AtomsTypeEnum.OPERATOR && (oldVal === '(' || oldVal === ')')) {
|
|
2347
|
+
if (val === '()') return;
|
|
2348
|
+
var matchingIndex = getMatchingParenthesisIndex(_caseList, i);
|
|
2349
|
+
if (matchingIndex >= 0) {
|
|
2350
|
+
_caseList.splice(matchingIndex, 1);
|
|
2351
|
+
}
|
|
2352
|
+
var currentIndex = matchingIndex >= 0 && matchingIndex < i ? i - 1 : i;
|
|
2353
|
+
_caseList[currentIndex].val = val;
|
|
2354
|
+
_caseList = insertTemplateAt(oldVal, val, _caseList, currentIndex);
|
|
2355
|
+
setCaseList(_caseList);
|
|
2356
|
+
return;
|
|
2357
|
+
}
|
|
2358
|
+
if (pairBrackets && oldType === AtomsTypeEnum.OPERATOR && val === '()') {
|
|
2359
|
+
_caseList.splice(i, 1, {
|
|
2360
|
+
type: AtomsTypeEnum.OPERATOR,
|
|
2361
|
+
val: '('
|
|
2362
|
+
}, {
|
|
2363
|
+
type: AtomsTypeEnum.OPERATOR,
|
|
2364
|
+
val: ')'
|
|
2365
|
+
});
|
|
2366
|
+
setCaseList(_caseList);
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2392
2369
|
if (oldType === AtomsTypeEnum.CONSTANT) {
|
|
2393
2370
|
_caseList[i].id = val;
|
|
2394
2371
|
_caseList[i].val = getConstantLabel(store.constantList, val);
|
|
@@ -2399,7 +2376,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2399
2376
|
} else {
|
|
2400
2377
|
_caseList[i].val = val;
|
|
2401
2378
|
}
|
|
2402
|
-
|
|
2379
|
+
if (isOperatorItem) {
|
|
2380
|
+
_caseList = insertTemplateAt(oldVal, val, _caseList, i);
|
|
2381
|
+
}
|
|
2403
2382
|
setCaseList(_caseList);
|
|
2404
2383
|
};
|
|
2405
2384
|
function handleExpression(e, i, val) {
|
|
@@ -2423,17 +2402,45 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2423
2402
|
})
|
|
2424
2403
|
});
|
|
2425
2404
|
}
|
|
2405
|
+
function getMatchingParenthesisIndex(list, index) {
|
|
2406
|
+
var item = list[index];
|
|
2407
|
+
if ((item === null || item === void 0 ? void 0 : item.type) !== AtomsTypeEnum.OPERATOR) return -1;
|
|
2408
|
+
var isOpening = item.val === '(';
|
|
2409
|
+
var isClosing = item.val === ')';
|
|
2410
|
+
if (!isOpening && !isClosing) return -1;
|
|
2411
|
+
var depth = 0;
|
|
2412
|
+
var step = isOpening ? 1 : -1;
|
|
2413
|
+
for (var currentIndex = index; currentIndex >= 0 && currentIndex < list.length; currentIndex += step) {
|
|
2414
|
+
var currentItem = list[currentIndex];
|
|
2415
|
+
if ((currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) !== AtomsTypeEnum.OPERATOR) continue;
|
|
2416
|
+
if (currentItem.val === '(') depth += isOpening ? 1 : -1;
|
|
2417
|
+
if (currentItem.val === ')') depth += isOpening ? -1 : 1;
|
|
2418
|
+
if (depth === 0) return currentIndex;
|
|
2419
|
+
}
|
|
2420
|
+
return -1;
|
|
2421
|
+
}
|
|
2422
|
+
function getDeletionIndexSet(list, indices) {
|
|
2423
|
+
var indexSet = new Set(indices);
|
|
2424
|
+
if (!pairBrackets) return indexSet;
|
|
2425
|
+
indices.forEach(function (index) {
|
|
2426
|
+
var matchingIndex = getMatchingParenthesisIndex(list, index);
|
|
2427
|
+
if (matchingIndex >= 0) indexSet.add(matchingIndex);
|
|
2428
|
+
});
|
|
2429
|
+
return indexSet;
|
|
2430
|
+
}
|
|
2426
2431
|
function handleDel(e, index) {
|
|
2427
2432
|
e.stopPropagation();
|
|
2428
2433
|
var _caseList = caseList.slice();
|
|
2429
|
-
_caseList
|
|
2430
|
-
setCaseList(_caseList)
|
|
2434
|
+
var indexSet = getDeletionIndexSet(_caseList, [index]);
|
|
2435
|
+
setCaseList(_caseList.filter(function (_, itemIndex) {
|
|
2436
|
+
return !indexSet.has(itemIndex);
|
|
2437
|
+
}));
|
|
2431
2438
|
closePopup();
|
|
2432
2439
|
}
|
|
2433
2440
|
function handleDelItems(e, indices) {
|
|
2434
2441
|
e.stopPropagation();
|
|
2435
2442
|
if (!indices.length) return;
|
|
2436
|
-
var indexSet =
|
|
2443
|
+
var indexSet = getDeletionIndexSet(caseList, indices);
|
|
2437
2444
|
var _caseList = caseList.filter(function (_, itemIndex) {
|
|
2438
2445
|
return !indexSet.has(itemIndex);
|
|
2439
2446
|
});
|
|
@@ -2443,9 +2450,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2443
2450
|
function initPaste() {
|
|
2444
2451
|
var isDispatch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
2445
2452
|
setSelectedIndices([]);
|
|
2446
|
-
|
|
2453
|
+
setCopySource(myInstanceIdRef.current, []);
|
|
2447
2454
|
setIsCheck(false);
|
|
2448
2455
|
if (isDispatch) {
|
|
2456
|
+
clearAllCopySources();
|
|
2449
2457
|
window.dispatchEvent(new CustomEvent('sqb-check-active', {
|
|
2450
2458
|
detail: {
|
|
2451
2459
|
owner: myInstanceIdRef.current
|
|
@@ -2476,10 +2484,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2476
2484
|
return _caseList[i] ? cloneDeep(_caseList[i]) : null;
|
|
2477
2485
|
}).filter(Boolean);
|
|
2478
2486
|
}
|
|
2479
|
-
|
|
2480
|
-
window.dispatchEvent(new CustomEvent('sqb-checked-items-changed'));
|
|
2487
|
+
setCopySource(myInstanceIdRef.current, itemsToPaste);
|
|
2481
2488
|
}
|
|
2482
2489
|
function toggleSelect(index, checked) {
|
|
2490
|
+
if (forceChecked) return;
|
|
2483
2491
|
var next = selectedIndices.slice();
|
|
2484
2492
|
if (checked) {
|
|
2485
2493
|
if (!next.includes(index)) next.push(index);
|
|
@@ -2535,7 +2543,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2535
2543
|
return _regeneratorRuntime.wrap(function (_context0) {
|
|
2536
2544
|
while (1) switch (_context0.prev = _context0.next) {
|
|
2537
2545
|
case 0:
|
|
2538
|
-
selectedIndexSet =
|
|
2546
|
+
selectedIndexSet = getDeletionIndexSet(caseList, selectedIndices);
|
|
2539
2547
|
_caseList = caseList.filter(function (_, index) {
|
|
2540
2548
|
return !selectedIndexSet.has(index);
|
|
2541
2549
|
});
|
|
@@ -2576,41 +2584,88 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2576
2584
|
var _caseList = caseList.slice() || [];
|
|
2577
2585
|
var _ind = index;
|
|
2578
2586
|
var otherTypeConfig = otherTypeMap.get(String(type));
|
|
2579
|
-
var
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2587
|
+
var isParentheses = pairBrackets && type === '()';
|
|
2588
|
+
var isSingleParenthesis = !pairBrackets && (type === '(' || type === ')');
|
|
2589
|
+
var temItems;
|
|
2590
|
+
if (isParentheses) {
|
|
2591
|
+
temItems = [{
|
|
2592
|
+
type: AtomsTypeEnum.OPERATOR,
|
|
2593
|
+
val: '('
|
|
2594
|
+
}, {
|
|
2595
|
+
type: AtomsTypeEnum.OPERATOR,
|
|
2596
|
+
val: ')'
|
|
2597
|
+
}];
|
|
2598
|
+
} else if (isSingleParenthesis) {
|
|
2599
|
+
temItems = [{
|
|
2600
|
+
type: AtomsTypeEnum.OPERATOR,
|
|
2601
|
+
val: type
|
|
2602
|
+
}];
|
|
2603
|
+
} else {
|
|
2604
|
+
temItems = [otherTypeConfig ? {
|
|
2605
|
+
id: '',
|
|
2606
|
+
val: '',
|
|
2607
|
+
type: type
|
|
2608
|
+
} : getTemplateItem(type)];
|
|
2609
|
+
}
|
|
2584
2610
|
if (position === 'add') {
|
|
2585
|
-
_caseList.push(
|
|
2611
|
+
_caseList.push.apply(_caseList, _toConsumableArray(temItems));
|
|
2586
2612
|
_ind = _caseList.length - 1;
|
|
2587
2613
|
} else if (position === 'before') {
|
|
2588
|
-
_caseList.splice(index, 0
|
|
2614
|
+
_caseList.splice.apply(_caseList, [index, 0].concat(_toConsumableArray(temItems)));
|
|
2589
2615
|
_ind = index;
|
|
2590
2616
|
} else if (position === 'after') {
|
|
2591
|
-
_caseList.splice(index + 1, 0
|
|
2617
|
+
_caseList.splice.apply(_caseList, [index + 1, 0].concat(_toConsumableArray(temItems)));
|
|
2592
2618
|
_ind = index + 1;
|
|
2593
2619
|
} else {
|
|
2594
|
-
_caseList.splice(index, 1
|
|
2620
|
+
_caseList.splice.apply(_caseList, [index, 1].concat(_toConsumableArray(temItems)));
|
|
2595
2621
|
_ind = index;
|
|
2596
2622
|
}
|
|
2597
2623
|
setCaseList(_caseList);
|
|
2598
2624
|
return _ind < 0 ? 0 : _ind;
|
|
2599
2625
|
};
|
|
2626
|
+
var getNestedQueryChipProps = function getNestedQueryChipProps(metas, options) {
|
|
2627
|
+
var existsError = isExistsError(metas || [], store.existsError);
|
|
2628
|
+
var nestedIssue = findNestedMetaIssue(metas, 0, options);
|
|
2629
|
+
if (nestedIssue !== null && nestedIssue !== void 0 && nestedIssue.isError) {
|
|
2630
|
+
return {
|
|
2631
|
+
isError: true,
|
|
2632
|
+
message: __('metabase.sqlErrorOpenNested')
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2635
|
+
return {
|
|
2636
|
+
isError: existsError
|
|
2637
|
+
};
|
|
2638
|
+
};
|
|
2600
2639
|
var getItemNameProps = function getItemNameProps(v) {
|
|
2640
|
+
var referenceError = getFieldReferenceError(v, data);
|
|
2641
|
+
var referenceErrorMessage = referenceError ? __("metabase.".concat(referenceError, "NotExists")) : '';
|
|
2601
2642
|
if (v.type === AtomsTypeEnum.NOT_EXISTS || v.type === AtomsTypeEnum.EXISTS) {
|
|
2643
|
+
return getNestedQueryChipProps(v.notExists, {
|
|
2644
|
+
requireOutputFields: false
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
if (v.type === AtomsTypeEnum.SUB_QUERY) {
|
|
2648
|
+
return getNestedQueryChipProps(v.subQuery, {
|
|
2649
|
+
requireOutputFields: true
|
|
2650
|
+
});
|
|
2651
|
+
}
|
|
2652
|
+
if (v.type === AtomsTypeEnum.FIELD) {
|
|
2653
|
+
var fieldUnselected = !getFieldDisplayName(v);
|
|
2602
2654
|
return {
|
|
2603
|
-
isError:
|
|
2655
|
+
isError: fieldUnselected || Boolean(referenceError),
|
|
2656
|
+
message: fieldUnselected ? __('metabase.sqlErrorMissingField') : referenceErrorMessage
|
|
2604
2657
|
};
|
|
2605
2658
|
}
|
|
2606
|
-
if (v.type === AtomsTypeEnum.
|
|
2659
|
+
if (v.type === AtomsTypeEnum.UNKNOWN) {
|
|
2607
2660
|
return {
|
|
2608
|
-
isError:
|
|
2661
|
+
isError: !String(v.val || ''),
|
|
2662
|
+
message: __('metabase.sqlErrorMissingCustomInput')
|
|
2609
2663
|
};
|
|
2610
2664
|
}
|
|
2611
|
-
if (v.type
|
|
2665
|
+
if (isInputListType(v.type) && !getInputListValues(v.val).length) {
|
|
2612
2666
|
return {
|
|
2613
|
-
isError:
|
|
2667
|
+
isError: true,
|
|
2668
|
+
message: __('metabase.sqlErrorMissingSelection')
|
|
2614
2669
|
};
|
|
2615
2670
|
}
|
|
2616
2671
|
if (v.type === AtomsTypeEnum.CONSTANT) {
|
|
@@ -2628,15 +2683,18 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2628
2683
|
};
|
|
2629
2684
|
}
|
|
2630
2685
|
if (v.type === AtomsTypeEnum.EXPRESSION) {
|
|
2686
|
+
var incomplete = !isOk(v.lhs || []) || !isOk(v.rhs || []);
|
|
2631
2687
|
return {
|
|
2632
|
-
isError:
|
|
2688
|
+
isError: Boolean(referenceError) || incomplete,
|
|
2689
|
+
message: incomplete ? __('metabase.sqlErrorOpenNested') : referenceErrorMessage
|
|
2633
2690
|
};
|
|
2634
2691
|
}
|
|
2635
2692
|
if (v.type === AtomsTypeEnum.FORMULA) {
|
|
2636
2693
|
var formulaMissing = formulaIsError(v, formulaList);
|
|
2694
|
+
var _incomplete = Boolean(v.quotes) && !isOk(v.args || [], true);
|
|
2637
2695
|
return {
|
|
2638
|
-
isError:
|
|
2639
|
-
message: formulaMissing ? '公式丢失' : ''
|
|
2696
|
+
isError: Boolean(referenceError) || formulaMissing || _incomplete,
|
|
2697
|
+
message: formulaMissing ? '公式丢失' : _incomplete ? __('metabase.sqlErrorOpenNested') : referenceErrorMessage
|
|
2640
2698
|
};
|
|
2641
2699
|
}
|
|
2642
2700
|
return {
|
|
@@ -2665,6 +2723,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2665
2723
|
snapshotMode: snapshotMode,
|
|
2666
2724
|
notExistsColumns: exitData,
|
|
2667
2725
|
isExit: true,
|
|
2726
|
+
sqlValidationQueryKind: 'exists',
|
|
2668
2727
|
toolbar: _toolbar,
|
|
2669
2728
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
2670
2729
|
value: cloneDeep(_value),
|
|
@@ -2674,13 +2733,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2674
2733
|
return;
|
|
2675
2734
|
}
|
|
2676
2735
|
try {
|
|
2736
|
+
var _store$preProps4;
|
|
2677
2737
|
if (isEqual(newList, oldList)) {
|
|
2678
2738
|
o.close();
|
|
2679
2739
|
return;
|
|
2680
2740
|
}
|
|
2681
2741
|
var expression = {
|
|
2682
2742
|
notExists: cloneDeep(newList),
|
|
2683
|
-
quotes: buildSqlQuery(newList, caseList[i].type),
|
|
2743
|
+
quotes: buildSqlQuery(newList, caseList[i].type, (_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.sqlDialect),
|
|
2684
2744
|
type: caseList[i].type
|
|
2685
2745
|
};
|
|
2686
2746
|
caseList[i] = expression;
|
|
@@ -2697,13 +2757,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2697
2757
|
};
|
|
2698
2758
|
var showSubQuery = function showSubQuery(i) {
|
|
2699
2759
|
var _caseList$i3, _caseList$i4;
|
|
2700
|
-
var _store$
|
|
2701
|
-
subToolbar = _store$
|
|
2702
|
-
notExistsColumns = _store$
|
|
2703
|
-
showFields = _store$
|
|
2704
|
-
isExit = _store$
|
|
2705
|
-
toolbar = _store$
|
|
2706
|
-
other = _objectWithoutProperties(_store$
|
|
2760
|
+
var _store$preProps5 = store.preProps,
|
|
2761
|
+
subToolbar = _store$preProps5.subToolbar,
|
|
2762
|
+
notExistsColumns = _store$preProps5.notExistsColumns,
|
|
2763
|
+
showFields = _store$preProps5.showFields,
|
|
2764
|
+
isExit = _store$preProps5.isExit,
|
|
2765
|
+
toolbar = _store$preProps5.toolbar,
|
|
2766
|
+
other = _objectWithoutProperties(_store$preProps5, _excluded3);
|
|
2707
2767
|
var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
|
|
2708
2768
|
var oldList = cloneDeep(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
|
|
2709
2769
|
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
@@ -2719,9 +2779,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2719
2779
|
snapshotMode: snapshotMode,
|
|
2720
2780
|
isExit: true,
|
|
2721
2781
|
isSubquery: true,
|
|
2782
|
+
sqlValidationQueryKind: 'query',
|
|
2722
2783
|
notExistsColumns: exitData,
|
|
2723
2784
|
fieldEnableAlias: false,
|
|
2724
2785
|
toolbar: _toolbar,
|
|
2786
|
+
subToolbar: subToolbar,
|
|
2725
2787
|
btnText: __('SqlQueryBuilder.confirm'),
|
|
2726
2788
|
value: cloneDeep(_value),
|
|
2727
2789
|
onOk: function onOk(newList) {
|
|
@@ -2730,13 +2792,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2730
2792
|
return;
|
|
2731
2793
|
}
|
|
2732
2794
|
try {
|
|
2795
|
+
var _store$preProps6;
|
|
2733
2796
|
if (isEqual(newList, oldList)) {
|
|
2734
2797
|
o.close();
|
|
2735
2798
|
return;
|
|
2736
2799
|
}
|
|
2737
2800
|
var expression = {
|
|
2738
2801
|
subQuery: cloneDeep(newList),
|
|
2739
|
-
quotes: buildSqlQuery(newList, caseList[i].type),
|
|
2802
|
+
quotes: buildSqlQuery(newList, caseList[i].type, (_store$preProps6 = store.preProps) === null || _store$preProps6 === void 0 ? void 0 : _store$preProps6.sqlDialect),
|
|
2740
2803
|
type: caseList[i].type
|
|
2741
2804
|
};
|
|
2742
2805
|
caseList[i] = expression;
|
|
@@ -2792,15 +2855,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2792
2855
|
},
|
|
2793
2856
|
ref: _ref,
|
|
2794
2857
|
onOk: function onOk(data) {
|
|
2795
|
-
var _ref$current;
|
|
2796
|
-
var errorElements = ((_ref$current = _ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelectorAll('.isSqlError')) || [];
|
|
2797
|
-
if (errorElements.length) {
|
|
2798
|
-
Modal.error({
|
|
2799
|
-
title: __('metabase.prompt'),
|
|
2800
|
-
content: __('metabase.validationFormula')
|
|
2801
|
-
});
|
|
2802
|
-
return;
|
|
2803
|
-
}
|
|
2804
2858
|
var _caseList = caseList.slice();
|
|
2805
2859
|
_caseList[i] = data;
|
|
2806
2860
|
setCaseList(_caseList);
|
|
@@ -2852,10 +2906,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2852
2906
|
}
|
|
2853
2907
|
if (type === AtomsTypeEnum.INPUT_STRING) {
|
|
2854
2908
|
return {
|
|
2855
|
-
className: '
|
|
2909
|
+
className: 'green-name',
|
|
2856
2910
|
node: _jsxs(_Fragment, {
|
|
2857
2911
|
children: [_jsx(FieldString, {}), _jsx(Input, {
|
|
2858
|
-
className: '
|
|
2912
|
+
className: 'sqb-Custom-input',
|
|
2859
2913
|
value: v.val,
|
|
2860
2914
|
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
2861
2915
|
size: 'large',
|
|
@@ -2868,10 +2922,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2868
2922
|
}
|
|
2869
2923
|
if (type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
2870
2924
|
return {
|
|
2871
|
-
className: '
|
|
2925
|
+
className: 'green-name',
|
|
2872
2926
|
node: _jsxs(_Fragment, {
|
|
2873
2927
|
children: [_jsx(FieldNumber, {}), _jsx(InputNumber, {
|
|
2874
|
-
className: '
|
|
2928
|
+
className: 'sqb-Custom-input',
|
|
2875
2929
|
value: v.val,
|
|
2876
2930
|
placeholder: __('SqlQueryBuilder.pleaseEnter'),
|
|
2877
2931
|
size: 'large',
|
|
@@ -2882,6 +2936,47 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2882
2936
|
})
|
|
2883
2937
|
};
|
|
2884
2938
|
}
|
|
2939
|
+
if (isInputListType(type)) {
|
|
2940
|
+
var tagValues = getInputListValues(v.val);
|
|
2941
|
+
return {
|
|
2942
|
+
className: cx('teal-name sqb-InputListToken', {
|
|
2943
|
+
notSelected: !tagValues.length
|
|
2944
|
+
}),
|
|
2945
|
+
node: _jsxs(_Fragment, {
|
|
2946
|
+
children: [_jsx(Tags, {}), _jsx(Select, {
|
|
2947
|
+
className: 'sqb-Custom-input',
|
|
2948
|
+
size: 'large',
|
|
2949
|
+
autoWidth: true,
|
|
2950
|
+
maxWidth: '100%',
|
|
2951
|
+
animation: false,
|
|
2952
|
+
placeholder: __('customColumn.inputListPlaceholder'),
|
|
2953
|
+
allowCreate: true,
|
|
2954
|
+
multiple: true,
|
|
2955
|
+
dropdownMenuStyle: {
|
|
2956
|
+
minWidth: 160
|
|
2957
|
+
},
|
|
2958
|
+
triggerProps: _objectSpread(_objectSpread({}, getSelectTriggerProps()), {}, {
|
|
2959
|
+
autoAlignPopupWidth: false,
|
|
2960
|
+
autoAlignPopupMinWidth: true
|
|
2961
|
+
}),
|
|
2962
|
+
getPopupContainer: getCurrentPopupContainer,
|
|
2963
|
+
value: tagValues,
|
|
2964
|
+
onClick: function onClick(e) {
|
|
2965
|
+
return e.stopPropagation();
|
|
2966
|
+
},
|
|
2967
|
+
onChange: function onChange(val) {
|
|
2968
|
+
handleConstant(getInputListValues(val).join(','), index);
|
|
2969
|
+
},
|
|
2970
|
+
children: tagValues.map(function (option) {
|
|
2971
|
+
return _jsx(Select.Option, {
|
|
2972
|
+
value: option,
|
|
2973
|
+
children: option
|
|
2974
|
+
}, option);
|
|
2975
|
+
})
|
|
2976
|
+
}), renderDeleteIcon(v, index, groupType)]
|
|
2977
|
+
})
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2885
2980
|
if (type === AtomsTypeEnum.OPERATOR) {
|
|
2886
2981
|
return {
|
|
2887
2982
|
className: cx('operator-trigger', {
|
|
@@ -3039,8 +3134,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3039
3134
|
children: selectOperator({
|
|
3040
3135
|
triggerElement: function triggerElement() {
|
|
3041
3136
|
return _jsx("div", {
|
|
3042
|
-
className: cx('Sqb-TableName', customInputClassName),
|
|
3043
|
-
style: getTokenStyleByClassName(customInputClassName),
|
|
3137
|
+
className: cx('Sqb-TableName', 'Sqb-ExprToken', customInputClassName),
|
|
3044
3138
|
children: renderTokenContent(_jsxs(_Fragment, {
|
|
3045
3139
|
children: [__('customColumn.selectCustomInput'), renderDeleteIcon(v, index, groupType)]
|
|
3046
3140
|
}))
|
|
@@ -3052,12 +3146,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3052
3146
|
}))
|
|
3053
3147
|
};
|
|
3054
3148
|
};
|
|
3149
|
+
var hasClipboard = isCopy && (selectedIndices.length > 0 || checkedItemsCount > 0);
|
|
3055
3150
|
var copyDom = function copyDom() {
|
|
3056
3151
|
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
3057
3152
|
var positioned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
3058
3153
|
if (snapshotMode) return null;
|
|
3059
|
-
if (
|
|
3060
|
-
if (!
|
|
3154
|
+
if (forceChecked) return null;
|
|
3155
|
+
if (!hasClipboard) return null;
|
|
3061
3156
|
return _jsx("div", {
|
|
3062
3157
|
className: cx('Sqb-Filter-item-copy', {
|
|
3063
3158
|
'Sqb-Filter-item-copy-static': !positioned
|
|
@@ -3084,19 +3179,66 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3084
3179
|
})
|
|
3085
3180
|
});
|
|
3086
3181
|
};
|
|
3182
|
+
var renderInsertArrow = function renderInsertArrow(i, position) {
|
|
3183
|
+
return selectOperator({
|
|
3184
|
+
triggerElement: function triggerElement() {
|
|
3185
|
+
return _jsx("div", {
|
|
3186
|
+
className: position === 'before' ? 'left-arrow' : 'right-arrow',
|
|
3187
|
+
"v-index": i,
|
|
3188
|
+
"v-type": position,
|
|
3189
|
+
onClick: function onClick() {
|
|
3190
|
+
if (position === 'before') {
|
|
3191
|
+
if (!selectedIndices.length) addOperator(AtomsTypeEnum.UNKNOWN, i, 'before');
|
|
3192
|
+
return;
|
|
3193
|
+
}
|
|
3194
|
+
addOperator(AtomsTypeEnum.UNKNOWN, i, 'after');
|
|
3195
|
+
},
|
|
3196
|
+
children: _jsx("img", {
|
|
3197
|
+
src: arrow
|
|
3198
|
+
})
|
|
3199
|
+
});
|
|
3200
|
+
},
|
|
3201
|
+
ind: i,
|
|
3202
|
+
position: position,
|
|
3203
|
+
trigger: 'hover'
|
|
3204
|
+
});
|
|
3205
|
+
};
|
|
3087
3206
|
var renderItemShell = function renderItemShell(v, i, groupType, extraClassName) {
|
|
3088
3207
|
var showCheckbox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
3089
3208
|
var itemContent = itemDom(v, i, groupType);
|
|
3090
3209
|
var isCompositeAtom = v.type === AtomsTypeEnum.CASE_WHEN || v.type === AtomsTypeEnum.AND_OR;
|
|
3091
|
-
var showAfterArrow = !snapshotMode && canShowItemInsertArrows(v, groupType);
|
|
3092
|
-
var showBeforeArrow = !snapshotMode && canShowItemInsertArrows(v, groupType);
|
|
3210
|
+
var showAfterArrow = !snapshotMode && !inCheckMode && canShowItemInsertArrows(v, groupType);
|
|
3211
|
+
var showBeforeArrow = !snapshotMode && !inCheckMode && canShowItemInsertArrows(v, groupType);
|
|
3093
3212
|
var canOpenInSnapshot = v.type === AtomsTypeEnum.FORMULA || v.type === AtomsTypeEnum.FIELD || v.type === AtomsTypeEnum.SUB_QUERY || v.type === AtomsTypeEnum.EXISTS || v.type === AtomsTypeEnum.NOT_EXISTS;
|
|
3094
|
-
|
|
3095
|
-
|
|
3213
|
+
var itemNode = _jsx("div", {
|
|
3214
|
+
style: {
|
|
3215
|
+
pointerEvents: snapshotMode && !canOpenInSnapshot || inCheckMode && !isCompositeAtom || store.isMetabaseCopy ? 'none' : 'auto'
|
|
3216
|
+
},
|
|
3217
|
+
className: cx('Sqb-Filter-item-node', {
|
|
3218
|
+
openCheck: inCheckMode && !isCompositeAtom
|
|
3219
|
+
}),
|
|
3220
|
+
children: itemContent.raw ? itemContent.node : _jsx(ItemName, _objectSpread(_objectSpread({}, getItemNameProps(v)), {}, {
|
|
3221
|
+
children: _jsx(RightClickValue, {
|
|
3222
|
+
value: v,
|
|
3223
|
+
children: _jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
3224
|
+
className: cx('Sqb-TableName', 'Sqb-ExprToken', itemContent.className)
|
|
3225
|
+
}, snapshotMode && canOpenInSnapshot ? {
|
|
3226
|
+
'data-sqb-snapshot-allow': 'true'
|
|
3227
|
+
} : {}), {}, {
|
|
3228
|
+
onClick: itemContent.onClick,
|
|
3229
|
+
style: itemContent.style
|
|
3230
|
+
}, itemContent.attrs || {}), {}, {
|
|
3231
|
+
children: itemContent.node
|
|
3232
|
+
}))
|
|
3233
|
+
})
|
|
3234
|
+
}))
|
|
3235
|
+
});
|
|
3236
|
+
return _jsxs(React.Fragment, {
|
|
3237
|
+
children: [copyDom(i, false), _jsxs("div", {
|
|
3096
3238
|
className: cx('Sqb-Filter-item', _defineProperty({
|
|
3097
3239
|
hover: ind === i && hoveredCopyIndex !== i,
|
|
3098
3240
|
'item-fixed': v.fixed || false,
|
|
3099
|
-
'item-selected':
|
|
3241
|
+
'item-selected': inCheckMode,
|
|
3100
3242
|
'item-composite': isCompositeAtom,
|
|
3101
3243
|
'has-left-arrow': showBeforeArrow,
|
|
3102
3244
|
'has-right-arrow': showAfterArrow,
|
|
@@ -3105,79 +3247,32 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3105
3247
|
'group-logic-child': groupType === 'logic'
|
|
3106
3248
|
}, extraClassName || '', !!extraClassName)),
|
|
3107
3249
|
onMouseEnter: function onMouseEnter(e) {
|
|
3108
|
-
if (
|
|
3250
|
+
if (inCheckMode) return;
|
|
3109
3251
|
setInd(i);
|
|
3110
3252
|
},
|
|
3111
3253
|
onMouseLeave: function onMouseLeave() {
|
|
3112
|
-
if (
|
|
3254
|
+
if (inCheckMode) return;
|
|
3113
3255
|
setInd(-1);
|
|
3114
3256
|
},
|
|
3115
|
-
children: [
|
|
3116
|
-
triggerElement: function triggerElement() {
|
|
3117
|
-
return _jsx("div", {
|
|
3118
|
-
className: 'left-arrow',
|
|
3119
|
-
"v-index": i,
|
|
3120
|
-
"v-type": 'before',
|
|
3121
|
-
onClick: function onClick() {
|
|
3122
|
-
if (!selectedIndices.length) addOperator(AtomsTypeEnum.UNKNOWN, i, 'before');
|
|
3123
|
-
},
|
|
3124
|
-
children: _jsx("img", {
|
|
3125
|
-
src: arrow
|
|
3126
|
-
})
|
|
3127
|
-
});
|
|
3128
|
-
},
|
|
3129
|
-
ind: i,
|
|
3130
|
-
position: 'before',
|
|
3131
|
-
trigger: 'hover'
|
|
3132
|
-
}), !snapshotMode && !embedded && showCheckbox && v.type !== AtomsTypeEnum.UNKNOWN && _jsx(Checkbox, {
|
|
3257
|
+
children: [!snapshotMode && (!embedded || inCheckMode) && showCheckbox && _jsx(Checkbox, {
|
|
3133
3258
|
className: 'item-check',
|
|
3134
|
-
checked: selectedIndices.includes(i),
|
|
3135
|
-
disabled: globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
|
|
3259
|
+
checked: forceChecked || selectedIndices.includes(i),
|
|
3260
|
+
disabled: forceChecked || globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
|
|
3261
|
+
onClick: function onClick(e) {
|
|
3262
|
+
return e.stopPropagation();
|
|
3263
|
+
},
|
|
3136
3264
|
onChange: function onChange(e) {
|
|
3137
3265
|
var _e$target$checked, _e$target;
|
|
3138
|
-
|
|
3266
|
+
if (forceChecked) return;
|
|
3267
|
+
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));
|
|
3139
3268
|
}
|
|
3140
|
-
}),
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
openCheck: isCheck && !isCompositeAtom
|
|
3146
|
-
}),
|
|
3147
|
-
children: itemContent.raw ? itemContent.node : _jsx(ItemName, _objectSpread(_objectSpread({}, getItemNameProps(v)), {}, {
|
|
3148
|
-
children: _jsx(RightClickValue, {
|
|
3149
|
-
value: v,
|
|
3150
|
-
children: _jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
3151
|
-
className: cx('Sqb-TableName', itemContent.className)
|
|
3152
|
-
}, snapshotMode && canOpenInSnapshot ? {
|
|
3153
|
-
'data-sqb-snapshot-allow': 'true'
|
|
3154
|
-
} : {}), {}, {
|
|
3155
|
-
onClick: itemContent.onClick,
|
|
3156
|
-
style: getTokenStyleByClassName(itemContent.className, itemContent.style)
|
|
3157
|
-
}, itemContent.attrs || {}), {}, {
|
|
3158
|
-
children: itemContent.node
|
|
3159
|
-
}))
|
|
3160
|
-
})
|
|
3161
|
-
}))
|
|
3162
|
-
}), showAfterArrow && selectOperator({
|
|
3163
|
-
triggerElement: function triggerElement(value) {
|
|
3164
|
-
return _jsx("div", {
|
|
3165
|
-
className: 'right-arrow',
|
|
3166
|
-
"v-index": i,
|
|
3167
|
-
"v-type": 'after',
|
|
3168
|
-
onClick: function onClick() {
|
|
3169
|
-
addOperator(AtomsTypeEnum.UNKNOWN, i, 'after');
|
|
3170
|
-
},
|
|
3171
|
-
children: _jsx("img", {
|
|
3172
|
-
src: arrow
|
|
3173
|
-
})
|
|
3174
|
-
});
|
|
3175
|
-
},
|
|
3176
|
-
ind: i,
|
|
3177
|
-
position: 'after',
|
|
3178
|
-
trigger: 'hover'
|
|
3269
|
+
}), isCompositeAtom ? _jsxs("div", {
|
|
3270
|
+
className: 'Sqb-Filter-item-frame',
|
|
3271
|
+
children: [showBeforeArrow && renderInsertArrow(i, 'before'), itemNode, showAfterArrow && renderInsertArrow(i, 'after')]
|
|
3272
|
+
}) : _jsxs(_Fragment, {
|
|
3273
|
+
children: [showBeforeArrow && renderInsertArrow(i, 'before'), itemNode, showAfterArrow && renderInsertArrow(i, 'after')]
|
|
3179
3274
|
})]
|
|
3180
|
-
})
|
|
3275
|
+
})]
|
|
3181
3276
|
}, i);
|
|
3182
3277
|
};
|
|
3183
3278
|
var renderCaseSection = function renderCaseSection(itemIndices, groupType, sectionClassName) {
|
|
@@ -3205,19 +3300,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3205
3300
|
})
|
|
3206
3301
|
});
|
|
3207
3302
|
};
|
|
3208
|
-
var renderCaseRecoverButton = function renderCaseRecoverButton(onClick, className, label) {
|
|
3209
|
-
return _jsx(Tooltip, {
|
|
3210
|
-
title: label,
|
|
3211
|
-
children: _jsxs("button", {
|
|
3212
|
-
type: 'button',
|
|
3213
|
-
className: cx('Sqb-CaseRecover', className),
|
|
3214
|
-
onClick: onClick,
|
|
3215
|
-
children: [_jsx(FfPlus, {}), _jsx("span", {
|
|
3216
|
-
children: label
|
|
3217
|
-
})]
|
|
3218
|
-
})
|
|
3219
|
-
});
|
|
3220
|
-
};
|
|
3221
3303
|
var renderGroupInsertArrow = function renderGroupInsertArrow(index, position) {
|
|
3222
3304
|
return selectOperator({
|
|
3223
3305
|
triggerElement: function triggerElement() {
|
|
@@ -3256,7 +3338,8 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3256
3338
|
return _jsx(_Fragment, {
|
|
3257
3339
|
children: _jsxs("div", {
|
|
3258
3340
|
className: cx('Sqb-NotebookCell', {
|
|
3259
|
-
'Sqb-NotebookCell--embedded': embedded
|
|
3341
|
+
'Sqb-NotebookCell--embedded': embedded,
|
|
3342
|
+
'Sqb-NotebookCell--pasteable': hasClipboard
|
|
3260
3343
|
}),
|
|
3261
3344
|
children: [showCopyTools ? _jsxs("div", {
|
|
3262
3345
|
className: 'Sqb-FormulaListTopTools',
|
|
@@ -3309,7 +3392,15 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3309
3392
|
triggerElement: function triggerElement() {
|
|
3310
3393
|
return _jsx(Tooltip, {
|
|
3311
3394
|
title: "\u6DFB\u52A0",
|
|
3312
|
-
children:
|
|
3395
|
+
children: embedded ? _jsxs("div", {
|
|
3396
|
+
className: 'CwLine-add',
|
|
3397
|
+
children: [_jsx(AddIcon, {
|
|
3398
|
+
width: 10,
|
|
3399
|
+
height: 10
|
|
3400
|
+
}), _jsx("span", {
|
|
3401
|
+
children: "\u6DFB\u52A0"
|
|
3402
|
+
})]
|
|
3403
|
+
}) : _jsx("div", {
|
|
3313
3404
|
className: cx("Sqb-TableName gray-name"),
|
|
3314
3405
|
style: ADD_TRIGGER_STYLE,
|
|
3315
3406
|
children: _jsx(AddIcon, {})
|
|
@@ -3319,7 +3410,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3319
3410
|
ind: -1,
|
|
3320
3411
|
position: 'add',
|
|
3321
3412
|
trigger: 'click'
|
|
3322
|
-
}), !
|
|
3413
|
+
}), !snapshotMode && copyDom(-1, false), !snapshotMode && !embedded && showPreview && _jsx("div", {
|
|
3323
3414
|
className: cx("mb-2 font-bold uppercase tracking-wider preview-box"),
|
|
3324
3415
|
style: {
|
|
3325
3416
|
fontSize: 12,
|
|
@@ -3329,7 +3420,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3329
3420
|
children: _jsxs(Space, {
|
|
3330
3421
|
direction: 'vertical',
|
|
3331
3422
|
size: 'middle',
|
|
3332
|
-
className: 'preview-container',
|
|
3423
|
+
className: cx('preview-container', {
|
|
3424
|
+
isSqlError: errorInfo.isError
|
|
3425
|
+
}),
|
|
3333
3426
|
children: [_jsxs("div", {
|
|
3334
3427
|
className: 'Sqb-FormulaPreviewHeader',
|
|
3335
3428
|
children: [_jsx("p", {
|