@gingkoo/pandora-metabase 1.0.157 → 1.0.158-alpha.10
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/column-type-label/index.d.ts +8 -0
- package/lib/cjs/components/dialog/column-type-label/index.js +22 -0
- package/lib/cjs/components/dialog/column-type-label/index.less +17 -0
- package/lib/cjs/components/dialog/expression/index.js +7 -6
- package/lib/cjs/components/dialog/formula/index.js +1 -1
- package/lib/cjs/components/dialog/formula/utils.js +2 -0
- package/lib/cjs/components/dialog/formula-list/index.js +87 -23
- package/lib/cjs/components/dialog/formula-list/index.less +16 -0
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +5 -4
- package/lib/cjs/components/dialog/formula-list/utils.js +61 -13
- package/lib/cjs/components/dialog/select-column/index.js +7 -1
- package/lib/cjs/components/dialog/select-column/index.less +6 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +9 -6
- package/lib/cjs/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column/index.js +7 -3
- package/lib/cjs/components/dialog/select-join-column/index.less +10 -0
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +7 -3
- package/lib/cjs/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/cjs/components/metabase/index.js +51 -0
- package/lib/cjs/components/metabase/index.less +0 -19
- package/lib/cjs/components/modules/components/meta-icon.js +1 -3
- package/lib/cjs/components/modules/join-data.js +81 -13
- package/lib/cjs/components/modules/summarize/group-by.js +10 -6
- package/lib/cjs/components/modules/table-data.js +25 -7
- package/lib/cjs/hooks/use-state.js +31 -63
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/locale/en.js +2 -0
- package/lib/cjs/locale/zh.js +2 -0
- package/lib/cjs/store/types.d.ts +2 -0
- package/lib/cjs/utils/transformSql.js +4 -0
- package/lib/cjs/utils.d.ts +2 -0
- package/lib/cjs/utils.js +74 -36
- package/lib/es/components/dialog/column-type-label/index.d.ts +8 -0
- package/lib/es/components/dialog/column-type-label/index.js +16 -0
- package/lib/es/components/dialog/column-type-label/index.less +17 -0
- package/lib/es/components/dialog/expression/index.js +7 -6
- package/lib/es/components/dialog/formula/index.js +1 -1
- package/lib/es/components/dialog/formula/utils.js +2 -0
- package/lib/es/components/dialog/formula-list/index.js +89 -25
- package/lib/es/components/dialog/formula-list/index.less +16 -0
- package/lib/es/components/dialog/formula-list/utils.d.ts +5 -4
- package/lib/es/components/dialog/formula-list/utils.js +60 -12
- package/lib/es/components/dialog/select-column/index.js +7 -1
- package/lib/es/components/dialog/select-column/index.less +6 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +9 -6
- package/lib/es/components/dialog/select-column-multiple/index.less +10 -0
- package/lib/es/components/dialog/select-join-column/index.js +7 -3
- package/lib/es/components/dialog/select-join-column/index.less +10 -0
- package/lib/es/components/dialog/select-join-column-multiple/index.js +7 -3
- package/lib/es/components/dialog/select-join-column-multiple/index.less +10 -0
- package/lib/es/components/metabase/index.js +51 -0
- package/lib/es/components/metabase/index.less +0 -19
- package/lib/es/components/modules/components/meta-icon.js +2 -4
- package/lib/es/components/modules/join-data.js +83 -15
- package/lib/es/components/modules/summarize/group-by.js +10 -6
- package/lib/es/components/modules/table-data.js +27 -9
- package/lib/es/hooks/use-state.js +31 -63
- package/lib/es/index.js +1 -1
- package/lib/es/locale/en.js +2 -0
- package/lib/es/locale/zh.js +2 -0
- package/lib/es/store/types.d.ts +2 -0
- package/lib/es/utils/transformSql.js +4 -0
- package/lib/es/utils.d.ts +2 -0
- package/lib/es/utils.js +74 -36
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './index.less';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { MetaData_ColumnsType } from '../../../store/types';
|
|
4
|
+
interface PropsType {
|
|
5
|
+
column: Pick<MetaData_ColumnsType, 'field_type' | 'field_length'>;
|
|
6
|
+
}
|
|
7
|
+
declare const ColumnTypeLabel: ({ column }: PropsType) => React.JSX.Element | null;
|
|
8
|
+
export default ColumnTypeLabel;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
require("./index.less");
|
|
9
|
+
var ColumnTypeLabel = function ColumnTypeLabel(_ref) {
|
|
10
|
+
var column = _ref.column;
|
|
11
|
+
var fieldType = String(column.field_type || '').trim();
|
|
12
|
+
var fieldLength = column.field_length;
|
|
13
|
+
var hasLength = fieldLength !== undefined && fieldLength !== null && "".concat(fieldLength).trim() !== '';
|
|
14
|
+
if (!fieldType && !hasLength) return null;
|
|
15
|
+
var label = fieldType && hasLength ? "".concat(fieldType, "(").concat(fieldLength, ")") : fieldType || "".concat(fieldLength);
|
|
16
|
+
return (0, _jsxRuntime.jsx)("span", {
|
|
17
|
+
className: 'Sqb-ColumnTypeLabel',
|
|
18
|
+
title: label,
|
|
19
|
+
children: label
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var _default = exports["default"] = ColumnTypeLabel;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.Sqb-ColumnTypeLabel {
|
|
2
|
+
flex: 0 0 auto;
|
|
3
|
+
margin-left: auto;
|
|
4
|
+
padding-left: 12px;
|
|
5
|
+
color: #949aab;
|
|
6
|
+
font-size: 12px;
|
|
7
|
+
font-weight: 400;
|
|
8
|
+
line-height: 20px;
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.Sqb-List-item:hover,
|
|
13
|
+
.Sqb-List-item.active {
|
|
14
|
+
.Sqb-ColumnTypeLabel {
|
|
15
|
+
color: rgba(255, 255, 255, 0.82);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -32,13 +32,14 @@ var _dateFormatPicker = require("./date-format-picker");
|
|
|
32
32
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
33
|
var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
34
34
|
var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
|
|
35
|
-
var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '
|
|
35
|
+
var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '为空', '不为空'];
|
|
36
36
|
var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
|
|
37
37
|
var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
|
|
38
38
|
var LEGACY_DATE_CONDITION_MAP = {
|
|
39
39
|
早于: '小于',
|
|
40
40
|
晚于: '大于或等于'
|
|
41
41
|
};
|
|
42
|
+
var LEGACY_EMPTY_CONDITIONS = new Set(['是空的', '不是空的']);
|
|
42
43
|
var typeList = [{
|
|
43
44
|
key: _enum.SQL_COLUMN_TYPE.STRING,
|
|
44
45
|
label: _enum.SQL_COLUMN_TYPE.STRING
|
|
@@ -75,7 +76,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
75
76
|
_ref$filterCustomType = _ref.filterCustomType,
|
|
76
77
|
filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
|
|
77
78
|
parentPopupChannel = _ref.parentPopupChannel;
|
|
78
|
-
var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data);
|
|
79
|
+
var normalizedInitialValue = (0, _utils.normalizeExpressionAtom)(value, data, filterCustomType);
|
|
79
80
|
var _useState = (0, _react.useState)(normalizedInitialValue),
|
|
80
81
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
81
82
|
curColumn = _useState2[0],
|
|
@@ -332,7 +333,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
332
333
|
rhs: rhsVal,
|
|
333
334
|
condition: condition,
|
|
334
335
|
database_type: databaseType
|
|
335
|
-
}), filterCustomType
|
|
336
|
+
}), data, filterCustomType);
|
|
336
337
|
var quotes = generateQuotes(nextExpression.rhs, nextExpression);
|
|
337
338
|
typeof onChange === 'function' && onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, nextExpression), {}, {
|
|
338
339
|
quotes: quotes
|
|
@@ -361,8 +362,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
361
362
|
if (isCustom) {
|
|
362
363
|
conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
|
|
363
364
|
}
|
|
364
|
-
var
|
|
365
|
-
if (!conditions.includes(condition) && !nextCondition && !
|
|
365
|
+
var isLegacyEmptyCondition = LEGACY_EMPTY_CONDITIONS.has(condition);
|
|
366
|
+
if (!conditions.includes(condition) && !nextCondition && !isLegacyEmptyCondition) {
|
|
366
367
|
setDefaultVal(conditions[0], type);
|
|
367
368
|
}
|
|
368
369
|
return {
|
|
@@ -1019,7 +1020,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
1019
1020
|
onSelect: function onSelect(fields, quotes) {
|
|
1020
1021
|
setCurColumn((0, _utils.normalizeExpressionAtom)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, curColumn), {}, {
|
|
1021
1022
|
lhs: fields
|
|
1022
|
-
}), data));
|
|
1023
|
+
}), data, filterCustomType));
|
|
1023
1024
|
setIsNext(true);
|
|
1024
1025
|
}
|
|
1025
1026
|
})
|
|
@@ -91,7 +91,7 @@ var CaseEditor = _react["default"].forwardRef(function (props, ref) {
|
|
|
91
91
|
rightClickMenuState = _useState6[0],
|
|
92
92
|
setRightClickMenuState = _useState6[1];
|
|
93
93
|
var usable = (0, _react.useMemo)(function () {
|
|
94
|
-
return fun.name && (0, _utils.isOk)(fun.args);
|
|
94
|
+
return fun.name && (0, _utils.isOk)(fun.args, true);
|
|
95
95
|
}, [fun]);
|
|
96
96
|
var _onClose = function _onClose() {
|
|
97
97
|
onCancel === null || onCancel === void 0 || onCancel();
|
|
@@ -87,6 +87,8 @@ var getQuotes = exports.getQuotes = function getQuotes(fun, _args, formulaList)
|
|
|
87
87
|
return vv === null || vv === void 0 ? void 0 : vv.quotes;
|
|
88
88
|
} else if (vv !== null && vv !== void 0 && vv.fieldName) {
|
|
89
89
|
return vv === null || vv === void 0 ? void 0 : vv.fieldName;
|
|
90
|
+
} else if ((vv === null || vv === void 0 ? void 0 : vv.type) === _types.AtomsTypeEnum.INPUT_STRING && vv.val === '') {
|
|
91
|
+
return "''";
|
|
90
92
|
} else if ((vv === null || vv === void 0 ? void 0 : vv.type) === _types.AtomsTypeEnum.SELECT) {
|
|
91
93
|
var displayField = vv.displayField || 'value';
|
|
92
94
|
var getOptionText = function getOptionText(value) {
|
|
@@ -1056,8 +1056,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1056
1056
|
return (0, _utils2.normalizeAndOrStructure)(value || []);
|
|
1057
1057
|
}, [value]);
|
|
1058
1058
|
var normalizedExpressionValue = (0, _react.useMemo)(function () {
|
|
1059
|
-
return (0, _utils3.normalizeExpressionAtoms)(normalizedStructureValue, data);
|
|
1060
|
-
}, [normalizedStructureValue, data]);
|
|
1059
|
+
return (0, _utils3.normalizeExpressionAtoms)(normalizedStructureValue, data, store.filterCustomType);
|
|
1060
|
+
}, [normalizedStructureValue, data, store.filterCustomType]);
|
|
1061
1061
|
var normalizedValue = (0, _react.useMemo)(function () {
|
|
1062
1062
|
return normalizedExpressionValue.map(_utils2.syncAtomQuotes);
|
|
1063
1063
|
}, [normalizedExpressionValue]);
|
|
@@ -1076,9 +1076,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1076
1076
|
var hasFormulaDiffAction = Boolean(store.showFormulaDiff && store.hasFormulaDiffCode);
|
|
1077
1077
|
var operatorList = (0, _react.useMemo)(function () {
|
|
1078
1078
|
if (store.operatorList.length > 0) {
|
|
1079
|
-
return store.operatorList;
|
|
1079
|
+
return (0, _utils3.normalizeOperatorList)(store.operatorList);
|
|
1080
1080
|
}
|
|
1081
|
-
return _utils3.operatorList;
|
|
1081
|
+
return (0, _utils3.normalizeOperatorList)(_utils3.operatorList);
|
|
1082
1082
|
}, [store.operatorList]);
|
|
1083
1083
|
var _useState15 = (0, _react.useState)(false),
|
|
1084
1084
|
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
@@ -1281,7 +1281,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1281
1281
|
return _withSyncedQuotesInner(item, new WeakMap());
|
|
1282
1282
|
};
|
|
1283
1283
|
var setCaseList = function setCaseList(atoms) {
|
|
1284
|
-
var nextData = (0, _utils3.normalizeExpressionAtoms)(atoms, data).map(function (item) {
|
|
1284
|
+
var nextData = (0, _utils3.normalizeExpressionAtoms)(atoms, data, store.filterCustomType).map(function (item) {
|
|
1285
1285
|
return withSyncedQuotes(item);
|
|
1286
1286
|
});
|
|
1287
1287
|
var quotes = nextData.map(function (item) {
|
|
@@ -2396,8 +2396,32 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2396
2396
|
var _caseList = caseList.slice();
|
|
2397
2397
|
var currentItem = _caseList[i];
|
|
2398
2398
|
var oldVal = _caseList[i].val;
|
|
2399
|
-
var oldType =
|
|
2399
|
+
var oldType = (currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) || '';
|
|
2400
|
+
var isOperatorItem = oldType === _types.AtomsTypeEnum.OPERATOR;
|
|
2400
2401
|
var otherTypeConfig = otherTypeMap.get(String(oldType));
|
|
2402
|
+
if (oldType === _types.AtomsTypeEnum.OPERATOR && (oldVal === '(' || oldVal === ')')) {
|
|
2403
|
+
if (val === '()') return;
|
|
2404
|
+
var matchingIndex = getMatchingParenthesisIndex(_caseList, i);
|
|
2405
|
+
if (matchingIndex >= 0) {
|
|
2406
|
+
_caseList.splice(matchingIndex, 1);
|
|
2407
|
+
}
|
|
2408
|
+
var currentIndex = matchingIndex >= 0 && matchingIndex < i ? i - 1 : i;
|
|
2409
|
+
_caseList[currentIndex].val = val;
|
|
2410
|
+
_caseList = (0, _utils3.insertTemplateAt)(oldVal, val, _caseList, currentIndex);
|
|
2411
|
+
setCaseList(_caseList);
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
if (oldType === _types.AtomsTypeEnum.OPERATOR && val === '()') {
|
|
2415
|
+
_caseList.splice(i, 1, {
|
|
2416
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
2417
|
+
val: '('
|
|
2418
|
+
}, {
|
|
2419
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
2420
|
+
val: ')'
|
|
2421
|
+
});
|
|
2422
|
+
setCaseList(_caseList);
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2401
2425
|
if (oldType === _types.AtomsTypeEnum.CONSTANT) {
|
|
2402
2426
|
_caseList[i].id = val;
|
|
2403
2427
|
_caseList[i].val = (0, _utils3.getConstantLabel)(store.constantList, val);
|
|
@@ -2408,7 +2432,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2408
2432
|
} else {
|
|
2409
2433
|
_caseList[i].val = val;
|
|
2410
2434
|
}
|
|
2411
|
-
|
|
2435
|
+
if (isOperatorItem) {
|
|
2436
|
+
_caseList = (0, _utils3.insertTemplateAt)(oldVal, val, _caseList, i);
|
|
2437
|
+
}
|
|
2412
2438
|
setCaseList(_caseList);
|
|
2413
2439
|
};
|
|
2414
2440
|
function handleExpression(e, i, val) {
|
|
@@ -2432,17 +2458,44 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2432
2458
|
})
|
|
2433
2459
|
});
|
|
2434
2460
|
}
|
|
2461
|
+
function getMatchingParenthesisIndex(list, index) {
|
|
2462
|
+
var item = list[index];
|
|
2463
|
+
if ((item === null || item === void 0 ? void 0 : item.type) !== _types.AtomsTypeEnum.OPERATOR) return -1;
|
|
2464
|
+
var isOpening = item.val === '(';
|
|
2465
|
+
var isClosing = item.val === ')';
|
|
2466
|
+
if (!isOpening && !isClosing) return -1;
|
|
2467
|
+
var depth = 0;
|
|
2468
|
+
var step = isOpening ? 1 : -1;
|
|
2469
|
+
for (var currentIndex = index; currentIndex >= 0 && currentIndex < list.length; currentIndex += step) {
|
|
2470
|
+
var currentItem = list[currentIndex];
|
|
2471
|
+
if ((currentItem === null || currentItem === void 0 ? void 0 : currentItem.type) !== _types.AtomsTypeEnum.OPERATOR) continue;
|
|
2472
|
+
if (currentItem.val === '(') depth += isOpening ? 1 : -1;
|
|
2473
|
+
if (currentItem.val === ')') depth += isOpening ? -1 : 1;
|
|
2474
|
+
if (depth === 0) return currentIndex;
|
|
2475
|
+
}
|
|
2476
|
+
return -1;
|
|
2477
|
+
}
|
|
2478
|
+
function getDeletionIndexSet(list, indices) {
|
|
2479
|
+
var indexSet = new Set(indices);
|
|
2480
|
+
indices.forEach(function (index) {
|
|
2481
|
+
var matchingIndex = getMatchingParenthesisIndex(list, index);
|
|
2482
|
+
if (matchingIndex >= 0) indexSet.add(matchingIndex);
|
|
2483
|
+
});
|
|
2484
|
+
return indexSet;
|
|
2485
|
+
}
|
|
2435
2486
|
function handleDel(e, index) {
|
|
2436
2487
|
e.stopPropagation();
|
|
2437
2488
|
var _caseList = caseList.slice();
|
|
2438
|
-
_caseList
|
|
2439
|
-
setCaseList(_caseList)
|
|
2489
|
+
var indexSet = getDeletionIndexSet(_caseList, [index]);
|
|
2490
|
+
setCaseList(_caseList.filter(function (_, itemIndex) {
|
|
2491
|
+
return !indexSet.has(itemIndex);
|
|
2492
|
+
}));
|
|
2440
2493
|
closePopup();
|
|
2441
2494
|
}
|
|
2442
2495
|
function handleDelItems(e, indices) {
|
|
2443
2496
|
e.stopPropagation();
|
|
2444
2497
|
if (!indices.length) return;
|
|
2445
|
-
var indexSet =
|
|
2498
|
+
var indexSet = getDeletionIndexSet(caseList, indices);
|
|
2446
2499
|
var _caseList = caseList.filter(function (_, itemIndex) {
|
|
2447
2500
|
return !indexSet.has(itemIndex);
|
|
2448
2501
|
});
|
|
@@ -2544,7 +2597,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2544
2597
|
return _regenerator["default"].wrap(function (_context0) {
|
|
2545
2598
|
while (1) switch (_context0.prev = _context0.next) {
|
|
2546
2599
|
case 0:
|
|
2547
|
-
selectedIndexSet =
|
|
2600
|
+
selectedIndexSet = getDeletionIndexSet(caseList, selectedIndices);
|
|
2548
2601
|
_caseList = caseList.filter(function (_, index) {
|
|
2549
2602
|
return !selectedIndexSet.has(index);
|
|
2550
2603
|
});
|
|
@@ -2585,28 +2638,37 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2585
2638
|
var _caseList = caseList.slice() || [];
|
|
2586
2639
|
var _ind = index;
|
|
2587
2640
|
var otherTypeConfig = otherTypeMap.get(String(type));
|
|
2588
|
-
var
|
|
2641
|
+
var isParentheses = type === '()';
|
|
2642
|
+
var temItems = isParentheses ? [{
|
|
2643
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
2644
|
+
val: '('
|
|
2645
|
+
}, {
|
|
2646
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
2647
|
+
val: ')'
|
|
2648
|
+
}] : [otherTypeConfig ? {
|
|
2589
2649
|
id: '',
|
|
2590
2650
|
val: '',
|
|
2591
2651
|
type: type
|
|
2592
|
-
} : (0, _utils3.getTemplateItem)(type);
|
|
2652
|
+
} : (0, _utils3.getTemplateItem)(type)];
|
|
2593
2653
|
if (position === 'add') {
|
|
2594
|
-
_caseList.push(
|
|
2654
|
+
_caseList.push.apply(_caseList, temItems);
|
|
2595
2655
|
_ind = _caseList.length - 1;
|
|
2596
2656
|
} else if (position === 'before') {
|
|
2597
|
-
_caseList.splice(index, 0
|
|
2657
|
+
_caseList.splice.apply(_caseList, [index, 0].concat(temItems));
|
|
2598
2658
|
_ind = index;
|
|
2599
2659
|
} else if (position === 'after') {
|
|
2600
|
-
_caseList.splice(index + 1, 0
|
|
2660
|
+
_caseList.splice.apply(_caseList, [index + 1, 0].concat(temItems));
|
|
2601
2661
|
_ind = index + 1;
|
|
2602
2662
|
} else {
|
|
2603
|
-
_caseList.splice(index, 1
|
|
2663
|
+
_caseList.splice.apply(_caseList, [index, 1].concat(temItems));
|
|
2604
2664
|
_ind = index;
|
|
2605
2665
|
}
|
|
2606
2666
|
setCaseList(_caseList);
|
|
2607
2667
|
return _ind < 0 ? 0 : _ind;
|
|
2608
2668
|
};
|
|
2609
2669
|
var getItemNameProps = function getItemNameProps(v) {
|
|
2670
|
+
var referenceError = (0, _utils2.getFieldReferenceError)(v, data);
|
|
2671
|
+
var referenceErrorMessage = referenceError ? (0, _locale.__)("metabase.".concat(referenceError, "NotExists")) : '';
|
|
2610
2672
|
if (v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.EXISTS) {
|
|
2611
2673
|
return {
|
|
2612
2674
|
isError: (0, _utils2.isExistsError)(v.notExists, store.existsError)
|
|
@@ -2619,7 +2681,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2619
2681
|
}
|
|
2620
2682
|
if (v.type === _types.AtomsTypeEnum.FIELD) {
|
|
2621
2683
|
return {
|
|
2622
|
-
isError: (
|
|
2684
|
+
isError: Boolean(referenceError),
|
|
2685
|
+
message: referenceErrorMessage
|
|
2623
2686
|
};
|
|
2624
2687
|
}
|
|
2625
2688
|
if (v.type === _types.AtomsTypeEnum.CONSTANT) {
|
|
@@ -2638,14 +2701,15 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2638
2701
|
}
|
|
2639
2702
|
if (v.type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
2640
2703
|
return {
|
|
2641
|
-
isError: (
|
|
2704
|
+
isError: Boolean(referenceError),
|
|
2705
|
+
message: referenceErrorMessage
|
|
2642
2706
|
};
|
|
2643
2707
|
}
|
|
2644
2708
|
if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
2645
2709
|
var formulaMissing = (0, _utils.formulaIsError)(v, formulaList);
|
|
2646
2710
|
return {
|
|
2647
|
-
isError: (
|
|
2648
|
-
message: formulaMissing ? '公式丢失' :
|
|
2711
|
+
isError: Boolean(referenceError) || formulaMissing,
|
|
2712
|
+
message: formulaMissing ? '公式丢失' : referenceErrorMessage
|
|
2649
2713
|
};
|
|
2650
2714
|
}
|
|
2651
2715
|
return {
|
|
@@ -2864,7 +2928,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2864
2928
|
className: 'notSelected',
|
|
2865
2929
|
node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
2866
2930
|
children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldString, {}), (0, _jsxRuntime.jsx)(_pandora.Input, {
|
|
2867
|
-
className: '
|
|
2931
|
+
className: 'sqb-Custom-input',
|
|
2868
2932
|
value: v.val,
|
|
2869
2933
|
placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
|
|
2870
2934
|
size: 'large',
|
|
@@ -2880,7 +2944,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2880
2944
|
className: 'notSelected',
|
|
2881
2945
|
node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
2882
2946
|
children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldNumber, {}), (0, _jsxRuntime.jsx)(_pandora.InputNumber, {
|
|
2883
|
-
className: '
|
|
2947
|
+
className: 'sqb-Custom-input',
|
|
2884
2948
|
value: v.val,
|
|
2885
2949
|
placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
|
|
2886
2950
|
size: 'large',
|
|
@@ -407,6 +407,22 @@
|
|
|
407
407
|
position: relative;
|
|
408
408
|
// margin: 0 var(--sqb-item-shell-margin-x);
|
|
409
409
|
|
|
410
|
+
// Keep value inputs consistent in both the inline editor and its modal.
|
|
411
|
+
.sqb-Custom-input {
|
|
412
|
+
border: 0;
|
|
413
|
+
border-radius: 0;
|
|
414
|
+
padding: 0;
|
|
415
|
+
background: none !important;
|
|
416
|
+
|
|
417
|
+
.pd-Input,
|
|
418
|
+
.pd-Input-inner-wrapper {
|
|
419
|
+
border: 0;
|
|
420
|
+
border-radius: 0;
|
|
421
|
+
padding: 0;
|
|
422
|
+
background: none !important;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
410
426
|
&.hover,
|
|
411
427
|
&:hover {
|
|
412
428
|
z-index: 5;
|
|
@@ -7,11 +7,12 @@ type ExpressionTable = {
|
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
9
|
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
10
|
-
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
11
|
-
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
12
|
-
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
10
|
+
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => string;
|
|
11
|
+
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsExpression;
|
|
12
|
+
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[], filterCustomType?: boolean) => AtomsItem[];
|
|
13
13
|
export declare const insertTemplateAt: (oldType: string, type: string, list: any[], index: number) => any[];
|
|
14
14
|
export declare const operatorList: string[];
|
|
15
|
+
export declare const normalizeOperatorList: (operators?: string[]) => string[];
|
|
15
16
|
export declare const customTypes: ({
|
|
16
17
|
value: AtomsTypeEnum;
|
|
17
18
|
label: any;
|
|
@@ -22,7 +23,7 @@ export declare const customTypes: ({
|
|
|
22
23
|
children: string[];
|
|
23
24
|
})[];
|
|
24
25
|
export declare const getTemplateItem: (type: AtomsTypeEnum, item?: any) => AtomsItem;
|
|
25
|
-
export declare const isOk: (rhsVal: AtomsItem[]) => boolean;
|
|
26
|
+
export declare const isOk: (rhsVal: AtomsItem[], allowEmptyInputString?: boolean) => boolean;
|
|
26
27
|
export declare function validateExpressionIntegrity(list: AtomsItem[]): {
|
|
27
28
|
isError: boolean;
|
|
28
29
|
error?: string;
|
|
@@ -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.operatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = exports.EMPTY_RHS_CONDITIONS = void 0;
|
|
7
|
+
exports.operatorList = exports.normalizeOperatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = exports.EMPTY_RHS_CONDITIONS = void 0;
|
|
8
8
|
exports.validateExpressionIntegrity = validateExpressionIntegrity;
|
|
9
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
@@ -36,6 +36,10 @@ var findExpressionColumn = function findExpressionColumn(expression) {
|
|
|
36
36
|
};
|
|
37
37
|
var getExpressionDatabaseType = exports.getExpressionDatabaseType = function getExpressionDatabaseType(expression) {
|
|
38
38
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
39
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
40
|
+
if (filterCustomType) {
|
|
41
|
+
return String(expression.database_type || '').toUpperCase();
|
|
42
|
+
}
|
|
39
43
|
var column = findExpressionColumn(expression, tables);
|
|
40
44
|
return String((column === null || column === void 0 ? void 0 : column.database_type) || expression.database_type || '').toUpperCase();
|
|
41
45
|
};
|
|
@@ -45,7 +49,8 @@ var normalizeExpressionRhs = function normalizeExpressionRhs(expression) {
|
|
|
45
49
|
};
|
|
46
50
|
var normalizeExpressionAtom = exports.normalizeExpressionAtom = function normalizeExpressionAtom(expression) {
|
|
47
51
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
48
|
-
var
|
|
52
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
53
|
+
var databaseType = getExpressionDatabaseType(expression, tables, filterCustomType);
|
|
49
54
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, expression), {}, {
|
|
50
55
|
lhs: expression.lhs || [],
|
|
51
56
|
rhs: normalizeExpressionRhs(expression),
|
|
@@ -55,6 +60,7 @@ var normalizeExpressionAtom = exports.normalizeExpressionAtom = function normali
|
|
|
55
60
|
var normalizeExpressionAtoms = exports.normalizeExpressionAtoms = function normalizeExpressionAtoms() {
|
|
56
61
|
var atoms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
57
62
|
var tables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
63
|
+
var filterCustomType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
58
64
|
var normalizeList = function normalizeList() {
|
|
59
65
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
60
66
|
return items.map(normalizeItem);
|
|
@@ -62,7 +68,7 @@ var normalizeExpressionAtoms = exports.normalizeExpressionAtoms = function norma
|
|
|
62
68
|
var normalizeItem = function normalizeItem(item) {
|
|
63
69
|
if (!item || (0, _typeof2["default"])(item) !== 'object') return item;
|
|
64
70
|
if (item.type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
65
|
-
var nextExpression = normalizeExpressionAtom(item, tables);
|
|
71
|
+
var nextExpression = normalizeExpressionAtom(item, tables, filterCustomType);
|
|
66
72
|
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, nextExpression), {}, {
|
|
67
73
|
lhs: normalizeList(nextExpression.lhs),
|
|
68
74
|
rhs: normalizeList(nextExpression.rhs)
|
|
@@ -111,6 +117,9 @@ var normalizeExpressionAtoms = exports.normalizeExpressionAtoms = function norma
|
|
|
111
117
|
};
|
|
112
118
|
var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldType, type, list, index) {
|
|
113
119
|
var temList = [];
|
|
120
|
+
var isInOperator = function isInOperator(operator) {
|
|
121
|
+
return ['in', 'not in'].includes(String(operator || '').toLowerCase());
|
|
122
|
+
};
|
|
114
123
|
var needChange = ['RANK()', 'DENSE_RANK()', 'ROW_NUMBER()', 'when', 'case', 'then'].includes(oldType);
|
|
115
124
|
if (needChange) {
|
|
116
125
|
return list;
|
|
@@ -197,10 +206,46 @@ var insertTemplateAt = exports.insertTemplateAt = function insertTemplateAt(oldT
|
|
|
197
206
|
type: _types.AtomsTypeEnum.OPERATOR
|
|
198
207
|
}];
|
|
199
208
|
}
|
|
209
|
+
if (isInOperator(type) && !isInOperator(oldType)) {
|
|
210
|
+
temList = [{
|
|
211
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
212
|
+
val: '('
|
|
213
|
+
}, {
|
|
214
|
+
type: _types.AtomsTypeEnum.INPUT_STRING,
|
|
215
|
+
val: ''
|
|
216
|
+
}, {
|
|
217
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
218
|
+
val: ','
|
|
219
|
+
}, {
|
|
220
|
+
type: _types.AtomsTypeEnum.INPUT_STRING,
|
|
221
|
+
val: ''
|
|
222
|
+
}, {
|
|
223
|
+
type: _types.AtomsTypeEnum.OPERATOR,
|
|
224
|
+
val: ')'
|
|
225
|
+
}];
|
|
226
|
+
}
|
|
200
227
|
list.splice.apply(list, [index + 1, 0].concat((0, _toConsumableArray2["default"])(temList)));
|
|
201
228
|
return list;
|
|
202
229
|
};
|
|
203
|
-
var operatorList = exports.operatorList = ['and', 'or', '(
|
|
230
|
+
var operatorList = exports.operatorList = ['and', 'or', '()', ',', '+', '-', '*', '/', '!', '!=', '<=', '>=', '<', '>', '=', 'case', 'when', 'then', 'else', 'end', 'NULL', 'DESC', 'ASC', 'OVER', 'PARTITION BY', 'ORDER BY', 'RANK()', 'DENSE_RANK()', 'ROW_NUMBER()'];
|
|
231
|
+
var normalizeOperatorList = exports.normalizeOperatorList = function normalizeOperatorList() {
|
|
232
|
+
var operators = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : operatorList;
|
|
233
|
+
var normalized = [];
|
|
234
|
+
var hasParentheses = false;
|
|
235
|
+
operators.forEach(function (operator) {
|
|
236
|
+
if (operator === '(' || operator === ')' || operator === '()') {
|
|
237
|
+
if (!hasParentheses) {
|
|
238
|
+
normalized.push('()');
|
|
239
|
+
hasParentheses = true;
|
|
240
|
+
}
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!normalized.includes(operator)) {
|
|
244
|
+
normalized.push(operator);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
return normalized;
|
|
248
|
+
};
|
|
204
249
|
var customTypes = exports.customTypes = [{
|
|
205
250
|
value: _types.AtomsTypeEnum.FIELD,
|
|
206
251
|
label: (0, _locale.__)('customColumn.field')
|
|
@@ -225,11 +270,11 @@ var customTypes = exports.customTypes = [{
|
|
|
225
270
|
}, {
|
|
226
271
|
value: _types.AtomsTypeEnum.OPERATOR,
|
|
227
272
|
label: (0, _locale.__)('customColumn.operator'),
|
|
228
|
-
children: operatorList
|
|
273
|
+
children: normalizeOperatorList(operatorList)
|
|
229
274
|
}, {
|
|
230
275
|
value: _types.AtomsTypeEnum.FORMULA,
|
|
231
276
|
label: (0, _locale.__)('customColumn.formula'),
|
|
232
|
-
children: operatorList
|
|
277
|
+
children: normalizeOperatorList(operatorList)
|
|
233
278
|
}, {
|
|
234
279
|
value: _types.AtomsTypeEnum.NOT_EXISTS,
|
|
235
280
|
label: 'NOT_EXISTS'
|
|
@@ -360,6 +405,7 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
360
405
|
return temItem;
|
|
361
406
|
};
|
|
362
407
|
var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
408
|
+
var allowEmptyInputString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
363
409
|
return rhsVal.every(function (v) {
|
|
364
410
|
if (v.type === _types.AtomsTypeEnum.UNKNOWN) {
|
|
365
411
|
return false;
|
|
@@ -369,36 +415,38 @@ var _isOk = exports.isOk = function isOk(rhsVal) {
|
|
|
369
415
|
return Boolean(v.fieldName);
|
|
370
416
|
} else if (v.type === _types.AtomsTypeEnum.EXPRESSION || v.type === _types.AtomsTypeEnum.EXISTS || v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.SUB_QUERY) {
|
|
371
417
|
return Boolean(v.quotes);
|
|
418
|
+
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING) {
|
|
419
|
+
return allowEmptyInputString ? typeof v.val === 'string' : Boolean(v.val);
|
|
372
420
|
} else if (v.type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
373
421
|
return Array.isArray(v.val) && v.val.every(function (vv) {
|
|
374
422
|
return Boolean(vv);
|
|
375
423
|
});
|
|
376
424
|
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
377
|
-
return _isOk(v.list || []);
|
|
425
|
+
return _isOk(v.list || [], allowEmptyInputString);
|
|
378
426
|
} else if (v.type === _types.AtomsTypeEnum.CASE_WHEN) {
|
|
379
427
|
return (v.whenClauses || []).length > 0 && (v.whenClauses || []).every(function (clause) {
|
|
380
|
-
return _isOk(clause.whenAtoms || []) && _isOk(clause.thenAtoms || []);
|
|
381
|
-
}) && _isOk(v.caseAtoms || []) && _isOk(v.elseAtoms || []);
|
|
428
|
+
return _isOk(clause.whenAtoms || [], allowEmptyInputString) && _isOk(clause.thenAtoms || [], allowEmptyInputString);
|
|
429
|
+
}) && _isOk(v.caseAtoms || [], allowEmptyInputString) && _isOk(v.elseAtoms || [], allowEmptyInputString);
|
|
382
430
|
} else if (v.type === _types.AtomsTypeEnum.AND_OR) {
|
|
383
431
|
if (Array.isArray(v.items) && v.items.length > 0) {
|
|
384
432
|
return v.items.every(function (item, index) {
|
|
385
433
|
var _item$atoms;
|
|
386
434
|
if (index > 0 && !item.operator) return false;
|
|
387
|
-
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || []);
|
|
435
|
+
return Boolean((_item$atoms = item.atoms) === null || _item$atoms === void 0 ? void 0 : _item$atoms.length) && _isOk(item.atoms || [], allowEmptyInputString);
|
|
388
436
|
});
|
|
389
437
|
}
|
|
390
438
|
var legacyItem = v;
|
|
391
439
|
var hasBinarySides = Array.isArray(legacyItem.leftAtoms) || Array.isArray(legacyItem.rightAtoms);
|
|
392
440
|
if (hasBinarySides) {
|
|
393
441
|
var _legacyItem$leftAtoms, _legacyItem$rightAtom;
|
|
394
|
-
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || []) && _isOk(legacyItem.rightAtoms || []);
|
|
442
|
+
return Boolean(legacyItem.operator) && Boolean((_legacyItem$leftAtoms = legacyItem.leftAtoms) === null || _legacyItem$leftAtoms === void 0 ? void 0 : _legacyItem$leftAtoms.length) && Boolean((_legacyItem$rightAtom = legacyItem.rightAtoms) === null || _legacyItem$rightAtom === void 0 ? void 0 : _legacyItem$rightAtom.length) && _isOk(legacyItem.leftAtoms || [], allowEmptyInputString) && _isOk(legacyItem.rightAtoms || [], allowEmptyInputString);
|
|
395
443
|
}
|
|
396
|
-
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || []);
|
|
444
|
+
return Boolean(legacyItem.operator) && _isOk(legacyItem.atoms || [], allowEmptyInputString);
|
|
397
445
|
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
398
446
|
if (!v.quotes) {
|
|
399
447
|
return false;
|
|
400
448
|
}
|
|
401
|
-
return _isOk(v.args || []);
|
|
449
|
+
return _isOk(v.args || [], true);
|
|
402
450
|
} else if (v.type === _types.AtomsTypeEnum.SELECT) {
|
|
403
451
|
return Array.isArray(v.val) ? v.val.length > 0 : Boolean(v.val);
|
|
404
452
|
} else {
|
|
@@ -22,6 +22,7 @@ var _icons = require("../../icons");
|
|
|
22
22
|
var _useProvider = require("../../../hooks/use-provider");
|
|
23
23
|
var _helper = require("../../../utils/helper");
|
|
24
24
|
var _utils = require("../../../utils");
|
|
25
|
+
var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
|
|
25
26
|
var SelectColumn = function SelectColumn(_ref) {
|
|
26
27
|
var _ref$data = _ref.data,
|
|
27
28
|
data = _ref$data === void 0 ? [] : _ref$data,
|
|
@@ -233,7 +234,12 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
233
234
|
children: (0, _jsxRuntime.jsx)(_icons.SelectIcon, {})
|
|
234
235
|
}) : (0, _jsxRuntime.jsx)("div", {
|
|
235
236
|
className: 'no-select mr-2'
|
|
236
|
-
}),
|
|
237
|
+
}), (0, _jsxRuntime.jsxs)("span", {
|
|
238
|
+
className: 'Sqb-SelectColumn-name',
|
|
239
|
+
children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
240
|
+
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
241
|
+
column: v
|
|
242
|
+
}), store.fieldEnableAlias && !readonly && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
237
243
|
title: (0, _locale.__)('SqlQueryBuilder.alias'),
|
|
238
244
|
children: (0, _jsxRuntime.jsx)(_pandora.Button, {
|
|
239
245
|
className: ':Sqb-TableName-as',
|
|
@@ -37,9 +37,14 @@
|
|
|
37
37
|
}
|
|
38
38
|
.Sqb-TableName-as {
|
|
39
39
|
// font-size: 16px;
|
|
40
|
-
margin-left:
|
|
40
|
+
margin-left: 8px;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
.Sqb-SelectColumn-name {
|
|
44
|
+
flex: 1 1 auto;
|
|
45
|
+
min-width: 0;
|
|
46
|
+
overflow-wrap: anywhere;
|
|
47
|
+
}
|
|
43
48
|
.Sqb-SelectColumn--header {
|
|
44
49
|
position: sticky;
|
|
45
50
|
top: 0;
|
|
@@ -20,6 +20,7 @@ var _helper = require("../../../store/helper");
|
|
|
20
20
|
var _types = require("../../../store/types");
|
|
21
21
|
var _locale = require("../../../locale");
|
|
22
22
|
var _const = require("../const");
|
|
23
|
+
var _columnTypeLabel = _interopRequireDefault(require("../column-type-label"));
|
|
23
24
|
var _useProvider = require("../../../hooks/use-provider");
|
|
24
25
|
var _helper2 = require("../../../utils/helper");
|
|
25
26
|
var _icons = require("../../icons");
|
|
@@ -271,9 +272,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
271
272
|
return matchedColumn ? syncSelectedFieldByColumn(field, matchedColumn, tableItem) : field;
|
|
272
273
|
});
|
|
273
274
|
setValue(syncedValue);
|
|
274
|
-
if (!readonly && !(0, _isEqual["default"])(syncedValue, _value || [])) {
|
|
275
|
-
|
|
276
|
-
(_ref2 = onValueSync || onSelect) === null || _ref2 === void 0 || _ref2(syncedValue, getQuotes(syncedValue));
|
|
275
|
+
if (!readonly && onValueSync && !(0, _isEqual["default"])(syncedValue, _value || [])) {
|
|
276
|
+
onValueSync(syncedValue, getQuotes(syncedValue));
|
|
277
277
|
}
|
|
278
278
|
}, [data, _value, onValueSync]);
|
|
279
279
|
var changeValue = function changeValue(tableUuid, val) {
|
|
@@ -509,11 +509,14 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
509
509
|
children: [(0, _jsxRuntime.jsx)("span", {
|
|
510
510
|
className: 'List-item-icon',
|
|
511
511
|
children: IconMap[special_type || database_type] || (0, _jsxRuntime.jsx)(_icons.LetterAaIcon, {})
|
|
512
|
-
}), (0, _jsxRuntime.
|
|
513
|
-
|
|
512
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
513
|
+
className: 'List-item-content',
|
|
514
|
+
children: [(0, _jsxRuntime.jsxs)("h4", {
|
|
514
515
|
className: 'List-item-title ml-2',
|
|
515
516
|
children: [(0, _helper2.replaceTpl)(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
516
|
-
})
|
|
517
|
+
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
518
|
+
column: v
|
|
519
|
+
})]
|
|
517
520
|
})]
|
|
518
521
|
})
|
|
519
522
|
})
|