@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.
- package/lib/cjs/common/SplitView/index.js +12 -11
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +2 -1
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +2 -1
- package/lib/cjs/components/dialog/custom-editor/index.js +2 -1
- package/lib/cjs/components/dialog/expression/index.js +13 -12
- package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
- package/lib/cjs/components/dialog/formula/index.js +242 -0
- package/lib/cjs/components/dialog/formula/index.less +81 -0
- package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +45 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/cjs/components/dialog/formula-list/index.js +107 -43
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
- package/lib/cjs/components/dialog/index.d.ts +1 -0
- package/lib/cjs/components/dialog/index.js +9 -2
- package/lib/cjs/components/dialog/select-column/index.js +6 -13
- package/lib/cjs/components/dialog/select-column-multiple/index.js +0 -1
- package/lib/cjs/components/dialog/select-table/index.js +7 -7
- package/lib/cjs/components/icons.js +36 -36
- package/lib/cjs/components/metabase/index.js +6 -6
- package/lib/cjs/components/metabase/index.less +10 -0
- package/lib/cjs/components/modules/components/Wrapper.js +6 -6
- package/lib/cjs/components/modules/custom-column.js +4 -4
- package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
- package/lib/cjs/components/modules/join-data.js +78 -36
- package/lib/cjs/components/modules/summarize/group-by.js +6 -13
- package/lib/cjs/components/modules/summarize/select-index.js +6 -13
- package/lib/cjs/components/modules/table-data.js +9 -16
- package/lib/cjs/components/popup.js +2 -1
- package/lib/cjs/hooks/patch.js +106 -76
- package/lib/cjs/hooks/use-state.js +100 -65
- package/lib/cjs/index.js +5 -2
- package/lib/cjs/locale/en.js +6 -3
- package/lib/cjs/locale/zh.js +6 -3
- package/lib/cjs/store/helper.d.ts +1 -2
- package/lib/cjs/store/helper.js +1 -76
- package/lib/cjs/store/types.d.ts +36 -2
- package/lib/cjs/store/types.js +3 -0
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +16 -2
- package/lib/es/common/SplitView/index.js +10 -10
- package/lib/es/components/dialog/custom-editor/index.js +2 -1
- package/lib/es/components/dialog/expression/index.js +11 -11
- package/lib/es/components/dialog/formula/index.d.ts +10 -0
- package/lib/es/components/dialog/formula/index.js +236 -0
- package/lib/es/components/dialog/formula/index.less +81 -0
- package/lib/es/components/dialog/formula/utils.d.ts +7 -0
- package/lib/es/components/dialog/formula/utils.js +37 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/es/components/dialog/formula-list/index.js +104 -40
- package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/es/components/dialog/formula-list/utils.js +160 -2
- package/lib/es/components/dialog/index.d.ts +1 -0
- package/lib/es/components/dialog/index.js +2 -1
- package/lib/es/components/dialog/select-column/index.js +7 -14
- package/lib/es/components/dialog/select-column-multiple/index.js +0 -1
- package/lib/es/components/dialog/select-table/index.js +7 -7
- package/lib/es/components/icons.js +36 -36
- package/lib/es/components/metabase/index.js +6 -6
- package/lib/es/components/metabase/index.less +10 -0
- package/lib/es/components/modules/components/Wrapper.js +6 -6
- package/lib/es/components/modules/custom-column.js +4 -4
- package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/es/components/modules/enum/filter-enum.js +8 -2
- package/lib/es/components/modules/join-data.js +78 -36
- package/lib/es/components/modules/summarize/group-by.js +7 -14
- package/lib/es/components/modules/summarize/select-index.js +7 -14
- package/lib/es/components/modules/table-data.js +10 -17
- package/lib/es/hooks/patch.js +105 -75
- package/lib/es/hooks/use-state.js +101 -66
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +6 -3
- package/lib/es/locale/zh.js +6 -3
- package/lib/es/store/helper.d.ts +1 -2
- package/lib/es/store/helper.js +0 -75
- package/lib/es/store/types.d.ts +36 -2
- package/lib/es/store/types.js +3 -0
- package/lib/es/types.d.ts +2 -1
- package/lib/es/types.js +18 -1
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +13 -1
- package/package.json +2 -2
- package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
- package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/es/components/dialog/formula-list/enum.js +0 -117
package/lib/es/hooks/patch.js
CHANGED
|
@@ -4,33 +4,35 @@ import { buildSqlQuery } from '../utils';
|
|
|
4
4
|
import { AtomsTypeEnum } from '../store/types';
|
|
5
5
|
import { TypeEnum } from '../store/enum';
|
|
6
6
|
export var dataPatch = function dataPatch(newMeta) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (item
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
8
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
9
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
10
|
+
// return newMeta;
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
14
13
|
newMeta.subquery = _patchMetas(newMeta.subquery);
|
|
15
14
|
return newMeta;
|
|
16
15
|
};
|
|
17
16
|
export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
if (item
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
var _fields, _fields2, _fields3, _fields4, _newMeta$expressions;
|
|
18
|
+
// let item = newMeta.expressions?.[0] || {};
|
|
19
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
20
|
+
// if (
|
|
21
|
+
// (item.type === AtomsTypeEnum.EXPRESSION || item.type === AtomsTypeEnum.JOIN_DEFAULT) &&
|
|
22
|
+
// item.lhs
|
|
23
|
+
// ) {
|
|
24
|
+
// return newMeta;
|
|
25
|
+
// }
|
|
26
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
27
|
+
// return newMeta;
|
|
28
|
+
// }
|
|
29
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
30
|
+
// return newMeta;
|
|
31
|
+
// }
|
|
32
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
33
|
+
// return newMeta;
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
34
36
|
// if (
|
|
35
37
|
// newMeta.expressions?.[0]?.type &&
|
|
36
38
|
// Object.values(AtomsTypeEnum).includes(newMeta.expressions[0].type)
|
|
@@ -120,7 +122,7 @@ export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
120
122
|
type: 'default' // 默认是字段模式
|
|
121
123
|
}];
|
|
122
124
|
}
|
|
123
|
-
var expressions = ((_newMeta$
|
|
125
|
+
var expressions = ((_newMeta$expressions = newMeta.expressions) === null || _newMeta$expressions === void 0 ? void 0 : _newMeta$expressions.map(function (v) {
|
|
124
126
|
var _left_fields, _right_fields;
|
|
125
127
|
var left_fields = v.left_fields || [];
|
|
126
128
|
var right_fields = v.right_fields || [];
|
|
@@ -261,23 +263,23 @@ export var joinDataPatch = function joinDataPatch(newMeta) {
|
|
|
261
263
|
return newMeta;
|
|
262
264
|
};
|
|
263
265
|
export var filterPatch = function filterPatch(newMeta) {
|
|
264
|
-
var _newMeta$filter
|
|
265
|
-
|
|
266
|
-
if (item
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
var _filter = (_newMeta$
|
|
266
|
+
var _newMeta$filter;
|
|
267
|
+
// let item = newMeta.filter?.[0] || {};
|
|
268
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
269
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
270
|
+
// return newMeta;
|
|
271
|
+
// }
|
|
272
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
273
|
+
// return newMeta;
|
|
274
|
+
// }
|
|
275
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
276
|
+
// return newMeta;
|
|
277
|
+
// }
|
|
278
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
279
|
+
// return newMeta;
|
|
280
|
+
// }
|
|
281
|
+
// }
|
|
282
|
+
var _filter = (_newMeta$filter = newMeta.filter) === null || _newMeta$filter === void 0 ? void 0 : _newMeta$filter.map(function (v) {
|
|
281
283
|
// 表达式
|
|
282
284
|
var tem;
|
|
283
285
|
if (typeof v === 'string') {
|
|
@@ -369,23 +371,23 @@ export var filterPatch = function filterPatch(newMeta) {
|
|
|
369
371
|
return newMeta;
|
|
370
372
|
};
|
|
371
373
|
export var customColumnPatch = function customColumnPatch(newMeta) {
|
|
372
|
-
var _newMeta$customColumn
|
|
373
|
-
|
|
374
|
-
if (item
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$
|
|
374
|
+
var _newMeta$customColumn;
|
|
375
|
+
// let item = newMeta.customColumn?.[0]?.formulaList?.[0] || {};
|
|
376
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
377
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
378
|
+
// return newMeta;
|
|
379
|
+
// }
|
|
380
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
381
|
+
// return newMeta;
|
|
382
|
+
// }
|
|
383
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
384
|
+
// return newMeta;
|
|
385
|
+
// }
|
|
386
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
387
|
+
// return newMeta;
|
|
388
|
+
// }
|
|
389
|
+
// }
|
|
390
|
+
newMeta.customColumn = (newMeta === null || newMeta === void 0 || (_newMeta$customColumn = newMeta.customColumn) === null || _newMeta$customColumn === void 0 ? void 0 : _newMeta$customColumn.map(function (v) {
|
|
389
391
|
var _formulaList = v.formulaList.map(function (formula) {
|
|
390
392
|
var tem = formula;
|
|
391
393
|
if (formula.type === 'expression') {
|
|
@@ -502,23 +504,23 @@ export var customColumnPatch = function customColumnPatch(newMeta) {
|
|
|
502
504
|
return newMeta;
|
|
503
505
|
};
|
|
504
506
|
export var sortPatch = function sortPatch(newMeta) {
|
|
505
|
-
var _newMeta$sort
|
|
506
|
-
|
|
507
|
-
if (item
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
var _sort = (_newMeta$
|
|
507
|
+
var _newMeta$sort;
|
|
508
|
+
// let item = newMeta.sort?.[0].expression?.[0] || {};
|
|
509
|
+
// if (item?.type && Object.values(AtomsTypeEnum).includes(item.type)) {
|
|
510
|
+
// if (item.type === AtomsTypeEnum.EXPRESSION && item.lhs) {
|
|
511
|
+
// return newMeta;
|
|
512
|
+
// }
|
|
513
|
+
// if (item.type === AtomsTypeEnum.EXISTS && !item.tableUuid) {
|
|
514
|
+
// return newMeta;
|
|
515
|
+
// }
|
|
516
|
+
// if (item.type === AtomsTypeEnum.NOT_EXISTS && !item.tableUuid) {
|
|
517
|
+
// return newMeta;
|
|
518
|
+
// }
|
|
519
|
+
// if (item.type === AtomsTypeEnum.FIELD && item.fieldName) {
|
|
520
|
+
// return newMeta;
|
|
521
|
+
// }
|
|
522
|
+
// }
|
|
523
|
+
var _sort = (_newMeta$sort = newMeta.sort) === null || _newMeta$sort === void 0 ? void 0 : _newMeta$sort.map(function (v) {
|
|
522
524
|
return {
|
|
523
525
|
expression: [{
|
|
524
526
|
fieldName: v.name,
|
|
@@ -543,6 +545,9 @@ export var sortPatch = function sortPatch(newMeta) {
|
|
|
543
545
|
};
|
|
544
546
|
var _patchMetas = function patchMetas(items) {
|
|
545
547
|
return (items === null || items === void 0 ? void 0 : items.map(function (v) {
|
|
548
|
+
if (v.type === TypeEnum.data) {
|
|
549
|
+
v = dataPatch(v);
|
|
550
|
+
}
|
|
546
551
|
if (v.type === TypeEnum.joinData) {
|
|
547
552
|
v = joinDataPatch(v);
|
|
548
553
|
}
|
|
@@ -561,4 +566,29 @@ var _patchMetas = function patchMetas(items) {
|
|
|
561
566
|
return v;
|
|
562
567
|
})) || [];
|
|
563
568
|
};
|
|
569
|
+
// export const patchMetas1 = (items: MetaListType[]) => {
|
|
570
|
+
// return (
|
|
571
|
+
// items?.map((v: MetaListType): MetaListType => {
|
|
572
|
+
// // if (v.type === TypeEnum.data) {
|
|
573
|
+
// // v = dataPatch(v);
|
|
574
|
+
// // }
|
|
575
|
+
// // if (v.type === TypeEnum.joinData) {
|
|
576
|
+
// // v = joinDataPatch(v);
|
|
577
|
+
// // }
|
|
578
|
+
// // if (v.type === TypeEnum.filter) {
|
|
579
|
+
// // v = filterPatch(v);
|
|
580
|
+
// // }
|
|
581
|
+
// // if (v.type === TypeEnum.sort) {
|
|
582
|
+
// // v = sortPatch(v);
|
|
583
|
+
// // }
|
|
584
|
+
// // if (v.type === TypeEnum.customColumn) {
|
|
585
|
+
// // v = customColumnPatch(v);
|
|
586
|
+
// // }
|
|
587
|
+
// if (v.type === TypeEnum.union) {
|
|
588
|
+
// v.subquery = patchMetas(v.subquery || []);
|
|
589
|
+
// }
|
|
590
|
+
// return v;
|
|
591
|
+
// }) || []
|
|
592
|
+
// );
|
|
593
|
+
// };
|
|
564
594
|
export { _patchMetas as patchMetas };
|
|
@@ -8,7 +8,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
8
8
|
import { useState, useRef, useMemo } from 'react';
|
|
9
9
|
import { uuidv4 } from '../utils/helper';
|
|
10
10
|
import { TypeEnum, JoinEnum, UnionEnum } from '../store/enum';
|
|
11
|
-
import { getSubColumns } from '../utils';
|
|
11
|
+
import { getSubColumns, findIndex } from '../utils';
|
|
12
12
|
var metaKey = 1;
|
|
13
13
|
export var SummarizeAlias = 'source';
|
|
14
14
|
var useStore = function useStore() {
|
|
@@ -55,65 +55,69 @@ var useStore = function useStore() {
|
|
|
55
55
|
toolbar = _useState8[0],
|
|
56
56
|
setToolbar = _useState8[1]; //工具列表
|
|
57
57
|
var _useState9 = useState('${name}'),
|
|
58
|
-
|
|
59
|
-
fieldNameTpl =
|
|
60
|
-
setFieldNameTpl =
|
|
61
|
-
var
|
|
62
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
63
|
-
tableNameTpl = _useState10[0],
|
|
64
|
-
setTableNameTpl = _useState10[1]; //显示字段
|
|
65
|
-
var _useState11 = useState([]),
|
|
58
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
59
|
+
fieldNameTpl = _useState10[0],
|
|
60
|
+
setFieldNameTpl = _useState10[1]; //显示字段
|
|
61
|
+
var _useState11 = useState('${name}'),
|
|
66
62
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
tableNameTpl = _useState12[0],
|
|
64
|
+
setTableNameTpl = _useState12[1]; //显示字段
|
|
69
65
|
var _useState13 = useState([]),
|
|
70
66
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var _useState15 = useState(
|
|
67
|
+
sourceList = _useState14[0],
|
|
68
|
+
setSourceList = _useState14[1]; //数据源列表
|
|
69
|
+
var _useState15 = useState([]),
|
|
74
70
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var _useState17 = useState(
|
|
71
|
+
constantList = _useState16[0],
|
|
72
|
+
setConstantList = _useState16[1]; //常量列表
|
|
73
|
+
var _useState17 = useState([]),
|
|
78
74
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var _useState19 = useState(
|
|
75
|
+
formulaTemplates = _useState18[0],
|
|
76
|
+
setFormulaTemplates = _useState18[1]; //公式配置数组
|
|
77
|
+
var _useState19 = useState(false),
|
|
82
78
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var _useState21 = useState(
|
|
79
|
+
ignoreGroupByType = _useState20[0],
|
|
80
|
+
setIgnoreGroupByType = _useState20[1]; // 忽略groupBy类型
|
|
81
|
+
var _useState21 = useState(false),
|
|
86
82
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _useState23 = useState(
|
|
83
|
+
filterCustomType = _useState22[0],
|
|
84
|
+
setfilterCustomType = _useState22[1]; // 过滤器自定义类型
|
|
85
|
+
var _useState23 = useState({}),
|
|
90
86
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var _useState25 = useState({
|
|
87
|
+
_cacheSource2TableMap = _useState24[0],
|
|
88
|
+
set_cacheSource2TableMap = _useState24[1]; //数据源id 对应数据集列表
|
|
89
|
+
var _useState25 = useState({}),
|
|
90
|
+
_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({
|
|
94
98
|
visible: false,
|
|
95
99
|
node: null,
|
|
96
100
|
content: null
|
|
97
101
|
}),
|
|
98
|
-
|
|
99
|
-
popupData =
|
|
100
|
-
setPopup =
|
|
101
|
-
var
|
|
102
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
103
|
+
popupData = _useState30[0],
|
|
104
|
+
setPopup = _useState30[1]; //弹窗
|
|
105
|
+
var _useState31 = useState({
|
|
102
106
|
visible: false,
|
|
103
107
|
node: null,
|
|
104
108
|
content: null
|
|
105
109
|
}),
|
|
106
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
-
popupData2 = _useState28[0],
|
|
108
|
-
setPopup2 = _useState28[1]; //弹窗
|
|
109
|
-
var _useState29 = useState(true),
|
|
110
|
-
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
-
popupClosable = _useState30[0],
|
|
112
|
-
setClosable = _useState30[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
113
|
-
var _useState31 = useState(true),
|
|
114
110
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
popupData2 = _useState32[0],
|
|
112
|
+
setPopup2 = _useState32[1]; //弹窗
|
|
113
|
+
var _useState33 = useState(true),
|
|
114
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
115
|
+
popupClosable = _useState34[0],
|
|
116
|
+
setClosable = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
117
|
+
var _useState35 = useState(true),
|
|
118
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
|
119
|
+
popupClosable2 = _useState36[0],
|
|
120
|
+
setClosable2 = _useState36[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
117
121
|
// 外层ref
|
|
118
122
|
var popupContainer = useRef();
|
|
119
123
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -138,14 +142,21 @@ var useStore = function useStore() {
|
|
|
138
142
|
var summarizeItems = item.list.filter(function (v) {
|
|
139
143
|
return v.type === TypeEnum.summarize;
|
|
140
144
|
});
|
|
145
|
+
var index = findIndex(item.list, summarizeItems[summarizeItems.length - 1]);
|
|
141
146
|
// 如果没有汇总项,默认显示主列
|
|
142
147
|
if (summarizeItems.length === 0) {
|
|
143
|
-
return
|
|
148
|
+
return {
|
|
149
|
+
showColumn: true,
|
|
150
|
+
index: -1
|
|
151
|
+
};
|
|
144
152
|
}
|
|
145
153
|
// 如果只有一个汇总项,并且 group 和 by 都为空,则也显示主列
|
|
146
154
|
var onlyItem = summarizeItems[0];
|
|
147
155
|
var hasGroupOrBy = Array.isArray(onlyItem.group) && onlyItem.group.length > 0 || Array.isArray(onlyItem.by) && onlyItem.by.length > 0;
|
|
148
|
-
return
|
|
156
|
+
return {
|
|
157
|
+
showColumn: !hasGroupOrBy,
|
|
158
|
+
index: index
|
|
159
|
+
};
|
|
149
160
|
});
|
|
150
161
|
}, [metaList]);
|
|
151
162
|
// const showMainColumn = useMemo(() => {
|
|
@@ -166,23 +177,23 @@ var useStore = function useStore() {
|
|
|
166
177
|
var fetchDataset = /*#__PURE__*/function () {
|
|
167
178
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(datasourceId) {
|
|
168
179
|
var tables, _tables;
|
|
169
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
180
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
170
181
|
while (1) switch (_context.prev = _context.next) {
|
|
171
182
|
case 0:
|
|
172
183
|
tables = getDataset(datasourceId);
|
|
173
184
|
if (!tables.length) {
|
|
174
|
-
_context.next =
|
|
185
|
+
_context.next = 3;
|
|
175
186
|
break;
|
|
176
187
|
}
|
|
177
188
|
return _context.abrupt("return", tables);
|
|
178
|
-
case
|
|
179
|
-
_context.next =
|
|
189
|
+
case 3:
|
|
190
|
+
_context.next = 5;
|
|
180
191
|
return fetchDatasetFn.current(datasourceId);
|
|
181
|
-
case
|
|
192
|
+
case 5:
|
|
182
193
|
_tables = _context.sent;
|
|
183
194
|
setDataset(datasourceId, _tables);
|
|
184
195
|
return _context.abrupt("return", _tables);
|
|
185
|
-
case
|
|
196
|
+
case 8:
|
|
186
197
|
case "end":
|
|
187
198
|
return _context.stop();
|
|
188
199
|
}
|
|
@@ -196,38 +207,60 @@ var useStore = function useStore() {
|
|
|
196
207
|
// fetchDataset():
|
|
197
208
|
// 查询表字段
|
|
198
209
|
var fetchColumns = /*#__PURE__*/function () {
|
|
199
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(table, datasourceId
|
|
210
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(table, datasourceId) {
|
|
200
211
|
var _columns2;
|
|
201
|
-
var
|
|
202
|
-
|
|
212
|
+
var oldColumns,
|
|
213
|
+
callback,
|
|
214
|
+
selectId,
|
|
215
|
+
_table$alias,
|
|
216
|
+
alias,
|
|
217
|
+
datasourceName,
|
|
218
|
+
did,
|
|
219
|
+
column,
|
|
220
|
+
extra,
|
|
221
|
+
tableName,
|
|
222
|
+
columns,
|
|
223
|
+
_columns,
|
|
224
|
+
_args2 = arguments;
|
|
225
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
203
226
|
while (1) switch (_context2.prev = _context2.next) {
|
|
204
227
|
case 0:
|
|
228
|
+
oldColumns = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
|
|
229
|
+
callback = _args2.length > 3 ? _args2[3] : undefined;
|
|
230
|
+
// 获取之前选中的数据
|
|
231
|
+
selectId = oldColumns.filter(function (v) {
|
|
232
|
+
return v.select;
|
|
233
|
+
}).map(function (v) {
|
|
234
|
+
return v.id;
|
|
235
|
+
});
|
|
205
236
|
_table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = _objectWithoutProperties(table, _excluded);
|
|
206
237
|
tableName = table.name;
|
|
207
238
|
columns = getColumns(tableName);
|
|
208
239
|
if (columns.length) {
|
|
209
|
-
_context2.next =
|
|
240
|
+
_context2.next = 11;
|
|
210
241
|
break;
|
|
211
242
|
}
|
|
212
|
-
_context2.next =
|
|
243
|
+
_context2.next = 9;
|
|
213
244
|
return fetchColumnsFn.current(extra, datasourceId);
|
|
214
|
-
case
|
|
245
|
+
case 9:
|
|
215
246
|
columns = _context2.sent;
|
|
216
247
|
setColumns(tableName, columns);
|
|
217
|
-
case
|
|
248
|
+
case 11:
|
|
218
249
|
_columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
|
|
250
|
+
var select = selectId.includes(v.id);
|
|
219
251
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
220
|
-
|
|
252
|
+
select: select,
|
|
253
|
+
fieldUuid: v.fieldUuid || uuidv4('field')
|
|
221
254
|
});
|
|
222
255
|
});
|
|
223
256
|
typeof callback === 'function' && callback(_columns);
|
|
224
|
-
case
|
|
257
|
+
case 13:
|
|
225
258
|
case "end":
|
|
226
259
|
return _context2.stop();
|
|
227
260
|
}
|
|
228
261
|
}, _callee2);
|
|
229
262
|
}));
|
|
230
|
-
return function fetchColumns(_x2, _x3
|
|
263
|
+
return function fetchColumns(_x2, _x3) {
|
|
231
264
|
return _ref2.apply(this, arguments);
|
|
232
265
|
};
|
|
233
266
|
}();
|
|
@@ -283,8 +316,8 @@ var useStore = function useStore() {
|
|
|
283
316
|
// newMeta[i] = setFilterQuotes(newMeta[i]);
|
|
284
317
|
// }
|
|
285
318
|
// 设置右侧column
|
|
286
|
-
if ((_v$table = v.table2) !== null && _v$table !== void 0 && _v$table.datasourceId
|
|
287
|
-
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, function () {
|
|
319
|
+
if ((_v$table = v.table2) !== null && _v$table !== void 0 && _v$table.datasourceId) {
|
|
320
|
+
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, v.columns, function () {
|
|
288
321
|
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
289
322
|
if (v.isSubquery) {
|
|
290
323
|
var newColumns = [];
|
|
@@ -301,8 +334,8 @@ var useStore = function useStore() {
|
|
|
301
334
|
return _objectSpread({}, v);
|
|
302
335
|
}
|
|
303
336
|
// 设置column
|
|
304
|
-
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId
|
|
305
|
-
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, function () {
|
|
337
|
+
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId) {
|
|
338
|
+
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, v.columns, function () {
|
|
306
339
|
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
307
340
|
if (v.isSubquery) {
|
|
308
341
|
var newColumns = [];
|
|
@@ -585,7 +618,9 @@ var useStore = function useStore() {
|
|
|
585
618
|
ignoreGroupByType: ignoreGroupByType,
|
|
586
619
|
setIgnoreGroupByType: setIgnoreGroupByType,
|
|
587
620
|
filterCustomType: filterCustomType,
|
|
588
|
-
setfilterCustomType: setfilterCustomType
|
|
621
|
+
setfilterCustomType: setfilterCustomType,
|
|
622
|
+
formulaTemplates: formulaTemplates,
|
|
623
|
+
setFormulaTemplates: setFormulaTemplates
|
|
589
624
|
};
|
|
590
625
|
};
|
|
591
626
|
export default useStore;
|
package/lib/es/index.js
CHANGED
|
@@ -38,6 +38,7 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
38
38
|
_props$subShowSubquer = props.subShowSubquery,
|
|
39
39
|
subShowSubquery = _props$subShowSubquer === void 0 ? false : _props$subShowSubquer,
|
|
40
40
|
constantList = props.constantList,
|
|
41
|
+
formulaTemplates = props.formulaTemplates,
|
|
41
42
|
_props$ignoreGroupByT = props.ignoreGroupByType,
|
|
42
43
|
ignoreGroupByType = _props$ignoreGroupByT === void 0 ? false : _props$ignoreGroupByT,
|
|
43
44
|
_props$filterCustomTy = props.filterCustomType,
|
|
@@ -65,9 +66,10 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
65
66
|
store.setShowSubquery(showSubquery);
|
|
66
67
|
store._setShowSubquery(subShowSubquery);
|
|
67
68
|
store.setConstantList(constantList || []);
|
|
69
|
+
store.setFormulaTemplates(formulaTemplates || []);
|
|
68
70
|
store.setIgnoreGroupByType(ignoreGroupByType);
|
|
69
71
|
store.setfilterCustomType(filterCustomType);
|
|
70
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, ignoreGroupByType, filterCustomType]);
|
|
72
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType]);
|
|
71
73
|
React.useImperativeHandle(ref, function () {
|
|
72
74
|
return {
|
|
73
75
|
// setDatasource: (list) => {
|
package/lib/es/locale/en.js
CHANGED
|
@@ -33,8 +33,10 @@ export default register('en', {
|
|
|
33
33
|
'SqlQueryBuilder.customExpression': 'customExpression',
|
|
34
34
|
'SqlQueryBuilder.pickTable': 'Select data table...',
|
|
35
35
|
'SqlQueryBuilder.pickConstant': 'Select constant...',
|
|
36
|
-
'
|
|
37
|
-
'
|
|
36
|
+
'customColumn.input': 'Input',
|
|
37
|
+
'customColumn.numberInput': 'Number input',
|
|
38
|
+
'customColumn.formula': 'Formula',
|
|
39
|
+
'customColumn.selectFormula': 'Select formula...',
|
|
38
40
|
'SqlQueryBuilder.switchSubQuery': 'Open subquery',
|
|
39
41
|
'SqlQueryBuilder.setSubQuery': 'Set Subquery...',
|
|
40
42
|
'SqlQueryBuilder.subquery': 'Subquery',
|
|
@@ -47,8 +49,9 @@ export default register('en', {
|
|
|
47
49
|
'SqlQueryBuilder.visualize': 'visualize',
|
|
48
50
|
'SqlQueryBuilder.selectColumnAll': 'select all',
|
|
49
51
|
'SqlQueryBuilder.alias': 'alias',
|
|
50
|
-
'SqlQueryBuilder.
|
|
52
|
+
'SqlQueryBuilder.aliasForRules': 'Please modify the alias according to the rules, and ensure its length does not exceed 30 characters',
|
|
51
53
|
'customColumn.operator': 'operator',
|
|
54
|
+
'customColumn.collection': 'collection',
|
|
52
55
|
'customColumn.field': 'field',
|
|
53
56
|
'customColumn.constant': 'constant',
|
|
54
57
|
'customColumn.str': 'string',
|
package/lib/es/locale/zh.js
CHANGED
|
@@ -33,8 +33,6 @@ export default register('zh', {
|
|
|
33
33
|
'SqlQueryBuilder.customExpression': '自定义表达方式',
|
|
34
34
|
'SqlQueryBuilder.pickTable': '选择数据表...',
|
|
35
35
|
'SqlQueryBuilder.pickConstant': '选择常量...',
|
|
36
|
-
'SqlQueryBuilder.input': '输入框',
|
|
37
|
-
'SqlQueryBuilder.numberInput': '数字输入框',
|
|
38
36
|
'SqlQueryBuilder.switchSubQuery': '切换子查询',
|
|
39
37
|
'SqlQueryBuilder.setSubQuery': '设置子查询...',
|
|
40
38
|
'SqlQueryBuilder.subquery': '子查询',
|
|
@@ -47,8 +45,9 @@ export default register('zh', {
|
|
|
47
45
|
'SqlQueryBuilder.visualize': '可视化',
|
|
48
46
|
'SqlQueryBuilder.selectColumnAll': '全选',
|
|
49
47
|
'SqlQueryBuilder.alias': '别名',
|
|
50
|
-
'SqlQueryBuilder.
|
|
48
|
+
'SqlQueryBuilder.aliasForRules': '请按规则修改别名,且长度不能超过30',
|
|
51
49
|
'customColumn.operator': '操作符',
|
|
50
|
+
'customColumn.collection': '自定义组合',
|
|
52
51
|
'customColumn.field': '字段',
|
|
53
52
|
'customColumn.constant': '常量',
|
|
54
53
|
'customColumn.str': '字符串',
|
|
@@ -65,6 +64,10 @@ export default register('zh', {
|
|
|
65
64
|
'customColumn.selectExpression': '选择表达式',
|
|
66
65
|
'customColumn.selectOtherSyntax': '选择其他语法',
|
|
67
66
|
'customColumn.selectCustomInput': '选择自定义输入框',
|
|
67
|
+
'customColumn.formula': '公式',
|
|
68
|
+
'customColumn.selectFormula': '选择公式...',
|
|
69
|
+
'customColumn.input': '输入框',
|
|
70
|
+
'customColumn.numberInput': '数字输入框',
|
|
68
71
|
'filter.addFilter': '添加过滤器',
|
|
69
72
|
'filter.confirm': '确认',
|
|
70
73
|
'filter.pleaseEnter': '请输入',
|
package/lib/es/store/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaListType, MetaSummarize_Group
|
|
1
|
+
import { MetaListType, MetaSummarize_Group } from './types';
|
|
2
2
|
export declare const SummarizeAlias = "source";
|
|
3
3
|
export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSummarize_Group) => {
|
|
4
4
|
sql: string;
|
|
@@ -6,4 +6,3 @@ export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSu
|
|
|
6
6
|
};
|
|
7
7
|
export declare const compressionStructure: (data: MetaListType[]) => string;
|
|
8
8
|
export declare const restoreStructure: (data: string) => MetaListType[];
|
|
9
|
-
export declare const getTemItem: (type: AtomsTypeEnum) => AtomsItem;
|