@gingkoo/pandora-metabase 1.0.27 → 1.0.28

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 (66) hide show
  1. package/lib/cjs/common/SplitView/index.js +11 -12
  2. package/lib/cjs/components/dialog/custom-column/expression-editor.js +1 -2
  3. package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -2
  4. package/lib/cjs/components/dialog/expression/index.js +11 -12
  5. package/lib/cjs/components/dialog/formula-list/index.js +53 -43
  6. package/lib/cjs/components/dialog/index.js +2 -2
  7. package/lib/cjs/components/dialog/select-column/index.js +4 -4
  8. package/lib/cjs/components/dialog/select-column-multiple/index.js +7 -7
  9. package/lib/cjs/components/dialog/select-join-column/index.js +4 -0
  10. package/lib/cjs/components/dialog/select-permission-table/index.js +2 -2
  11. package/lib/cjs/components/dialog/select-table/index.js +7 -7
  12. package/lib/cjs/components/icons.js +36 -36
  13. package/lib/cjs/components/metabase/index.js +41 -12
  14. package/lib/cjs/components/metabase/index.less +3 -0
  15. package/lib/cjs/components/modules/components/Wrapper.js +6 -6
  16. package/lib/cjs/components/modules/components/item-name.d.ts +7 -0
  17. package/lib/cjs/components/modules/components/item-name.js +34 -0
  18. package/lib/cjs/components/modules/components/meta-icon.js +6 -0
  19. package/lib/cjs/components/modules/custom-column.js +25 -25
  20. package/lib/cjs/components/modules/filter.js +2 -2
  21. package/lib/cjs/components/modules/join-data.js +206 -80
  22. package/lib/cjs/components/modules/permission-table.js +24 -10
  23. package/lib/cjs/components/modules/sort.js +17 -13
  24. package/lib/cjs/components/modules/summarize/group-by.js +90 -38
  25. package/lib/cjs/components/modules/summarize/select-index.js +84 -38
  26. package/lib/cjs/components/modules/table-data.js +14 -6
  27. package/lib/cjs/components/popup.js +1 -2
  28. package/lib/cjs/hooks/use-state.js +58 -65
  29. package/lib/cjs/index.js +1 -2
  30. package/lib/cjs/locale/en.js +5 -2
  31. package/lib/cjs/locale/zh.js +5 -2
  32. package/lib/cjs/utils/transformSql.d.ts +6 -0
  33. package/lib/cjs/utils/transformSql.js +968 -0
  34. package/lib/cjs/utils.d.ts +7 -1
  35. package/lib/cjs/utils.js +112 -15
  36. package/lib/es/common/SplitView/index.js +10 -10
  37. package/lib/es/components/dialog/expression/index.js +10 -10
  38. package/lib/es/components/dialog/formula-list/index.js +54 -44
  39. package/lib/es/components/dialog/select-column/index.js +4 -4
  40. package/lib/es/components/dialog/select-column-multiple/index.js +7 -7
  41. package/lib/es/components/dialog/select-join-column/index.js +4 -0
  42. package/lib/es/components/dialog/select-permission-table/index.js +2 -2
  43. package/lib/es/components/dialog/select-table/index.js +7 -7
  44. package/lib/es/components/icons.js +36 -36
  45. package/lib/es/components/metabase/index.js +42 -13
  46. package/lib/es/components/metabase/index.less +3 -0
  47. package/lib/es/components/modules/components/Wrapper.js +6 -6
  48. package/lib/es/components/modules/components/item-name.d.ts +7 -0
  49. package/lib/es/components/modules/components/item-name.js +28 -0
  50. package/lib/es/components/modules/components/meta-icon.js +6 -0
  51. package/lib/es/components/modules/custom-column.js +26 -26
  52. package/lib/es/components/modules/filter.js +2 -2
  53. package/lib/es/components/modules/join-data.js +207 -81
  54. package/lib/es/components/modules/permission-table.js +24 -10
  55. package/lib/es/components/modules/sort.js +18 -14
  56. package/lib/es/components/modules/summarize/group-by.js +92 -40
  57. package/lib/es/components/modules/summarize/select-index.js +86 -40
  58. package/lib/es/components/modules/table-data.js +14 -6
  59. package/lib/es/hooks/use-state.js +58 -65
  60. package/lib/es/locale/en.js +5 -2
  61. package/lib/es/locale/zh.js +5 -2
  62. package/lib/es/utils/transformSql.d.ts +6 -0
  63. package/lib/es/utils/transformSql.js +961 -0
  64. package/lib/es/utils.d.ts +7 -1
  65. package/lib/es/utils.js +102 -4
  66. package/package.json +1 -1
@@ -6,13 +6,15 @@ import cx from 'classnames';
6
6
  import { __ } from '../../../locale';
7
7
  import { findIndex, getHelper } from '../../../utils';
8
8
  import { TypeEnum, ColumnsPopupThemeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
9
- import { MetaSummarize_Enum } from '../../../store/types';
9
+ import { MetaSummarize_Enum, AtomsTypeEnum } from '../../../store/types';
10
10
  import SelectJoinColumn from '../../dialog/select-join-column';
11
11
  import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
12
12
  import { uuidv4 } from '../../../utils/helper';
13
- import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
13
+ import { changeFieldAlias, isValidSQLAlias, isError } from '../../../utils';
14
+ import ItemName from '../components/item-name';
14
15
  import { AddIcon, CloseIcon } from '../../icons';
15
16
  import { useStore } from '../../../hooks/use-provider';
17
+ import cloneDeep from 'lodash/cloneDeep';
16
18
  var GroupBy = function GroupBy(props) {
17
19
  var meta = props.meta,
18
20
  groupIndex = props.groupIndex;
@@ -82,6 +84,8 @@ var GroupBy = function GroupBy(props) {
82
84
  tableUuid: v.table2.tableUuid,
83
85
  tableId: v.table2.id,
84
86
  table: v.table2.name,
87
+ datasourceId: v.table2.datasourceId,
88
+ datasourceName: v.table2.datasourceName,
85
89
  columns: v.columns
86
90
  };
87
91
  }));
@@ -95,6 +99,8 @@ var GroupBy = function GroupBy(props) {
95
99
  table: v.table.name,
96
100
  tableUuid: v.table.tableUuid,
97
101
  tableId: v.table.id,
102
+ datasourceId: v.table.datasourceId,
103
+ datasourceName: v.table.datasourceName,
98
104
  columns: v.columns
99
105
  };
100
106
  } else if (v.type === TypeEnum.joinData) {
@@ -103,6 +109,8 @@ var GroupBy = function GroupBy(props) {
103
109
  table: v.table2.name,
104
110
  tableId: v.table2.id,
105
111
  tableUuid: v.table2.tableUuid,
112
+ datasourceId: v.table2.datasourceId,
113
+ datasourceName: v.table2.datasourceName,
106
114
  columns: v.columns
107
115
  };
108
116
  } else {
@@ -140,11 +148,9 @@ var GroupBy = function GroupBy(props) {
140
148
  fieldAlias: fieldAlias
141
149
  });
142
150
  });
143
- if (value.quotes !== data.quotes) {
144
- newMeta = newMeta.filter(function (_, _i) {
145
- return _i <= index;
146
- });
147
- }
151
+ // if (value.quotes !== data.quotes) {
152
+ // newMeta = newMeta.filter((_: MetaListType, _i: number) => _i <= index);
153
+ // }
148
154
  store.setMeta(newMeta, groupIndex);
149
155
  closePopup();
150
156
  }
@@ -210,9 +216,7 @@ var GroupBy = function GroupBy(props) {
210
216
  newMeta[index].by = by.filter(function (_, i) {
211
217
  return i !== itemId;
212
218
  });
213
- newMeta = newMeta.filter(function (_, _i) {
214
- return _i <= index;
215
- });
219
+ // newMeta = newMeta.filter((_: MetaListType, _i: number) => _i <= index);
216
220
  store.setMeta(newMeta, groupIndex);
217
221
  }
218
222
  function closePopup() {
@@ -234,22 +238,22 @@ var GroupBy = function GroupBy(props) {
234
238
  onOk: function () {
235
239
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
236
240
  var newMeta;
237
- return _regeneratorRuntime.wrap(function _callee$(_context) {
241
+ return _regeneratorRuntime.wrap(function (_context) {
238
242
  while (1) switch (_context.prev = _context.next) {
239
243
  case 0:
240
244
  if (isValidSQLAlias(fieldAlias)) {
241
- _context.next = 3;
245
+ _context.next = 1;
242
246
  break;
243
247
  }
244
248
  Toast.warning(__('SqlQueryBuilder.aliasForRules'));
245
249
  return _context.abrupt("return", false);
246
- case 3:
250
+ case 1:
247
251
  newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
248
252
  newMeta[index].by[i].sql = newMeta[index].by[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
249
253
  newMeta[index].by[i].fieldAlias = fieldAlias;
250
254
  newMeta = changeFieldAlias(newMeta, newMeta[index].by[i]);
251
255
  store.setMeta(newMeta, groupIndex);
252
- case 8:
256
+ case 2:
253
257
  case "end":
254
258
  return _context.stop();
255
259
  }
@@ -263,36 +267,84 @@ var GroupBy = function GroupBy(props) {
263
267
  onCancel: function onCancel() {}
264
268
  });
265
269
  };
270
+ var _getColumns = function _getColumns() {
271
+ return getColumns().map(function (v) {
272
+ return _objectSpread(_objectSpread({}, v), {}, {
273
+ name: v.table,
274
+ id: v.tableId,
275
+ name_zh: '',
276
+ tableUuid: v.tableUuid,
277
+ alias: v.alias,
278
+ // 线上的都为空,默认会标红。 等统一格式后可隐藏
279
+ datasourceName: '',
280
+ // 数据源名
281
+ datasourceId: '' // 数据源id
282
+ });
283
+ });
284
+ };
285
+ var getField = function getField(v) {
286
+ var _v = cloneDeep(v);
287
+ return _objectSpread(_objectSpread({}, _v), {}, {
288
+ fieldName: v.name,
289
+ // 字段名
290
+ fieldNameZh: v.name_zh,
291
+ // 字段中文名
292
+ fieldAlias: v.fieldAlias,
293
+ // 别名
294
+ fieldUuid: v.fieldUuid,
295
+ // uuid
296
+ fieldId: v.fieldId,
297
+ // 字段id
298
+ tableName: v.table,
299
+ // 表名
300
+ tableNameZh: '',
301
+ tableId: v.tableId,
302
+ // 表名
303
+ tableAlias: v.alias,
304
+ // 别名
305
+ tableUuid: v.tableUuid,
306
+ // 表唯一标识
307
+ // 线上的都为空,默认会标红。 等统一格式后可隐藏
308
+ datasourceName: '',
309
+ // 数据源名
310
+ datasourceId: '',
311
+ // 数据源id
312
+ type: AtomsTypeEnum.FIELD
313
+ });
314
+ };
266
315
  return _jsxs(_Fragment, {
267
316
  children: [meta.by.map(function (v, i) {
268
- return _jsxs("div", {
269
- className: "Sqb-TableName green-name",
270
- onClick: function onClick(e) {
271
- return handleUpdate(e, i);
272
- },
273
- children: [v.quotes && _jsx(Tooltip, {
274
- title: __('SqlQueryBuilder.alias'),
275
- children: _jsx(Button, {
276
- className: ':Sqb-TableName-as :Sqb-TableName green-name',
277
- shape: 'circle',
278
- iconOnly: true,
279
- primary: true,
280
- icon: 'As',
281
- size: 'small',
282
- onClick: function onClick(e) {
283
- e.stopPropagation();
284
- onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
285
- }
286
- })
287
- }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), _jsx("span", {
288
- style: {
289
- fontSize: 0
290
- },
317
+ return _jsx(ItemName, {
318
+ isError: isError(getField(v), _getColumns()),
319
+ children: _jsxs("div", {
320
+ className: "Sqb-TableName green-name",
291
321
  onClick: function onClick(e) {
292
- return handleDel(e, i);
322
+ return handleUpdate(e, i);
293
323
  },
294
- children: _jsx(CloseIcon, {})
295
- })]
324
+ children: [v.quotes && _jsx(Tooltip, {
325
+ title: __('SqlQueryBuilder.alias'),
326
+ children: _jsx(Button, {
327
+ className: ':Sqb-TableName-as :Sqb-TableName green-name',
328
+ shape: 'circle',
329
+ iconOnly: true,
330
+ primary: true,
331
+ icon: 'As',
332
+ size: 'small',
333
+ onClick: function onClick(e) {
334
+ e.stopPropagation();
335
+ onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
336
+ }
337
+ })
338
+ }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), _jsx("span", {
339
+ style: {
340
+ fontSize: 0
341
+ },
342
+ onClick: function onClick(e) {
343
+ return handleDel(e, i);
344
+ },
345
+ children: _jsx(CloseIcon, {})
346
+ })]
347
+ })
296
348
  }, i);
297
349
  }), _jsx("div", {
298
350
  className: cx("Sqb-TableName green-name", {
@@ -9,11 +9,13 @@ import { TypeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
9
9
  import { summarizeToSql } from '../../../store/helper';
10
10
  import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
11
11
  import { uuidv4 } from '../../../utils/helper';
12
- import { MetaSummarize_Enum } from '../../../store/types';
13
- import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
12
+ import { MetaSummarize_Enum, AtomsTypeEnum } from '../../../store/types';
13
+ import { changeFieldAlias, isValidSQLAlias, isError } from '../../../utils';
14
+ import ItemName from '../components/item-name';
14
15
  import { AddIcon, CloseIcon } from '../../icons';
15
16
  import { SelectSummarize } from '../../dialog';
16
17
  import { useStore } from '../../../hooks/use-provider';
18
+ import cloneDeep from 'lodash/cloneDeep';
17
19
  var SelectIndex = function SelectIndex(props) {
18
20
  var meta = props.meta,
19
21
  groupIndex = props.groupIndex;
@@ -147,11 +149,9 @@ var SelectIndex = function SelectIndex(props) {
147
149
  fieldAlias: fieldAlias
148
150
  });
149
151
  });
150
- if (value.quotes !== data.quotes) {
151
- newMeta = newMeta.filter(function (_, _i) {
152
- return _i <= index;
153
- });
154
- }
152
+ // if (value.quotes !== data.quotes) {
153
+ // newMeta = newMeta.filter((_: MetaListType, _i: number) => _i <= index);
154
+ // }
155
155
  store.setMeta(newMeta, groupIndex);
156
156
  closePopup();
157
157
  }
@@ -217,9 +217,7 @@ var SelectIndex = function SelectIndex(props) {
217
217
  newMeta[index].group = group.filter(function (_, i) {
218
218
  return i !== itemId;
219
219
  });
220
- newMeta = newMeta.filter(function (_, _i) {
221
- return _i <= index;
222
- });
220
+ // newMeta = newMeta.filter((_: MetaListType, _i: number) => _i <= index);
223
221
  store.setMeta(newMeta, groupIndex);
224
222
  }
225
223
  function closePopup() {
@@ -242,22 +240,22 @@ var SelectIndex = function SelectIndex(props) {
242
240
  onOk: function () {
243
241
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
244
242
  var newMeta;
245
- return _regeneratorRuntime.wrap(function _callee$(_context) {
243
+ return _regeneratorRuntime.wrap(function (_context) {
246
244
  while (1) switch (_context.prev = _context.next) {
247
245
  case 0:
248
246
  if (isValidSQLAlias(fieldAlias)) {
249
- _context.next = 3;
247
+ _context.next = 1;
250
248
  break;
251
249
  }
252
250
  Toast.warning(__('SqlQueryBuilder.aliasForRules'));
253
251
  return _context.abrupt("return", false);
254
- case 3:
252
+ case 1:
255
253
  newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
256
254
  newMeta[index].group[i].fieldAlias = fieldAlias;
257
255
  newMeta[index].group[i].sql = newMeta[index].group[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
258
256
  newMeta = changeFieldAlias(newMeta, newMeta[index].group[i]);
259
257
  store.setMeta(newMeta, groupIndex);
260
- case 8:
258
+ case 2:
261
259
  case "end":
262
260
  return _context.stop();
263
261
  }
@@ -271,36 +269,84 @@ var SelectIndex = function SelectIndex(props) {
271
269
  onCancel: function onCancel() {}
272
270
  });
273
271
  };
272
+ var _getColumns = function _getColumns() {
273
+ return getColumns().map(function (v) {
274
+ return _objectSpread(_objectSpread({}, v), {}, {
275
+ name: v.table,
276
+ id: v.tableId,
277
+ name_zh: '',
278
+ tableUuid: v.tableUuid,
279
+ alias: v.alias,
280
+ // 线上的都为空,默认会标红。 等统一格式后可隐藏
281
+ datasourceName: '',
282
+ // 数据源名
283
+ datasourceId: '' // 数据源id
284
+ });
285
+ });
286
+ };
287
+ var getField = function getField(v) {
288
+ var _v = cloneDeep(v);
289
+ return _objectSpread(_objectSpread({}, _v), {}, {
290
+ fieldName: v.name,
291
+ // 字段名
292
+ fieldNameZh: v.name_zh,
293
+ // 字段中文名
294
+ fieldAlias: v.fieldAlias,
295
+ // 别名
296
+ fieldUuid: v.fieldUuid,
297
+ // uuid
298
+ fieldId: v.fieldId,
299
+ // 字段id
300
+ tableName: v.table,
301
+ // 表名
302
+ tableNameZh: '',
303
+ tableId: v.tableId,
304
+ // 表名
305
+ tableAlias: v.alias,
306
+ // 别名
307
+ tableUuid: v.tableUuid,
308
+ // 表唯一标识
309
+ // 线上的都为空,默认会标红。 等统一格式后可隐藏
310
+ datasourceName: '',
311
+ // 数据源名
312
+ datasourceId: '',
313
+ // 数据源id
314
+ type: AtomsTypeEnum.FIELD
315
+ });
316
+ };
274
317
  return _jsxs(_Fragment, {
275
318
  children: [meta.group.map(function (v, i) {
276
- return _jsxs("div", {
277
- className: "Sqb-TableName green-name",
278
- onClick: function onClick(e) {
279
- return handleUpdate(e, i);
280
- },
281
- children: [v.quotes && _jsx(Tooltip, {
282
- title: __('SqlQueryBuilder.alias'),
283
- children: _jsx(Button, {
284
- className: ':Sqb-TableName-as :Sqb-TableName green-name',
285
- shape: 'circle',
286
- iconOnly: true,
287
- primary: true,
288
- icon: 'As',
289
- size: 'small',
290
- onClick: function onClick(e) {
291
- e.stopPropagation();
292
- onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
293
- }
294
- })
295
- }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), _jsx("span", {
296
- style: {
297
- fontSize: 0
298
- },
319
+ return _jsx(ItemName, {
320
+ isError: isError(getField(v), _getColumns()),
321
+ children: _jsxs("div", {
322
+ className: "Sqb-TableName green-name",
299
323
  onClick: function onClick(e) {
300
- return handleDel(e, i);
324
+ return handleUpdate(e, i);
301
325
  },
302
- children: _jsx(CloseIcon, {})
303
- })]
326
+ children: [v.quotes && _jsx(Tooltip, {
327
+ title: __('SqlQueryBuilder.alias'),
328
+ children: _jsx(Button, {
329
+ className: ':Sqb-TableName-as :Sqb-TableName green-name',
330
+ shape: 'circle',
331
+ iconOnly: true,
332
+ primary: true,
333
+ icon: 'As',
334
+ size: 'small',
335
+ onClick: function onClick(e) {
336
+ e.stopPropagation();
337
+ onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
338
+ }
339
+ })
340
+ }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), _jsx("span", {
341
+ style: {
342
+ fontSize: 0
343
+ },
344
+ onClick: function onClick(e) {
345
+ return handleDel(e, i);
346
+ },
347
+ children: _jsx(CloseIcon, {})
348
+ })]
349
+ })
304
350
  }, i);
305
351
  }), _jsx("div", {
306
352
  className: cx("Sqb-TableName green-name", {
@@ -84,21 +84,21 @@ var TableData = function TableData(props) {
84
84
  onOk: function () {
85
85
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
86
86
  var newMetaList;
87
- return _regeneratorRuntime.wrap(function _callee$(_context) {
87
+ return _regeneratorRuntime.wrap(function (_context) {
88
88
  while (1) switch (_context.prev = _context.next) {
89
89
  case 0:
90
90
  if (isValidSQLAlias(alias)) {
91
- _context.next = 3;
91
+ _context.next = 1;
92
92
  break;
93
93
  }
94
94
  Toast.warning(__('SqlQueryBuilder.aliasForRules'));
95
95
  return _context.abrupt("return", false);
96
- case 3:
96
+ case 1:
97
97
  newMetaList = store.metaList[groupIndex].list.slice(); // @ts-ignore
98
98
  newMetaList[0].table.alias = alias;
99
99
  newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
100
100
  store.setMeta(newMetaList, groupIndex);
101
- case 7:
101
+ case 2:
102
102
  case "end":
103
103
  return _context.stop();
104
104
  }
@@ -134,7 +134,7 @@ var TableData = function TableData(props) {
134
134
  showSubquery: store._showSubquery,
135
135
  toolbar: _toolbar,
136
136
  btnText: __('SqlQueryBuilder.confirm'),
137
- value: val,
137
+ value: cloneDeep(val),
138
138
  onOk: function onOk(newList) {
139
139
  try {
140
140
  // 子查询未改变不做操作
@@ -151,7 +151,15 @@ var TableData = function TableData(props) {
151
151
  var newColumns = items.flatMap(function (item) {
152
152
  return item.columns;
153
153
  });
154
- newMetaList.columns = newColumns;
154
+ // newMetaList.columns = newColumns;
155
+ newMetaList.columns = newColumns.map(function (newCol) {
156
+ // 查找旧列中是否有相同 name 的列
157
+ var existingCol = newMetaList.columns.find(function (oldCol) {
158
+ return oldCol.name === newCol.name;
159
+ });
160
+ // 如果存在,返回旧列;否则返回新列
161
+ return existingCol ? existingCol : newCol;
162
+ });
155
163
  // (newMeta[index] as MetaJoin).expressions = [];
156
164
  store.setMeta([newMetaList], groupIndex);
157
165
  o.close();
@@ -55,69 +55,73 @@ var useStore = function useStore() {
55
55
  toolbar = _useState8[0],
56
56
  setToolbar = _useState8[1]; //工具列表
57
57
  var _useState9 = useState('${name}'),
58
- _useState10 = _slicedToArray(_useState9, 2),
59
- fieldNameTpl = _useState10[0],
60
- setFieldNameTpl = _useState10[1]; //显示字段
61
- var _useState11 = useState('${name}'),
58
+ _useState0 = _slicedToArray(_useState9, 2),
59
+ fieldNameTpl = _useState0[0],
60
+ setFieldNameTpl = _useState0[1]; //显示字段
61
+ var _useState1 = useState('${name}'),
62
+ _useState10 = _slicedToArray(_useState1, 2),
63
+ tableNameTpl = _useState10[0],
64
+ setTableNameTpl = _useState10[1]; //显示字段
65
+ var _useState11 = useState([]),
62
66
  _useState12 = _slicedToArray(_useState11, 2),
63
- tableNameTpl = _useState12[0],
64
- setTableNameTpl = _useState12[1]; //显示字段
67
+ sourceList = _useState12[0],
68
+ setSourceList = _useState12[1]; //数据源列表
65
69
  var _useState13 = useState([]),
66
70
  _useState14 = _slicedToArray(_useState13, 2),
67
- sourceList = _useState14[0],
68
- setSourceList = _useState14[1]; //数据源列表
71
+ constantList = _useState14[0],
72
+ setConstantList = _useState14[1]; //常量列表
69
73
  var _useState15 = useState([]),
70
74
  _useState16 = _slicedToArray(_useState15, 2),
71
- constantList = _useState16[0],
72
- setConstantList = _useState16[1]; //常量列表
73
- var _useState17 = useState([]),
75
+ formulaTemplates = _useState16[0],
76
+ setFormulaTemplates = _useState16[1]; //公式配置数组
77
+ var _useState17 = useState(false),
74
78
  _useState18 = _slicedToArray(_useState17, 2),
75
- formulaTemplates = _useState18[0],
76
- setFormulaTemplates = _useState18[1]; //公式配置数组
79
+ ignoreGroupByType = _useState18[0],
80
+ setIgnoreGroupByType = _useState18[1]; // 忽略groupBy类型
77
81
  var _useState19 = useState(false),
78
82
  _useState20 = _slicedToArray(_useState19, 2),
79
- ignoreGroupByType = _useState20[0],
80
- setIgnoreGroupByType = _useState20[1]; // 忽略groupBy类型
81
- var _useState21 = useState(false),
83
+ filterCustomType = _useState20[0],
84
+ setfilterCustomType = _useState20[1]; // 过滤器自定义类型
85
+ var _useState21 = useState({}),
82
86
  _useState22 = _slicedToArray(_useState21, 2),
83
- filterCustomType = _useState22[0],
84
- setfilterCustomType = _useState22[1]; // 过滤器自定义类型
87
+ _cacheSource2TableMap = _useState22[0],
88
+ set_cacheSource2TableMap = _useState22[1]; //数据源id 对应数据集列表
85
89
  var _useState23 = useState({}),
86
90
  _useState24 = _slicedToArray(_useState23, 2),
87
- _cacheSource2TableMap = _useState24[0],
88
- set_cacheSource2TableMap = _useState24[1]; //数据源id 对应数据集列表
89
- var _useState25 = useState({}),
91
+ _cacheColumnsMap = _useState24[0],
92
+ set_cacheColumnsMap = _useState24[1]; //数据源id 对应数据集列表
93
+ var _useState25 = useState(defaultMeta),
90
94
  _useState26 = _slicedToArray(_useState25, 2),
91
- _cacheColumnsMap = _useState26[0],
92
- set_cacheColumnsMap = _useState26[1]; //数据源id 对应数据集列表
93
- var _useState27 = useState(defaultMeta),
94
- _useState28 = _slicedToArray(_useState27, 2),
95
- metaList = _useState28[0],
96
- _setMeta = _useState28[1]; //数据源id 对应数据集列表
97
- var _useState29 = useState({
95
+ metaList = _useState26[0],
96
+ _setMeta = _useState26[1]; //数据源id 对应数据集列表
97
+ var _useState27 = useState({
98
98
  visible: false,
99
99
  node: null,
100
100
  content: null
101
101
  }),
102
- _useState30 = _slicedToArray(_useState29, 2),
103
- popupData = _useState30[0],
104
- setPopup = _useState30[1]; //弹窗
105
- var _useState31 = useState({
102
+ _useState28 = _slicedToArray(_useState27, 2),
103
+ popupData = _useState28[0],
104
+ setPopup = _useState28[1]; //弹窗
105
+ var _useState29 = useState({
106
106
  visible: false,
107
107
  node: null,
108
108
  content: null
109
109
  }),
110
+ _useState30 = _slicedToArray(_useState29, 2),
111
+ popupData2 = _useState30[0],
112
+ setPopup2 = _useState30[1]; //弹窗
113
+ var _useState31 = useState(true),
110
114
  _useState32 = _slicedToArray(_useState31, 2),
111
- popupData2 = _useState32[0],
112
- setPopup2 = _useState32[1]; //弹窗
115
+ popupClosable = _useState32[0],
116
+ setClosable = _useState32[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
113
117
  var _useState33 = useState(true),
114
118
  _useState34 = _slicedToArray(_useState33, 2),
115
- popupClosable = _useState34[0],
116
- setClosable = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
117
- var _useState35 = useState(true),
119
+ popupClosable2 = _useState34[0],
120
+ setClosable2 = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
121
+ var _useState35 = useState({}),
118
122
  _useState36 = _slicedToArray(_useState35, 2),
119
- popupClosable2 = _useState36[0],
120
- setClosable2 = _useState36[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
123
+ currentTable = _useState36[0],
124
+ setCurrentTable = _useState36[1]; // 当前存在的表
121
125
  // 外层ref
122
126
  var popupContainer = useRef();
123
127
  // const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
@@ -177,23 +181,23 @@ var useStore = function useStore() {
177
181
  var fetchDataset = /*#__PURE__*/function () {
178
182
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(datasourceId) {
179
183
  var tables, _tables;
180
- return _regeneratorRuntime.wrap(function _callee$(_context) {
184
+ return _regeneratorRuntime.wrap(function (_context) {
181
185
  while (1) switch (_context.prev = _context.next) {
182
186
  case 0:
183
187
  tables = getDataset(datasourceId);
184
188
  if (!tables.length) {
185
- _context.next = 3;
189
+ _context.next = 1;
186
190
  break;
187
191
  }
188
192
  return _context.abrupt("return", tables);
189
- case 3:
190
- _context.next = 5;
193
+ case 1:
194
+ _context.next = 2;
191
195
  return fetchDatasetFn.current(datasourceId);
192
- case 5:
196
+ case 2:
193
197
  _tables = _context.sent;
194
198
  setDataset(datasourceId, _tables);
195
199
  return _context.abrupt("return", _tables);
196
- case 8:
200
+ case 3:
197
201
  case "end":
198
202
  return _context.stop();
199
203
  }
@@ -222,7 +226,7 @@ var useStore = function useStore() {
222
226
  columns,
223
227
  _columns,
224
228
  _args2 = arguments;
225
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
229
+ return _regeneratorRuntime.wrap(function (_context2) {
226
230
  while (1) switch (_context2.prev = _context2.next) {
227
231
  case 0:
228
232
  oldColumns = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
@@ -232,20 +236,22 @@ var useStore = function useStore() {
232
236
  return v.select;
233
237
  }).map(function (v) {
234
238
  return v.id;
239
+ }).filter(function (v) {
240
+ return v;
235
241
  });
236
242
  _table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = _objectWithoutProperties(table, _excluded);
237
243
  tableName = table.name;
238
244
  columns = getColumns(tableName);
239
245
  if (columns.length) {
240
- _context2.next = 11;
246
+ _context2.next = 2;
241
247
  break;
242
248
  }
243
- _context2.next = 9;
249
+ _context2.next = 1;
244
250
  return fetchColumnsFn.current(extra, datasourceId);
245
- case 9:
251
+ case 1:
246
252
  columns = _context2.sent;
247
253
  setColumns(tableName, columns);
248
- case 11:
254
+ case 2:
249
255
  _columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
250
256
  var select = selectId.includes(v.id);
251
257
  return _objectSpread(_objectSpread({}, v), {}, {
@@ -254,7 +260,7 @@ var useStore = function useStore() {
254
260
  });
255
261
  });
256
262
  typeof callback === 'function' && callback(_columns);
257
- case 13:
263
+ case 3:
258
264
  case "end":
259
265
  return _context2.stop();
260
266
  }
@@ -270,19 +276,6 @@ var useStore = function useStore() {
270
276
  _setMeta(newMeta);
271
277
  };
272
278
  // 回显
273
- var setFilterQuotes = function setFilterQuotes(newMeta) {
274
- newMeta.filter = newMeta.filter.map(function (v) {
275
- if (!v.expression) {
276
- return {
277
- expression: _objectSpread({}, v),
278
- type: v.type
279
- };
280
- } else {
281
- return _objectSpread({}, v);
282
- }
283
- });
284
- return newMeta;
285
- };
286
279
  var setPreData = function setPreData(data) {
287
280
  // let patchVersion = (data?.[0]?.list?.[0] as any)?.patchVersion || '';
288
281
  if (data.length) {
@@ -509,7 +502,7 @@ var useStore = function useStore() {
509
502
  if (meta.type === TypeEnum.joinData) {
510
503
  if (meta.table2.name) {
511
504
  var _metaList2 = newMeta.filter(function (v, i) {
512
- return i < index;
505
+ return i != index;
513
506
  });
514
507
  setMeta(_metaList2, groupIndex);
515
508
  return void 0;
@@ -49,7 +49,7 @@ export default register('en', {
49
49
  'SqlQueryBuilder.visualize': 'visualize',
50
50
  'SqlQueryBuilder.selectColumnAll': 'select all',
51
51
  'SqlQueryBuilder.alias': 'alias',
52
- 'SqlQueryBuilder.aliasForRules': 'Please enter letters and underscores, with a length not exceeding 30 bytes',
52
+ 'SqlQueryBuilder.aliasForRules': 'Please enter a combination of letters, underscores, and numbers, with a length not exceeding 30 bytes',
53
53
  'customColumn.operator': 'operator',
54
54
  'customColumn.collection': 'collection',
55
55
  'customColumn.field': 'field',
@@ -155,5 +155,8 @@ export default register('en', {
155
155
  'result.queryResult': 'query result',
156
156
  'result.fieldOperations': 'field operations',
157
157
  'metabase.nextBtn': 'next step',
158
- 'metabase.nextOk': 'ok'
158
+ 'metabase.nextOk': 'ok',
159
+ 'metabase.verify': 'The table has been modified. Please select again',
160
+ 'metabase.validationFailed': 'Validation failed. Do you still want to save?',
161
+ 'metabase.prompt': 'Prompt'
159
162
  });