@gingkoo/pandora-metabase 1.0.158-alpha.5 → 1.0.158-alpha.7

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.
Files changed (31) hide show
  1. package/lib/cjs/components/dialog/column-type-label/index.d.ts +8 -0
  2. package/lib/cjs/components/dialog/column-type-label/index.js +22 -0
  3. package/lib/cjs/components/dialog/column-type-label/index.less +17 -0
  4. package/lib/cjs/components/dialog/select-column/index.js +7 -1
  5. package/lib/cjs/components/dialog/select-column/index.less +6 -1
  6. package/lib/cjs/components/dialog/select-column-multiple/index.js +7 -3
  7. package/lib/cjs/components/dialog/select-column-multiple/index.less +10 -0
  8. package/lib/cjs/components/dialog/select-join-column/index.js +7 -3
  9. package/lib/cjs/components/dialog/select-join-column/index.less +10 -0
  10. package/lib/cjs/components/dialog/select-join-column-multiple/index.js +7 -3
  11. package/lib/cjs/components/dialog/select-join-column-multiple/index.less +10 -0
  12. package/lib/cjs/components/metabase/index.js +51 -0
  13. package/lib/cjs/components/modules/components/meta-icon.js +1 -3
  14. package/lib/cjs/hooks/use-state.js +1 -51
  15. package/lib/cjs/store/types.d.ts +1 -0
  16. package/lib/es/components/dialog/column-type-label/index.d.ts +8 -0
  17. package/lib/es/components/dialog/column-type-label/index.js +16 -0
  18. package/lib/es/components/dialog/column-type-label/index.less +17 -0
  19. package/lib/es/components/dialog/select-column/index.js +7 -1
  20. package/lib/es/components/dialog/select-column/index.less +6 -1
  21. package/lib/es/components/dialog/select-column-multiple/index.js +7 -3
  22. package/lib/es/components/dialog/select-column-multiple/index.less +10 -0
  23. package/lib/es/components/dialog/select-join-column/index.js +7 -3
  24. package/lib/es/components/dialog/select-join-column/index.less +10 -0
  25. package/lib/es/components/dialog/select-join-column-multiple/index.js +7 -3
  26. package/lib/es/components/dialog/select-join-column-multiple/index.less +10 -0
  27. package/lib/es/components/metabase/index.js +51 -0
  28. package/lib/es/components/modules/components/meta-icon.js +2 -4
  29. package/lib/es/hooks/use-state.js +1 -51
  30. package/lib/es/store/types.d.ts +1 -0
  31. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import './index.less';
2
+ import React from 'react';
3
+ import { MetaData_ColumnsType } from '../../../store/types';
4
+ interface PropsType {
5
+ column: Pick<MetaData_ColumnsType, 'database_type' | 'database_length'>;
6
+ }
7
+ declare const ColumnTypeLabel: ({ column }: PropsType) => React.JSX.Element | null;
8
+ export default ColumnTypeLabel;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _jsxRuntime = require("react/jsx-runtime");
8
+ require("./index.less");
9
+ var ColumnTypeLabel = function ColumnTypeLabel(_ref) {
10
+ var column = _ref.column;
11
+ var databaseType = String(column.database_type || '').trim();
12
+ var databaseLength = column.database_length;
13
+ var hasLength = databaseLength !== undefined && databaseLength !== null && "".concat(databaseLength).trim() !== '';
14
+ if (!databaseType) return null;
15
+ var label = hasLength ? "".concat(databaseType, "(").concat(databaseLength, ")") : databaseType;
16
+ return (0, _jsxRuntime.jsx)("span", {
17
+ className: 'Sqb-ColumnTypeLabel',
18
+ title: label,
19
+ children: label
20
+ });
21
+ };
22
+ var _default = exports["default"] = ColumnTypeLabel;
@@ -0,0 +1,17 @@
1
+ .Sqb-ColumnTypeLabel {
2
+ flex: 0 0 auto;
3
+ margin-left: auto;
4
+ padding-left: 12px;
5
+ color: #949aab;
6
+ font-size: 12px;
7
+ font-weight: 400;
8
+ line-height: 20px;
9
+ white-space: nowrap;
10
+ }
11
+
12
+ .Sqb-List-item:hover,
13
+ .Sqb-List-item.active {
14
+ .Sqb-ColumnTypeLabel {
15
+ color: rgba(255, 255, 255, 0.82);
16
+ }
17
+ }
@@ -22,6 +22,7 @@ var _icons = require("../../icons");
22
22
  var _useProvider = require("../../../hooks/use-provider");
23
23
  var _helper = require("../../../utils/helper");
24
24
  var _utils = require("../../../utils");
25
+ var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
25
26
  var SelectColumn = function SelectColumn(_ref) {
26
27
  var _ref$data = _ref.data,
27
28
  data = _ref$data === void 0 ? [] : _ref$data,
@@ -233,7 +234,12 @@ var SelectColumn = function SelectColumn(_ref) {
233
234
  children: (0, _jsxRuntime.jsx)(_icons.SelectIcon, {})
234
235
  }) : (0, _jsxRuntime.jsx)("div", {
235
236
  className: 'no-select mr-2'
236
- }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', store.fieldEnableAlias && !readonly && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
237
+ }), (0, _jsxRuntime.jsxs)("span", {
238
+ className: 'Sqb-SelectColumn-name',
239
+ children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
240
+ }), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
241
+ column: v
242
+ }), store.fieldEnableAlias && !readonly && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
237
243
  title: (0, _locale.__)('SqlQueryBuilder.alias'),
238
244
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
239
245
  className: ':Sqb-TableName-as',
@@ -37,9 +37,14 @@
37
37
  }
38
38
  .Sqb-TableName-as {
39
39
  // font-size: 16px;
40
- margin-left: auto;
40
+ margin-left: 8px;
41
41
  }
42
42
  }
43
+ .Sqb-SelectColumn-name {
44
+ flex: 1 1 auto;
45
+ min-width: 0;
46
+ overflow-wrap: anywhere;
47
+ }
43
48
  .Sqb-SelectColumn--header {
44
49
  position: sticky;
45
50
  top: 0;
@@ -20,6 +20,7 @@ var _helper = require("../../../store/helper");
20
20
  var _types = require("../../../store/types");
21
21
  var _locale = require("../../../locale");
22
22
  var _const = require("../const");
23
+ var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
23
24
  var _useProvider = require("../../../hooks/use-provider");
24
25
  var _helper2 = require("../../../utils/helper");
25
26
  var _icons = require("../../icons");
@@ -509,11 +510,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
509
510
  children: [(0, _jsxRuntime.jsx)("span", {
510
511
  className: 'List-item-icon',
511
512
  children: IconMap[special_type || database_type] || (0, _jsxRuntime.jsx)(_icons.LetterAaIcon, {})
512
- }), (0, _jsxRuntime.jsx)("div", {
513
- children: (0, _jsxRuntime.jsxs)("h4", {
513
+ }), (0, _jsxRuntime.jsxs)("div", {
514
+ className: 'List-item-content',
515
+ children: [(0, _jsxRuntime.jsxs)("h4", {
514
516
  className: 'List-item-title ml-2',
515
517
  children: [(0, _helper2.replaceTpl)(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
516
- })
518
+ }), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
519
+ column: v
520
+ })]
517
521
  })]
518
522
  })
519
523
  })
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -17,6 +17,7 @@ var _enum = require("../../../store/enum");
17
17
  var _helper = require("../../../store/helper");
18
18
  var _locale = require("../../../locale");
19
19
  var _const = require("../const");
20
+ var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
20
21
  var _useProvider = require("../../../hooks/use-provider");
21
22
  var _helper2 = require("../../../utils/helper");
22
23
  var _icons = require("../../icons");
@@ -315,11 +316,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
315
316
  children: [(0, _jsxRuntime.jsx)("span", {
316
317
  className: 'List-item-icon',
317
318
  children: IconMap[special_type || database_type] || (0, _jsxRuntime.jsx)(_icons.LetterAaIcon, {})
318
- }), (0, _jsxRuntime.jsx)("div", {
319
- children: (0, _jsxRuntime.jsx)("h4", {
319
+ }), (0, _jsxRuntime.jsxs)("div", {
320
+ className: 'List-item-content',
321
+ children: [(0, _jsxRuntime.jsx)("h4", {
320
322
  className: 'List-item-title ml-2',
321
323
  children: (0, _helper2.replaceTpl)(store.fieldNameTpl, v)
322
- })
324
+ }), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
325
+ column: v
326
+ })]
323
327
  })]
324
328
  }), OPEN_GROUP && isGroup && groupe !== _enum.SQL_GROUP_TYPE.STRING && (0, _jsxRuntime.jsx)(_pandora.Popover, {
325
329
  placement: 'rt',
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -17,6 +17,7 @@ var _enum = require("../../../store/enum");
17
17
  var _helper = require("../../../store/helper");
18
18
  var _locale = require("../../../locale");
19
19
  var _const = require("../const");
20
+ var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
20
21
  var _useProvider = require("../../../hooks/use-provider");
21
22
  var _helper2 = require("../../../utils/helper");
22
23
  var _icons = require("../../icons");
@@ -251,11 +252,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
251
252
  children: [(0, _jsxRuntime.jsx)("span", {
252
253
  className: 'List-item-icon',
253
254
  children: IconMap[special_type || database_type] || (0, _jsxRuntime.jsx)(_icons.LetterAaIcon, {})
254
- }), (0, _jsxRuntime.jsx)("div", {
255
- children: (0, _jsxRuntime.jsx)("h4", {
255
+ }), (0, _jsxRuntime.jsxs)("div", {
256
+ className: 'List-item-content',
257
+ children: [(0, _jsxRuntime.jsx)("h4", {
256
258
  className: 'List-item-title ml-2',
257
259
  children: (0, _helper2.replaceTpl)(store.fieldNameTpl, v)
258
- })
260
+ }), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
261
+ column: v
262
+ })]
259
263
  })]
260
264
  })
261
265
  })
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -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, function (conflictingAlias) {
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"));
@@ -884,57 +883,8 @@ var useStore = function useStore() {
884
883
  }
885
884
  return item;
886
885
  };
887
- var checkTable1Conflict = function checkTable1Conflict(objList, _index, groupIndex) {
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 === _enum.TypeEnum.joinData && item.table1 && item.table2) {
899
- existingJoinKeys.add(getJoinKey(item.table1, item.table2));
900
- }
901
- });
902
- var _iterator = (0, _createForOfIteratorHelper2["default"])(objList),
903
- _step;
904
- try {
905
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
906
- var pastedItem = _step.value;
907
- if (pastedItem.type !== _enum.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) {
886
+ var addMeta = function addMeta(type, index, groupIndex, obj) {
930
887
  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
888
  var newMeta = metaList[groupIndex].list.slice();
939
889
  var items = [];
940
890
  var sharedUuidMap = {};
@@ -202,6 +202,7 @@ export interface MetaData_ColumnsType {
202
202
  tableUuid?: string;
203
203
  realName?: string;
204
204
  database_type: SQL_COLUMN_TYPE | '';
205
+ database_length?: number | string;
205
206
  special_type: SpecialType | '';
206
207
  datasourceId: string;
207
208
  datasourceName: string;
@@ -0,0 +1,8 @@
1
+ import './index.less';
2
+ import React from 'react';
3
+ import { MetaData_ColumnsType } from '../../../store/types';
4
+ interface PropsType {
5
+ column: Pick<MetaData_ColumnsType, 'database_type' | 'database_length'>;
6
+ }
7
+ declare const ColumnTypeLabel: ({ column }: PropsType) => React.JSX.Element | null;
8
+ export default ColumnTypeLabel;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import './index.less';
3
+ var ColumnTypeLabel = function ColumnTypeLabel(_ref) {
4
+ var column = _ref.column;
5
+ var databaseType = String(column.database_type || '').trim();
6
+ var databaseLength = column.database_length;
7
+ var hasLength = databaseLength !== undefined && databaseLength !== null && "".concat(databaseLength).trim() !== '';
8
+ if (!databaseType) return null;
9
+ var label = hasLength ? "".concat(databaseType, "(").concat(databaseLength, ")") : databaseType;
10
+ return _jsx("span", {
11
+ className: 'Sqb-ColumnTypeLabel',
12
+ title: label,
13
+ children: label
14
+ });
15
+ };
16
+ export default ColumnTypeLabel;
@@ -0,0 +1,17 @@
1
+ .Sqb-ColumnTypeLabel {
2
+ flex: 0 0 auto;
3
+ margin-left: auto;
4
+ padding-left: 12px;
5
+ color: #949aab;
6
+ font-size: 12px;
7
+ font-weight: 400;
8
+ line-height: 20px;
9
+ white-space: nowrap;
10
+ }
11
+
12
+ .Sqb-List-item:hover,
13
+ .Sqb-List-item.active {
14
+ .Sqb-ColumnTypeLabel {
15
+ color: rgba(255, 255, 255, 0.82);
16
+ }
17
+ }
@@ -16,6 +16,7 @@ import { useStore } from '../../../hooks/use-provider';
16
16
  import { getColumnIdFirstKey, isSameColumnByIdFirst, uuidv4 } from '../../../utils/helper';
17
17
  import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
18
18
  import { SearchIcon } from '../../icons';
19
+ import ColumnTypeLabel from '../column-type-label';
19
20
  var SelectColumn = function SelectColumn(_ref) {
20
21
  var _ref$data = _ref.data,
21
22
  data = _ref$data === void 0 ? [] : _ref$data,
@@ -227,7 +228,12 @@ var SelectColumn = function SelectColumn(_ref) {
227
228
  children: _jsx(SelectIcon, {})
228
229
  }) : _jsx("div", {
229
230
  className: 'no-select mr-2'
230
- }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', store.fieldEnableAlias && !readonly && _jsx(Tooltip, {
231
+ }), _jsxs("span", {
232
+ className: 'Sqb-SelectColumn-name',
233
+ children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
234
+ }), _jsx(ColumnTypeLabel, {
235
+ column: v
236
+ }), store.fieldEnableAlias && !readonly && _jsx(Tooltip, {
231
237
  title: __('SqlQueryBuilder.alias'),
232
238
  children: _jsx(Button, {
233
239
  className: ':Sqb-TableName-as',
@@ -37,9 +37,14 @@
37
37
  }
38
38
  .Sqb-TableName-as {
39
39
  // font-size: 16px;
40
- margin-left: auto;
40
+ margin-left: 8px;
41
41
  }
42
42
  }
43
+ .Sqb-SelectColumn-name {
44
+ flex: 1 1 auto;
45
+ min-width: 0;
46
+ overflow-wrap: anywhere;
47
+ }
43
48
  .Sqb-SelectColumn--header {
44
49
  position: sticky;
45
50
  top: 0;
@@ -14,6 +14,7 @@ import { SummarizeAlias } from '../../../store/helper';
14
14
  import { AtomsTypeEnum } from '../../../store/types';
15
15
  import { __ } from '../../../locale';
16
16
  import { NUMBER_GROUP, DATE_GROUP } from '../const';
17
+ import ColumnTypeLabel from '../column-type-label';
17
18
  import { useStore } from '../../../hooks/use-provider';
18
19
  import { replaceTpl, mergeNameAlias, uuidv4 } from '../../../utils/helper';
19
20
  import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
@@ -503,11 +504,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
503
504
  children: [_jsx("span", {
504
505
  className: 'List-item-icon',
505
506
  children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
506
- }), _jsx("div", {
507
- children: _jsxs("h4", {
507
+ }), _jsxs("div", {
508
+ className: 'List-item-content',
509
+ children: [_jsxs("h4", {
508
510
  className: 'List-item-title ml-2',
509
511
  children: [replaceTpl(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
510
- })
512
+ }), _jsx(ColumnTypeLabel, {
513
+ column: v
514
+ })]
511
515
  })]
512
516
  })
513
517
  })
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -10,6 +10,7 @@ import { ColumnsPopupThemeEnum, SQL_GROUP_TYPE } from '../../../store/enum';
10
10
  import { SummarizeAlias } from '../../../store/helper';
11
11
  import { __ } from '../../../locale';
12
12
  import { NUMBER_GROUP, DATE_GROUP } from '../const';
13
+ import ColumnTypeLabel from '../column-type-label';
13
14
  import { useStore } from '../../../hooks/use-provider';
14
15
  import { getColumnIdFirstKey, isSameColumnByIdName, replaceTpl, mergeNameAlias } from '../../../utils/helper';
15
16
  import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2, RightArrowIcon } from '../../icons';
@@ -308,11 +309,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
308
309
  children: [_jsx("span", {
309
310
  className: 'List-item-icon',
310
311
  children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
311
- }), _jsx("div", {
312
- children: _jsx("h4", {
312
+ }), _jsxs("div", {
313
+ className: 'List-item-content',
314
+ children: [_jsx("h4", {
313
315
  className: 'List-item-title ml-2',
314
316
  children: replaceTpl(store.fieldNameTpl, v)
315
- })
317
+ }), _jsx(ColumnTypeLabel, {
318
+ column: v
319
+ })]
316
320
  })]
317
321
  }), OPEN_GROUP && isGroup && groupe !== SQL_GROUP_TYPE.STRING && _jsx(Popover, {
318
322
  placement: 'rt',
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -10,6 +10,7 @@ import { ColumnsPopupThemeEnum, SQL_GROUP_TYPE } from '../../../store/enum';
10
10
  import { SummarizeAlias } from '../../../store/helper';
11
11
  import { __ } from '../../../locale';
12
12
  import { NUMBER_GROUP, DATE_GROUP } from '../const';
13
+ import ColumnTypeLabel from '../column-type-label';
13
14
  import { useStore } from '../../../hooks/use-provider';
14
15
  import { getColumnIdFirstKey, isSameColumnByIdName, replaceTpl, mergeNameAlias } from '../../../utils/helper';
15
16
  import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
@@ -244,11 +245,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
244
245
  children: [_jsx("span", {
245
246
  className: 'List-item-icon',
246
247
  children: IconMap[special_type || database_type] || _jsx(LetterAaIcon, {})
247
- }), _jsx("div", {
248
- children: _jsx("h4", {
248
+ }), _jsxs("div", {
249
+ className: 'List-item-content',
250
+ children: [_jsx("h4", {
249
251
  className: 'List-item-title ml-2',
250
252
  children: replaceTpl(store.fieldNameTpl, v)
251
- })
253
+ }), _jsx(ColumnTypeLabel, {
254
+ column: v
255
+ })]
252
256
  })]
253
257
  })
254
258
  })
@@ -23,6 +23,16 @@
23
23
  align-items: center;
24
24
  color: #b8bbc3;
25
25
  }
26
+ .List-item-content {
27
+ display: flex;
28
+ align-items: center;
29
+ min-width: 0;
30
+ width: 100%;
31
+ .List-item-title {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
34
+ }
35
+ }
26
36
  .List-item-title {
27
37
  word-break: break-word;
28
38
  word-wrap: anywhere;
@@ -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, Toast } from '@gingkoo/pandora';
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, function (conflictingAlias) {
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";
@@ -878,57 +877,8 @@ var useStore = function useStore() {
878
877
  }
879
878
  return item;
880
879
  };
881
- var checkTable1Conflict = function checkTable1Conflict(objList, _index, groupIndex) {
882
- var _metaList$groupIndex;
883
- if (!objList || objList.length === 0) return {
884
- hasConflict: false
885
- };
886
- var groupList = ((_metaList$groupIndex = metaList[groupIndex]) === null || _metaList$groupIndex === void 0 ? void 0 : _metaList$groupIndex.list) || [];
887
- var getJoinKey = function getJoinKey(table1, table2) {
888
- 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) || '');
889
- };
890
- var existingJoinKeys = new Set();
891
- groupList.forEach(function (item) {
892
- if (item.type === TypeEnum.joinData && item.table1 && item.table2) {
893
- existingJoinKeys.add(getJoinKey(item.table1, item.table2));
894
- }
895
- });
896
- var _iterator = _createForOfIteratorHelper(objList),
897
- _step;
898
- try {
899
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
900
- var pastedItem = _step.value;
901
- if (pastedItem.type !== TypeEnum.joinData || !pastedItem.table1 || !pastedItem.table2) {
902
- continue;
903
- }
904
- var pastedKey = getJoinKey(pastedItem.table1, pastedItem.table2);
905
- if (existingJoinKeys.has(pastedKey)) {
906
- var _pastedItem$table, _pastedItem$table2;
907
- return {
908
- hasConflict: true,
909
- conflictingAlias: (_pastedItem$table = pastedItem.table2) === null || _pastedItem$table === void 0 ? void 0 : _pastedItem$table.alias,
910
- conflictingId: (_pastedItem$table2 = pastedItem.table2) === null || _pastedItem$table2 === void 0 ? void 0 : _pastedItem$table2.id
911
- };
912
- }
913
- }
914
- } catch (err) {
915
- _iterator.e(err);
916
- } finally {
917
- _iterator.f();
918
- }
919
- return {
920
- hasConflict: false
921
- };
922
- };
923
- var addMeta = function addMeta(type, index, groupIndex, obj, onConflict) {
880
+ var addMeta = function addMeta(type, index, groupIndex, obj) {
924
881
  if (snapshotMode) return false;
925
- if (joinAliasConflictCheck && obj && obj.length > 0) {
926
- var conflict = checkTable1Conflict(obj, index, groupIndex);
927
- if (conflict.hasConflict && conflict.conflictingAlias && onConflict) {
928
- onConflict(conflict.conflictingAlias);
929
- return false;
930
- }
931
- }
932
882
  var newMeta = metaList[groupIndex].list.slice();
933
883
  var items = [];
934
884
  var sharedUuidMap = {};
@@ -202,6 +202,7 @@ export interface MetaData_ColumnsType {
202
202
  tableUuid?: string;
203
203
  realName?: string;
204
204
  database_type: SQL_COLUMN_TYPE | '';
205
+ database_length?: number | string;
205
206
  special_type: SpecialType | '';
206
207
  datasourceId: string;
207
208
  datasourceName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.158-alpha.5",
3
+ "version": "1.0.158-alpha.7",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",