@gingkoo/pandora-metabase 1.0.118 → 1.0.119

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 (195) hide show
  1. package/lib/cjs/common/Portal/index.js +0 -2
  2. package/lib/cjs/common/SplitView/index.d.ts +0 -4
  3. package/lib/cjs/common/SplitView/index.js +0 -10
  4. package/lib/cjs/components/dialog/custom-column/config.js +4 -48
  5. package/lib/cjs/components/dialog/custom-column/expression-editor.js +3 -14
  6. package/lib/cjs/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
  7. package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -43
  8. package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +8 -65
  9. package/lib/cjs/components/dialog/custom-column/index.js +2 -4
  10. package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +2 -3
  11. package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -1
  12. package/lib/cjs/components/dialog/custom-editor/index.js +2 -7
  13. package/lib/cjs/components/dialog/diff-viewer/index copy.js +1 -16
  14. package/lib/cjs/components/dialog/expression/date-format-picker.js +2 -20
  15. package/lib/cjs/components/dialog/expression/date-format.js +2 -8
  16. package/lib/cjs/components/dialog/expression/index.d.ts +0 -3
  17. package/lib/cjs/components/dialog/expression/index.js +2 -83
  18. package/lib/cjs/components/dialog/formula/index.js +1 -30
  19. package/lib/cjs/components/dialog/formula/utils.js +2 -10
  20. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
  21. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +109 -0
  22. package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +9 -0
  23. package/lib/cjs/components/dialog/formula-list/LogicGroup.js +43 -0
  24. package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
  25. package/lib/cjs/components/dialog/formula-list/index.js +967 -503
  26. package/lib/cjs/components/dialog/formula-list/index.less +724 -0
  27. package/lib/cjs/components/dialog/formula-list/utils.d.ts +0 -7
  28. package/lib/cjs/components/dialog/formula-list/utils.js +117 -113
  29. package/lib/cjs/components/dialog/select-column/index.d.ts +0 -6
  30. package/lib/cjs/components/dialog/select-column/index.js +4 -15
  31. package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +0 -8
  32. package/lib/cjs/components/dialog/select-column-multiple/index.js +6 -45
  33. package/lib/cjs/components/dialog/select-join/index.d.ts +0 -5
  34. package/lib/cjs/components/dialog/select-join/index.js +0 -6
  35. package/lib/cjs/components/dialog/select-join-column/index.d.ts +0 -8
  36. package/lib/cjs/components/dialog/select-join-column/index.js +7 -21
  37. package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +0 -8
  38. package/lib/cjs/components/dialog/select-join-column-multiple/index.js +5 -35
  39. package/lib/cjs/components/dialog/select-permission-table/index.d.ts +0 -5
  40. package/lib/cjs/components/dialog/select-permission-table/index.js +0 -6
  41. package/lib/cjs/components/dialog/select-summarize/index.d.ts +3 -3
  42. package/lib/cjs/components/dialog/select-summarize/index.js +105 -18
  43. package/lib/cjs/components/dialog/select-summarize/index.less +23 -0
  44. package/lib/cjs/components/dialog/select-table/index.d.ts +0 -6
  45. package/lib/cjs/components/dialog/select-table/index.js +1 -9
  46. package/lib/cjs/components/metabase/index.js +72 -86
  47. package/lib/cjs/components/metabase/index.less +7 -7
  48. package/lib/cjs/components/modules/components/Wrapper.js +1 -1
  49. package/lib/cjs/components/modules/components/header.js +2 -2
  50. package/lib/cjs/components/modules/components/meta-icon.d.ts +0 -3
  51. package/lib/cjs/components/modules/components/meta-icon.js +2 -47
  52. package/lib/cjs/components/modules/custom-column.js +3 -29
  53. package/lib/cjs/components/modules/enum/filter-enum.js +9 -88
  54. package/lib/cjs/components/modules/filter.js +2 -20
  55. package/lib/cjs/components/modules/index.d.ts +4 -2
  56. package/lib/cjs/components/modules/index.js +24 -1
  57. package/lib/cjs/components/modules/join-data.js +13 -291
  58. package/lib/cjs/components/modules/row-limit.js +0 -1
  59. package/lib/cjs/components/modules/sort.js +1 -61
  60. package/lib/cjs/components/modules/summarize/group-by.d.ts +0 -5
  61. package/lib/cjs/components/modules/summarize/group-by.js +231 -76
  62. package/lib/cjs/components/modules/summarize/select-index.js +96 -46
  63. package/lib/cjs/components/modules/table-data.js +11 -64
  64. package/lib/cjs/components/popup.js +26 -32
  65. package/lib/cjs/hooks/patch.d.ts +1 -0
  66. package/lib/cjs/hooks/patch.js +104 -6
  67. package/lib/cjs/hooks/patch2.js +3 -165
  68. package/lib/cjs/hooks/use-provider.js +0 -3
  69. package/lib/cjs/hooks/use-state.js +55 -135
  70. package/lib/cjs/index.js +0 -15
  71. package/lib/cjs/locale/en.js +5 -0
  72. package/lib/cjs/locale/index.js +1 -4
  73. package/lib/cjs/locale/zh.js +5 -0
  74. package/lib/cjs/sql-formula.js +0 -1
  75. package/lib/cjs/store/enum.d.ts +6 -6
  76. package/lib/cjs/store/enum.js +0 -13
  77. package/lib/cjs/store/helper.d.ts +2 -1
  78. package/lib/cjs/store/helper.js +15 -225
  79. package/lib/cjs/store/types.d.ts +45 -67
  80. package/lib/cjs/store/types.js +3 -49
  81. package/lib/cjs/types.d.ts +1 -0
  82. package/lib/cjs/utils/cookies.js +0 -3
  83. package/lib/cjs/utils/event.js +1 -1
  84. package/lib/cjs/utils/helper-dom.d.ts +1 -0
  85. package/lib/cjs/utils/helper-dom.js +17 -10
  86. package/lib/cjs/utils/helper.js +1 -24
  87. package/lib/cjs/utils/keydown.js +4 -7
  88. package/lib/cjs/utils/platform.d.ts +0 -9
  89. package/lib/cjs/utils/platform.js +0 -10
  90. package/lib/cjs/utils/selection.js +0 -6
  91. package/lib/cjs/utils/storage.d.ts +0 -9
  92. package/lib/cjs/utils/storage.js +1 -11
  93. package/lib/cjs/utils/transformSql.d.ts +5 -0
  94. package/lib/cjs/utils/transformSql.js +42 -113
  95. package/lib/cjs/utils.d.ts +1 -6
  96. package/lib/cjs/utils.js +115 -255
  97. package/lib/es/common/Portal/index.js +0 -2
  98. package/lib/es/common/SplitView/index.d.ts +0 -4
  99. package/lib/es/common/SplitView/index.js +0 -10
  100. package/lib/es/components/dialog/custom-column/config.js +4 -48
  101. package/lib/es/components/dialog/custom-column/expression-editor.js +3 -14
  102. package/lib/es/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
  103. package/lib/es/components/dialog/custom-column/expressions/suggest.js +2 -43
  104. package/lib/es/components/dialog/custom-column/expressions/tokenizer.js +8 -65
  105. package/lib/es/components/dialog/custom-column/index.js +2 -4
  106. package/lib/es/components/dialog/custom-column/tokenized-expression.js +1 -3
  107. package/lib/es/components/dialog/custom-column/tokenizedI-input.js +1 -1
  108. package/lib/es/components/dialog/custom-editor/index.js +1 -7
  109. package/lib/es/components/dialog/diff-viewer/index copy.js +1 -15
  110. package/lib/es/components/dialog/expression/date-format-picker.js +2 -20
  111. package/lib/es/components/dialog/expression/date-format.js +2 -8
  112. package/lib/es/components/dialog/expression/index.d.ts +0 -3
  113. package/lib/es/components/dialog/expression/index.js +2 -82
  114. package/lib/es/components/dialog/formula/index.js +0 -30
  115. package/lib/es/components/dialog/formula/utils.js +2 -10
  116. package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
  117. package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +102 -0
  118. package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +9 -0
  119. package/lib/es/components/dialog/formula-list/LogicGroup.js +36 -0
  120. package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
  121. package/lib/es/components/dialog/formula-list/index.js +966 -503
  122. package/lib/es/components/dialog/formula-list/index.less +724 -0
  123. package/lib/es/components/dialog/formula-list/utils.d.ts +0 -7
  124. package/lib/es/components/dialog/formula-list/utils.js +117 -113
  125. package/lib/es/components/dialog/index.js +3 -3
  126. package/lib/es/components/dialog/select-column/index.d.ts +0 -6
  127. package/lib/es/components/dialog/select-column/index.js +4 -14
  128. package/lib/es/components/dialog/select-column-multiple/index.d.ts +0 -8
  129. package/lib/es/components/dialog/select-column-multiple/index.js +7 -47
  130. package/lib/es/components/dialog/select-join/index.d.ts +0 -5
  131. package/lib/es/components/dialog/select-join/index.js +0 -5
  132. package/lib/es/components/dialog/select-join-column/index.d.ts +0 -8
  133. package/lib/es/components/dialog/select-join-column/index.js +7 -20
  134. package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +0 -8
  135. package/lib/es/components/dialog/select-join-column-multiple/index.js +5 -34
  136. package/lib/es/components/dialog/select-permission-table/index.d.ts +0 -5
  137. package/lib/es/components/dialog/select-permission-table/index.js +0 -5
  138. package/lib/es/components/dialog/select-summarize/index.d.ts +3 -3
  139. package/lib/es/components/dialog/select-summarize/index.js +106 -18
  140. package/lib/es/components/dialog/select-summarize/index.less +23 -0
  141. package/lib/es/components/dialog/select-table/index.d.ts +0 -6
  142. package/lib/es/components/dialog/select-table/index.js +1 -8
  143. package/lib/es/components/metabase/index.js +72 -87
  144. package/lib/es/components/metabase/index.less +7 -7
  145. package/lib/es/components/modules/components/Wrapper.js +1 -1
  146. package/lib/es/components/modules/components/header.js +2 -2
  147. package/lib/es/components/modules/components/meta-icon.d.ts +0 -3
  148. package/lib/es/components/modules/components/meta-icon.js +2 -46
  149. package/lib/es/components/modules/custom-column.js +3 -29
  150. package/lib/es/components/modules/enum/filter-enum.js +9 -88
  151. package/lib/es/components/modules/filter.js +2 -19
  152. package/lib/es/components/modules/index.d.ts +4 -2
  153. package/lib/es/components/modules/index.js +24 -1
  154. package/lib/es/components/modules/join-data.js +13 -291
  155. package/lib/es/components/modules/row-limit.js +0 -1
  156. package/lib/es/components/modules/sort.js +1 -61
  157. package/lib/es/components/modules/summarize/group-by.d.ts +0 -5
  158. package/lib/es/components/modules/summarize/group-by.js +233 -78
  159. package/lib/es/components/modules/summarize/select-index.js +96 -46
  160. package/lib/es/components/modules/table-data.js +11 -64
  161. package/lib/es/components/popup.js +27 -33
  162. package/lib/es/hooks/patch.d.ts +1 -0
  163. package/lib/es/hooks/patch.js +103 -5
  164. package/lib/es/hooks/patch2.js +2 -164
  165. package/lib/es/hooks/use-provider.js +0 -3
  166. package/lib/es/hooks/use-state.js +55 -135
  167. package/lib/es/index.js +0 -14
  168. package/lib/es/locale/en.js +5 -0
  169. package/lib/es/locale/index.js +1 -4
  170. package/lib/es/locale/zh.js +5 -0
  171. package/lib/es/sql-formula.js +0 -1
  172. package/lib/es/store/enum.d.ts +6 -6
  173. package/lib/es/store/enum.js +0 -13
  174. package/lib/es/store/helper.d.ts +2 -1
  175. package/lib/es/store/helper.js +13 -224
  176. package/lib/es/store/types.d.ts +45 -67
  177. package/lib/es/store/types.js +3 -49
  178. package/lib/es/types.d.ts +1 -0
  179. package/lib/es/types.js +1 -18
  180. package/lib/es/utils/cookies.js +0 -3
  181. package/lib/es/utils/event.js +1 -1
  182. package/lib/es/utils/helper-dom.d.ts +1 -0
  183. package/lib/es/utils/helper-dom.js +16 -9
  184. package/lib/es/utils/helper.js +1 -24
  185. package/lib/es/utils/keydown.js +4 -7
  186. package/lib/es/utils/platform.d.ts +0 -9
  187. package/lib/es/utils/platform.js +0 -10
  188. package/lib/es/utils/selection.js +0 -6
  189. package/lib/es/utils/storage.d.ts +0 -9
  190. package/lib/es/utils/storage.js +1 -10
  191. package/lib/es/utils/transformSql.d.ts +5 -0
  192. package/lib/es/utils/transformSql.js +42 -112
  193. package/lib/es/utils.d.ts +1 -6
  194. package/lib/es/utils.js +116 -255
  195. package/package.json +1 -1
@@ -1,14 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
- /**
5
- * 选择表字段当条件
6
- * 谁在用?
7
- * 1、关联模块
8
- * 2、过滤器模块
9
- * 3、聚合模块
10
- * 4、排序模块
11
- */
12
4
  import './index.less';
13
5
  import { useEffect, useState } from 'react';
14
6
  import { Empty } from '@gingkoo/pandora';
@@ -17,9 +9,7 @@ import cloneDeep from 'lodash/cloneDeep';
17
9
  import cx from 'classnames';
18
10
  import { ColumnsPopupThemeEnum, SQL_GROUP_TYPE } from '../../../store/enum';
19
11
  import { SummarizeAlias } from '../../../store/helper';
20
- import {
21
- // AtomsField,
22
- AtomsTypeEnum } from '../../../store/types';
12
+ import { AtomsTypeEnum } from '../../../store/types';
23
13
  import { __ } from '../../../locale';
24
14
  import { NUMBER_GROUP, DATE_GROUP } from '../const';
25
15
  import { useStore } from '../../../hooks/use-provider';
@@ -40,7 +30,7 @@ var IconMap = {
40
30
  PK: _jsx(CircleIcon, {}),
41
31
  FK: _jsx(ForeignKeyIcon, {})
42
32
  };
43
- var OPEN_GROUP = false; // mr.chen 说不弄这块 弄个开关防止后面要用
33
+ var OPEN_GROUP = false;
44
34
  var SelectJoinColumn = function SelectJoinColumn(_ref) {
45
35
  var _value$, _value$2;
46
36
  var _ref$data = _ref.data,
@@ -63,7 +53,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
63
53
  var _useState = useState(_value),
64
54
  _useState2 = _slicedToArray(_useState, 2),
65
55
  value = _useState2[0],
66
- setValue = _useState2[1]; // 当前选择的字段
56
+ setValue = _useState2[1];
67
57
  var _useState3 = useState((_value === null || _value === void 0 || (_value$ = _value[0]) === null || _value$ === void 0 ? void 0 : _value$.tableId) === SummarizeAlias ? '' : _value === null || _value === void 0 || (_value$2 = _value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.tableUuid),
68
58
  _useState4 = _slicedToArray(_useState3, 2),
69
59
  curTable = _useState4[0],
@@ -71,11 +61,9 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
71
61
  var _useState5 = useState(''),
72
62
  _useState6 = _slicedToArray(_useState5, 2),
73
63
  searchTableText = _useState6[0],
74
- setSearchTableText = _useState6[1]; // 搜索表的文字
75
- // 当前选择的表
76
- // const [curColumn, setCurColumn] = useState(_value); // 当前选择的字段
64
+ setSearchTableText = _useState6[1];
77
65
  var _useState7 = useState(data.map(function (v, i) {
78
- var open = !i && !curTable ? true : v.tableUuid === curTable; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
66
+ var open = !i && !curTable ? true : v.tableUuid === curTable;
79
67
  return _objectSpread(_objectSpread({}, v), {}, {
80
68
  open: open,
81
69
  searchText: '',
@@ -90,7 +78,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
90
78
  tableList = _useState8[0],
91
79
  setTableList = _useState8[1];
92
80
  useEffect(function () {
93
- // setCurColumn(_value);
94
81
  setValue(_value);
95
82
  }, [_value]);
96
83
  var isActive = function isActive(id_alias) {
@@ -108,7 +95,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
108
95
  tableUuid = (data === null || data === void 0 || (_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.tableUuid) || '';
109
96
  }
110
97
  setTableList(data === null || data === void 0 ? void 0 : data.map(function (v, i) {
111
- var open = !i && !tableUuid ? true : v.tableUuid === tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
98
+ var open = !i && !tableUuid ? true : v.tableUuid === tableUuid;
112
99
  return _objectSpread(_objectSpread({}, v), {}, {
113
100
  open: open,
114
101
  searchText: '',
@@ -162,13 +149,11 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
162
149
  return v.fieldId != (val === null || val === void 0 ? void 0 : val.fieldId);
163
150
  });
164
151
  }
165
- // 当前选中的表字段
166
152
  var curTableColumn = data.filter(function (v) {
167
153
  return v.tableUuid === tableUuid;
168
154
  }).flatMap(function (v) {
169
155
  return v.columns;
170
156
  });
171
- // 过滤选中字段不在当前选中的表字段中,
172
157
  _value = _value.filter(function (item2) {
173
158
  return curTableColumn.some(function (item1) {
174
159
  return item1.name === item2.fieldName;
@@ -186,7 +171,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
186
171
  datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
187
172
  var fullName = datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias, store.tableEnableAlias)) : mergeNameAlias(tableName, tableAlias, store.tableEnableAlias);
188
173
  if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
189
- // let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
190
174
  return _objectSpread({}, v);
191
175
  }
192
176
  return null;
@@ -196,7 +180,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
196
180
  setSearchTableText(val);
197
181
  setTableList(newData);
198
182
  };
199
- // const _condition = value?.condition || '';
200
183
  if (data.length < 1) {
201
184
  return _jsx("div", {
202
185
  className: 'Sqb-SelectColumns--box',
@@ -244,7 +227,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
244
227
  _tableItem$tableUuid = tableItem.tableUuid,
245
228
  tableUuid = _tableItem$tableUuid === void 0 ? '' : _tableItem$tableUuid;
246
229
  var isMultiple = tableList.length > 1;
247
- // 只有一张表时 展开
248
230
  if (!isMultiple) {
249
231
  open = true;
250
232
  }
@@ -308,7 +290,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
308
290
  }), _jsx("input", {
309
291
  type: 'text',
310
292
  className: 'p-2',
311
- // autoFocus
312
293
  value: searchText,
313
294
  placeholder: __('joinData.search'),
314
295
  onChange: function onChange() {},
@@ -326,16 +307,12 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
326
307
  realName = _v$realName === void 0 ? '' : _v$realName,
327
308
  fieldId = v.id;
328
309
  var groupe = SQL_GROUP_TYPE.STRING;
329
- // @ts-ignore
330
310
  if (~NUMBER_GROUP.indexOf(database_type)) {
331
311
  groupe = SQL_GROUP_TYPE.NUMBER;
332
312
  }
333
- // @ts-ignore
334
313
  if (~DATE_GROUP.indexOf(database_type)) {
335
314
  groupe = SQL_GROUP_TYPE.DATE;
336
315
  }
337
- // let showCondition =
338
- // curColumn === name && curTable === tableUuid && _condition;
339
316
  return _jsx("div", {
340
317
  className: cx("Sqb-List-section"),
341
318
  children: _jsx("div", {
@@ -343,9 +320,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
343
320
  active: isActive((v.id || v.name) + (v.fieldAlias || ''))
344
321
  }),
345
322
  onClick: function onClick() {
346
- if (isSummarize) {
347
- // console.log(v, 'v');
348
- }
323
+ if (isSummarize) {}
349
324
  changeValue(tableUuid, {
350
325
  tableName: tableItem.name || '',
351
326
  tableId: tableItem.id || '',
@@ -360,22 +335,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
360
335
  fieldAlias: v.fieldAlias || '',
361
336
  fieldUuid: v.fieldUuid || '',
362
337
  type: AtomsTypeEnum.FIELD
363
- // quotes: v.fieldAlias || v.name,
364
338
  });
365
- // setCurTable(tableUuid);
366
- // typeof onSelect === 'function' &&
367
- // onSelect({
368
- // ...v,
369
- // table,
370
- // tableId,
371
- // alias: tableAlias,
372
- // name,
373
- // database_type,
374
- // sql: v.sql || '',
375
- // datasourceId,
376
- // datasourceName,
377
- // realName,
378
- // });
379
339
  },
380
340
  children: _jsxs("div", {
381
341
  className: 'p-2 List-item',
@@ -1,8 +1,3 @@
1
- /**
2
- * 选择关联方式
3
- * 谁在用?
4
- * 1、关联模块
5
- */
6
1
  import './index.less';
7
2
  import { JoinEnum } from '../../../store/enum';
8
3
  interface PropsType {
@@ -1,9 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /**
3
- * 选择关联方式
4
- * 谁在用?
5
- * 1、关联模块
6
- */
7
2
  import './index.less';
8
3
  import cx from 'classnames';
9
4
  import { JoinEnum } from '../../../store/enum';
@@ -1,11 +1,3 @@
1
- /**
2
- * 选择表字段当条件
3
- * 谁在用?
4
- * 1、关联模块
5
- * 2、过滤器模块
6
- * 3、聚合模块
7
- * 4、排序模块
8
- */
9
1
  import './index.less';
10
2
  import { ColumnsPopupThemeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
11
3
  import { MetaData_ColumnsType, MetaJoin_TalbeType } from '../../../store/types';
@@ -1,14 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
- /**
5
- * 选择表字段当条件
6
- * 谁在用?
7
- * 1、关联模块
8
- * 2、过滤器模块
9
- * 3、聚合模块
10
- * 4、排序模块
11
- */
12
4
  import './index.less';
13
5
  import { useEffect, useState } from 'react';
14
6
  import { Menu, Popover } from '@gingkoo/pandora';
@@ -35,7 +27,7 @@ var IconMap = {
35
27
  PK: _jsx(CircleIcon, {}),
36
28
  FK: _jsx(ForeignKeyIcon, {})
37
29
  };
38
- var OPEN_GROUP = false; // mr.chen 说不弄这块 弄个开关防止后面要用
30
+ var OPEN_GROUP = false;
39
31
  var SelectJoinColumn = function SelectJoinColumn(_ref) {
40
32
  var _ref$data = _ref.data,
41
33
  data = _ref$data === void 0 ? [] : _ref$data,
@@ -52,21 +44,21 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
52
44
  var _useState = useState(_value),
53
45
  _useState2 = _slicedToArray(_useState, 2),
54
46
  value = _useState2[0],
55
- setValue = _useState2[1]; // 当前选择的字段
47
+ setValue = _useState2[1];
56
48
  var _useState3 = useState(_value.tableUuid),
57
49
  _useState4 = _slicedToArray(_useState3, 2),
58
50
  curTable = _useState4[0],
59
- setCurTable = _useState4[1]; // 当前选择的表
51
+ setCurTable = _useState4[1];
60
52
  var _useState5 = useState(_value.name),
61
53
  _useState6 = _slicedToArray(_useState5, 2),
62
54
  curColumn = _useState6[0],
63
- setCurColumn = _useState6[1]; // 当前选择的字段
55
+ setCurColumn = _useState6[1];
64
56
  var _useState7 = useState(''),
65
57
  _useState8 = _slicedToArray(_useState7, 2),
66
58
  searchTableText = _useState8[0],
67
- setSearchTableText = _useState8[1]; // 搜索表的文字
59
+ setSearchTableText = _useState8[1];
68
60
  var _useState9 = useState(data.map(function (v, i) {
69
- var open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
61
+ var open = !i && !_value.tableUuid ? true : v.tableUuid === _value.tableUuid;
70
62
  return _objectSpread(_objectSpread({}, v), {}, {
71
63
  open: open,
72
64
  searchText: '',
@@ -91,7 +83,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
91
83
  }
92
84
  setCurTable(tableUuid);
93
85
  setTableList(data.map(function (v, i) {
94
- var open = !i && !tableUuid ? true : v.tableUuid === tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
86
+ var open = !i && !tableUuid ? true : v.tableUuid === tableUuid;
95
87
  return _objectSpread(_objectSpread({}, v), {}, {
96
88
  open: open,
97
89
  searchText: '',
@@ -125,7 +117,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
125
117
  datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
126
118
  var fullName = datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias, store.tableEnableAlias)) : mergeNameAlias(tableName, tableAlias, store.tableEnableAlias);
127
119
  if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
128
- // let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
129
120
  return _objectSpread({}, v);
130
121
  }
131
122
  return null;
@@ -172,7 +163,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
172
163
  _tableItem$tableUuid = tableItem.tableUuid,
173
164
  tableUuid = _tableItem$tableUuid === void 0 ? '' : _tableItem$tableUuid;
174
165
  var isMultiple = tableList.length > 1;
175
- // 只有一张表时 展开
176
166
  if (!isMultiple) {
177
167
  open = true;
178
168
  }
@@ -233,7 +223,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
233
223
  }), _jsx("input", {
234
224
  type: 'text',
235
225
  className: 'p-2',
236
- // autoFocus
237
226
  value: searchText,
238
227
  placeholder: __('joinData.search'),
239
228
  onChange: function onChange() {},
@@ -249,11 +238,9 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
249
238
  _v$realName = v.realName,
250
239
  realName = _v$realName === void 0 ? '' : _v$realName;
251
240
  var groupe = SQL_GROUP_TYPE.STRING;
252
- // @ts-ignore
253
241
  if (~NUMBER_GROUP.indexOf(database_type)) {
254
242
  groupe = SQL_GROUP_TYPE.NUMBER;
255
243
  }
256
- // @ts-ignore
257
244
  if (~DATE_GROUP.indexOf(database_type)) {
258
245
  groupe = SQL_GROUP_TYPE.DATE;
259
246
  }
@@ -1,11 +1,3 @@
1
- /**
2
- * 选择表字段当条件
3
- * 谁在用?
4
- * 1、关联模块
5
- * 2、过滤器模块
6
- * 3、聚合模块
7
- * 4、排序模块
8
- */
9
1
  import './index.less';
10
2
  import { ColumnsPopupThemeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
11
3
  import { MetaData_ColumnsType, MetaJoin_TalbeType, MetaJoin_Field } from '../../../store/types';
@@ -2,14 +2,6 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
- /**
6
- * 选择表字段当条件
7
- * 谁在用?
8
- * 1、关联模块
9
- * 2、过滤器模块
10
- * 3、聚合模块
11
- * 4、排序模块
12
- */
13
5
  import './index.less';
14
6
  import { useEffect, useState } from 'react';
15
7
  import cloneDeep from 'lodash/cloneDeep';
@@ -35,7 +27,7 @@ var IconMap = {
35
27
  PK: _jsx(CircleIcon, {}),
36
28
  FK: _jsx(ForeignKeyIcon, {})
37
29
  };
38
- var OPEN_GROUP = false; // mr.chen 说不弄这块 弄个开关防止后面要用
30
+ var OPEN_GROUP = false;
39
31
  var SelectJoinColumn = function SelectJoinColumn(_ref) {
40
32
  var _ref$data = _ref.data,
41
33
  data = _ref$data === void 0 ? [] : _ref$data,
@@ -53,14 +45,13 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
53
45
  var _useState = useState(_value),
54
46
  _useState2 = _slicedToArray(_useState, 2),
55
47
  value = _useState2[0],
56
- setValue = _useState2[1]; // 当前选择的字段
48
+ setValue = _useState2[1];
57
49
  var _useState3 = useState(tableInfo),
58
50
  _useState4 = _slicedToArray(_useState3, 2),
59
51
  curTable = _useState4[0],
60
- setCurTable = _useState4[1]; // 当前选择的表
61
- // const [curColumn, setCurColumn] = useState(_value); // 当前选择的字段
52
+ setCurTable = _useState4[1];
62
53
  var _useState5 = useState(data.map(function (v, i) {
63
- var open = !i && !tableInfo.tableUuid ? true : v.tableUuid === tableInfo.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
54
+ var open = !i && !tableInfo.tableUuid ? true : v.tableUuid === tableInfo.tableUuid;
64
55
  return _objectSpread(_objectSpread({}, v), {}, {
65
56
  open: open,
66
57
  searchText: '',
@@ -74,7 +65,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
74
65
  setCurTable(tableInfo);
75
66
  }, [tableInfo]);
76
67
  useEffect(function () {
77
- // setCurColumn(_value);
78
68
  setValue(_value);
79
69
  }, [_value]);
80
70
  var isActive = function isActive(fieldUuid) {
@@ -84,7 +74,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
84
74
  };
85
75
  useEffect(function () {
86
76
  setTableList(data.map(function (v, i) {
87
- var open = !i && !tableInfo.tableUuid ? true : v.tableUuid === tableInfo.tableUuid; // TODO.这里只判断表名相等 没有用了 因为表上面加了一层数据源 先这样吧
77
+ var open = !i && !tableInfo.tableUuid ? true : v.tableUuid === tableInfo.tableUuid;
88
78
  return _objectSpread(_objectSpread({}, v), {}, {
89
79
  open: open,
90
80
  searchText: '',
@@ -129,7 +119,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
129
119
  setCurTable(table);
130
120
  onSelect === null || onSelect === void 0 || onSelect(table, _value);
131
121
  };
132
- // const _condition = value?.condition || '';
133
122
  return _jsx("div", {
134
123
  className: cx("Sqb-SelectColumns--box ".concat(theme)),
135
124
  children: _jsx("div", {
@@ -224,16 +213,12 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
224
213
  realName = _v$realName === void 0 ? '' : _v$realName,
225
214
  fieldId = v.id;
226
215
  var groupe = SQL_GROUP_TYPE.STRING;
227
- // @ts-ignore
228
216
  if (~NUMBER_GROUP.indexOf(database_type)) {
229
217
  groupe = SQL_GROUP_TYPE.NUMBER;
230
218
  }
231
- // @ts-ignore
232
219
  if (~DATE_GROUP.indexOf(database_type)) {
233
220
  groupe = SQL_GROUP_TYPE.DATE;
234
221
  }
235
- // let showCondition =
236
- // curColumn === name && curTable === tableUuid && _condition;
237
222
  return _jsx("div", {
238
223
  className: cx("Sqb-List-section"),
239
224
  children: _jsx("div", {
@@ -247,20 +232,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
247
232
  fieldUuid: v.fieldUuid,
248
233
  quotes: v.fieldAlias || v.name
249
234
  });
250
- // setCurTable(tableUuid);
251
- // typeof onSelect === 'function' &&
252
- // onSelect({
253
- // ...v,
254
- // table,
255
- // tableId,
256
- // alias: tableAlias,
257
- // name,
258
- // database_type,
259
- // sql: v.sql || '',
260
- // datasourceId,
261
- // datasourceName,
262
- // realName,
263
- // });
264
235
  },
265
236
  children: _jsxs("div", {
266
237
  className: 'p-2 List-item',
@@ -1,8 +1,3 @@
1
- /**
2
- * 选择表弹框
3
- * 谁在用?
4
- * 1、选择权限表
5
- */
6
1
  import './index.less';
7
2
  import { MetaData_TableType } from '../../../store/types';
8
3
  interface PropsType {
@@ -1,10 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- /**
4
- * 选择表弹框
5
- * 谁在用?
6
- * 1、选择权限表
7
- */
8
3
  import './index.less';
9
4
  import { useState, useEffect } from 'react';
10
5
  import cx from 'classnames';
@@ -1,11 +1,11 @@
1
- /**
2
- * 关联模块 选择表字段
3
- */
4
1
  import './index.less';
5
2
  import { DataType, ColumnType } from '../select-join-column';
3
+ import { AtomsItem } from '../../../store/types';
6
4
  export type ValueType = Partial<ColumnType> & {
5
+ name_zh?: string;
7
6
  condition: string;
8
7
  quotes: string;
8
+ atoms?: AtomsItem[];
9
9
  };
10
10
  interface PropsType {
11
11
  data: DataType[];
@@ -1,20 +1,19 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- /**
5
- * 关联模块 选择表字段
6
- */
7
4
  import './index.less';
8
5
  import { useState } from 'react';
9
- import { Tooltip } from '@gingkoo/pandora';
6
+ import { Tooltip, Button } from '@gingkoo/pandora';
10
7
  import cx from 'classnames';
11
8
  import { ColumnsPopupThemeEnum } from '../../../store/enum';
12
9
  import { NUMBER_GROUP, DATE_GROUP } from '../const';
13
10
  import { __ } from '../../../locale';
14
11
  import { TableIcon, LeftArrowIcon } from '../../icons';
15
- import { SelectJoinColumn } from '../index';
12
+ import FormulaList from '../formula-list';
13
+ import { AtomsTypeEnum } from '../../../store/types';
14
+ import { uuidv4 } from '../../../utils/helper';
16
15
  var theme = ColumnsPopupThemeEnum.greenGrass;
17
- var FormulaList = [{
16
+ var metricOptions = [{
18
17
  name: '总行数',
19
18
  tip: '总的数据行数'
20
19
  }, {
@@ -83,20 +82,78 @@ var SelectSummarize = function SelectSummarize(_ref) {
83
82
  _useState2 = _slicedToArray(_useState, 2),
84
83
  condition = _useState2[0],
85
84
  setCondition = _useState2[1];
85
+ var _useState3 = useState(function () {
86
+ if (Array.isArray(value.atoms) && value.atoms.length) {
87
+ return value.atoms;
88
+ }
89
+ if (value.name) {
90
+ var fieldAtom = {
91
+ fieldName: value.name,
92
+ fieldNameZh: value.name_zh || '',
93
+ fieldAlias: '',
94
+ fieldUuid: uuidv4('field'),
95
+ fieldId: value.id || '',
96
+ tableName: value.table || '',
97
+ tableNameZh: '',
98
+ tableId: value.tableId || '',
99
+ tableAlias: value.alias || '',
100
+ tableUuid: value.tableUuid || '',
101
+ datasourceName: value.datasourceName || '',
102
+ datasourceId: value.datasourceId || '',
103
+ type: AtomsTypeEnum.FIELD
104
+ };
105
+ return [fieldAtom];
106
+ }
107
+ return [];
108
+ }),
109
+ _useState4 = _slicedToArray(_useState3, 2),
110
+ atoms = _useState4[0],
111
+ setAtoms = _useState4[1];
86
112
  function goPrevPage() {
87
113
  setCondition('');
88
114
  }
115
+ function getFormulaSummary() {
116
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
117
+ var itemToText = function itemToText(item) {
118
+ if (!item) return '';
119
+ if (item.quotes) return item.quotes;
120
+ if (item.fieldName) return item.fieldName;
121
+ if (item.type === AtomsTypeEnum.FORMULA) {
122
+ var argsText = (item.args || []).map(function (arg) {
123
+ return getFormulaSummary((arg === null || arg === void 0 ? void 0 : arg.list) || []);
124
+ }).filter(Boolean).join(', ');
125
+ return "".concat(item.name || '').concat(argsText ? "(".concat(argsText, ")") : '').trim();
126
+ }
127
+ if (item.type === AtomsTypeEnum.EXPRESSION) {
128
+ var lhs = getFormulaSummary(item.lhs || []);
129
+ var rhs = getFormulaSummary(item.rhs || []);
130
+ return [lhs, item.condition, rhs].filter(Boolean).join(' ').trim();
131
+ }
132
+ if (item.type === AtomsTypeEnum.AND_OR) {
133
+ return "".concat(item.operator || 'and', " ( ").concat(getFormulaSummary(item.list || []), " )").replace(/\s+/g, ' ').trim();
134
+ }
135
+ if (item.type === AtomsTypeEnum.CASE_WHEN) {
136
+ return item.quotes || 'case when';
137
+ }
138
+ if (Array.isArray(item.val)) return item.val.join(', ');
139
+ return item.val || '';
140
+ };
141
+ return list.map(function (item) {
142
+ return itemToText(item);
143
+ }).filter(Boolean).join(' ').replace(/\s+/g, ' ').trim();
144
+ }
89
145
  function handleSelect(condition, record) {
90
- var quotes = __(localeMap[QuotesMap.get(condition)]) + ' ' + ((record === null || record === void 0 ? void 0 : record.name) || '');
146
+ var quotesPrefix = __(localeMap[QuotesMap.get(condition)]);
147
+ var formulaSummary = getFormulaSummary(record.atoms || atoms);
148
+ var quotes = [quotesPrefix, formulaSummary].filter(Boolean).join(' ').trim();
91
149
  onChange(_objectSpread(_objectSpread({}, record), {}, {
92
150
  condition: condition,
93
151
  quotes: quotes
94
152
  }));
95
153
  }
96
- if (condition && !~Special.indexOf(condition)) {
154
+ function getAvailableData() {
97
155
  var availableData = data.slice();
98
156
  if (condition !== '不重复值的总数' && !ignoreGroupByType) {
99
- // 只能用数字类型做聚合
100
157
  availableData = data.map(function (v) {
101
158
  return _objectSpread(_objectSpread({}, v), {}, {
102
159
  columns: v.columns.filter(function (o) {
@@ -107,7 +164,11 @@ var SelectSummarize = function SelectSummarize(_ref) {
107
164
  return v.columns.length;
108
165
  });
109
166
  }
167
+ return availableData;
168
+ }
169
+ if (condition && !~Special.indexOf(condition)) {
110
170
  return _jsxs("div", {
171
+ className: 'Sqb-SelectSummarize-formula',
111
172
  children: [_jsx("div", {
112
173
  className: 'back-title',
113
174
  children: _jsxs("div", {
@@ -116,14 +177,37 @@ var SelectSummarize = function SelectSummarize(_ref) {
116
177
  children: [" ", __(localeMap[condition]), " "]
117
178
  })]
118
179
  })
119
- }), _jsx(SelectJoinColumn, {
120
- data: availableData,
121
- value: value,
122
- theme: ColumnsPopupThemeEnum.greenGrass,
123
- didUpdate: didUpdate,
124
- onSelect: function onSelect(record) {
125
- handleSelect(condition, record);
126
- }
180
+ }), _jsx("div", {
181
+ className: 'Sqb-SelectSummarize-formula-body',
182
+ children: _jsx("div", {
183
+ className: 'Sqb-item',
184
+ children: _jsx("div", {
185
+ className: 'Sqb-item--content',
186
+ children: _jsx(FormulaList, {
187
+ value: atoms,
188
+ data: getAvailableData(),
189
+ exitData: getAvailableData(),
190
+ enableCopy: false,
191
+ parentPopupChannel: 'secondary',
192
+ onChange: function onChange(nextValue) {
193
+ setAtoms(nextValue);
194
+ didUpdate === null || didUpdate === void 0 || didUpdate();
195
+ }
196
+ })
197
+ })
198
+ })
199
+ }), _jsx("div", {
200
+ className: 'Sqb-SelectSummarize-formula-footer',
201
+ children: _jsx(Button, {
202
+ primary: true,
203
+ disabled: !atoms.length,
204
+ onClick: function onClick() {
205
+ handleSelect(condition, {
206
+ atoms: atoms
207
+ });
208
+ },
209
+ children: "\u786E\u5B9A"
210
+ })
127
211
  })]
128
212
  });
129
213
  }
@@ -150,7 +234,7 @@ var SelectSummarize = function SelectSummarize(_ref) {
150
234
  })]
151
235
  })
152
236
  })
153
- }), FormulaList.map(function (v, i) {
237
+ }), metricOptions.map(function (v, i) {
154
238
  return _jsx("div", {
155
239
  className: cx("Sqb-List-section"),
156
240
  children: _jsx("div", {
@@ -161,6 +245,10 @@ var SelectSummarize = function SelectSummarize(_ref) {
161
245
  if (~Special.indexOf(v.name)) {
162
246
  handleSelect(v.name, {});
163
247
  } else {
248
+ var _value$atoms;
249
+ if (!((_value$atoms = value.atoms) !== null && _value$atoms !== void 0 && _value$atoms.length) && !atoms.length) {
250
+ setAtoms([]);
251
+ }
164
252
  setCondition(v.name);
165
253
  }
166
254
  },
@@ -151,3 +151,26 @@
151
151
  }
152
152
  }
153
153
  }
154
+
155
+ .Sqb-SelectSummarize-formula {
156
+ width: min(760px, calc(100vw - 64px));
157
+ max-width: 100%;
158
+ background: #fff;
159
+ }
160
+
161
+ .Sqb-SelectSummarize-formula-body {
162
+ max-height: 420px;
163
+ overflow: auto;
164
+ padding: 16px 16px 8px;
165
+
166
+ .Sqb-item,
167
+ .Sqb-item--content {
168
+ width: 100%;
169
+ }
170
+ }
171
+
172
+ .Sqb-SelectSummarize-formula-footer {
173
+ display: flex;
174
+ justify-content: flex-end;
175
+ padding: 0 16px 16px;
176
+ }
@@ -1,9 +1,3 @@
1
- /**
2
- * 选择表弹框
3
- * 谁在用?
4
- * 1、数据模块
5
- * 2、关联模块
6
- */
7
1
  import './index.less';
8
2
  import { MetaData_TableType } from '../../../store/types';
9
3
  import { DatasourceType } from '../../../types';