@gingkoo/pandora-metabase 1.0.129 → 1.0.130
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.
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
|
|
11
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
11
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
12
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -34,6 +35,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
34
35
|
_ref$tableFlat = _ref.tableFlat,
|
|
35
36
|
tableFlat = _ref$tableFlat === void 0 ? false : _ref$tableFlat;
|
|
36
37
|
var store = (0, _useProvider.useStore)();
|
|
38
|
+
var flatTableRef = (0, _react.useRef)(null);
|
|
37
39
|
var _useState = (0, _react.useState)(false),
|
|
38
40
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
39
41
|
loading = _useState2[0],
|
|
@@ -41,11 +43,15 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
41
43
|
var _useState3 = (0, _react.useState)(data.slice()),
|
|
42
44
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
43
45
|
datasource = _useState4[0];
|
|
44
|
-
var _useState5 = (0, _react.useState)(
|
|
46
|
+
var _useState5 = (0, _react.useState)(function () {
|
|
47
|
+
return sortSelectedDatasourceFirst(sourceTable.slice(), value.datasourceId);
|
|
48
|
+
}),
|
|
45
49
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
46
50
|
originDatasourceTable = _useState6[0],
|
|
47
51
|
setOriginDatasourceTable = _useState6[1];
|
|
48
|
-
var _useState7 = (0, _react.useState)(
|
|
52
|
+
var _useState7 = (0, _react.useState)(function () {
|
|
53
|
+
return sortSelectedDatasourceFirst(sourceTable.slice(), value.datasourceId);
|
|
54
|
+
}),
|
|
49
55
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
50
56
|
datasourceTable = _useState8[0],
|
|
51
57
|
setDatasourceTable = _useState8[1];
|
|
@@ -76,7 +82,11 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
76
82
|
if (!value.datasourceType && _datasourceType) {
|
|
77
83
|
emitDatasourceTypeChange(nextVal);
|
|
78
84
|
}
|
|
79
|
-
loadTables(value.datasourceId, _datasourceType)
|
|
85
|
+
loadTables(value.datasourceId, _datasourceType).then(function (tables) {
|
|
86
|
+
if (tableFlat) {
|
|
87
|
+
updateFlatDatasourceTables(value.datasourceId, _datasourceType, tables);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
80
90
|
}
|
|
81
91
|
}, []);
|
|
82
92
|
function getDefaultDatasourceType(datasource) {
|
|
@@ -88,6 +98,47 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
88
98
|
return v.datasourceId === datasourceId;
|
|
89
99
|
});
|
|
90
100
|
}
|
|
101
|
+
function getFlatDatasourceType(datasourceItem) {
|
|
102
|
+
if (val.datasourceId === datasourceItem.datasourceId && val.datasourceType) {
|
|
103
|
+
return val.datasourceType;
|
|
104
|
+
}
|
|
105
|
+
return datasourceItem.datasourceType || getDefaultDatasourceType(datasourceItem);
|
|
106
|
+
}
|
|
107
|
+
function sortSelectedDatasourceFirst(tables, datasourceId) {
|
|
108
|
+
var selectedDatasourceId = datasourceId || value.datasourceId;
|
|
109
|
+
if (!tableFlat || !selectedDatasourceId) return tables.slice();
|
|
110
|
+
var selectedIndex = tables.findIndex(function (item) {
|
|
111
|
+
return item.datasourceId === selectedDatasourceId;
|
|
112
|
+
});
|
|
113
|
+
if (selectedIndex <= 0) return tables.slice();
|
|
114
|
+
var nextTables = tables.slice();
|
|
115
|
+
var _nextTables$splice = nextTables.splice(selectedIndex, 1),
|
|
116
|
+
_nextTables$splice2 = (0, _slicedToArray2["default"])(_nextTables$splice, 1),
|
|
117
|
+
selectedTable = _nextTables$splice2[0];
|
|
118
|
+
return [selectedTable].concat((0, _toConsumableArray2["default"])(nextTables));
|
|
119
|
+
}
|
|
120
|
+
function updateFlatDatasourceTables(datasourceId, datasourceType, tables) {
|
|
121
|
+
var tablesData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : originDatasourceTable;
|
|
122
|
+
var scrollToTop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
123
|
+
var nextOriginDatasourceTable = sortSelectedDatasourceFirst(tablesData, datasourceId).map(function (v) {
|
|
124
|
+
if (v.datasourceId !== datasourceId) return v;
|
|
125
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
|
|
126
|
+
datasourceType: datasourceType,
|
|
127
|
+
children: tables
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
setOriginDatasourceTable(nextOriginDatasourceTable);
|
|
131
|
+
setDatasourceTable(filterDatasourceTables(nextOriginDatasourceTable, tableFilterValue));
|
|
132
|
+
if (scrollToTop) {
|
|
133
|
+
requestAnimationFrame(function () {
|
|
134
|
+
var _flatTableRef$current;
|
|
135
|
+
var scrollContainer = (_flatTableRef$current = flatTableRef.current) === null || _flatTableRef$current === void 0 ? void 0 : _flatTableRef$current.parentElement;
|
|
136
|
+
if (scrollContainer) {
|
|
137
|
+
scrollContainer.scrollTop = 0;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
91
142
|
function filterDatasourceTables(tables, keyword) {
|
|
92
143
|
var searchVal = keyword.toLocaleLowerCase();
|
|
93
144
|
if (!searchVal) return tables.slice();
|
|
@@ -157,7 +208,6 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
157
208
|
datasourceType: datasourceType
|
|
158
209
|
});
|
|
159
210
|
setVal(nextVal);
|
|
160
|
-
emitDatasourceTypeChange(nextVal);
|
|
161
211
|
loadTables(nextVal.datasourceId, datasourceType, true);
|
|
162
212
|
}
|
|
163
213
|
function handleFlatDatasourceTypeChange(_x2, _x3) {
|
|
@@ -165,7 +215,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
165
215
|
}
|
|
166
216
|
function _handleFlatDatasourceTypeChange() {
|
|
167
217
|
_handleFlatDatasourceTypeChange = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(datasourceItem, datasourceType) {
|
|
168
|
-
var nextVal, tables
|
|
218
|
+
var nextVal, tables;
|
|
169
219
|
return _regenerator["default"].wrap(function (_context2) {
|
|
170
220
|
while (1) switch (_context2.prev = _context2.next) {
|
|
171
221
|
case 0:
|
|
@@ -174,24 +224,12 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
174
224
|
datasourceType: datasourceType
|
|
175
225
|
});
|
|
176
226
|
setVal(nextVal);
|
|
177
|
-
emitDatasourceTypeChange(nextVal);
|
|
178
227
|
}
|
|
179
228
|
_context2.next = 1;
|
|
180
229
|
return loadTables(datasourceItem.datasourceId, datasourceType, true);
|
|
181
230
|
case 1:
|
|
182
231
|
tables = _context2.sent;
|
|
183
|
-
|
|
184
|
-
return tablesData.map(function (v) {
|
|
185
|
-
if (v.datasourceId !== datasourceItem.datasourceId) return v;
|
|
186
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
|
|
187
|
-
datasourceType: datasourceType,
|
|
188
|
-
children: tables
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
nextOriginDatasourceTable = updateDatasourceTable(originDatasourceTable);
|
|
193
|
-
setOriginDatasourceTable(nextOriginDatasourceTable);
|
|
194
|
-
setDatasourceTable(filterDatasourceTables(nextOriginDatasourceTable, tableFilterValue));
|
|
232
|
+
updateFlatDatasourceTables(datasourceItem.datasourceId, datasourceType, tables, undefined, true);
|
|
195
233
|
case 2:
|
|
196
234
|
case "end":
|
|
197
235
|
return _context2.stop();
|
|
@@ -232,8 +270,19 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
232
270
|
});
|
|
233
271
|
}
|
|
234
272
|
(0, _react.useEffect)(function () {
|
|
235
|
-
|
|
236
|
-
|
|
273
|
+
var nextSourceTable = sourceTable.slice();
|
|
274
|
+
if (tableFlat && val.datasourceId) {
|
|
275
|
+
var _store$getDataset;
|
|
276
|
+
var _datasourceType2 = val.datasourceType;
|
|
277
|
+
var cachedTables = _datasourceType2 ? (_store$getDataset = store.getDataset) === null || _store$getDataset === void 0 ? void 0 : _store$getDataset.call(store, val.datasourceId, _datasourceType2) : [];
|
|
278
|
+
if (_datasourceType2 && cachedTables !== null && cachedTables !== void 0 && cachedTables.length) {
|
|
279
|
+
updateFlatDatasourceTables(val.datasourceId, _datasourceType2, cachedTables, nextSourceTable);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var sortedSourceTable = sortSelectedDatasourceFirst(nextSourceTable, val.datasourceId);
|
|
284
|
+
setOriginDatasourceTable(sortedSourceTable);
|
|
285
|
+
setDatasourceTable(filterDatasourceTables(sortedSourceTable, tableFilterValue));
|
|
237
286
|
}, [sourceTable]);
|
|
238
287
|
(0, _react.useEffect)(function () {
|
|
239
288
|
didUpdate === null || didUpdate === void 0 || didUpdate();
|
|
@@ -265,6 +314,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
265
314
|
if (tableFlat) {
|
|
266
315
|
return (0, _jsxRuntime.jsx)("div", {
|
|
267
316
|
className: (0, _classnames["default"])("Sqb-SelectTable--box pb-2"),
|
|
317
|
+
ref: flatTableRef,
|
|
268
318
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
269
319
|
style: {
|
|
270
320
|
minWidth: 300
|
|
@@ -290,7 +340,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
290
340
|
})
|
|
291
341
|
}), datasourceTable.map(function (table) {
|
|
292
342
|
var _table$children;
|
|
293
|
-
var datasourceType =
|
|
343
|
+
var datasourceType = getFlatDatasourceType(table);
|
|
294
344
|
return (0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
|
|
295
345
|
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
296
346
|
className: (0, _classnames["default"])("Sqb-List-title mx-4 pb-2 pt-2"),
|
|
@@ -314,7 +364,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
314
364
|
className: (0, _classnames["default"])("Sqb-List-section"),
|
|
315
365
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
316
366
|
className: (0, _classnames["default"])("Sqb-List-item mx-2", {
|
|
317
|
-
active: val.datasourceId === table.datasourceId && val.
|
|
367
|
+
active: val.datasourceId === table.datasourceId && val.id === v.id && (val.datasourceType || datasourceType) === datasourceType
|
|
318
368
|
}),
|
|
319
369
|
onClick: function onClick() {
|
|
320
370
|
onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _val), v), {}, {
|
|
@@ -433,7 +483,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
433
483
|
className: (0, _classnames["default"])("Sqb-List-section"),
|
|
434
484
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
435
485
|
className: (0, _classnames["default"])("Sqb-List-item mx-2", {
|
|
436
|
-
active: val.datasourceId === value.datasourceId && val.
|
|
486
|
+
active: val.datasourceId === value.datasourceId && val.id === v.id && (val.datasourceType || datasourceType) === datasourceType
|
|
437
487
|
}),
|
|
438
488
|
onClick: function onClick() {
|
|
439
489
|
onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, val), v), {}, {
|
|
@@ -93,11 +93,11 @@ var JoinData = function JoinData(props) {
|
|
|
93
93
|
var tableIsDel = function () {
|
|
94
94
|
var _ref = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
|
|
95
95
|
var _meta$table, _meta$table2;
|
|
96
|
-
var
|
|
96
|
+
var tableId, tables, ids;
|
|
97
97
|
return _regenerator["default"].wrap(function (_context) {
|
|
98
98
|
while (1) switch (_context.prev = _context.next) {
|
|
99
99
|
case 0:
|
|
100
|
-
|
|
100
|
+
tableId = (_meta$table = meta.table2) === null || _meta$table === void 0 ? void 0 : _meta$table.id;
|
|
101
101
|
if ((_meta$table2 = meta.table2) !== null && _meta$table2 !== void 0 && _meta$table2.datasourceId) {
|
|
102
102
|
_context.next = 1;
|
|
103
103
|
break;
|
|
@@ -109,10 +109,10 @@ var JoinData = function JoinData(props) {
|
|
|
109
109
|
return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table2.datasourceId, meta.table2.datasourceType);
|
|
110
110
|
case 2:
|
|
111
111
|
tables = _context.sent;
|
|
112
|
-
|
|
113
|
-
return v.
|
|
112
|
+
ids = (tables === null || tables === void 0 ? void 0 : tables.map(function (v) {
|
|
113
|
+
return v.id;
|
|
114
114
|
})) || [];
|
|
115
|
-
if (!
|
|
115
|
+
if (!ids.includes(tableId)) {
|
|
116
116
|
setIsDel(true);
|
|
117
117
|
} else {
|
|
118
118
|
setIsDel(false);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
7
|
import './index.less';
|
|
7
|
-
import React, { useState, useEffect } from 'react';
|
|
8
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
8
9
|
import cloneDeep from 'lodash/cloneDeep';
|
|
9
10
|
import cx from 'classnames';
|
|
10
11
|
import { uuidv4 } from '../../../utils/helper';
|
|
@@ -26,6 +27,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
26
27
|
_ref$tableFlat = _ref.tableFlat,
|
|
27
28
|
tableFlat = _ref$tableFlat === void 0 ? false : _ref$tableFlat;
|
|
28
29
|
var store = useStore();
|
|
30
|
+
var flatTableRef = useRef(null);
|
|
29
31
|
var _useState = useState(false),
|
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
31
33
|
loading = _useState2[0],
|
|
@@ -33,11 +35,15 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
33
35
|
var _useState3 = useState(data.slice()),
|
|
34
36
|
_useState4 = _slicedToArray(_useState3, 1),
|
|
35
37
|
datasource = _useState4[0];
|
|
36
|
-
var _useState5 = useState(
|
|
38
|
+
var _useState5 = useState(function () {
|
|
39
|
+
return sortSelectedDatasourceFirst(sourceTable.slice(), value.datasourceId);
|
|
40
|
+
}),
|
|
37
41
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
38
42
|
originDatasourceTable = _useState6[0],
|
|
39
43
|
setOriginDatasourceTable = _useState6[1];
|
|
40
|
-
var _useState7 = useState(
|
|
44
|
+
var _useState7 = useState(function () {
|
|
45
|
+
return sortSelectedDatasourceFirst(sourceTable.slice(), value.datasourceId);
|
|
46
|
+
}),
|
|
41
47
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
42
48
|
datasourceTable = _useState8[0],
|
|
43
49
|
setDatasourceTable = _useState8[1];
|
|
@@ -68,7 +74,11 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
68
74
|
if (!value.datasourceType && _datasourceType) {
|
|
69
75
|
emitDatasourceTypeChange(nextVal);
|
|
70
76
|
}
|
|
71
|
-
loadTables(value.datasourceId, _datasourceType)
|
|
77
|
+
loadTables(value.datasourceId, _datasourceType).then(function (tables) {
|
|
78
|
+
if (tableFlat) {
|
|
79
|
+
updateFlatDatasourceTables(value.datasourceId, _datasourceType, tables);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
72
82
|
}
|
|
73
83
|
}, []);
|
|
74
84
|
function getDefaultDatasourceType(datasource) {
|
|
@@ -80,6 +90,47 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
80
90
|
return v.datasourceId === datasourceId;
|
|
81
91
|
});
|
|
82
92
|
}
|
|
93
|
+
function getFlatDatasourceType(datasourceItem) {
|
|
94
|
+
if (val.datasourceId === datasourceItem.datasourceId && val.datasourceType) {
|
|
95
|
+
return val.datasourceType;
|
|
96
|
+
}
|
|
97
|
+
return datasourceItem.datasourceType || getDefaultDatasourceType(datasourceItem);
|
|
98
|
+
}
|
|
99
|
+
function sortSelectedDatasourceFirst(tables, datasourceId) {
|
|
100
|
+
var selectedDatasourceId = datasourceId || value.datasourceId;
|
|
101
|
+
if (!tableFlat || !selectedDatasourceId) return tables.slice();
|
|
102
|
+
var selectedIndex = tables.findIndex(function (item) {
|
|
103
|
+
return item.datasourceId === selectedDatasourceId;
|
|
104
|
+
});
|
|
105
|
+
if (selectedIndex <= 0) return tables.slice();
|
|
106
|
+
var nextTables = tables.slice();
|
|
107
|
+
var _nextTables$splice = nextTables.splice(selectedIndex, 1),
|
|
108
|
+
_nextTables$splice2 = _slicedToArray(_nextTables$splice, 1),
|
|
109
|
+
selectedTable = _nextTables$splice2[0];
|
|
110
|
+
return [selectedTable].concat(_toConsumableArray(nextTables));
|
|
111
|
+
}
|
|
112
|
+
function updateFlatDatasourceTables(datasourceId, datasourceType, tables) {
|
|
113
|
+
var tablesData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : originDatasourceTable;
|
|
114
|
+
var scrollToTop = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
115
|
+
var nextOriginDatasourceTable = sortSelectedDatasourceFirst(tablesData, datasourceId).map(function (v) {
|
|
116
|
+
if (v.datasourceId !== datasourceId) return v;
|
|
117
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
118
|
+
datasourceType: datasourceType,
|
|
119
|
+
children: tables
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
setOriginDatasourceTable(nextOriginDatasourceTable);
|
|
123
|
+
setDatasourceTable(filterDatasourceTables(nextOriginDatasourceTable, tableFilterValue));
|
|
124
|
+
if (scrollToTop) {
|
|
125
|
+
requestAnimationFrame(function () {
|
|
126
|
+
var _flatTableRef$current;
|
|
127
|
+
var scrollContainer = (_flatTableRef$current = flatTableRef.current) === null || _flatTableRef$current === void 0 ? void 0 : _flatTableRef$current.parentElement;
|
|
128
|
+
if (scrollContainer) {
|
|
129
|
+
scrollContainer.scrollTop = 0;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
83
134
|
function filterDatasourceTables(tables, keyword) {
|
|
84
135
|
var searchVal = keyword.toLocaleLowerCase();
|
|
85
136
|
if (!searchVal) return tables.slice();
|
|
@@ -149,7 +200,6 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
149
200
|
datasourceType: datasourceType
|
|
150
201
|
});
|
|
151
202
|
setVal(nextVal);
|
|
152
|
-
emitDatasourceTypeChange(nextVal);
|
|
153
203
|
loadTables(nextVal.datasourceId, datasourceType, true);
|
|
154
204
|
}
|
|
155
205
|
function handleFlatDatasourceTypeChange(_x2, _x3) {
|
|
@@ -157,7 +207,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
157
207
|
}
|
|
158
208
|
function _handleFlatDatasourceTypeChange() {
|
|
159
209
|
_handleFlatDatasourceTypeChange = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(datasourceItem, datasourceType) {
|
|
160
|
-
var nextVal, tables
|
|
210
|
+
var nextVal, tables;
|
|
161
211
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
162
212
|
while (1) switch (_context2.prev = _context2.next) {
|
|
163
213
|
case 0:
|
|
@@ -166,24 +216,12 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
166
216
|
datasourceType: datasourceType
|
|
167
217
|
});
|
|
168
218
|
setVal(nextVal);
|
|
169
|
-
emitDatasourceTypeChange(nextVal);
|
|
170
219
|
}
|
|
171
220
|
_context2.next = 1;
|
|
172
221
|
return loadTables(datasourceItem.datasourceId, datasourceType, true);
|
|
173
222
|
case 1:
|
|
174
223
|
tables = _context2.sent;
|
|
175
|
-
|
|
176
|
-
return tablesData.map(function (v) {
|
|
177
|
-
if (v.datasourceId !== datasourceItem.datasourceId) return v;
|
|
178
|
-
return _objectSpread(_objectSpread({}, v), {}, {
|
|
179
|
-
datasourceType: datasourceType,
|
|
180
|
-
children: tables
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
nextOriginDatasourceTable = updateDatasourceTable(originDatasourceTable);
|
|
185
|
-
setOriginDatasourceTable(nextOriginDatasourceTable);
|
|
186
|
-
setDatasourceTable(filterDatasourceTables(nextOriginDatasourceTable, tableFilterValue));
|
|
224
|
+
updateFlatDatasourceTables(datasourceItem.datasourceId, datasourceType, tables, undefined, true);
|
|
187
225
|
case 2:
|
|
188
226
|
case "end":
|
|
189
227
|
return _context2.stop();
|
|
@@ -224,8 +262,19 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
224
262
|
});
|
|
225
263
|
}
|
|
226
264
|
useEffect(function () {
|
|
227
|
-
|
|
228
|
-
|
|
265
|
+
var nextSourceTable = sourceTable.slice();
|
|
266
|
+
if (tableFlat && val.datasourceId) {
|
|
267
|
+
var _store$getDataset;
|
|
268
|
+
var _datasourceType2 = val.datasourceType;
|
|
269
|
+
var cachedTables = _datasourceType2 ? (_store$getDataset = store.getDataset) === null || _store$getDataset === void 0 ? void 0 : _store$getDataset.call(store, val.datasourceId, _datasourceType2) : [];
|
|
270
|
+
if (_datasourceType2 && cachedTables !== null && cachedTables !== void 0 && cachedTables.length) {
|
|
271
|
+
updateFlatDatasourceTables(val.datasourceId, _datasourceType2, cachedTables, nextSourceTable);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
var sortedSourceTable = sortSelectedDatasourceFirst(nextSourceTable, val.datasourceId);
|
|
276
|
+
setOriginDatasourceTable(sortedSourceTable);
|
|
277
|
+
setDatasourceTable(filterDatasourceTables(sortedSourceTable, tableFilterValue));
|
|
229
278
|
}, [sourceTable]);
|
|
230
279
|
useEffect(function () {
|
|
231
280
|
didUpdate === null || didUpdate === void 0 || didUpdate();
|
|
@@ -257,6 +306,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
257
306
|
if (tableFlat) {
|
|
258
307
|
return _jsx("div", {
|
|
259
308
|
className: cx("Sqb-SelectTable--box pb-2"),
|
|
309
|
+
ref: flatTableRef,
|
|
260
310
|
children: _jsx("div", {
|
|
261
311
|
style: {
|
|
262
312
|
minWidth: 300
|
|
@@ -282,7 +332,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
282
332
|
})
|
|
283
333
|
}), datasourceTable.map(function (table) {
|
|
284
334
|
var _table$children;
|
|
285
|
-
var datasourceType =
|
|
335
|
+
var datasourceType = getFlatDatasourceType(table);
|
|
286
336
|
return _jsxs(React.Fragment, {
|
|
287
337
|
children: [_jsxs("div", {
|
|
288
338
|
className: cx("Sqb-List-title mx-4 pb-2 pt-2"),
|
|
@@ -306,7 +356,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
306
356
|
className: cx("Sqb-List-section"),
|
|
307
357
|
children: _jsx("div", {
|
|
308
358
|
className: cx("Sqb-List-item mx-2", {
|
|
309
|
-
active: val.datasourceId === table.datasourceId && val.
|
|
359
|
+
active: val.datasourceId === table.datasourceId && val.id === v.id && (val.datasourceType || datasourceType) === datasourceType
|
|
310
360
|
}),
|
|
311
361
|
onClick: function onClick() {
|
|
312
362
|
onChange(_objectSpread(_objectSpread(_objectSpread({}, _val), v), {}, {
|
|
@@ -425,7 +475,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
425
475
|
className: cx("Sqb-List-section"),
|
|
426
476
|
children: _jsx("div", {
|
|
427
477
|
className: cx("Sqb-List-item mx-2", {
|
|
428
|
-
active: val.datasourceId === value.datasourceId && val.
|
|
478
|
+
active: val.datasourceId === value.datasourceId && val.id === v.id && (val.datasourceType || datasourceType) === datasourceType
|
|
429
479
|
}),
|
|
430
480
|
onClick: function onClick() {
|
|
431
481
|
onChange(_objectSpread(_objectSpread(_objectSpread({}, val), v), {}, {
|
|
@@ -88,11 +88,11 @@ var JoinData = function JoinData(props) {
|
|
|
88
88
|
var tableIsDel = function () {
|
|
89
89
|
var _ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
|
|
90
90
|
var _meta$table, _meta$table2;
|
|
91
|
-
var
|
|
91
|
+
var tableId, tables, ids;
|
|
92
92
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
93
93
|
while (1) switch (_context.prev = _context.next) {
|
|
94
94
|
case 0:
|
|
95
|
-
|
|
95
|
+
tableId = (_meta$table = meta.table2) === null || _meta$table === void 0 ? void 0 : _meta$table.id;
|
|
96
96
|
if ((_meta$table2 = meta.table2) !== null && _meta$table2 !== void 0 && _meta$table2.datasourceId) {
|
|
97
97
|
_context.next = 1;
|
|
98
98
|
break;
|
|
@@ -104,10 +104,10 @@ var JoinData = function JoinData(props) {
|
|
|
104
104
|
return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table2.datasourceId, meta.table2.datasourceType);
|
|
105
105
|
case 2:
|
|
106
106
|
tables = _context.sent;
|
|
107
|
-
|
|
108
|
-
return v.
|
|
107
|
+
ids = (tables === null || tables === void 0 ? void 0 : tables.map(function (v) {
|
|
108
|
+
return v.id;
|
|
109
109
|
})) || [];
|
|
110
|
-
if (!
|
|
110
|
+
if (!ids.includes(tableId)) {
|
|
111
111
|
setIsDel(true);
|
|
112
112
|
} else {
|
|
113
113
|
setIsDel(false);
|