@gingkoo/pandora-metabase 1.0.23 → 1.0.25

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 (89) hide show
  1. package/lib/cjs/common/SplitView/index.js +12 -11
  2. package/lib/cjs/components/dialog/custom-column/expression-editor.js +2 -1
  3. package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +2 -1
  4. package/lib/cjs/components/dialog/custom-editor/index.js +2 -1
  5. package/lib/cjs/components/dialog/expression/index.js +13 -12
  6. package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
  7. package/lib/cjs/components/dialog/formula/index.js +242 -0
  8. package/lib/cjs/components/dialog/formula/index.less +81 -0
  9. package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
  10. package/lib/cjs/components/dialog/formula/utils.js +45 -0
  11. package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -1
  12. package/lib/cjs/components/dialog/formula-list/index.js +107 -43
  13. package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
  14. package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
  15. package/lib/cjs/components/dialog/index.d.ts +1 -0
  16. package/lib/cjs/components/dialog/index.js +9 -2
  17. package/lib/cjs/components/dialog/select-column/index.js +6 -13
  18. package/lib/cjs/components/dialog/select-column-multiple/index.js +0 -1
  19. package/lib/cjs/components/dialog/select-table/index.js +7 -7
  20. package/lib/cjs/components/icons.js +36 -36
  21. package/lib/cjs/components/metabase/index.js +6 -6
  22. package/lib/cjs/components/metabase/index.less +10 -0
  23. package/lib/cjs/components/modules/components/Wrapper.js +6 -6
  24. package/lib/cjs/components/modules/custom-column.js +4 -4
  25. package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
  26. package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
  27. package/lib/cjs/components/modules/join-data.js +78 -36
  28. package/lib/cjs/components/modules/summarize/group-by.js +6 -13
  29. package/lib/cjs/components/modules/summarize/select-index.js +6 -13
  30. package/lib/cjs/components/modules/table-data.js +9 -16
  31. package/lib/cjs/components/popup.js +2 -1
  32. package/lib/cjs/hooks/patch.js +106 -76
  33. package/lib/cjs/hooks/use-state.js +100 -65
  34. package/lib/cjs/index.js +5 -2
  35. package/lib/cjs/locale/en.js +6 -3
  36. package/lib/cjs/locale/zh.js +6 -3
  37. package/lib/cjs/store/helper.d.ts +1 -2
  38. package/lib/cjs/store/helper.js +1 -76
  39. package/lib/cjs/store/types.d.ts +36 -2
  40. package/lib/cjs/store/types.js +3 -0
  41. package/lib/cjs/types.d.ts +2 -1
  42. package/lib/cjs/utils.d.ts +1 -0
  43. package/lib/cjs/utils.js +16 -2
  44. package/lib/es/common/SplitView/index.js +10 -10
  45. package/lib/es/components/dialog/custom-editor/index.js +2 -1
  46. package/lib/es/components/dialog/expression/index.js +11 -11
  47. package/lib/es/components/dialog/formula/index.d.ts +10 -0
  48. package/lib/es/components/dialog/formula/index.js +236 -0
  49. package/lib/es/components/dialog/formula/index.less +81 -0
  50. package/lib/es/components/dialog/formula/utils.d.ts +7 -0
  51. package/lib/es/components/dialog/formula/utils.js +37 -0
  52. package/lib/es/components/dialog/formula-list/index.d.ts +3 -1
  53. package/lib/es/components/dialog/formula-list/index.js +104 -40
  54. package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
  55. package/lib/es/components/dialog/formula-list/utils.js +160 -2
  56. package/lib/es/components/dialog/index.d.ts +1 -0
  57. package/lib/es/components/dialog/index.js +2 -1
  58. package/lib/es/components/dialog/select-column/index.js +7 -14
  59. package/lib/es/components/dialog/select-column-multiple/index.js +0 -1
  60. package/lib/es/components/dialog/select-table/index.js +7 -7
  61. package/lib/es/components/icons.js +36 -36
  62. package/lib/es/components/metabase/index.js +6 -6
  63. package/lib/es/components/metabase/index.less +10 -0
  64. package/lib/es/components/modules/components/Wrapper.js +6 -6
  65. package/lib/es/components/modules/custom-column.js +4 -4
  66. package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
  67. package/lib/es/components/modules/enum/filter-enum.js +8 -2
  68. package/lib/es/components/modules/join-data.js +78 -36
  69. package/lib/es/components/modules/summarize/group-by.js +7 -14
  70. package/lib/es/components/modules/summarize/select-index.js +7 -14
  71. package/lib/es/components/modules/table-data.js +10 -17
  72. package/lib/es/hooks/patch.js +105 -75
  73. package/lib/es/hooks/use-state.js +101 -66
  74. package/lib/es/index.js +3 -1
  75. package/lib/es/locale/en.js +6 -3
  76. package/lib/es/locale/zh.js +6 -3
  77. package/lib/es/store/helper.d.ts +1 -2
  78. package/lib/es/store/helper.js +0 -75
  79. package/lib/es/store/types.d.ts +36 -2
  80. package/lib/es/store/types.js +3 -0
  81. package/lib/es/types.d.ts +2 -1
  82. package/lib/es/types.js +18 -1
  83. package/lib/es/utils.d.ts +1 -0
  84. package/lib/es/utils.js +13 -1
  85. package/package.json +2 -2
  86. package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
  87. package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
  88. package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
  89. package/lib/es/components/dialog/formula-list/enum.js +0 -117
@@ -169,12 +169,12 @@ export var LeftJoinIcon = function LeftJoinIcon(_ref9) {
169
169
  })
170
170
  });
171
171
  };
172
- export var InnerJoinIcon = function InnerJoinIcon(_ref0) {
173
- var _ref0$width = _ref0.width,
174
- width = _ref0$width === void 0 ? 32 : _ref0$width,
175
- _ref0$height = _ref0.height,
176
- height = _ref0$height === void 0 ? 32 : _ref0$height,
177
- style = _ref0.style;
172
+ export var InnerJoinIcon = function InnerJoinIcon(_ref10) {
173
+ var _ref10$width = _ref10.width,
174
+ width = _ref10$width === void 0 ? 32 : _ref10$width,
175
+ _ref10$height = _ref10.height,
176
+ height = _ref10$height === void 0 ? 32 : _ref10$height,
177
+ style = _ref10.style;
178
178
  return _jsx("svg", {
179
179
  viewBox: '0 0 32 32',
180
180
  width: width,
@@ -188,11 +188,11 @@ export var InnerJoinIcon = function InnerJoinIcon(_ref0) {
188
188
  })
189
189
  });
190
190
  };
191
- export var UpArrowIcon = function UpArrowIcon(_ref1) {
192
- var _ref1$width = _ref1.width,
193
- width = _ref1$width === void 0 ? 16 : _ref1$width,
194
- _ref1$height = _ref1.height,
195
- height = _ref1$height === void 0 ? 17 : _ref1$height;
191
+ export var UpArrowIcon = function UpArrowIcon(_ref11) {
192
+ var _ref11$width = _ref11.width,
193
+ width = _ref11$width === void 0 ? 16 : _ref11$width,
194
+ _ref11$height = _ref11.height,
195
+ height = _ref11$height === void 0 ? 17 : _ref11$height;
196
196
  return _jsx("svg", {
197
197
  className: 'sort-arrow',
198
198
  viewBox: '0 0 32 34',
@@ -206,11 +206,11 @@ export var UpArrowIcon = function UpArrowIcon(_ref1) {
206
206
  })
207
207
  });
208
208
  };
209
- export var DownArrowIcon = function DownArrowIcon(_ref10) {
210
- var _ref10$width = _ref10.width,
211
- width = _ref10$width === void 0 ? 16 : _ref10$width,
212
- _ref10$height = _ref10.height,
213
- height = _ref10$height === void 0 ? 17 : _ref10$height;
209
+ export var DownArrowIcon = function DownArrowIcon(_ref12) {
210
+ var _ref12$width = _ref12.width,
211
+ width = _ref12$width === void 0 ? 16 : _ref12$width,
212
+ _ref12$height = _ref12.height,
213
+ height = _ref12$height === void 0 ? 17 : _ref12$height;
214
214
  return _jsx("svg", {
215
215
  className: 'sort-arrow',
216
216
  viewBox: '0 0 32 34',
@@ -224,11 +224,11 @@ export var DownArrowIcon = function DownArrowIcon(_ref10) {
224
224
  })
225
225
  });
226
226
  };
227
- export var CloseIcon = function CloseIcon(_ref11) {
228
- var _ref11$width = _ref11.width,
229
- width = _ref11$width === void 0 ? 16 : _ref11$width,
230
- _ref11$height = _ref11.height,
231
- height = _ref11$height === void 0 ? 16 : _ref11$height;
227
+ export var CloseIcon = function CloseIcon(_ref13) {
228
+ var _ref13$width = _ref13.width,
229
+ width = _ref13$width === void 0 ? 16 : _ref13$width,
230
+ _ref13$height = _ref13.height,
231
+ height = _ref13$height === void 0 ? 16 : _ref13$height;
232
232
  return _jsx("svg", {
233
233
  className: 'closeIcon',
234
234
  viewBox: '0 0 32 32',
@@ -242,11 +242,11 @@ export var CloseIcon = function CloseIcon(_ref11) {
242
242
  })
243
243
  });
244
244
  };
245
- export var AddIcon = function AddIcon(_ref12) {
246
- var _ref12$width = _ref12.width,
247
- width = _ref12$width === void 0 ? 16 : _ref12$width,
248
- _ref12$height = _ref12.height,
249
- height = _ref12$height === void 0 ? 16 : _ref12$height;
245
+ export var AddIcon = function AddIcon(_ref14) {
246
+ var _ref14$width = _ref14.width,
247
+ width = _ref14$width === void 0 ? 16 : _ref14$width,
248
+ _ref14$height = _ref14.height,
249
+ height = _ref14$height === void 0 ? 16 : _ref14$height;
250
250
  return _jsx("svg", {
251
251
  viewBox: '0 0 32 32',
252
252
  width: width,
@@ -259,11 +259,11 @@ export var AddIcon = function AddIcon(_ref12) {
259
259
  })
260
260
  });
261
261
  };
262
- export var TableIcon = function TableIcon(_ref13) {
263
- var _ref13$width = _ref13.width,
264
- width = _ref13$width === void 0 ? 18 : _ref13$width,
265
- _ref13$height = _ref13.height,
266
- height = _ref13$height === void 0 ? 18 : _ref13$height;
262
+ export var TableIcon = function TableIcon(_ref15) {
263
+ var _ref15$width = _ref15.width,
264
+ width = _ref15$width === void 0 ? 18 : _ref15$width,
265
+ _ref15$height = _ref15.height,
266
+ height = _ref15$height === void 0 ? 18 : _ref15$height;
267
267
  return _jsx("svg", {
268
268
  viewBox: '0 0 32 32',
269
269
  width: width,
@@ -276,11 +276,11 @@ export var TableIcon = function TableIcon(_ref13) {
276
276
  })
277
277
  });
278
278
  };
279
- export var SearchIcon = function SearchIcon(_ref14) {
280
- var _ref14$width = _ref14.width,
281
- width = _ref14$width === void 0 ? 16 : _ref14$width,
282
- _ref14$height = _ref14.height,
283
- height = _ref14$height === void 0 ? 16 : _ref14$height;
279
+ export var SearchIcon = function SearchIcon(_ref16) {
280
+ var _ref16$width = _ref16.width,
281
+ width = _ref16$width === void 0 ? 16 : _ref16$width,
282
+ _ref16$height = _ref16.height,
283
+ height = _ref16$height === void 0 ? 16 : _ref16$height;
284
284
  return _jsx("svg", {
285
285
  viewBox: '0 0 32 32',
286
286
  width: width,
@@ -49,7 +49,7 @@ var Metabase = function Metabase(props) {
49
49
  var onSave = /*#__PURE__*/function () {
50
50
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
51
51
  var intercept, _metaList;
52
- return _regeneratorRuntime.wrap(function (_context) {
52
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
53
53
  while (1) switch (_context.prev = _context.next) {
54
54
  case 0:
55
55
  intercept = false; // 是否返回
@@ -63,17 +63,17 @@ var Metabase = function Metabase(props) {
63
63
  }
64
64
  });
65
65
  if (!(saveLoading || intercept)) {
66
- _context.next = 1;
66
+ _context.next = 6;
67
67
  break;
68
68
  }
69
69
  return _context.abrupt("return", null);
70
- case 1:
70
+ case 6:
71
71
  setSaveLoading(true);
72
- _context.next = 2;
72
+ _context.next = 9;
73
73
  return onOk === null || onOk === void 0 ? void 0 : onOk(_metaList);
74
- case 2:
74
+ case 9:
75
75
  setSaveLoading(false);
76
- case 3:
76
+ case 10:
77
77
  case "end":
78
78
  return _context.stop();
79
79
  }
@@ -152,6 +152,7 @@
152
152
  -webkit-box-align: center;
153
153
  align-items: center;
154
154
  cursor: pointer;
155
+ height: 36px;
155
156
  // &-OPERATOR {
156
157
  // // 操作符
157
158
  // background-color: var(--link-5);
@@ -277,6 +278,15 @@
277
278
  width: 100%;
278
279
  }
279
280
  }
281
+ .Sqb-collection-box {
282
+ display: flex;
283
+ align-items: center;
284
+ margin-bottom: 8px;
285
+ .Sqb-NotebookCell {
286
+ padding-bottom: 0;
287
+ padding-top: 8px;
288
+ }
289
+ }
280
290
  .operator-icon,
281
291
  .operator-icon button {
282
292
  font-size: 18px !important;
@@ -25,19 +25,19 @@ var Wrapper = function Wrapper(_ref) {
25
25
  function _animation() {
26
26
  _animation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
27
27
  var _couterRef$current;
28
- return _regeneratorRuntime.wrap(function (_context) {
28
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
29
29
  while (1) switch (_context.prev = _context.next) {
30
30
  case 0:
31
- _context.next = 1;
31
+ _context.next = 2;
32
32
  return sleep(10);
33
- case 1:
33
+ case 2:
34
34
  setOpacity(1);
35
35
  ((_couterRef$current = couterRef.current) === null || _couterRef$current === void 0 || (_couterRef$current = _couterRef$current.childNodes) === null || _couterRef$current === void 0 ? void 0 : _couterRef$current.length) && setMaxHeight(couterRef.current.childNodes[0].clientHeight + 16);
36
- _context.next = 2;
36
+ _context.next = 6;
37
37
  return sleep(500);
38
- case 2:
38
+ case 6:
39
39
  setMaxHeight('auto');
40
- case 3:
40
+ case 7:
41
41
  case "end":
42
42
  return _context.stop();
43
43
  }
@@ -69,14 +69,14 @@ var CustomColumn = function CustomColumn(props) {
69
69
  function _handleUpdate() {
70
70
  _handleUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(e, i) {
71
71
  var node, newMeta, value, columns;
72
- return _regeneratorRuntime.wrap(function (_context) {
72
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
73
73
  while (1) switch (_context.prev = _context.next) {
74
74
  case 0:
75
75
  node = e.currentTarget;
76
76
  closePopup();
77
- _context.next = 1;
77
+ _context.next = 4;
78
78
  return sleep(100);
79
- case 1:
79
+ case 4:
80
80
  newMeta = store.metaList[groupIndex].list.slice();
81
81
  value = customColumn[i];
82
82
  columns = getAvailableColumns();
@@ -98,7 +98,7 @@ var CustomColumn = function CustomColumn(props) {
98
98
  onClose: closePopup
99
99
  })
100
100
  });
101
- case 2:
101
+ case 8:
102
102
  case "end":
103
103
  return _context.stop();
104
104
  }
@@ -28,7 +28,12 @@ export declare enum FunctionEnum {
28
28
  'COALESCE' = "coalesce"
29
29
  }
30
30
  export declare const operatorList: string[];
31
- export declare const customTypes: {
31
+ export declare const customTypes: ({
32
32
  value: AtomsTypeEnum;
33
33
  label: any;
34
- }[];
34
+ children?: undefined;
35
+ } | {
36
+ value: AtomsTypeEnum;
37
+ label: any;
38
+ children: string[];
39
+ })[];
@@ -98,12 +98,12 @@ export var customTypes = [
98
98
  // 输入框
99
99
  {
100
100
  value: AtomsTypeEnum.INPUT_STRING,
101
- label: __('SqlQueryBuilder.input')
101
+ label: __('customColumn.input')
102
102
  },
103
103
  // 数字输入框
104
104
  {
105
105
  value: AtomsTypeEnum.INPUT_NUMBER,
106
- label: __('SqlQueryBuilder.numberInput')
106
+ label: __('customColumn.numberInput')
107
107
  },
108
108
  // 表达式
109
109
  {
@@ -115,6 +115,12 @@ export var customTypes = [
115
115
  value: AtomsTypeEnum.OPERATOR,
116
116
  label: __('customColumn.operator')
117
117
  },
118
+ // 函数
119
+ {
120
+ value: AtomsTypeEnum.FORMULA,
121
+ label: __('customColumn.formula'),
122
+ children: operatorList
123
+ },
118
124
  // EXISTS
119
125
  {
120
126
  value: AtomsTypeEnum.NOT_EXISTS,
@@ -17,13 +17,13 @@ import { findIndex, getSubColumns } from '../../utils';
17
17
  import { TypeEnum, ColumnsPopupThemeEnum, JoinEnum, SQL_COLUMN_TYPE } from '../../store/enum';
18
18
  import { AtomsTypeEnum } from '../../store/types';
19
19
  import { SummarizeAlias } from '../../store/helper';
20
- import { getHelper, changeTableAlias } from '../../utils';
20
+ import { getHelper, changeTableAlias, isValidSQLAlias } from '../../utils';
21
21
  import Wrapper from './components/Wrapper';
22
22
  import NextDom from './components/meta-icon';
23
23
  import Header from './components/header';
24
24
  import SelectList from '../dialog/select-list';
25
25
  import { LeftJoinIcon, InnerJoinIcon } from '../icons';
26
- import { SelectTable, SelectJoin, SelectColumnMultiple, SelectColumn, Expression, SelectPermissionTable } from '../dialog';
26
+ import { SelectTable, SelectJoin, SelectColumnMultiple, SelectColumn, Expression, SelectPermissionTable, FormulaList, getTemplateItem } from '../dialog';
27
27
  import { useStore } from '../../hooks/use-provider';
28
28
  var PrevResult = 'Previous results';
29
29
  var operators = ['AND', 'OR', '(', ')', ',', '+', '-', '*', '/', '!=', '<=', '>=', '<', '>', '='];
@@ -38,7 +38,7 @@ var ExpressionsEnum;
38
38
  ExpressionsEnum["RIGHT"] = "rhs";
39
39
  })(ExpressionsEnum || (ExpressionsEnum = {}));
40
40
  var getText = function getText(v) {
41
- return _defineProperty(_defineProperty(_defineProperty({}, AtomsTypeEnum.JOIN_DEFAULT, 'joinData.default'), AtomsTypeEnum.EXPRESSION, 'joinData.expression'), AtomsTypeEnum.OPERATOR, 'customColumn.operator')[v];
41
+ return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, AtomsTypeEnum.JOIN_DEFAULT, 'joinData.default'), AtomsTypeEnum.EXPRESSION, 'joinData.expression'), AtomsTypeEnum.OPERATOR, 'customColumn.operator'), AtomsTypeEnum.COLLECTION, 'customColumn.collection')[v];
42
42
  };
43
43
  var menuTypes = [{
44
44
  key: AtomsTypeEnum.JOIN_DEFAULT,
@@ -49,6 +49,9 @@ var menuTypes = [{
49
49
  }, {
50
50
  key: AtomsTypeEnum.OPERATOR,
51
51
  label: __(getText(AtomsTypeEnum.OPERATOR))
52
+ }, {
53
+ key: AtomsTypeEnum.COLLECTION,
54
+ label: __(getText(AtomsTypeEnum.COLLECTION))
52
55
  }];
53
56
  var menuOperator = operators.map(function (v) {
54
57
  return {
@@ -57,7 +60,7 @@ var menuOperator = operators.map(function (v) {
57
60
  };
58
61
  });
59
62
  var JoinData = function JoinData(props) {
60
- var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table2, _meta$table3, _meta$table5, _meta$table6, _meta$table7, _meta$table8, _meta$expressions, _meta$table9, _meta$table0, _meta$expressions2;
63
+ var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table2, _meta$table3, _meta$table5, _meta$table6, _meta$table7, _meta$table8, _meta$expressions, _meta$table9, _meta$table10, _meta$expressions2, _store$showMainColumn, _store$showMainColumn2;
61
64
  var meta = props.meta,
62
65
  groupIndex = props.groupIndex;
63
66
  var store = useStore();
@@ -68,6 +71,7 @@ var JoinData = function JoinData(props) {
68
71
  var table2Selected = Boolean(meta.table2.name);
69
72
  var subQuerySelected = Boolean((_meta$subquery = meta.subquery) === null || _meta$subquery === void 0 || (_meta$subquery = _meta$subquery[0]) === null || _meta$subquery === void 0 || (_meta$subquery = _meta$subquery.table) === null || _meta$subquery === void 0 ? void 0 : _meta$subquery.name);
70
73
  var columnsSelected = meta.table1.name && meta.table2.name;
74
+ // const ref = useRef(null);
71
75
  // useEffect(() => {
72
76
  // let newMetaList = store.metaList[groupIndex].list.slice();
73
77
  // newMetaList[index] = setQuotes(meta);
@@ -371,7 +375,7 @@ var JoinData = function JoinData(props) {
371
375
  });
372
376
  newMeta[index].table2 = _table2;
373
377
  initExpressions();
374
- store.fetchColumns(_table2, data.datasourceId, function (columns) {
378
+ store.fetchColumns(_table2, data.datasourceId, [], function (columns) {
375
379
  newMeta[index].columns = columns;
376
380
  // 关联表变了 下面模块全部删除
377
381
  newMeta = newMeta.filter(function (v, i) {
@@ -687,10 +691,10 @@ var JoinData = function JoinData(props) {
687
691
  // value={(((newMeta[index] as MetaJoin).expressions[_ind] as AtomsExpression)[position])[`type`]}
688
692
  list: [{
689
693
  value: AtomsTypeEnum.INPUT_STRING,
690
- label: __('SqlQueryBuilder.input')
694
+ label: __('customColumn.input')
691
695
  }, {
692
696
  value: AtomsTypeEnum.INPUT_NUMBER,
693
- label: __('SqlQueryBuilder.numberInput')
697
+ label: __('customColumn.numberInput')
694
698
  }, {
695
699
  value: AtomsTypeEnum.CONSTANT,
696
700
  label: __('customColumn.constant')
@@ -854,30 +858,23 @@ var JoinData = function JoinData(props) {
854
858
  }),
855
859
  onOk: function () {
856
860
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
857
- var _index, newMeta;
858
- return _regeneratorRuntime.wrap(function (_context) {
861
+ var index, newMeta;
862
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
859
863
  while (1) switch (_context.prev = _context.next) {
860
864
  case 0:
861
- if (alias) {
862
- _context.next = 1;
863
- break;
864
- }
865
- Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
866
- return _context.abrupt("return", false);
867
- case 1:
868
- if (!(alias.length > 30)) {
869
- _context.next = 2;
865
+ if (isValidSQLAlias(alias)) {
866
+ _context.next = 3;
870
867
  break;
871
868
  }
872
- Toast.warning('别名长度不能超过30');
869
+ Toast.warning(__('SqlQueryBuilder.aliasForRules'));
873
870
  return _context.abrupt("return", false);
874
- case 2:
875
- _index = findIndex(store.metaList[groupIndex].list, meta);
871
+ case 3:
872
+ index = findIndex(store.metaList[groupIndex].list, meta);
876
873
  newMeta = store.metaList[groupIndex].list.slice();
877
- newMeta[_index].table2.alias = alias;
878
- newMeta = changeTableAlias(newMeta, newMeta[_index].table2);
874
+ newMeta[index].table2.alias = alias;
875
+ newMeta = changeTableAlias(newMeta, newMeta[index].table2);
879
876
  store.setMeta(newMeta, groupIndex);
880
- case 3:
877
+ case 8:
881
878
  case "end":
882
879
  return _context.stop();
883
880
  }
@@ -923,7 +920,8 @@ var JoinData = function JoinData(props) {
923
920
  var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
924
921
  var index = findIndex(store.metaList[groupIndex].list, meta);
925
922
  var newMeta = store.metaList[groupIndex].list.slice();
926
- var item = null;
923
+ var item = getTemplateItem(type);
924
+ console.log('🚀 ~ addExpression ~ item:', item);
927
925
  if (type === AtomsTypeEnum.JOIN_DEFAULT) {
928
926
  item = {
929
927
  lhs: [{
@@ -992,15 +990,6 @@ var JoinData = function JoinData(props) {
992
990
  type: type
993
991
  };
994
992
  }
995
- if (type === AtomsTypeEnum.EXPRESSION) {
996
- item = {
997
- lhs: [],
998
- condition: '',
999
- rhs: [],
1000
- quotes: '',
1001
- type: type
1002
- };
1003
- }
1004
993
  if (!item) {
1005
994
  return;
1006
995
  }
@@ -1356,7 +1345,60 @@ var JoinData = function JoinData(props) {
1356
1345
  })]
1357
1346
  }, i);
1358
1347
  }
1359
- })), ((_meta$table9 = meta.table2) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.name) && ((_meta$table0 = meta.table1) === null || _meta$table0 === void 0 ? void 0 : _meta$table0.name) && (((_meta$expressions2 = meta.expressions) === null || _meta$expressions2 === void 0 ? void 0 : _meta$expressions2.length) || 0) < 1 && _jsx(Tooltip, {
1348
+ if (v.type === AtomsTypeEnum.COLLECTION) {
1349
+ return _jsxs("div", {
1350
+ className: cx(" Sqb-collection-box"),
1351
+ children: [_jsx("div", {
1352
+ children: _jsx(FormulaList
1353
+ // showPreview={false}
1354
+ // check={formulaList?.[fun.name]?.args?.[i]?.check || ''}
1355
+ , {
1356
+ // showPreview={false}
1357
+ // check={formulaList?.[fun.name]?.args?.[i]?.check || ''}
1358
+ value: v.list,
1359
+ data: getTableColumns(),
1360
+ // ref={ref}
1361
+ onChange: function onChange(data, _quotes) {
1362
+ var newMeta = store.metaList[groupIndex].list.slice();
1363
+ newMeta[index].expressions[i].list = data;
1364
+ newMeta[index].expressions[i].quotes = _quotes;
1365
+ store.setMeta(newMeta, groupIndex);
1366
+ }
1367
+ })
1368
+ }), _jsx(Tooltip, {
1369
+ title: __('SqlQueryBuilder.add'),
1370
+ children: _jsx(Dropdown, {
1371
+ trigger: ['click'],
1372
+ onChange: function onChange(key) {
1373
+ addExpression(key, i);
1374
+ },
1375
+ droplist: menuTypes,
1376
+ children: _jsx(Button, {
1377
+ disabled: meta.readonly,
1378
+ primary: true,
1379
+ ghost: true,
1380
+ className: 'mr-2 operator-icon',
1381
+ icon: _jsx(FfPlus, {})
1382
+ })
1383
+ })
1384
+ }), _jsx(Tooltip, {
1385
+ title: __('SqlQueryBuilder.del'),
1386
+ children: _jsx(Button, {
1387
+ disabled: meta.readonly,
1388
+ danger: true,
1389
+ className: 'mr-2 operator-icon',
1390
+ icon: _jsx(FfLine, {}),
1391
+ onClick: function onClick() {
1392
+ var index = findIndex(store.metaList[groupIndex].list, meta);
1393
+ var newMeta = store.metaList[groupIndex].list.slice();
1394
+ newMeta[index].expressions.splice(i, 1);
1395
+ store.setMeta(newMeta, groupIndex);
1396
+ }
1397
+ })
1398
+ })]
1399
+ }, i);
1400
+ }
1401
+ })), ((_meta$table9 = meta.table2) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.name) && ((_meta$table10 = meta.table1) === null || _meta$table10 === void 0 ? void 0 : _meta$table10.name) && (((_meta$expressions2 = meta.expressions) === null || _meta$expressions2 === void 0 ? void 0 : _meta$expressions2.length) || 0) < 1 && _jsx(Tooltip, {
1360
1402
  title: __('SqlQueryBuilder.add'),
1361
1403
  children: _jsx(Dropdown, {
1362
1404
  trigger: ['click'],
@@ -1372,7 +1414,7 @@ var JoinData = function JoinData(props) {
1372
1414
  icon: _jsx(FfPlus, {})
1373
1415
  })
1374
1416
  })
1375
- }), columnsSelected && store.showFields && _jsx("div", {
1417
+ }), columnsSelected && (((_store$showMainColumn = store.showMainColumn[groupIndex]) === null || _store$showMainColumn === void 0 ? void 0 : _store$showMainColumn.showColumn) || ((_store$showMainColumn2 = store.showMainColumn[groupIndex]) === null || _store$showMainColumn2 === void 0 ? void 0 : _store$showMainColumn2.index) < index) && store.showFields && _jsx("div", {
1376
1418
  className: "Sqb-TableColumns",
1377
1419
  onClick: selectColumns,
1378
1420
  children: __('SqlQueryBuilder.columns')
@@ -10,7 +10,7 @@ import { MetaSummarize_Enum } 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 } from '../../../utils';
13
+ import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
14
14
  import { AddIcon, CloseIcon } from '../../icons';
15
15
  import { useStore } from '../../../hooks/use-provider';
16
16
  var GroupBy = function GroupBy(props) {
@@ -234,29 +234,22 @@ var GroupBy = function GroupBy(props) {
234
234
  onOk: function () {
235
235
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
236
236
  var newMeta;
237
- return _regeneratorRuntime.wrap(function (_context) {
237
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
238
238
  while (1) switch (_context.prev = _context.next) {
239
239
  case 0:
240
- if (fieldAlias) {
241
- _context.next = 1;
240
+ if (isValidSQLAlias(fieldAlias)) {
241
+ _context.next = 3;
242
242
  break;
243
243
  }
244
- Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
244
+ Toast.warning(__('SqlQueryBuilder.aliasForRules'));
245
245
  return _context.abrupt("return", false);
246
- case 1:
247
- if (!(fieldAlias.length > 30)) {
248
- _context.next = 2;
249
- break;
250
- }
251
- Toast.warning('别名长度不能超过30');
252
- return _context.abrupt("return", false);
253
- case 2:
246
+ case 3:
254
247
  newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
255
248
  newMeta[index].by[i].sql = newMeta[index].by[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
256
249
  newMeta[index].by[i].fieldAlias = fieldAlias;
257
250
  newMeta = changeFieldAlias(newMeta, newMeta[index].by[i]);
258
251
  store.setMeta(newMeta, groupIndex);
259
- case 3:
252
+ case 8:
260
253
  case "end":
261
254
  return _context.stop();
262
255
  }
@@ -10,7 +10,7 @@ import { summarizeToSql } from '../../../store/helper';
10
10
  import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
11
11
  import { uuidv4 } from '../../../utils/helper';
12
12
  import { MetaSummarize_Enum } from '../../../store/types';
13
- import { changeFieldAlias } from '../../../utils';
13
+ import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
14
14
  import { AddIcon, CloseIcon } from '../../icons';
15
15
  import { SelectSummarize } from '../../dialog';
16
16
  import { useStore } from '../../../hooks/use-provider';
@@ -242,29 +242,22 @@ var SelectIndex = function SelectIndex(props) {
242
242
  onOk: function () {
243
243
  var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
244
244
  var newMeta;
245
- return _regeneratorRuntime.wrap(function (_context) {
245
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
246
246
  while (1) switch (_context.prev = _context.next) {
247
247
  case 0:
248
- if (fieldAlias) {
249
- _context.next = 1;
248
+ if (isValidSQLAlias(fieldAlias)) {
249
+ _context.next = 3;
250
250
  break;
251
251
  }
252
- Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
252
+ Toast.warning(__('SqlQueryBuilder.aliasForRules'));
253
253
  return _context.abrupt("return", false);
254
- case 1:
255
- if (!(fieldAlias.length > 30)) {
256
- _context.next = 2;
257
- break;
258
- }
259
- Toast.warning('别名长度不能超过30');
260
- return _context.abrupt("return", false);
261
- case 2:
254
+ case 3:
262
255
  newMeta = store.metaList[groupIndex].list.slice(); // @ts-ignore
263
256
  newMeta[index].group[i].fieldAlias = fieldAlias;
264
257
  newMeta[index].group[i].sql = newMeta[index].group[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias); //修改sql
265
258
  newMeta = changeFieldAlias(newMeta, newMeta[index].group[i]);
266
259
  store.setMeta(newMeta, groupIndex);
267
- case 3:
260
+ case 8:
268
261
  case "end":
269
262
  return _context.stop();
270
263
  }
@@ -10,7 +10,7 @@ import { __ } from '../../locale';
10
10
  import { Tooltip, Button, Modal, Modal2, Input, Toast } from '@gingkoo/pandora';
11
11
  import Metabase from '../../index';
12
12
  import { uuidv4, getAlias } from '../../utils/helper';
13
- import { changeTableAlias, getSubColumns } from '../../utils';
13
+ import { changeTableAlias, getSubColumns, isValidSQLAlias } from '../../utils';
14
14
  import { RelatedWork } from '@gingkoo/pandora-icons';
15
15
  import cloneDeep from 'lodash/cloneDeep';
16
16
  import isEqual from 'lodash/isEqual';
@@ -20,7 +20,7 @@ import NextDom from './components/meta-icon';
20
20
  import Header from './components/header';
21
21
  import { useStore } from '../../hooks/use-provider';
22
22
  var TableData = function TableData(props) {
23
- var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table2, _meta$table3, _meta$table5, _meta$table6;
23
+ var _meta$subquery, _meta$subquery2, _meta$subquery3, _meta$table2, _meta$table3, _meta$table5, _meta$table6, _store$showMainColumn;
24
24
  var meta = props.meta,
25
25
  groupIndex = props.groupIndex;
26
26
  var store = useStore();
@@ -40,7 +40,7 @@ var TableData = function TableData(props) {
40
40
  tableUuid: uuidv4('table'),
41
41
  alias: getAlias(data.name, store.metaList[groupIndex].list.slice())
42
42
  });
43
- store.fetchColumns(data, data.datasourceId, function (columns) {
43
+ store.fetchColumns(data, data.datasourceId, [], function (columns) {
44
44
  newMetaList.columns = columns;
45
45
  // ① 主表动了 其他都得重新选
46
46
  store.setMeta([newMetaList], groupIndex);
@@ -84,28 +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 (_context) {
87
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
88
88
  while (1) switch (_context.prev = _context.next) {
89
89
  case 0:
90
- if (alias) {
91
- _context.next = 1;
90
+ if (isValidSQLAlias(alias)) {
91
+ _context.next = 3;
92
92
  break;
93
93
  }
94
- Toast.warning(__('SqlQueryBuilder.aliasCannotEmpty'));
94
+ Toast.warning(__('SqlQueryBuilder.aliasForRules'));
95
95
  return _context.abrupt("return", false);
96
- case 1:
97
- if (!(alias.length > 30)) {
98
- _context.next = 2;
99
- break;
100
- }
101
- Toast.warning('别名长度不能超过30');
102
- return _context.abrupt("return", false);
103
- case 2:
96
+ case 3:
104
97
  newMetaList = store.metaList[groupIndex].list.slice(); // @ts-ignore
105
98
  newMetaList[0].table.alias = alias;
106
99
  newMetaList = changeTableAlias(newMetaList, newMetaList[0].table);
107
100
  store.setMeta(newMetaList, groupIndex);
108
- case 3:
101
+ case 7:
109
102
  case "end":
110
103
  return _context.stop();
111
104
  }
@@ -259,7 +252,7 @@ var TableData = function TableData(props) {
259
252
  icon: _jsx(RelatedWork, {}),
260
253
  onClick: switchSubQuery
261
254
  })
262
- }), selected && store.showFields && _jsx("div", {
255
+ }), selected && store.showFields && ((_store$showMainColumn = store.showMainColumn[groupIndex]) === null || _store$showMainColumn === void 0 ? void 0 : _store$showMainColumn.showColumn) && _jsx("div", {
263
256
  className: "Sqb-TableColumns",
264
257
  onClick: selectColumns,
265
258
  children: __('SqlQueryBuilder.columns')