@gingkoo/pandora-metabase 1.0.158-alpha.4 → 1.0.158-alpha.6
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/components/metabase/index.js +51 -0
- package/lib/cjs/components/modules/components/meta-icon.js +1 -3
- package/lib/cjs/hooks/use-state.js +5 -61
- package/lib/cjs/index.js +1 -1
- package/lib/es/components/metabase/index.js +51 -0
- package/lib/es/components/modules/components/meta-icon.js +2 -4
- package/lib/es/hooks/use-state.js +5 -61
- package/lib/es/index.js +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ exports["default"] = void 0;
|
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
12
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
12
13
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
require("./index.less");
|
|
@@ -30,6 +31,49 @@ var VisualBox = _styledComponents["default"].div.attrs({
|
|
|
30
31
|
className: 'visual-box scroller'
|
|
31
32
|
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
32
33
|
var EMPTY_ARRAY = [];
|
|
34
|
+
var findJoinRelationConflict = function findJoinRelationConflict(metaList) {
|
|
35
|
+
var _iterator = (0, _createForOfIteratorHelper2["default"])(metaList),
|
|
36
|
+
_step;
|
|
37
|
+
try {
|
|
38
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
|
+
var group = _step.value;
|
|
40
|
+
if (group.type !== 'group') continue;
|
|
41
|
+
var joinKeys = new Set();
|
|
42
|
+
var _iterator2 = (0, _createForOfIteratorHelper2["default"])(group.list || []),
|
|
43
|
+
_step2;
|
|
44
|
+
try {
|
|
45
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
46
|
+
var item = _step2.value;
|
|
47
|
+
if (item.type !== 'joinData' || !item.table1 || !item.table2) continue;
|
|
48
|
+
var key = "".concat(item.table1.id || '', "_").concat(item.table2.id || '', "_").concat(item.table2.name || '');
|
|
49
|
+
if (joinKeys.has(key)) {
|
|
50
|
+
return {
|
|
51
|
+
table1: item.table1,
|
|
52
|
+
table2: item.table2
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
joinKeys.add(key);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_iterator2.e(err);
|
|
59
|
+
} finally {
|
|
60
|
+
_iterator2.f();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch (err) {
|
|
64
|
+
_iterator.e(err);
|
|
65
|
+
} finally {
|
|
66
|
+
_iterator.f();
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
var formatTableName = function formatTableName(table) {
|
|
71
|
+
var _table$name, _table$name_zh;
|
|
72
|
+
var name = (_table$name = table.name) === null || _table$name === void 0 ? void 0 : _table$name.trim();
|
|
73
|
+
var nameZh = (_table$name_zh = table.name_zh) === null || _table$name_zh === void 0 ? void 0 : _table$name_zh.trim();
|
|
74
|
+
if (nameZh && name && nameZh !== name) return "".concat(nameZh, "\uFF08").concat(name, "\uFF09");
|
|
75
|
+
return nameZh || name || '未命名表';
|
|
76
|
+
};
|
|
33
77
|
var Metabase = function Metabase(props) {
|
|
34
78
|
var _props$btnText = props.btnText,
|
|
35
79
|
btnText = _props$btnText === void 0 ? '' : _props$btnText,
|
|
@@ -67,6 +111,13 @@ var Metabase = function Metabase(props) {
|
|
|
67
111
|
return content;
|
|
68
112
|
}, [store.popupData2]);
|
|
69
113
|
var onCheck = function onCheck() {
|
|
114
|
+
if (store.joinAliasConflictCheck) {
|
|
115
|
+
var conflict = findJoinRelationConflict(store.metaList);
|
|
116
|
+
if (conflict) {
|
|
117
|
+
_pandora.Toast.warning("\u5173\u8054\u91CD\u590D\uFF1A\u5DE6\u8868\u300C".concat(formatTableName(conflict.table1), "\u300D\u4E0E\u53F3\u8868\u300C").concat(formatTableName(conflict.table2), "\u300D\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u4FDD\u5B58"));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
70
121
|
var doms = store.popupContainer.current.querySelectorAll('.isError');
|
|
71
122
|
var isSqlError = store.popupContainer.current.querySelectorAll('.isSqlError');
|
|
72
123
|
if (isSqlError.length) {
|
|
@@ -315,9 +315,7 @@ var NextDom = function NextDom(props) {
|
|
|
315
315
|
var handlePaste = function handlePaste() {
|
|
316
316
|
var _store$metaList3;
|
|
317
317
|
var index = (_store$metaList3 = store.metaList) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3[groupIndex]) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3.list) === null || _store$metaList3 === void 0 ? void 0 : _store$metaList3.indexOf(meta);
|
|
318
|
-
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule
|
|
319
|
-
_pandora.Toast.warning("\u8BE5\u8868\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u590D\u5236");
|
|
320
|
-
});
|
|
318
|
+
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule);
|
|
321
319
|
if (success) {
|
|
322
320
|
store.setMetabaseCopyModule([]);
|
|
323
321
|
store.setIsMetabaseCopy(false);
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = exports.SummarizeAlias = void 0;
|
|
8
|
-
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
9
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
|
|
10
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
11
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
@@ -523,7 +522,6 @@ var useStore = function useStore() {
|
|
|
523
522
|
var oldColumns,
|
|
524
523
|
callback,
|
|
525
524
|
isSelect,
|
|
526
|
-
_isSubquery,
|
|
527
525
|
_isExit,
|
|
528
526
|
_table$alias,
|
|
529
527
|
alias,
|
|
@@ -541,11 +539,7 @@ var useStore = function useStore() {
|
|
|
541
539
|
oldColumns = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : [];
|
|
542
540
|
callback = _args8.length > 3 ? _args8[3] : undefined;
|
|
543
541
|
isSelect = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : isSelectFields;
|
|
544
|
-
|
|
545
|
-
_isExit = _args8.length > 6 && _args8[6] !== undefined ? _args8[6] : isExit;
|
|
546
|
-
if (_isSubquery && oldColumns.length < 1) {
|
|
547
|
-
isSelect = false;
|
|
548
|
-
}
|
|
542
|
+
_isExit = _args8.length > 5 && _args8[5] !== undefined ? _args8[5] : isExit;
|
|
549
543
|
_table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = (0, _objectWithoutProperties2["default"])(table, _excluded);
|
|
550
544
|
tableName = table.name;
|
|
551
545
|
columns = getColumns(tableName);
|
|
@@ -639,8 +633,7 @@ var useStore = function useStore() {
|
|
|
639
633
|
};
|
|
640
634
|
}();
|
|
641
635
|
var setPreData = function setPreData(data) {
|
|
642
|
-
var
|
|
643
|
-
var _isExit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isExit;
|
|
636
|
+
var _isExit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isExit;
|
|
644
637
|
if (data.length) {
|
|
645
638
|
var _metaList = data === null || data === void 0 ? void 0 : data.map(function (item, groupIndex) {
|
|
646
639
|
var _item$list;
|
|
@@ -657,7 +650,7 @@ var useStore = function useStore() {
|
|
|
657
650
|
newMeta[i].columns = columns || [];
|
|
658
651
|
}
|
|
659
652
|
setMeta(newMeta, groupIndex, 'init', data);
|
|
660
|
-
}, false,
|
|
653
|
+
}, false, _isExit);
|
|
661
654
|
return (0, _objectSpread2["default"])({}, v);
|
|
662
655
|
}
|
|
663
656
|
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId) {
|
|
@@ -667,7 +660,7 @@ var useStore = function useStore() {
|
|
|
667
660
|
newMeta[i].columns = columns || [];
|
|
668
661
|
}
|
|
669
662
|
setMeta(newMeta, groupIndex, 'init', data);
|
|
670
|
-
}, false,
|
|
663
|
+
}, false, _isExit);
|
|
671
664
|
return (0, _objectSpread2["default"])({}, v);
|
|
672
665
|
}
|
|
673
666
|
return (0, _objectSpread2["default"])({}, v);
|
|
@@ -890,57 +883,8 @@ var useStore = function useStore() {
|
|
|
890
883
|
}
|
|
891
884
|
return item;
|
|
892
885
|
};
|
|
893
|
-
var
|
|
894
|
-
var _metaList$groupIndex;
|
|
895
|
-
if (!objList || objList.length === 0) return {
|
|
896
|
-
hasConflict: false
|
|
897
|
-
};
|
|
898
|
-
var groupList = ((_metaList$groupIndex = metaList[groupIndex]) === null || _metaList$groupIndex === void 0 ? void 0 : _metaList$groupIndex.list) || [];
|
|
899
|
-
var getJoinKey = function getJoinKey(table1, table2) {
|
|
900
|
-
return "".concat((table1 === null || table1 === void 0 ? void 0 : table1.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.name) || '');
|
|
901
|
-
};
|
|
902
|
-
var existingJoinKeys = new Set();
|
|
903
|
-
groupList.forEach(function (item) {
|
|
904
|
-
if (item.type === _enum.TypeEnum.joinData && item.table1 && item.table2) {
|
|
905
|
-
existingJoinKeys.add(getJoinKey(item.table1, item.table2));
|
|
906
|
-
}
|
|
907
|
-
});
|
|
908
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(objList),
|
|
909
|
-
_step;
|
|
910
|
-
try {
|
|
911
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
912
|
-
var pastedItem = _step.value;
|
|
913
|
-
if (pastedItem.type !== _enum.TypeEnum.joinData || !pastedItem.table1 || !pastedItem.table2) {
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
var pastedKey = getJoinKey(pastedItem.table1, pastedItem.table2);
|
|
917
|
-
if (existingJoinKeys.has(pastedKey)) {
|
|
918
|
-
var _pastedItem$table, _pastedItem$table2;
|
|
919
|
-
return {
|
|
920
|
-
hasConflict: true,
|
|
921
|
-
conflictingAlias: (_pastedItem$table = pastedItem.table2) === null || _pastedItem$table === void 0 ? void 0 : _pastedItem$table.alias,
|
|
922
|
-
conflictingId: (_pastedItem$table2 = pastedItem.table2) === null || _pastedItem$table2 === void 0 ? void 0 : _pastedItem$table2.id
|
|
923
|
-
};
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
} catch (err) {
|
|
927
|
-
_iterator.e(err);
|
|
928
|
-
} finally {
|
|
929
|
-
_iterator.f();
|
|
930
|
-
}
|
|
931
|
-
return {
|
|
932
|
-
hasConflict: false
|
|
933
|
-
};
|
|
934
|
-
};
|
|
935
|
-
var addMeta = function addMeta(type, index, groupIndex, obj, onConflict) {
|
|
886
|
+
var addMeta = function addMeta(type, index, groupIndex, obj) {
|
|
936
887
|
if (snapshotMode) return false;
|
|
937
|
-
if (joinAliasConflictCheck && obj && obj.length > 0) {
|
|
938
|
-
var conflict = checkTable1Conflict(obj, index, groupIndex);
|
|
939
|
-
if (conflict.hasConflict && conflict.conflictingAlias && onConflict) {
|
|
940
|
-
onConflict(conflict.conflictingAlias);
|
|
941
|
-
return false;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
888
|
var newMeta = metaList[groupIndex].list.slice();
|
|
945
889
|
var items = [];
|
|
946
890
|
var sharedUuidMap = {};
|
package/lib/cjs/index.js
CHANGED
|
@@ -116,7 +116,7 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
|
|
|
116
116
|
(0, _react.useEffect)(function () {
|
|
117
117
|
var source_value = (0, _utils.normalizeAndOrStructure)((0, _utils.patchData)(value, constantList, formulaTemplates));
|
|
118
118
|
var _value = (0, _utils.reassembleByUnion)(source_value);
|
|
119
|
-
store.setPreData((0, _cloneDeep["default"])(_value),
|
|
119
|
+
store.setPreData((0, _cloneDeep["default"])(_value), isExit);
|
|
120
120
|
store.setSourceData(source_value);
|
|
121
121
|
getExistsError && store.setExistsErrorFn(getExistsError, value);
|
|
122
122
|
}, [value, constantList, formulaTemplates]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
5
|
var _templateObject;
|
|
5
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -21,6 +22,49 @@ var VisualBox = Styled.div.attrs({
|
|
|
21
22
|
className: 'visual-box scroller'
|
|
22
23
|
})(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
|
|
23
24
|
var EMPTY_ARRAY = [];
|
|
25
|
+
var findJoinRelationConflict = function findJoinRelationConflict(metaList) {
|
|
26
|
+
var _iterator = _createForOfIteratorHelper(metaList),
|
|
27
|
+
_step;
|
|
28
|
+
try {
|
|
29
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
30
|
+
var group = _step.value;
|
|
31
|
+
if (group.type !== 'group') continue;
|
|
32
|
+
var joinKeys = new Set();
|
|
33
|
+
var _iterator2 = _createForOfIteratorHelper(group.list || []),
|
|
34
|
+
_step2;
|
|
35
|
+
try {
|
|
36
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
37
|
+
var item = _step2.value;
|
|
38
|
+
if (item.type !== 'joinData' || !item.table1 || !item.table2) continue;
|
|
39
|
+
var key = "".concat(item.table1.id || '', "_").concat(item.table2.id || '', "_").concat(item.table2.name || '');
|
|
40
|
+
if (joinKeys.has(key)) {
|
|
41
|
+
return {
|
|
42
|
+
table1: item.table1,
|
|
43
|
+
table2: item.table2
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
joinKeys.add(key);
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_iterator2.e(err);
|
|
50
|
+
} finally {
|
|
51
|
+
_iterator2.f();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
_iterator.e(err);
|
|
56
|
+
} finally {
|
|
57
|
+
_iterator.f();
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
var formatTableName = function formatTableName(table) {
|
|
62
|
+
var _table$name, _table$name_zh;
|
|
63
|
+
var name = (_table$name = table.name) === null || _table$name === void 0 ? void 0 : _table$name.trim();
|
|
64
|
+
var nameZh = (_table$name_zh = table.name_zh) === null || _table$name_zh === void 0 ? void 0 : _table$name_zh.trim();
|
|
65
|
+
if (nameZh && name && nameZh !== name) return "".concat(nameZh, "\uFF08").concat(name, "\uFF09");
|
|
66
|
+
return nameZh || name || '未命名表';
|
|
67
|
+
};
|
|
24
68
|
var Metabase = function Metabase(props) {
|
|
25
69
|
var _props$btnText = props.btnText,
|
|
26
70
|
btnText = _props$btnText === void 0 ? '' : _props$btnText,
|
|
@@ -58,6 +102,13 @@ var Metabase = function Metabase(props) {
|
|
|
58
102
|
return content;
|
|
59
103
|
}, [store.popupData2]);
|
|
60
104
|
var onCheck = function onCheck() {
|
|
105
|
+
if (store.joinAliasConflictCheck) {
|
|
106
|
+
var conflict = findJoinRelationConflict(store.metaList);
|
|
107
|
+
if (conflict) {
|
|
108
|
+
Toast.warning("\u5173\u8054\u91CD\u590D\uFF1A\u5DE6\u8868\u300C".concat(formatTableName(conflict.table1), "\u300D\u4E0E\u53F3\u8868\u300C").concat(formatTableName(conflict.table2), "\u300D\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u4FDD\u5B58"));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
61
112
|
var doms = store.popupContainer.current.querySelectorAll('.isError');
|
|
62
113
|
var isSqlError = store.popupContainer.current.querySelectorAll('.isSqlError');
|
|
63
114
|
if (isSqlError.length) {
|
|
@@ -5,7 +5,7 @@ import React, { useEffect } from 'react';
|
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { __ } from '../../../locale';
|
|
7
7
|
import { TypeEnum } from '../../../store/enum';
|
|
8
|
-
import { Tooltip, Button
|
|
8
|
+
import { Tooltip, Button } from '@gingkoo/pandora';
|
|
9
9
|
import { FfPlus } from '@gingkoo/pandora-icons';
|
|
10
10
|
import storage from '../../../utils/storage';
|
|
11
11
|
import { getHelper, isCanPaste } from '../../../utils';
|
|
@@ -306,9 +306,7 @@ var NextDom = function NextDom(props) {
|
|
|
306
306
|
var handlePaste = function handlePaste() {
|
|
307
307
|
var _store$metaList3;
|
|
308
308
|
var index = (_store$metaList3 = store.metaList) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3[groupIndex]) === null || _store$metaList3 === void 0 || (_store$metaList3 = _store$metaList3.list) === null || _store$metaList3 === void 0 ? void 0 : _store$metaList3.indexOf(meta);
|
|
309
|
-
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule
|
|
310
|
-
Toast.warning("\u8BE5\u8868\u5DF2\u5B58\u5728\u5173\u8054\uFF0C\u4E0D\u80FD\u590D\u5236");
|
|
311
|
-
});
|
|
309
|
+
var success = store.addMeta('', index + 1, groupIndex, store.metabaseCopyModule);
|
|
312
310
|
if (success) {
|
|
313
311
|
store.setMetabaseCopyModule([]);
|
|
314
312
|
store.setIsMetabaseCopy(false);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
@@ -517,7 +516,6 @@ var useStore = function useStore() {
|
|
|
517
516
|
var oldColumns,
|
|
518
517
|
callback,
|
|
519
518
|
isSelect,
|
|
520
|
-
_isSubquery,
|
|
521
519
|
_isExit,
|
|
522
520
|
_table$alias,
|
|
523
521
|
alias,
|
|
@@ -535,11 +533,7 @@ var useStore = function useStore() {
|
|
|
535
533
|
oldColumns = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : [];
|
|
536
534
|
callback = _args8.length > 3 ? _args8[3] : undefined;
|
|
537
535
|
isSelect = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : isSelectFields;
|
|
538
|
-
|
|
539
|
-
_isExit = _args8.length > 6 && _args8[6] !== undefined ? _args8[6] : isExit;
|
|
540
|
-
if (_isSubquery && oldColumns.length < 1) {
|
|
541
|
-
isSelect = false;
|
|
542
|
-
}
|
|
536
|
+
_isExit = _args8.length > 5 && _args8[5] !== undefined ? _args8[5] : isExit;
|
|
543
537
|
_table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = _objectWithoutProperties(table, _excluded);
|
|
544
538
|
tableName = table.name;
|
|
545
539
|
columns = getColumns(tableName);
|
|
@@ -633,8 +627,7 @@ var useStore = function useStore() {
|
|
|
633
627
|
};
|
|
634
628
|
}();
|
|
635
629
|
var setPreData = function setPreData(data) {
|
|
636
|
-
var
|
|
637
|
-
var _isExit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isExit;
|
|
630
|
+
var _isExit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isExit;
|
|
638
631
|
if (data.length) {
|
|
639
632
|
var _metaList = data === null || data === void 0 ? void 0 : data.map(function (item, groupIndex) {
|
|
640
633
|
var _item$list;
|
|
@@ -651,7 +644,7 @@ var useStore = function useStore() {
|
|
|
651
644
|
newMeta[i].columns = columns || [];
|
|
652
645
|
}
|
|
653
646
|
setMeta(newMeta, groupIndex, 'init', data);
|
|
654
|
-
}, false,
|
|
647
|
+
}, false, _isExit);
|
|
655
648
|
return _objectSpread({}, v);
|
|
656
649
|
}
|
|
657
650
|
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId) {
|
|
@@ -661,7 +654,7 @@ var useStore = function useStore() {
|
|
|
661
654
|
newMeta[i].columns = columns || [];
|
|
662
655
|
}
|
|
663
656
|
setMeta(newMeta, groupIndex, 'init', data);
|
|
664
|
-
}, false,
|
|
657
|
+
}, false, _isExit);
|
|
665
658
|
return _objectSpread({}, v);
|
|
666
659
|
}
|
|
667
660
|
return _objectSpread({}, v);
|
|
@@ -884,57 +877,8 @@ var useStore = function useStore() {
|
|
|
884
877
|
}
|
|
885
878
|
return item;
|
|
886
879
|
};
|
|
887
|
-
var
|
|
888
|
-
var _metaList$groupIndex;
|
|
889
|
-
if (!objList || objList.length === 0) return {
|
|
890
|
-
hasConflict: false
|
|
891
|
-
};
|
|
892
|
-
var groupList = ((_metaList$groupIndex = metaList[groupIndex]) === null || _metaList$groupIndex === void 0 ? void 0 : _metaList$groupIndex.list) || [];
|
|
893
|
-
var getJoinKey = function getJoinKey(table1, table2) {
|
|
894
|
-
return "".concat((table1 === null || table1 === void 0 ? void 0 : table1.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.id) || '', "_").concat((table2 === null || table2 === void 0 ? void 0 : table2.name) || '');
|
|
895
|
-
};
|
|
896
|
-
var existingJoinKeys = new Set();
|
|
897
|
-
groupList.forEach(function (item) {
|
|
898
|
-
if (item.type === TypeEnum.joinData && item.table1 && item.table2) {
|
|
899
|
-
existingJoinKeys.add(getJoinKey(item.table1, item.table2));
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
var _iterator = _createForOfIteratorHelper(objList),
|
|
903
|
-
_step;
|
|
904
|
-
try {
|
|
905
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
906
|
-
var pastedItem = _step.value;
|
|
907
|
-
if (pastedItem.type !== TypeEnum.joinData || !pastedItem.table1 || !pastedItem.table2) {
|
|
908
|
-
continue;
|
|
909
|
-
}
|
|
910
|
-
var pastedKey = getJoinKey(pastedItem.table1, pastedItem.table2);
|
|
911
|
-
if (existingJoinKeys.has(pastedKey)) {
|
|
912
|
-
var _pastedItem$table, _pastedItem$table2;
|
|
913
|
-
return {
|
|
914
|
-
hasConflict: true,
|
|
915
|
-
conflictingAlias: (_pastedItem$table = pastedItem.table2) === null || _pastedItem$table === void 0 ? void 0 : _pastedItem$table.alias,
|
|
916
|
-
conflictingId: (_pastedItem$table2 = pastedItem.table2) === null || _pastedItem$table2 === void 0 ? void 0 : _pastedItem$table2.id
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
} catch (err) {
|
|
921
|
-
_iterator.e(err);
|
|
922
|
-
} finally {
|
|
923
|
-
_iterator.f();
|
|
924
|
-
}
|
|
925
|
-
return {
|
|
926
|
-
hasConflict: false
|
|
927
|
-
};
|
|
928
|
-
};
|
|
929
|
-
var addMeta = function addMeta(type, index, groupIndex, obj, onConflict) {
|
|
880
|
+
var addMeta = function addMeta(type, index, groupIndex, obj) {
|
|
930
881
|
if (snapshotMode) return false;
|
|
931
|
-
if (joinAliasConflictCheck && obj && obj.length > 0) {
|
|
932
|
-
var conflict = checkTable1Conflict(obj, index, groupIndex);
|
|
933
|
-
if (conflict.hasConflict && conflict.conflictingAlias && onConflict) {
|
|
934
|
-
onConflict(conflict.conflictingAlias);
|
|
935
|
-
return false;
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
882
|
var newMeta = metaList[groupIndex].list.slice();
|
|
939
883
|
var items = [];
|
|
940
884
|
var sharedUuidMap = {};
|
package/lib/es/index.js
CHANGED
|
@@ -101,7 +101,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
101
101
|
useEffect(function () {
|
|
102
102
|
var source_value = normalizeAndOrStructure(patchData(value, constantList, formulaTemplates));
|
|
103
103
|
var _value = reassembleByUnion(source_value);
|
|
104
|
-
store.setPreData(cloneDeep(_value),
|
|
104
|
+
store.setPreData(cloneDeep(_value), isExit);
|
|
105
105
|
store.setSourceData(source_value);
|
|
106
106
|
getExistsError && store.setExistsErrorFn(getExistsError, value);
|
|
107
107
|
}, [value, constantList, formulaTemplates]);
|