@gingkoo/pandora-metabase 1.0.24 → 1.0.26
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 +1 -0
- package/lib/cjs/components/dialog/expression/index.js +12 -11
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/cjs/components/dialog/formula-list/index.js +25 -19
- 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 +9 -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/join-data.js +76 -59
- 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 +29 -1
- package/lib/cjs/hooks/use-state.js +91 -62
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/locale/en.js +2 -1
- package/lib/cjs/locale/zh.js +2 -1
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +14 -1
- package/lib/es/common/SplitView/index.js +10 -10
- package/lib/es/components/dialog/custom-editor/index.js +1 -0
- package/lib/es/components/dialog/expression/index.js +10 -10
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/es/components/dialog/formula-list/index.js +25 -19
- 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 +9 -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/join-data.js +76 -59
- 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 +28 -0
- package/lib/es/hooks/use-state.js +92 -63
- package/lib/es/locale/en.js +2 -1
- package/lib/es/locale/zh.js +2 -1
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +11 -0
- package/package.json +2 -2
|
@@ -62,69 +62,69 @@ var useStore = function useStore() {
|
|
|
62
62
|
toolbar = _useState8[0],
|
|
63
63
|
setToolbar = _useState8[1]; //工具列表
|
|
64
64
|
var _useState9 = (0, _react.useState)('${name}'),
|
|
65
|
-
|
|
66
|
-
fieldNameTpl =
|
|
67
|
-
setFieldNameTpl =
|
|
68
|
-
var
|
|
69
|
-
_useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
|
|
70
|
-
tableNameTpl = _useState10[0],
|
|
71
|
-
setTableNameTpl = _useState10[1]; //显示字段
|
|
72
|
-
var _useState11 = (0, _react.useState)([]),
|
|
65
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
66
|
+
fieldNameTpl = _useState10[0],
|
|
67
|
+
setFieldNameTpl = _useState10[1]; //显示字段
|
|
68
|
+
var _useState11 = (0, _react.useState)('${name}'),
|
|
73
69
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
tableNameTpl = _useState12[0],
|
|
71
|
+
setTableNameTpl = _useState12[1]; //显示字段
|
|
76
72
|
var _useState13 = (0, _react.useState)([]),
|
|
77
73
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
sourceList = _useState14[0],
|
|
75
|
+
setSourceList = _useState14[1]; //数据源列表
|
|
80
76
|
var _useState15 = (0, _react.useState)([]),
|
|
81
77
|
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var _useState17 = (0, _react.useState)(
|
|
78
|
+
constantList = _useState16[0],
|
|
79
|
+
setConstantList = _useState16[1]; //常量列表
|
|
80
|
+
var _useState17 = (0, _react.useState)([]),
|
|
85
81
|
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
formulaTemplates = _useState18[0],
|
|
83
|
+
setFormulaTemplates = _useState18[1]; //公式配置数组
|
|
88
84
|
var _useState19 = (0, _react.useState)(false),
|
|
89
85
|
_useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var _useState21 = (0, _react.useState)(
|
|
86
|
+
ignoreGroupByType = _useState20[0],
|
|
87
|
+
setIgnoreGroupByType = _useState20[1]; // 忽略groupBy类型
|
|
88
|
+
var _useState21 = (0, _react.useState)(false),
|
|
93
89
|
_useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
filterCustomType = _useState22[0],
|
|
91
|
+
setfilterCustomType = _useState22[1]; // 过滤器自定义类型
|
|
96
92
|
var _useState23 = (0, _react.useState)({}),
|
|
97
93
|
_useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var _useState25 = (0, _react.useState)(
|
|
94
|
+
_cacheSource2TableMap = _useState24[0],
|
|
95
|
+
set_cacheSource2TableMap = _useState24[1]; //数据源id 对应数据集列表
|
|
96
|
+
var _useState25 = (0, _react.useState)({}),
|
|
101
97
|
_useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
var _useState27 = (0, _react.useState)(
|
|
98
|
+
_cacheColumnsMap = _useState26[0],
|
|
99
|
+
set_cacheColumnsMap = _useState26[1]; //数据源id 对应数据集列表
|
|
100
|
+
var _useState27 = (0, _react.useState)(defaultMeta),
|
|
101
|
+
_useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
|
|
102
|
+
metaList = _useState28[0],
|
|
103
|
+
_setMeta = _useState28[1]; //数据源id 对应数据集列表
|
|
104
|
+
var _useState29 = (0, _react.useState)({
|
|
105
105
|
visible: false,
|
|
106
106
|
node: null,
|
|
107
107
|
content: null
|
|
108
108
|
}),
|
|
109
|
-
|
|
110
|
-
popupData =
|
|
111
|
-
setPopup =
|
|
112
|
-
var
|
|
109
|
+
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
|
110
|
+
popupData = _useState30[0],
|
|
111
|
+
setPopup = _useState30[1]; //弹窗
|
|
112
|
+
var _useState31 = (0, _react.useState)({
|
|
113
113
|
visible: false,
|
|
114
114
|
node: null,
|
|
115
115
|
content: null
|
|
116
116
|
}),
|
|
117
|
-
_useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
|
|
118
|
-
popupData2 = _useState30[0],
|
|
119
|
-
setPopup2 = _useState30[1]; //弹窗
|
|
120
|
-
var _useState31 = (0, _react.useState)(true),
|
|
121
117
|
_useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
popupData2 = _useState32[0],
|
|
119
|
+
setPopup2 = _useState32[1]; //弹窗
|
|
124
120
|
var _useState33 = (0, _react.useState)(true),
|
|
125
121
|
_useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
popupClosable = _useState34[0],
|
|
123
|
+
setClosable = _useState34[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
124
|
+
var _useState35 = (0, _react.useState)(true),
|
|
125
|
+
_useState36 = (0, _slicedToArray2["default"])(_useState35, 2),
|
|
126
|
+
popupClosable2 = _useState36[0],
|
|
127
|
+
setClosable2 = _useState36[1]; //是否可关闭 如果弹框里面再弹框 则不可关闭
|
|
128
128
|
// 外层ref
|
|
129
129
|
var popupContainer = (0, _react.useRef)();
|
|
130
130
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -149,14 +149,21 @@ var useStore = function useStore() {
|
|
|
149
149
|
var summarizeItems = item.list.filter(function (v) {
|
|
150
150
|
return v.type === _enum.TypeEnum.summarize;
|
|
151
151
|
});
|
|
152
|
+
var index = (0, _utils.findIndex)(item.list, summarizeItems[summarizeItems.length - 1]);
|
|
152
153
|
// 如果没有汇总项,默认显示主列
|
|
153
154
|
if (summarizeItems.length === 0) {
|
|
154
|
-
return
|
|
155
|
+
return {
|
|
156
|
+
showColumn: true,
|
|
157
|
+
index: -1
|
|
158
|
+
};
|
|
155
159
|
}
|
|
156
160
|
// 如果只有一个汇总项,并且 group 和 by 都为空,则也显示主列
|
|
157
161
|
var onlyItem = summarizeItems[0];
|
|
158
162
|
var hasGroupOrBy = Array.isArray(onlyItem.group) && onlyItem.group.length > 0 || Array.isArray(onlyItem.by) && onlyItem.by.length > 0;
|
|
159
|
-
return
|
|
163
|
+
return {
|
|
164
|
+
showColumn: !hasGroupOrBy,
|
|
165
|
+
index: index
|
|
166
|
+
};
|
|
160
167
|
});
|
|
161
168
|
}, [metaList]);
|
|
162
169
|
// const showMainColumn = useMemo(() => {
|
|
@@ -177,23 +184,23 @@ var useStore = function useStore() {
|
|
|
177
184
|
var fetchDataset = /*#__PURE__*/function () {
|
|
178
185
|
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(datasourceId) {
|
|
179
186
|
var tables, _tables;
|
|
180
|
-
return _regenerator["default"].wrap(function (_context) {
|
|
187
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
181
188
|
while (1) switch (_context.prev = _context.next) {
|
|
182
189
|
case 0:
|
|
183
190
|
tables = getDataset(datasourceId);
|
|
184
191
|
if (!tables.length) {
|
|
185
|
-
_context.next =
|
|
192
|
+
_context.next = 3;
|
|
186
193
|
break;
|
|
187
194
|
}
|
|
188
195
|
return _context.abrupt("return", tables);
|
|
189
|
-
case
|
|
190
|
-
_context.next =
|
|
196
|
+
case 3:
|
|
197
|
+
_context.next = 5;
|
|
191
198
|
return fetchDatasetFn.current(datasourceId);
|
|
192
|
-
case
|
|
199
|
+
case 5:
|
|
193
200
|
_tables = _context.sent;
|
|
194
201
|
setDataset(datasourceId, _tables);
|
|
195
202
|
return _context.abrupt("return", _tables);
|
|
196
|
-
case
|
|
203
|
+
case 8:
|
|
197
204
|
case "end":
|
|
198
205
|
return _context.stop();
|
|
199
206
|
}
|
|
@@ -207,38 +214,60 @@ var useStore = function useStore() {
|
|
|
207
214
|
// fetchDataset():
|
|
208
215
|
// 查询表字段
|
|
209
216
|
var fetchColumns = /*#__PURE__*/function () {
|
|
210
|
-
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(table, datasourceId
|
|
217
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(table, datasourceId) {
|
|
211
218
|
var _columns2;
|
|
212
|
-
var
|
|
213
|
-
|
|
219
|
+
var oldColumns,
|
|
220
|
+
callback,
|
|
221
|
+
selectId,
|
|
222
|
+
_table$alias,
|
|
223
|
+
alias,
|
|
224
|
+
datasourceName,
|
|
225
|
+
did,
|
|
226
|
+
column,
|
|
227
|
+
extra,
|
|
228
|
+
tableName,
|
|
229
|
+
columns,
|
|
230
|
+
_columns,
|
|
231
|
+
_args2 = arguments;
|
|
232
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
214
233
|
while (1) switch (_context2.prev = _context2.next) {
|
|
215
234
|
case 0:
|
|
235
|
+
oldColumns = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : [];
|
|
236
|
+
callback = _args2.length > 3 ? _args2[3] : undefined;
|
|
237
|
+
// 获取之前选中的数据
|
|
238
|
+
selectId = oldColumns.filter(function (v) {
|
|
239
|
+
return v.select;
|
|
240
|
+
}).map(function (v) {
|
|
241
|
+
return v.id;
|
|
242
|
+
});
|
|
216
243
|
_table$alias = table.alias, alias = _table$alias === void 0 ? '' : _table$alias, datasourceName = table.datasourceName, did = table.datasourceId, column = table.column, extra = (0, _objectWithoutProperties2["default"])(table, _excluded);
|
|
217
244
|
tableName = table.name;
|
|
218
245
|
columns = getColumns(tableName);
|
|
219
246
|
if (columns.length) {
|
|
220
|
-
_context2.next =
|
|
247
|
+
_context2.next = 11;
|
|
221
248
|
break;
|
|
222
249
|
}
|
|
223
|
-
_context2.next =
|
|
250
|
+
_context2.next = 9;
|
|
224
251
|
return fetchColumnsFn.current(extra, datasourceId);
|
|
225
|
-
case
|
|
252
|
+
case 9:
|
|
226
253
|
columns = _context2.sent;
|
|
227
254
|
setColumns(tableName, columns);
|
|
228
|
-
case
|
|
255
|
+
case 11:
|
|
229
256
|
_columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
|
|
257
|
+
var select = selectId.includes(v.id);
|
|
230
258
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
|
|
231
|
-
|
|
259
|
+
select: select,
|
|
260
|
+
fieldUuid: v.fieldUuid || (0, _helper.uuidv4)('field')
|
|
232
261
|
});
|
|
233
262
|
});
|
|
234
263
|
typeof callback === 'function' && callback(_columns);
|
|
235
|
-
case
|
|
264
|
+
case 13:
|
|
236
265
|
case "end":
|
|
237
266
|
return _context2.stop();
|
|
238
267
|
}
|
|
239
268
|
}, _callee2);
|
|
240
269
|
}));
|
|
241
|
-
return function fetchColumns(_x2, _x3
|
|
270
|
+
return function fetchColumns(_x2, _x3) {
|
|
242
271
|
return _ref2.apply(this, arguments);
|
|
243
272
|
};
|
|
244
273
|
}();
|
|
@@ -294,8 +323,8 @@ var useStore = function useStore() {
|
|
|
294
323
|
// newMeta[i] = setFilterQuotes(newMeta[i]);
|
|
295
324
|
// }
|
|
296
325
|
// 设置右侧column
|
|
297
|
-
if ((_v$table = v.table2) !== null && _v$table !== void 0 && _v$table.datasourceId
|
|
298
|
-
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, function () {
|
|
326
|
+
if ((_v$table = v.table2) !== null && _v$table !== void 0 && _v$table.datasourceId) {
|
|
327
|
+
fetchColumns(newMeta[i].table2, newMeta[i].table2.datasourceId, v.columns, function () {
|
|
299
328
|
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
300
329
|
if (v.isSubquery) {
|
|
301
330
|
var newColumns = [];
|
|
@@ -312,8 +341,8 @@ var useStore = function useStore() {
|
|
|
312
341
|
return (0, _objectSpread2["default"])({}, v);
|
|
313
342
|
}
|
|
314
343
|
// 设置column
|
|
315
|
-
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId
|
|
316
|
-
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, function () {
|
|
344
|
+
if ((_v$table2 = v.table) !== null && _v$table2 !== void 0 && _v$table2.datasourceId) {
|
|
345
|
+
fetchColumns(newMeta[i].table, newMeta[i].table.datasourceId, v.columns, function () {
|
|
317
346
|
var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
318
347
|
if (v.isSubquery) {
|
|
319
348
|
var newColumns = [];
|
package/lib/cjs/index.js
CHANGED
|
@@ -17,7 +17,8 @@ var _locale = require("./locale");
|
|
|
17
17
|
var _Loading = _interopRequireDefault(require("./common/Loading"));
|
|
18
18
|
var _metabase = _interopRequireDefault(require("./components/metabase"));
|
|
19
19
|
var _utils = require("./utils");
|
|
20
|
-
function
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
21
22
|
// export { restoreStructure, handleSqlStruct, compressionStructure } from './store/helper';
|
|
22
23
|
|
|
23
24
|
/**
|
package/lib/cjs/locale/en.js
CHANGED
|
@@ -55,8 +55,9 @@ var _default = exports["default"] = (0, _index.register)('en', {
|
|
|
55
55
|
'SqlQueryBuilder.visualize': 'visualize',
|
|
56
56
|
'SqlQueryBuilder.selectColumnAll': 'select all',
|
|
57
57
|
'SqlQueryBuilder.alias': 'alias',
|
|
58
|
-
'SqlQueryBuilder.
|
|
58
|
+
'SqlQueryBuilder.aliasForRules': 'Please enter a combination of letters and underscores, with a length not exceeding 30',
|
|
59
59
|
'customColumn.operator': 'operator',
|
|
60
|
+
'customColumn.collection': 'collection',
|
|
60
61
|
'customColumn.field': 'field',
|
|
61
62
|
'customColumn.constant': 'constant',
|
|
62
63
|
'customColumn.str': 'string',
|
package/lib/cjs/locale/zh.js
CHANGED
|
@@ -51,8 +51,9 @@ var _default = exports["default"] = (0, _index.register)('zh', {
|
|
|
51
51
|
'SqlQueryBuilder.visualize': '可视化',
|
|
52
52
|
'SqlQueryBuilder.selectColumnAll': '全选',
|
|
53
53
|
'SqlQueryBuilder.alias': '别名',
|
|
54
|
-
'SqlQueryBuilder.
|
|
54
|
+
'SqlQueryBuilder.aliasForRules': '请输入字母加下划线,且长度不能超过30',
|
|
55
55
|
'customColumn.operator': '操作符',
|
|
56
|
+
'customColumn.collection': '自定义组合',
|
|
56
57
|
'customColumn.field': '字段',
|
|
57
58
|
'customColumn.constant': '常量',
|
|
58
59
|
'customColumn.str': '字符串',
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface HelperResultType {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const getHelper: (list: MetaListType[], item: MetaListType) => HelperResultType;
|
|
16
16
|
export declare const getSubColumns: (metaList: any) => DataType[];
|
|
17
|
+
export declare function isValidSQLAlias(str: string): boolean;
|
|
17
18
|
export declare const changeTableAlias: (list: MetaListType[] | [], curObj: Pick<MetaData_TableType, "tableUuid" | "alias">) => MetaListType[];
|
|
18
19
|
export declare const changeFieldAlias: (list: MetaListType[], curObj: Pick<MetaData_ColumnsType, "fieldUuid" | "fieldAlias">) => MetaListType[];
|
|
19
20
|
export declare function splitByUnion(data: any): any[];
|
package/lib/cjs/utils.js
CHANGED
|
@@ -4,7 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.getSubColumns = exports.getHelper = exports.findIndex = exports.changeTableAlias = exports.changeFieldAlias = exports.buildSqlQuery = void 0;
|
|
8
|
+
exports.isValidSQLAlias = isValidSQLAlias;
|
|
9
|
+
exports.patchData = void 0;
|
|
8
10
|
exports.reassembleByUnion = reassembleByUnion;
|
|
9
11
|
exports.splitByUnion = splitByUnion;
|
|
10
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
@@ -250,11 +252,22 @@ var _changeAlias = function changeAlias(items, val, type) {
|
|
|
250
252
|
});
|
|
251
253
|
}
|
|
252
254
|
return v;
|
|
255
|
+
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
256
|
+
v.args = _changeAlias(v.args, val, type);
|
|
257
|
+
return v;
|
|
258
|
+
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
259
|
+
v.list = _changeAlias(v.list, val, type);
|
|
260
|
+
return v;
|
|
253
261
|
} else {
|
|
254
262
|
return v;
|
|
255
263
|
}
|
|
256
264
|
});
|
|
257
265
|
};
|
|
266
|
+
function isValidSQLAlias(str) {
|
|
267
|
+
if (!str) return false;
|
|
268
|
+
var regex = /^[A-Za-z_]{0,30}$/;
|
|
269
|
+
return regex.test(str);
|
|
270
|
+
}
|
|
258
271
|
var changeTableAlias = exports.changeTableAlias = function changeTableAlias(list, curObj) {
|
|
259
272
|
var _cloneDeep = (0, _cloneDeep3["default"])(curObj),
|
|
260
273
|
tableUuid = _cloneDeep.tableUuid,
|
|
@@ -51,17 +51,17 @@ var SplitView = React.forwardRef(function (props, ref) {
|
|
|
51
51
|
hMaximum = _useState8[0],
|
|
52
52
|
setHMaximum = _useState8[1];
|
|
53
53
|
var _useState9 = useState(false),
|
|
54
|
-
|
|
55
|
-
vMinimum =
|
|
56
|
-
setVMinimum =
|
|
57
|
-
var
|
|
58
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
59
|
-
vMaximum = _useState10[0],
|
|
60
|
-
setVMaximum = _useState10[1];
|
|
61
|
-
var _useState11 = useState(0),
|
|
54
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
55
|
+
vMinimum = _useState10[0],
|
|
56
|
+
setVMinimum = _useState10[1];
|
|
57
|
+
var _useState11 = useState(false),
|
|
62
58
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
vMaximum = _useState12[0],
|
|
60
|
+
setVMaximum = _useState12[1];
|
|
61
|
+
var _useState13 = useState(0),
|
|
62
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
63
|
+
bottomHeight = _useState14[0],
|
|
64
|
+
setBottomHeight = _useState14[1];
|
|
65
65
|
React.useImperativeHandle(ref, function () {
|
|
66
66
|
return {
|
|
67
67
|
open: function open() {
|
|
@@ -79,18 +79,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
79
79
|
special_type = _useState8[0],
|
|
80
80
|
setSpecial_type = _useState8[1];
|
|
81
81
|
var _useState9 = useState(value.formula || {}),
|
|
82
|
-
|
|
83
|
-
formula =
|
|
84
|
-
setFormula =
|
|
82
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
83
|
+
formula = _useState10[0],
|
|
84
|
+
setFormula = _useState10[1];
|
|
85
85
|
var store = useStore();
|
|
86
|
-
var
|
|
87
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
88
|
-
popupVisible = _useState10[0],
|
|
89
|
-
setPopupVisible = _useState10[1];
|
|
90
|
-
var _useState11 = useState((value === null || value === void 0 || (_value$lhs = value.lhs) === null || _value$lhs === void 0 ? void 0 : _value$lhs.length) > 0 || false),
|
|
86
|
+
var _useState11 = useState(false),
|
|
91
87
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
popupVisible = _useState12[0],
|
|
89
|
+
setPopupVisible = _useState12[1];
|
|
90
|
+
var _useState13 = useState((value === null || value === void 0 || (_value$lhs = value.lhs) === null || _value$lhs === void 0 ? void 0 : _value$lhs.length) > 0 || false),
|
|
91
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
92
|
+
isNext = _useState14[0],
|
|
93
|
+
setIsNext = _useState14[1];
|
|
94
94
|
var table2Selected = Boolean(rhsVal && (rhsVal === null || rhsVal === void 0 ? void 0 : rhsVal.length) > 0);
|
|
95
95
|
var disabled = useMemo(function () {
|
|
96
96
|
if (!condition) return true;
|
|
@@ -6,8 +6,10 @@ interface PropsType {
|
|
|
6
6
|
value: AtomsItem[];
|
|
7
7
|
data: any;
|
|
8
8
|
exitData?: any;
|
|
9
|
-
onChange?: (atoms: AtomsItem[], quotes
|
|
9
|
+
onChange?: (atoms: AtomsItem[], quotes: string) => void;
|
|
10
10
|
check?: string;
|
|
11
|
+
isCustom?: boolean;
|
|
12
|
+
showPreview?: boolean;
|
|
11
13
|
}
|
|
12
14
|
declare const FormulaList: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<unknown>>;
|
|
13
15
|
export default FormulaList;
|
|
@@ -31,6 +31,10 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
31
31
|
_customTypes = _props$customTypes === void 0 ? customTypes : _props$customTypes,
|
|
32
32
|
_props$operatorList = props.operatorList,
|
|
33
33
|
_operatorList = _props$operatorList === void 0 ? operatorList : _props$operatorList,
|
|
34
|
+
_props$isCustom = props.isCustom,
|
|
35
|
+
isCustom = _props$isCustom === void 0 ? false : _props$isCustom,
|
|
36
|
+
_props$showPreview = props.showPreview,
|
|
37
|
+
showPreview = _props$showPreview === void 0 ? true : _props$showPreview,
|
|
34
38
|
check = props.check;
|
|
35
39
|
var caseList = value || [];
|
|
36
40
|
var setCaseList = function setCaseList(data) {
|
|
@@ -91,6 +95,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
91
95
|
node: e.currentTarget,
|
|
92
96
|
container: ref === null || ref === void 0 ? void 0 : ref.current,
|
|
93
97
|
content: _jsx(Expression, {
|
|
98
|
+
isCustom: isCustom,
|
|
94
99
|
filterCustomType: filterCustomType,
|
|
95
100
|
data: data,
|
|
96
101
|
container: ref === null || ref === void 0 ? void 0 : ref.current,
|
|
@@ -165,7 +170,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
165
170
|
type: caseList[i].type
|
|
166
171
|
};
|
|
167
172
|
caseList[i] = expression;
|
|
168
|
-
onChange === null || onChange === void 0 || onChange(caseList);
|
|
173
|
+
onChange === null || onChange === void 0 || onChange(caseList, '');
|
|
169
174
|
setCaseList(_toConsumableArray(caseList));
|
|
170
175
|
o.close();
|
|
171
176
|
} catch (e) {
|
|
@@ -428,8 +433,8 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
428
433
|
});
|
|
429
434
|
}
|
|
430
435
|
};
|
|
431
|
-
return
|
|
432
|
-
children:
|
|
436
|
+
return _jsx(_Fragment, {
|
|
437
|
+
children: _jsxs("div", {
|
|
433
438
|
className: "Sqb-NotebookCell",
|
|
434
439
|
children: [caseList === null || caseList === void 0 ? void 0 : caseList.map(function (v, i) {
|
|
435
440
|
return _jsxs("div", {
|
|
@@ -534,23 +539,24 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
534
539
|
children: option.label
|
|
535
540
|
}, index + '' + ind);
|
|
536
541
|
})
|
|
542
|
+
}), showPreview && _jsxs("p", {
|
|
543
|
+
className: "mb-2 font-bold uppercase tracking-wider",
|
|
544
|
+
style: {
|
|
545
|
+
fontSize: 12,
|
|
546
|
+
color: '#949aab',
|
|
547
|
+
width: '100%'
|
|
548
|
+
},
|
|
549
|
+
children: ["\u9884\u89C8\uFF1A", caseList.map(function (v, i) {
|
|
550
|
+
if (v !== null && v !== void 0 && v.quotes) {
|
|
551
|
+
return v === null || v === void 0 ? void 0 : v.quotes;
|
|
552
|
+
} else if (v !== null && v !== void 0 && v.fieldName) {
|
|
553
|
+
return v === null || v === void 0 ? void 0 : v.fieldName;
|
|
554
|
+
} else {
|
|
555
|
+
return v.val;
|
|
556
|
+
}
|
|
557
|
+
}).join(' ')]
|
|
537
558
|
})]
|
|
538
|
-
})
|
|
539
|
-
className: "mb-2 font-bold uppercase tracking-wider",
|
|
540
|
-
style: {
|
|
541
|
-
fontSize: 12,
|
|
542
|
-
color: '#949aab'
|
|
543
|
-
},
|
|
544
|
-
children: ["\u9884\u89C8\uFF1A", caseList.map(function (v, i) {
|
|
545
|
-
if (v !== null && v !== void 0 && v.quotes) {
|
|
546
|
-
return v === null || v === void 0 ? void 0 : v.quotes;
|
|
547
|
-
} else if (v !== null && v !== void 0 && v.fieldName) {
|
|
548
|
-
return v === null || v === void 0 ? void 0 : v.fieldName;
|
|
549
|
-
} else {
|
|
550
|
-
return v.val;
|
|
551
|
-
}
|
|
552
|
-
}).join(' ')]
|
|
553
|
-
})]
|
|
559
|
+
})
|
|
554
560
|
});
|
|
555
561
|
});
|
|
556
562
|
export default FormulaList;
|
|
@@ -8,3 +8,4 @@ export { default as SelectTable } from './select-table/index';
|
|
|
8
8
|
export { default as SelectPermissionTable } from './select-permission-table/index';
|
|
9
9
|
export { default as FormulaList } from './formula-list/index';
|
|
10
10
|
export { default as Expression } from './expression/index';
|
|
11
|
+
export { getTemplateItem } from './formula-list/utils';
|
|
@@ -7,4 +7,5 @@ export { default as SelectJoin } from './select-join/index';
|
|
|
7
7
|
export { default as SelectTable } from './select-table/index';
|
|
8
8
|
export { default as SelectPermissionTable } from './select-permission-table/index';
|
|
9
9
|
export { default as FormulaList } from './formula-list/index'; // 自定义公式列表
|
|
10
|
-
export { default as Expression } from './expression/index'; // 表达式编辑器
|
|
10
|
+
export { default as Expression } from './expression/index'; // 表达式编辑器
|
|
11
|
+
export { getTemplateItem } from './formula-list/utils'; // 表达式编辑器
|
|
@@ -18,7 +18,7 @@ import { __ } from '../../../locale';
|
|
|
18
18
|
import { NotSelectIcon, SelectIcon } from '../../icons';
|
|
19
19
|
import { useStore } from '../../../hooks/use-provider';
|
|
20
20
|
import { uuidv4 } from '../../../utils/helper';
|
|
21
|
-
import { changeFieldAlias } from '../../../utils';
|
|
21
|
+
import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
|
|
22
22
|
import { SearchIcon } from '../../icons';
|
|
23
23
|
// 选择表中参数
|
|
24
24
|
var SelectColumn = function SelectColumn(_ref) {
|
|
@@ -97,23 +97,16 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
97
97
|
onOk: function () {
|
|
98
98
|
var _onOk = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
99
99
|
var newColumns, newMetaList;
|
|
100
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
100
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
101
101
|
while (1) switch (_context.prev = _context.next) {
|
|
102
102
|
case 0:
|
|
103
|
-
if (fieldAlias) {
|
|
104
|
-
_context.next =
|
|
103
|
+
if (isValidSQLAlias(fieldAlias)) {
|
|
104
|
+
_context.next = 3;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
|
-
Toast.warning(__('SqlQueryBuilder.
|
|
107
|
+
Toast.warning(__('SqlQueryBuilder.aliasForRules'));
|
|
108
108
|
return _context.abrupt("return", false);
|
|
109
|
-
case
|
|
110
|
-
if (!(fieldAlias.length > 30)) {
|
|
111
|
-
_context.next = 2;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
Toast.warning('别名长度不能超过30');
|
|
115
|
-
return _context.abrupt("return", false);
|
|
116
|
-
case 2:
|
|
109
|
+
case 3:
|
|
117
110
|
newColumns = cloneDeep(columns);
|
|
118
111
|
newMetaList = store.metaList[groupIndex].list.slice();
|
|
119
112
|
newColumns[i].fieldAlias = fieldAlias;
|
|
@@ -124,7 +117,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
124
117
|
setTimeout(function () {
|
|
125
118
|
store.setClosable(true);
|
|
126
119
|
}, 0);
|
|
127
|
-
case
|
|
120
|
+
case 11:
|
|
128
121
|
case "end":
|
|
129
122
|
return _context.stop();
|
|
130
123
|
}
|
|
@@ -269,7 +269,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
269
269
|
if (isSummarize) {
|
|
270
270
|
// console.log(v, 'v');
|
|
271
271
|
}
|
|
272
|
-
console.log('🚀 ~ SelectJoinColumn ~ tableItem:', tableItem);
|
|
273
272
|
changeValue(tableUuid, {
|
|
274
273
|
tableName: tableItem.name,
|
|
275
274
|
tableId: tableItem.id,
|
|
@@ -43,9 +43,9 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
43
43
|
originList = _useState8[0],
|
|
44
44
|
setOriginList = _useState8[1];
|
|
45
45
|
var _useState9 = useState(value),
|
|
46
|
-
|
|
47
|
-
val =
|
|
48
|
-
setVal =
|
|
46
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
47
|
+
val = _useState10[0],
|
|
48
|
+
setVal = _useState10[1];
|
|
49
49
|
useEffect(function () {
|
|
50
50
|
if (value.datasourceId) {
|
|
51
51
|
getTables(value.datasourceId);
|
|
@@ -57,18 +57,18 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
57
57
|
function _getTables() {
|
|
58
58
|
_getTables = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(datasourceId) {
|
|
59
59
|
var tables;
|
|
60
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
60
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
61
61
|
while (1) switch (_context.prev = _context.next) {
|
|
62
62
|
case 0:
|
|
63
63
|
setLoading(true);
|
|
64
|
-
_context.next =
|
|
64
|
+
_context.next = 3;
|
|
65
65
|
return store.fetchDataset(datasourceId);
|
|
66
|
-
case
|
|
66
|
+
case 3:
|
|
67
67
|
tables = _context.sent;
|
|
68
68
|
setLoading(false);
|
|
69
69
|
setList(tables);
|
|
70
70
|
setOriginList(tables);
|
|
71
|
-
case
|
|
71
|
+
case 7:
|
|
72
72
|
case "end":
|
|
73
73
|
return _context.stop();
|
|
74
74
|
}
|