@gingkoo/pandora-metabase 1.0.57 → 1.0.59
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 +3 -3
- package/lib/cjs/components/dialog/select-join-column/index.js +3 -3
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +2 -2
- package/lib/cjs/components/dialog/select-permission-table/index.js +3 -2
- package/lib/cjs/components/modules/join-data.js +1 -1
- package/lib/cjs/components/modules/summarize/group-by.js +3 -0
- package/lib/cjs/components/modules/table-data.js +0 -1
- package/lib/cjs/hooks/use-state.js +10 -3
- package/lib/cjs/types.d.ts +7 -4
- package/lib/cjs/utils/helper.d.ts +1 -0
- package/lib/cjs/utils/helper.js +4 -1
- package/lib/cjs/utils.js +1 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +4 -4
- package/lib/es/components/dialog/select-join-column/index.js +4 -4
- package/lib/es/components/dialog/select-join-column-multiple/index.js +3 -3
- package/lib/es/components/dialog/select-permission-table/index.js +3 -2
- package/lib/es/components/modules/join-data.js +2 -2
- package/lib/es/components/modules/summarize/group-by.js +3 -0
- package/lib/es/components/modules/table-data.js +0 -1
- package/lib/es/hooks/use-state.js +10 -3
- package/lib/es/types.d.ts +7 -4
- package/lib/es/utils/helper.d.ts +1 -0
- package/lib/es/utils/helper.js +3 -0
- package/lib/es/utils.js +1 -1
- package/package.json +1 -1
|
@@ -188,7 +188,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
188
188
|
tableName = v.name,
|
|
189
189
|
_v$datasourceName = v.datasourceName,
|
|
190
190
|
datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
|
|
191
|
-
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(
|
|
191
|
+
var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias);
|
|
192
192
|
if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
|
|
193
193
|
// let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
|
|
194
194
|
return (0, _objectSpread2["default"])({}, v);
|
|
@@ -281,8 +281,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
281
281
|
},
|
|
282
282
|
children: (0, _jsxRuntime.jsx)("h3", {
|
|
283
283
|
className: 'List-item-title ml-2',
|
|
284
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
285
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
284
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias),
|
|
285
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias)
|
|
286
286
|
})
|
|
287
287
|
}), isMultiple && !isGroup && (0, _jsxRuntime.jsx)("span", {
|
|
288
288
|
className: 'List-title-arrow',
|
|
@@ -130,7 +130,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
130
130
|
tableName = v.name,
|
|
131
131
|
_v$datasourceName = v.datasourceName,
|
|
132
132
|
datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
|
|
133
|
-
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(
|
|
133
|
+
var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias);
|
|
134
134
|
if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
|
|
135
135
|
// let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
|
|
136
136
|
return (0, _objectSpread2["default"])({}, v);
|
|
@@ -220,8 +220,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
220
220
|
},
|
|
221
221
|
children: (0, _jsxRuntime.jsx)("h3", {
|
|
222
222
|
className: 'List-item-title ml-2',
|
|
223
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
224
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
223
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias),
|
|
224
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias)
|
|
225
225
|
})
|
|
226
226
|
}), isMultiple && (0, _jsxRuntime.jsx)("span", {
|
|
227
227
|
className: 'List-title-arrow',
|
|
@@ -195,8 +195,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
195
195
|
},
|
|
196
196
|
children: (0, _jsxRuntime.jsx)("h3", {
|
|
197
197
|
className: 'List-item-title ml-2',
|
|
198
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
199
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(
|
|
198
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias),
|
|
199
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias)
|
|
200
200
|
})
|
|
201
201
|
}), isMultiple && (0, _jsxRuntime.jsx)("span", {
|
|
202
202
|
className: 'List-title-arrow',
|
|
@@ -13,6 +13,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
13
13
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
14
14
|
var _locale = require("../../../locale");
|
|
15
15
|
var _icons = require("../../icons");
|
|
16
|
+
var _helper = require("../../../utils/helper");
|
|
16
17
|
/**
|
|
17
18
|
* 选择表弹框
|
|
18
19
|
* 谁在用?
|
|
@@ -38,7 +39,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
38
39
|
var val = e.target.value;
|
|
39
40
|
var newList = (0, _cloneDeep["default"])(data.slice());
|
|
40
41
|
setDatasource(newList.filter(function (v) {
|
|
41
|
-
return ~(v.datasourceName + '.' + (v.
|
|
42
|
+
return ~(v.datasourceName + '.' + (0, _helper.mergeNameAlias)(v.name, v.alias)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
44
45
|
return (0, _jsxRuntime.jsx)("div", {
|
|
@@ -84,7 +85,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
84
85
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
85
86
|
children: (0, _jsxRuntime.jsxs)("h4", {
|
|
86
87
|
className: 'List-item-title ml-2',
|
|
87
|
-
children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : v.
|
|
88
|
+
children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : (0, _helper.mergeNameAlias)(v.name, v.alias)]
|
|
88
89
|
})
|
|
89
90
|
})]
|
|
90
91
|
})
|
|
@@ -1347,7 +1347,7 @@ var JoinData = function JoinData(props) {
|
|
|
1347
1347
|
if (meta.table1.name === _helper2.SummarizeAlias) {
|
|
1348
1348
|
return PrevResult;
|
|
1349
1349
|
} else {
|
|
1350
|
-
return "".concat(meta.table1.datasourceName, ".").concat(meta.table1.
|
|
1350
|
+
return "".concat(meta.table1.datasourceName, ".").concat((0, _helper.mergeNameAlias)(meta.table1.name, meta.table1.alias));
|
|
1351
1351
|
}
|
|
1352
1352
|
} else {
|
|
1353
1353
|
return '';
|
|
@@ -205,6 +205,9 @@ var GroupBy = function GroupBy(props) {
|
|
|
205
205
|
newMeta[index].by = newMeta[index].by.map(function (v) {
|
|
206
206
|
var _store$preProps;
|
|
207
207
|
var fieldAlias = "".concat((0, _helper.getAlias)(v.alias, newMeta, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), "__").concat(v.name);
|
|
208
|
+
if (!(0, _utils.isValidSQLAlias)(fieldAlias)) {
|
|
209
|
+
_pandora.Toast.warning((0, _locale.__)('SqlQueryBuilder.aliasForRules'));
|
|
210
|
+
}
|
|
208
211
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
|
|
209
212
|
sql: "".concat(v.alias, ".").concat(v.realName || v.name),
|
|
210
213
|
fieldAlias: fieldAlias,
|
|
@@ -90,7 +90,6 @@ var TableData = function TableData(props) {
|
|
|
90
90
|
data: store.sourceList,
|
|
91
91
|
value: meta.table,
|
|
92
92
|
onChange: function onChange(data) {
|
|
93
|
-
console.log('🚀 ~ selectTable ~ data:', data);
|
|
94
93
|
if (meta.table.datasourceId !== data.datasourceId || meta.table.name !== data.name) {
|
|
95
94
|
var _store$preProps;
|
|
96
95
|
var newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
@@ -220,7 +220,9 @@ var useStore = function useStore() {
|
|
|
220
220
|
return _context.abrupt("return", tables);
|
|
221
221
|
case 1:
|
|
222
222
|
_context.next = 2;
|
|
223
|
-
return fetchDatasetFn.current(datasourceId
|
|
223
|
+
return fetchDatasetFn.current(datasourceId, {
|
|
224
|
+
isExit: isExit
|
|
225
|
+
});
|
|
224
226
|
case 2:
|
|
225
227
|
_tables = _context.sent;
|
|
226
228
|
setDataset(datasourceId, _tables);
|
|
@@ -280,7 +282,9 @@ var useStore = function useStore() {
|
|
|
280
282
|
break;
|
|
281
283
|
}
|
|
282
284
|
_context2.next = 1;
|
|
283
|
-
return fetchColumnsFn.current(extra, datasourceId
|
|
285
|
+
return fetchColumnsFn.current(extra, datasourceId, {
|
|
286
|
+
isExit: isExit
|
|
287
|
+
});
|
|
284
288
|
case 1:
|
|
285
289
|
columns = _context2.sent;
|
|
286
290
|
setColumns(tableName, columns);
|
|
@@ -330,9 +334,12 @@ var useStore = function useStore() {
|
|
|
330
334
|
return _context3.abrupt("return");
|
|
331
335
|
case 1:
|
|
332
336
|
_context3.next = 2;
|
|
333
|
-
return fetchChangeFn.current((0, _utils.splitByUnion)(_metaList), changeObj
|
|
337
|
+
return fetchChangeFn.current((0, _utils.splitByUnion)(_metaList), changeObj, {
|
|
338
|
+
isExit: isExit
|
|
339
|
+
});
|
|
334
340
|
case 2:
|
|
335
341
|
isChange = _context3.sent;
|
|
342
|
+
// 是否还原
|
|
336
343
|
if (isChange === false) {
|
|
337
344
|
_setMeta(_metaList);
|
|
338
345
|
}
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -8,16 +8,19 @@ export interface MetaListProps {
|
|
|
8
8
|
subquery?: MetaListType[];
|
|
9
9
|
list: MetaListType[];
|
|
10
10
|
}
|
|
11
|
+
export interface FetchOptions {
|
|
12
|
+
isExit: boolean;
|
|
13
|
+
}
|
|
11
14
|
export interface MetabaseProps {
|
|
12
15
|
loading?: boolean;
|
|
13
16
|
btnText?: string;
|
|
14
17
|
showFields?: boolean;
|
|
15
18
|
readonly?: boolean;
|
|
16
|
-
getTables: (datasourceId: string) => Promise<any>;
|
|
19
|
+
getTables: (datasourceId: string, options: FetchOptions) => Promise<any>;
|
|
17
20
|
getColumns: (table: {
|
|
18
21
|
name: string;
|
|
19
22
|
[key: string]: any;
|
|
20
|
-
}, datasourceId: string) => Promise<any>;
|
|
23
|
+
}, datasourceId: string, options: FetchOptions) => Promise<any>;
|
|
21
24
|
toolbar?: ToolbarType[];
|
|
22
25
|
subToolbar?: ToolbarType[];
|
|
23
26
|
tableNameTpl?: string;
|
|
@@ -38,10 +41,10 @@ export interface MetabaseProps {
|
|
|
38
41
|
tableEnableAlias?: boolean;
|
|
39
42
|
fieldEnableAlias?: boolean;
|
|
40
43
|
isSelectFields?: boolean;
|
|
41
|
-
onChange?: (newData: MetaListType[], curData
|
|
44
|
+
onChange?: (newData: MetaListType[], curData: {
|
|
42
45
|
data: any;
|
|
43
46
|
type: ChangeType;
|
|
44
|
-
}) => Promise<void | Boolean>;
|
|
47
|
+
}, options: FetchOptions) => Promise<void | Boolean>;
|
|
45
48
|
}
|
|
46
49
|
export interface OptionItem {
|
|
47
50
|
value?: string;
|
|
@@ -17,3 +17,4 @@ export declare const replaceTpl: (inputString: string, values: {
|
|
|
17
17
|
}) => string;
|
|
18
18
|
export declare const uuidv4: (prefix?: string) => string;
|
|
19
19
|
export declare const getAlias: (name: string | undefined, list: MetaListType[], columns?: any[]) => string;
|
|
20
|
+
export declare const mergeNameAlias: (name: string, alias: string) => string;
|
package/lib/cjs/utils/helper.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.uuidv4 = exports.throttle = exports.sleep = exports.replaceTpl = exports.mobx2Object = exports.getUrlParams = exports.getScreenInfo = exports.getAlias = exports.fullScreen = exports.flatArray = exports.exitFullscreen = exports.debounce = void 0;
|
|
7
|
+
exports.uuidv4 = exports.throttle = exports.sleep = exports.replaceTpl = exports.mobx2Object = exports.mergeNameAlias = exports.getUrlParams = exports.getScreenInfo = exports.getAlias = exports.fullScreen = exports.flatArray = exports.exitFullscreen = exports.debounce = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
9
9
|
var _enum = require("../store/enum");
|
|
10
10
|
// 节流
|
|
@@ -188,4 +188,7 @@ var getAlias = exports.getAlias = function getAlias() {
|
|
|
188
188
|
// 获取下一个可用编号
|
|
189
189
|
var nextIndex = Math.max.apply(Math, (0, _toConsumableArray2["default"])(uniqueIndexes)) + 1;
|
|
190
190
|
return "".concat(name, "_").concat(nextIndex);
|
|
191
|
+
};
|
|
192
|
+
var mergeNameAlias = exports.mergeNameAlias = function mergeNameAlias(name, alias) {
|
|
193
|
+
return name + (alias ? "\uFF08".concat(alias, "\uFF09") : '');
|
|
191
194
|
};
|
package/lib/cjs/utils.js
CHANGED
|
@@ -302,7 +302,7 @@ var _changeAlias = function changeAlias(items, val, type) {
|
|
|
302
302
|
};
|
|
303
303
|
function isValidSQLAlias(str) {
|
|
304
304
|
if (!str) return false;
|
|
305
|
-
var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,
|
|
305
|
+
var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,29}$/;
|
|
306
306
|
return regex.test(str);
|
|
307
307
|
}
|
|
308
308
|
var changeTableAlias = exports.changeTableAlias = function changeTableAlias(list, curObj) {
|
|
@@ -22,7 +22,7 @@ AtomsTypeEnum } from '../../../store/types';
|
|
|
22
22
|
import { __ } from '../../../locale';
|
|
23
23
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
24
24
|
import { useStore } from '../../../hooks/use-provider';
|
|
25
|
-
import { replaceTpl } from '../../../utils/helper';
|
|
25
|
+
import { replaceTpl, mergeNameAlias } from '../../../utils/helper';
|
|
26
26
|
import { uuidv4 } from '../../../utils/helper';
|
|
27
27
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
28
28
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
@@ -183,7 +183,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
183
183
|
tableName = v.name,
|
|
184
184
|
_v$datasourceName = v.datasourceName,
|
|
185
185
|
datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
|
|
186
|
-
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
186
|
+
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias)) : mergeNameAlias(tableName, tableAlias);
|
|
187
187
|
if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
|
|
188
188
|
// let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
|
|
189
189
|
return _objectSpread({}, v);
|
|
@@ -276,8 +276,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
276
276
|
},
|
|
277
277
|
children: _jsx("h3", {
|
|
278
278
|
className: 'List-item-title ml-2',
|
|
279
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
280
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
279
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias)) : mergeNameAlias(tableName, tableAlias),
|
|
280
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias)) : mergeNameAlias(tableName, tableAlias)
|
|
281
281
|
})
|
|
282
282
|
}), isMultiple && !isGroup && _jsx("span", {
|
|
283
283
|
className: 'List-title-arrow',
|
|
@@ -19,7 +19,7 @@ import { SummarizeAlias } from '../../../store/helper';
|
|
|
19
19
|
import { __ } from '../../../locale';
|
|
20
20
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
21
21
|
import { useStore } from '../../../hooks/use-provider';
|
|
22
|
-
import { replaceTpl } from '../../../utils/helper';
|
|
22
|
+
import { replaceTpl, mergeNameAlias } from '../../../utils/helper';
|
|
23
23
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2, RightArrowIcon } from '../../icons';
|
|
24
24
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
25
25
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -122,7 +122,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
122
122
|
tableName = v.name,
|
|
123
123
|
_v$datasourceName = v.datasourceName,
|
|
124
124
|
datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
|
|
125
|
-
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
125
|
+
var fullName = datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(tableName, tableAlias)) : mergeNameAlias(tableName, tableAlias);
|
|
126
126
|
if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
|
|
127
127
|
// let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
|
|
128
128
|
return _objectSpread({}, v);
|
|
@@ -212,8 +212,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
212
212
|
},
|
|
213
213
|
children: _jsx("h3", {
|
|
214
214
|
className: 'List-item-title ml-2',
|
|
215
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
216
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
215
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(table, tableAlias)) : mergeNameAlias(table, tableAlias),
|
|
216
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(table, tableAlias)) : mergeNameAlias(table, tableAlias)
|
|
217
217
|
})
|
|
218
218
|
}), isMultiple && _jsx("span", {
|
|
219
219
|
className: 'List-title-arrow',
|
|
@@ -19,7 +19,7 @@ import { SummarizeAlias } from '../../../store/helper';
|
|
|
19
19
|
import { __ } from '../../../locale';
|
|
20
20
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
21
21
|
import { useStore } from '../../../hooks/use-provider';
|
|
22
|
-
import { replaceTpl } from '../../../utils/helper';
|
|
22
|
+
import { replaceTpl, mergeNameAlias } from '../../../utils/helper';
|
|
23
23
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
24
24
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
25
25
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -187,8 +187,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
187
187
|
},
|
|
188
188
|
children: _jsx("h3", {
|
|
189
189
|
className: 'List-item-title ml-2',
|
|
190
|
-
title: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
191
|
-
children: datasourceName ? "".concat(datasourceName, ".").concat(tableAlias
|
|
190
|
+
title: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(table, tableAlias)) : mergeNameAlias(table, tableAlias),
|
|
191
|
+
children: datasourceName ? "".concat(datasourceName, ".").concat(mergeNameAlias(table, tableAlias)) : mergeNameAlias(table, tableAlias)
|
|
192
192
|
})
|
|
193
193
|
}), isMultiple && _jsx("span", {
|
|
194
194
|
className: 'List-title-arrow',
|
|
@@ -11,6 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import cloneDeep from 'lodash/cloneDeep';
|
|
12
12
|
import { __ } from '../../../locale';
|
|
13
13
|
import { TableIcon, SearchIcon } from '../../icons';
|
|
14
|
+
import { mergeNameAlias } from '../../../utils/helper';
|
|
14
15
|
var PrevResult = 'Previous results';
|
|
15
16
|
var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
16
17
|
var _ref$data = _ref.data,
|
|
@@ -30,7 +31,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
30
31
|
var val = e.target.value;
|
|
31
32
|
var newList = cloneDeep(data.slice());
|
|
32
33
|
setDatasource(newList.filter(function (v) {
|
|
33
|
-
return ~(v.datasourceName + '.' + (v.
|
|
34
|
+
return ~(v.datasourceName + '.' + mergeNameAlias(v.name, v.alias)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
36
37
|
return _jsx("div", {
|
|
@@ -76,7 +77,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
|
|
|
76
77
|
}), _jsx("div", {
|
|
77
78
|
children: _jsxs("h4", {
|
|
78
79
|
className: 'List-item-title ml-2',
|
|
79
|
-
children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : v.
|
|
80
|
+
children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : mergeNameAlias(v.name, v.alias)]
|
|
80
81
|
})
|
|
81
82
|
})]
|
|
82
83
|
})
|
|
@@ -13,7 +13,7 @@ import { FfPlus, FfLine, Repeat, RelatedWork } from '@gingkoo/pandora-icons';
|
|
|
13
13
|
import Metabase from '../../index';
|
|
14
14
|
import isEqual from 'lodash/isEqual';
|
|
15
15
|
import cloneDeep from 'lodash/cloneDeep';
|
|
16
|
-
import { uuidv4, getAlias } from '../../utils/helper';
|
|
16
|
+
import { uuidv4, getAlias, mergeNameAlias } from '../../utils/helper';
|
|
17
17
|
import { __ } from '../../locale';
|
|
18
18
|
import { findIndex, getSubColumns } from '../../utils';
|
|
19
19
|
import { TypeEnum, ColumnsPopupThemeEnum, JoinEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
@@ -1342,7 +1342,7 @@ var JoinData = function JoinData(props) {
|
|
|
1342
1342
|
if (meta.table1.name === SummarizeAlias) {
|
|
1343
1343
|
return PrevResult;
|
|
1344
1344
|
} else {
|
|
1345
|
-
return "".concat(meta.table1.datasourceName, ".").concat(meta.table1.
|
|
1345
|
+
return "".concat(meta.table1.datasourceName, ".").concat(mergeNameAlias(meta.table1.name, meta.table1.alias));
|
|
1346
1346
|
}
|
|
1347
1347
|
} else {
|
|
1348
1348
|
return '';
|
|
@@ -199,6 +199,9 @@ var GroupBy = function GroupBy(props) {
|
|
|
199
199
|
newMeta[index].by = newMeta[index].by.map(function (v) {
|
|
200
200
|
var _store$preProps;
|
|
201
201
|
var fieldAlias = "".concat(getAlias(v.alias, newMeta, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), "__").concat(v.name);
|
|
202
|
+
if (!isValidSQLAlias(fieldAlias)) {
|
|
203
|
+
Toast.warning(__('SqlQueryBuilder.aliasForRules'));
|
|
204
|
+
}
|
|
202
205
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
203
206
|
sql: "".concat(v.alias, ".").concat(v.realName || v.name),
|
|
204
207
|
fieldAlias: fieldAlias,
|
|
@@ -84,7 +84,6 @@ var TableData = function TableData(props) {
|
|
|
84
84
|
data: store.sourceList,
|
|
85
85
|
value: meta.table,
|
|
86
86
|
onChange: function onChange(data) {
|
|
87
|
-
console.log('🚀 ~ selectTable ~ data:', data);
|
|
88
87
|
if (meta.table.datasourceId !== data.datasourceId || meta.table.name !== data.name) {
|
|
89
88
|
var _store$preProps;
|
|
90
89
|
var newMetaList = store.metaList[groupIndex].list.slice()[0];
|
|
@@ -214,7 +214,9 @@ var useStore = function useStore() {
|
|
|
214
214
|
return _context.abrupt("return", tables);
|
|
215
215
|
case 1:
|
|
216
216
|
_context.next = 2;
|
|
217
|
-
return fetchDatasetFn.current(datasourceId
|
|
217
|
+
return fetchDatasetFn.current(datasourceId, {
|
|
218
|
+
isExit: isExit
|
|
219
|
+
});
|
|
218
220
|
case 2:
|
|
219
221
|
_tables = _context.sent;
|
|
220
222
|
setDataset(datasourceId, _tables);
|
|
@@ -274,7 +276,9 @@ var useStore = function useStore() {
|
|
|
274
276
|
break;
|
|
275
277
|
}
|
|
276
278
|
_context2.next = 1;
|
|
277
|
-
return fetchColumnsFn.current(extra, datasourceId
|
|
279
|
+
return fetchColumnsFn.current(extra, datasourceId, {
|
|
280
|
+
isExit: isExit
|
|
281
|
+
});
|
|
278
282
|
case 1:
|
|
279
283
|
columns = _context2.sent;
|
|
280
284
|
setColumns(tableName, columns);
|
|
@@ -324,9 +328,12 @@ var useStore = function useStore() {
|
|
|
324
328
|
return _context3.abrupt("return");
|
|
325
329
|
case 1:
|
|
326
330
|
_context3.next = 2;
|
|
327
|
-
return fetchChangeFn.current(splitByUnion(_metaList), changeObj
|
|
331
|
+
return fetchChangeFn.current(splitByUnion(_metaList), changeObj, {
|
|
332
|
+
isExit: isExit
|
|
333
|
+
});
|
|
328
334
|
case 2:
|
|
329
335
|
isChange = _context3.sent;
|
|
336
|
+
// 是否还原
|
|
330
337
|
if (isChange === false) {
|
|
331
338
|
_setMeta(_metaList);
|
|
332
339
|
}
|
package/lib/es/types.d.ts
CHANGED
|
@@ -8,16 +8,19 @@ export interface MetaListProps {
|
|
|
8
8
|
subquery?: MetaListType[];
|
|
9
9
|
list: MetaListType[];
|
|
10
10
|
}
|
|
11
|
+
export interface FetchOptions {
|
|
12
|
+
isExit: boolean;
|
|
13
|
+
}
|
|
11
14
|
export interface MetabaseProps {
|
|
12
15
|
loading?: boolean;
|
|
13
16
|
btnText?: string;
|
|
14
17
|
showFields?: boolean;
|
|
15
18
|
readonly?: boolean;
|
|
16
|
-
getTables: (datasourceId: string) => Promise<any>;
|
|
19
|
+
getTables: (datasourceId: string, options: FetchOptions) => Promise<any>;
|
|
17
20
|
getColumns: (table: {
|
|
18
21
|
name: string;
|
|
19
22
|
[key: string]: any;
|
|
20
|
-
}, datasourceId: string) => Promise<any>;
|
|
23
|
+
}, datasourceId: string, options: FetchOptions) => Promise<any>;
|
|
21
24
|
toolbar?: ToolbarType[];
|
|
22
25
|
subToolbar?: ToolbarType[];
|
|
23
26
|
tableNameTpl?: string;
|
|
@@ -38,10 +41,10 @@ export interface MetabaseProps {
|
|
|
38
41
|
tableEnableAlias?: boolean;
|
|
39
42
|
fieldEnableAlias?: boolean;
|
|
40
43
|
isSelectFields?: boolean;
|
|
41
|
-
onChange?: (newData: MetaListType[], curData
|
|
44
|
+
onChange?: (newData: MetaListType[], curData: {
|
|
42
45
|
data: any;
|
|
43
46
|
type: ChangeType;
|
|
44
|
-
}) => Promise<void | Boolean>;
|
|
47
|
+
}, options: FetchOptions) => Promise<void | Boolean>;
|
|
45
48
|
}
|
|
46
49
|
export interface OptionItem {
|
|
47
50
|
value?: string;
|
package/lib/es/utils/helper.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export declare const replaceTpl: (inputString: string, values: {
|
|
|
17
17
|
}) => string;
|
|
18
18
|
export declare const uuidv4: (prefix?: string) => string;
|
|
19
19
|
export declare const getAlias: (name: string | undefined, list: MetaListType[], columns?: any[]) => string;
|
|
20
|
+
export declare const mergeNameAlias: (name: string, alias: string) => string;
|
package/lib/es/utils/helper.js
CHANGED
|
@@ -181,4 +181,7 @@ export var getAlias = function getAlias() {
|
|
|
181
181
|
// 获取下一个可用编号
|
|
182
182
|
var nextIndex = Math.max.apply(Math, _toConsumableArray(uniqueIndexes)) + 1;
|
|
183
183
|
return "".concat(name, "_").concat(nextIndex);
|
|
184
|
+
};
|
|
185
|
+
export var mergeNameAlias = function mergeNameAlias(name, alias) {
|
|
186
|
+
return name + (alias ? "\uFF08".concat(alias, "\uFF09") : '');
|
|
184
187
|
};
|
package/lib/es/utils.js
CHANGED
|
@@ -291,7 +291,7 @@ var _changeAlias = function changeAlias(items, val, type) {
|
|
|
291
291
|
};
|
|
292
292
|
export function isValidSQLAlias(str) {
|
|
293
293
|
if (!str) return false;
|
|
294
|
-
var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,
|
|
294
|
+
var regex = /^[a-zA-Z][a-zA-Z0-9_]{0,29}$/;
|
|
295
295
|
return regex.test(str);
|
|
296
296
|
}
|
|
297
297
|
export var changeTableAlias = function changeTableAlias(list, curObj) {
|