@gingkoo/pandora-metabase 1.0.42 → 1.0.44
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/components/dialog/select-column-multiple/index.js +12 -0
- package/lib/cjs/components/dialog/select-permission-table/index.js +30 -5
- package/lib/cjs/components/dialog/select-table/index.js +1 -0
- package/lib/cjs/components/modules/join-data.js +0 -1
- package/lib/cjs/hooks/use-state.js +1 -3
- package/lib/cjs/utils.js +4 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +12 -0
- package/lib/es/components/dialog/select-permission-table/index.js +31 -6
- package/lib/es/components/dialog/select-table/index.js +1 -0
- package/lib/es/components/modules/join-data.js +0 -1
- package/lib/es/hooks/use-state.js +1 -3
- package/lib/es/utils.js +4 -1
- package/package.json +1 -1
|
@@ -158,6 +158,18 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
158
158
|
return v.fieldId != (val === null || val === void 0 ? void 0 : val.fieldId);
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
+
// 当前选中的表字段
|
|
162
|
+
var curTableColumn = data.filter(function (v) {
|
|
163
|
+
return v.tableUuid === curTable;
|
|
164
|
+
}).flatMap(function (v) {
|
|
165
|
+
return v.columns;
|
|
166
|
+
});
|
|
167
|
+
// 过滤选中字段不在当前选中的表字段中,
|
|
168
|
+
_value = _value.filter(function (item2) {
|
|
169
|
+
return curTableColumn.some(function (item1) {
|
|
170
|
+
return item1.name === item2.fieldName;
|
|
171
|
+
});
|
|
172
|
+
});
|
|
161
173
|
setValue(_value);
|
|
162
174
|
setCurTable(tableUuid);
|
|
163
175
|
onSelect === null || onSelect === void 0 || onSelect(_value, getQuotes(_value));
|
|
@@ -10,6 +10,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
10
10
|
require("./index.less");
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
14
|
+
var _locale = require("../../../locale");
|
|
13
15
|
var _icons = require("../../icons");
|
|
14
16
|
/**
|
|
15
17
|
* 选择表弹框
|
|
@@ -26,22 +28,45 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
26
28
|
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
27
29
|
didUpdate = _ref.didUpdate;
|
|
28
30
|
var _useState = (0, _react.useState)(data.slice()),
|
|
29
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState,
|
|
30
|
-
datasource = _useState2[0]
|
|
31
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
32
|
+
datasource = _useState2[0],
|
|
33
|
+
setDatasource = _useState2[1];
|
|
31
34
|
(0, _react.useEffect)(function () {
|
|
32
35
|
didUpdate === null || didUpdate === void 0 || didUpdate();
|
|
33
36
|
}, [datasource]);
|
|
37
|
+
function onInput(e) {
|
|
38
|
+
var val = e.target.value;
|
|
39
|
+
var newList = (0, _cloneDeep["default"])(data.slice());
|
|
40
|
+
setDatasource(newList.filter(function (v) {
|
|
41
|
+
return ~(v.datasourceName + '.' + (v.alias || v.name)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
34
44
|
return (0, _jsxRuntime.jsx)("div", {
|
|
35
45
|
className: (0, _classnames["default"])("Sqb-SelectTable--box pb-2 pt-2"),
|
|
36
46
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
37
47
|
style: {
|
|
38
48
|
width: 300
|
|
39
49
|
},
|
|
40
|
-
children: (0, _jsxRuntime.
|
|
50
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
41
51
|
style: {
|
|
42
52
|
width: '100%'
|
|
43
53
|
},
|
|
44
|
-
children:
|
|
54
|
+
children: [(0, _jsxRuntime.jsx)("div", {
|
|
55
|
+
className: (0, _classnames["default"])("Sqb-List-section"),
|
|
56
|
+
children: (0, _jsxRuntime.jsxs)("div", {
|
|
57
|
+
className: (0, _classnames["default"])("Sqb-List-search m-2 rounded-lg"),
|
|
58
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
59
|
+
className: 'px-2',
|
|
60
|
+
children: (0, _jsxRuntime.jsx)(_icons.SearchIcon, {})
|
|
61
|
+
}), (0, _jsxRuntime.jsx)("input", {
|
|
62
|
+
autoFocus: true,
|
|
63
|
+
type: 'text',
|
|
64
|
+
className: 'p-2',
|
|
65
|
+
placeholder: (0, _locale.__)('data.search'),
|
|
66
|
+
onInput: onInput
|
|
67
|
+
})]
|
|
68
|
+
})
|
|
69
|
+
}), Array.isArray(datasource) && datasource.map(function (v) {
|
|
45
70
|
return (0, _jsxRuntime.jsx)("div", {
|
|
46
71
|
className: (0, _classnames["default"])("Sqb-List-section"),
|
|
47
72
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
@@ -65,7 +90,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
65
90
|
})
|
|
66
91
|
})
|
|
67
92
|
}, v.alias || v.name);
|
|
68
|
-
})
|
|
93
|
+
})]
|
|
69
94
|
})
|
|
70
95
|
})
|
|
71
96
|
});
|
|
@@ -189,6 +189,7 @@ var SelectTable = function SelectTable(_ref) {
|
|
|
189
189
|
className: 'px-2',
|
|
190
190
|
children: (0, _jsxRuntime.jsx)(_icons.SearchIcon, {})
|
|
191
191
|
}), (0, _jsxRuntime.jsx)("input", {
|
|
192
|
+
autoFocus: true,
|
|
192
193
|
type: 'text',
|
|
193
194
|
className: 'p-2',
|
|
194
195
|
placeholder: (0, _locale.__)('data.search'),
|
|
@@ -1226,7 +1226,6 @@ var JoinData = function JoinData(props) {
|
|
|
1226
1226
|
var index = (0, _utils.findIndex)(store.metaList[groupIndex].list, meta);
|
|
1227
1227
|
var newMeta = store.metaList[groupIndex].list.slice();
|
|
1228
1228
|
var item = (0, _dialog.getTemplateItem)(type);
|
|
1229
|
-
console.log('🚀 ~ addExpression ~ item:', item);
|
|
1230
1229
|
if (type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
1231
1230
|
item = {
|
|
1232
1231
|
lhs: [{
|
|
@@ -269,9 +269,7 @@ var useStore = function useStore() {
|
|
|
269
269
|
_columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
|
|
270
270
|
var select = selectId.includes(v.id);
|
|
271
271
|
var obj = {};
|
|
272
|
-
|
|
273
|
-
obj = oldObj[v.id];
|
|
274
|
-
}
|
|
272
|
+
obj = oldObj[v.id] || {};
|
|
275
273
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, obj), v), {}, {
|
|
276
274
|
select: select,
|
|
277
275
|
fieldUuid: obj.fieldUuid || v.fieldUuid || (0, _helper.uuidv4)('field')
|
package/lib/cjs/utils.js
CHANGED
|
@@ -713,7 +713,10 @@ var _isError = exports.isError = function isError(item, data) {
|
|
|
713
713
|
}
|
|
714
714
|
} else {
|
|
715
715
|
var _tables$_datasourceId3;
|
|
716
|
-
|
|
716
|
+
var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
|
|
717
|
+
return v.name === fieldName;
|
|
718
|
+
})) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
|
|
719
|
+
return !hasField; // 注意:返回 true 表示“有错误”
|
|
717
720
|
}
|
|
718
721
|
}
|
|
719
722
|
// 表达式类型
|
|
@@ -152,6 +152,18 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
152
152
|
return v.fieldId != (val === null || val === void 0 ? void 0 : val.fieldId);
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
+
// 当前选中的表字段
|
|
156
|
+
var curTableColumn = data.filter(function (v) {
|
|
157
|
+
return v.tableUuid === curTable;
|
|
158
|
+
}).flatMap(function (v) {
|
|
159
|
+
return v.columns;
|
|
160
|
+
});
|
|
161
|
+
// 过滤选中字段不在当前选中的表字段中,
|
|
162
|
+
_value = _value.filter(function (item2) {
|
|
163
|
+
return curTableColumn.some(function (item1) {
|
|
164
|
+
return item1.name === item2.fieldName;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
155
167
|
setValue(_value);
|
|
156
168
|
setCurTable(tableUuid);
|
|
157
169
|
onSelect === null || onSelect === void 0 || onSelect(_value, getQuotes(_value));
|
|
@@ -8,7 +8,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
import './index.less';
|
|
9
9
|
import { useState, useEffect } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
-
import
|
|
11
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
12
|
+
import { __ } from '../../../locale';
|
|
13
|
+
import { TableIcon, SearchIcon } from '../../icons';
|
|
12
14
|
var PrevResult = 'Previous results';
|
|
13
15
|
var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
14
16
|
var _ref$data = _ref.data,
|
|
@@ -18,22 +20,45 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
18
20
|
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
19
21
|
didUpdate = _ref.didUpdate;
|
|
20
22
|
var _useState = useState(data.slice()),
|
|
21
|
-
_useState2 = _slicedToArray(_useState,
|
|
22
|
-
datasource = _useState2[0]
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
datasource = _useState2[0],
|
|
25
|
+
setDatasource = _useState2[1];
|
|
23
26
|
useEffect(function () {
|
|
24
27
|
didUpdate === null || didUpdate === void 0 || didUpdate();
|
|
25
28
|
}, [datasource]);
|
|
29
|
+
function onInput(e) {
|
|
30
|
+
var val = e.target.value;
|
|
31
|
+
var newList = cloneDeep(data.slice());
|
|
32
|
+
setDatasource(newList.filter(function (v) {
|
|
33
|
+
return ~(v.datasourceName + '.' + (v.alias || v.name)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
26
36
|
return _jsx("div", {
|
|
27
37
|
className: cx("Sqb-SelectTable--box pb-2 pt-2"),
|
|
28
38
|
children: _jsx("div", {
|
|
29
39
|
style: {
|
|
30
40
|
width: 300
|
|
31
41
|
},
|
|
32
|
-
children:
|
|
42
|
+
children: _jsxs("div", {
|
|
33
43
|
style: {
|
|
34
44
|
width: '100%'
|
|
35
45
|
},
|
|
36
|
-
children:
|
|
46
|
+
children: [_jsx("div", {
|
|
47
|
+
className: cx("Sqb-List-section"),
|
|
48
|
+
children: _jsxs("div", {
|
|
49
|
+
className: cx("Sqb-List-search m-2 rounded-lg"),
|
|
50
|
+
children: [_jsx("span", {
|
|
51
|
+
className: 'px-2',
|
|
52
|
+
children: _jsx(SearchIcon, {})
|
|
53
|
+
}), _jsx("input", {
|
|
54
|
+
autoFocus: true,
|
|
55
|
+
type: 'text',
|
|
56
|
+
className: 'p-2',
|
|
57
|
+
placeholder: __('data.search'),
|
|
58
|
+
onInput: onInput
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
}), Array.isArray(datasource) && datasource.map(function (v) {
|
|
37
62
|
return _jsx("div", {
|
|
38
63
|
className: cx("Sqb-List-section"),
|
|
39
64
|
children: _jsx("div", {
|
|
@@ -57,7 +82,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
57
82
|
})
|
|
58
83
|
})
|
|
59
84
|
}, v.alias || v.name);
|
|
60
|
-
})
|
|
85
|
+
})]
|
|
61
86
|
})
|
|
62
87
|
})
|
|
63
88
|
});
|
|
@@ -1221,7 +1221,6 @@ var JoinData = function JoinData(props) {
|
|
|
1221
1221
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
1222
1222
|
var newMeta = store.metaList[groupIndex].list.slice();
|
|
1223
1223
|
var item = getTemplateItem(type);
|
|
1224
|
-
console.log('🚀 ~ addExpression ~ item:', item);
|
|
1225
1224
|
if (type === AtomsTypeEnum.JOIN_DEFAULT) {
|
|
1226
1225
|
item = {
|
|
1227
1226
|
lhs: [{
|
|
@@ -262,9 +262,7 @@ var useStore = function useStore() {
|
|
|
262
262
|
_columns = (_columns2 = columns) === null || _columns2 === void 0 ? void 0 : _columns2.map(function (v) {
|
|
263
263
|
var select = selectId.includes(v.id);
|
|
264
264
|
var obj = {};
|
|
265
|
-
|
|
266
|
-
obj = oldObj[v.id];
|
|
267
|
-
}
|
|
265
|
+
obj = oldObj[v.id] || {};
|
|
268
266
|
return _objectSpread(_objectSpread(_objectSpread({}, obj), v), {}, {
|
|
269
267
|
select: select,
|
|
270
268
|
fieldUuid: obj.fieldUuid || v.fieldUuid || uuidv4('field')
|
package/lib/es/utils.js
CHANGED
|
@@ -702,7 +702,10 @@ var _isError = function isError(item, data) {
|
|
|
702
702
|
}
|
|
703
703
|
} else {
|
|
704
704
|
var _tables$_datasourceId3;
|
|
705
|
-
|
|
705
|
+
var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
|
|
706
|
+
return v.name === fieldName;
|
|
707
|
+
})) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
|
|
708
|
+
return !hasField; // 注意:返回 true 表示“有错误”
|
|
706
709
|
}
|
|
707
710
|
}
|
|
708
711
|
// 表达式类型
|