@gingkoo/pandora-metabase 1.0.158-alpha.21 → 1.0.158-alpha.24
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/expression/index.js +23 -14
- package/lib/cjs/components/dialog/formula-list/index.js +24 -17
- package/lib/cjs/components/dialog/select-column/index.js +2 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +2 -1
- package/lib/cjs/components/dialog/select-join-column/index.js +2 -1
- package/lib/cjs/components/dialog/select-join-column-multiple/index.js +2 -1
- package/lib/cjs/components/metabase/index.js +18 -2
- package/lib/cjs/components/metabase/index.less +13 -0
- package/lib/cjs/components/modules/join-data.js +16 -9
- package/lib/cjs/components/modules/sort.js +5 -1
- package/lib/cjs/components/modules/summarize/group-by.js +7 -1
- package/lib/cjs/components/modules/summarize/select-index.js +7 -1
- package/lib/cjs/components/modules/table-data.js +4 -2
- package/lib/cjs/hooks/use-state.js +114 -63
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/locale/en.js +2 -0
- package/lib/cjs/locale/zh.js +2 -0
- package/lib/cjs/types.d.ts +5 -0
- package/lib/cjs/utils/helper.d.ts +1 -0
- package/lib/cjs/utils/helper.js +9 -1
- package/lib/cjs/utils.d.ts +12 -1
- package/lib/cjs/utils.js +171 -29
- package/lib/es/components/dialog/expression/index.js +12 -3
- package/lib/es/components/dialog/formula-list/index.js +25 -18
- package/lib/es/components/dialog/select-column/index.js +3 -2
- package/lib/es/components/dialog/select-column-multiple/index.js +3 -2
- package/lib/es/components/dialog/select-join-column/index.js +3 -2
- package/lib/es/components/dialog/select-join-column-multiple/index.js +3 -2
- package/lib/es/components/metabase/index.js +19 -3
- package/lib/es/components/metabase/index.less +13 -0
- package/lib/es/components/modules/join-data.js +17 -10
- package/lib/es/components/modules/sort.js +6 -2
- package/lib/es/components/modules/summarize/group-by.js +8 -2
- package/lib/es/components/modules/summarize/select-index.js +8 -2
- package/lib/es/components/modules/table-data.js +4 -2
- package/lib/es/hooks/use-state.js +114 -63
- package/lib/es/index.js +15 -1
- package/lib/es/locale/en.js +2 -0
- package/lib/es/locale/zh.js +2 -0
- package/lib/es/types.d.ts +5 -0
- package/lib/es/utils/helper.d.ts +1 -0
- package/lib/es/utils/helper.js +8 -0
- package/lib/es/utils.d.ts +12 -1
- package/lib/es/utils.js +169 -27
- package/package.json +1 -1
|
@@ -25,8 +25,9 @@ var _selectList = _interopRequireDefault(require("../select-list"));
|
|
|
25
25
|
var _selectColumnMultiple = _interopRequireDefault(require("../select-column-multiple"));
|
|
26
26
|
var _icons = require("../../icons");
|
|
27
27
|
var _useProvider = require("../../../hooks/use-provider");
|
|
28
|
+
var _utils = require("../../../utils");
|
|
28
29
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
29
|
-
var
|
|
30
|
+
var _utils2 = require("../formula-list/utils");
|
|
30
31
|
var _itemName = _interopRequireDefault(require("../../modules/components/item-name"));
|
|
31
32
|
var _dateFormatPicker = require("./date-format-picker");
|
|
32
33
|
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); }
|
|
@@ -76,7 +77,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
76
77
|
_ref$filterCustomType = _ref.filterCustomType,
|
|
77
78
|
filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
|
|
78
79
|
parentPopupChannel = _ref.parentPopupChannel;
|
|
79
|
-
var normalizedInitialValue = (0,
|
|
80
|
+
var normalizedInitialValue = (0, _utils2.normalizeExpressionAtom)(value, data, filterCustomType);
|
|
80
81
|
var _useState = (0, _react.useState)(normalizedInitialValue),
|
|
81
82
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
82
83
|
curColumn = _useState2[0],
|
|
@@ -98,6 +99,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
98
99
|
formula = _useState0[0],
|
|
99
100
|
setFormula = _useState0[1];
|
|
100
101
|
var store = (0, _useProvider.useStore)();
|
|
102
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
101
103
|
var _useState1 = (0, _react.useState)(false),
|
|
102
104
|
_useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
|
|
103
105
|
popupVisible = _useState10[0],
|
|
@@ -151,7 +153,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
151
153
|
if (~['无需结果'].indexOf(condition)) {
|
|
152
154
|
return false;
|
|
153
155
|
}
|
|
154
|
-
if (
|
|
156
|
+
if (_utils2.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
155
157
|
return false;
|
|
156
158
|
}
|
|
157
159
|
if (!rhsVal.length) return true;
|
|
@@ -175,9 +177,13 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
175
177
|
didUpdate === null || didUpdate === void 0 || didUpdate();
|
|
176
178
|
}, [condition]);
|
|
177
179
|
var getAtomsQuotesName = function getAtomsQuotesName(items) {
|
|
180
|
+
var withAlias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
178
181
|
var names = items.map(function (v) {
|
|
179
182
|
if ((v === null || v === void 0 ? void 0 : v.type) === _types.AtomsTypeEnum.FIELD) {
|
|
180
|
-
return
|
|
183
|
+
return withAlias ? (0, _utils.getAtomDisplayText)(v, {
|
|
184
|
+
withTableAlias: true,
|
|
185
|
+
tables: data
|
|
186
|
+
}) : getFieldDisplayName(v);
|
|
181
187
|
} else {
|
|
182
188
|
return v.val;
|
|
183
189
|
}
|
|
@@ -222,7 +228,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
222
228
|
}[v];
|
|
223
229
|
};
|
|
224
230
|
function generateQuotes(val, curColumn) {
|
|
225
|
-
if (
|
|
231
|
+
if (_utils2.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
226
232
|
var lhsName = getQuotesName(curColumn.lhs);
|
|
227
233
|
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
228
234
|
if (_locale.isEn) {
|
|
@@ -327,8 +333,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
327
333
|
}
|
|
328
334
|
function addFilter() {
|
|
329
335
|
if (disabled) return void 0;
|
|
330
|
-
var databaseType = filterCustomType ? special_type : (0,
|
|
331
|
-
var nextExpression = (0,
|
|
336
|
+
var databaseType = filterCustomType ? special_type : (0, _utils2.normalizeExpressionAtom)(curColumn, data).database_type;
|
|
337
|
+
var nextExpression = (0, _utils2.normalizeExpressionAtom)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, curColumn), {}, {
|
|
332
338
|
formula: formula,
|
|
333
339
|
rhs: rhsVal,
|
|
334
340
|
condition: condition,
|
|
@@ -373,7 +379,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
373
379
|
};
|
|
374
380
|
}
|
|
375
381
|
function renderFilter(type, conditionText) {
|
|
376
|
-
if (
|
|
382
|
+
if (_utils2.EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
377
383
|
return null;
|
|
378
384
|
}
|
|
379
385
|
var _val = rhsVal[0];
|
|
@@ -658,7 +664,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
658
664
|
closePopup2();
|
|
659
665
|
var newVal = rhsVal.slice();
|
|
660
666
|
newVal[0].id = val;
|
|
661
|
-
newVal[0].val = (0,
|
|
667
|
+
newVal[0].val = (0, _utils2.getConstantLabel)(store.constantList, val);
|
|
662
668
|
setRhsVal(newVal);
|
|
663
669
|
setParentClosable(true);
|
|
664
670
|
}
|
|
@@ -809,7 +815,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
809
815
|
};
|
|
810
816
|
var getName = function getName(items) {
|
|
811
817
|
var _formula$params3, _formula$params4;
|
|
812
|
-
var names = getAtomsQuotesName(items);
|
|
818
|
+
var names = getAtomsQuotesName(items, showFieldTableAlias);
|
|
813
819
|
switch (formula.type) {
|
|
814
820
|
case 'SUBSTR':
|
|
815
821
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
@@ -915,7 +921,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
915
921
|
className: 'content',
|
|
916
922
|
children: [rhsVal === null || rhsVal === void 0 ? void 0 : rhsVal.map(function (v, i) {
|
|
917
923
|
if (v.type === _types.AtomsTypeEnum.FIELD) {
|
|
918
|
-
var displayName =
|
|
924
|
+
var displayName = showFieldTableAlias ? (0, _utils.getAtomDisplayText)(v, {
|
|
925
|
+
withTableAlias: true,
|
|
926
|
+
tables: data
|
|
927
|
+
}) : getFieldDisplayName(v);
|
|
919
928
|
return (0, _jsxRuntime.jsx)("div", {
|
|
920
929
|
className: (0, _classnames["default"])("Sqb-TableName purple-name", {
|
|
921
930
|
notSelected: !displayName
|
|
@@ -927,7 +936,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
927
936
|
}
|
|
928
937
|
if (v.type === _types.AtomsTypeEnum.CONSTANT) {
|
|
929
938
|
return (0, _jsxRuntime.jsx)(_itemName["default"], {
|
|
930
|
-
isError: !!(v.id || v.val) && !(0,
|
|
939
|
+
isError: !!(v.id || v.val) && !(0, _utils2.getConstantLabel)(store.constantList, v.id || v.val),
|
|
931
940
|
message: "\u5E38\u91CF\u4E22\u5931",
|
|
932
941
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
933
942
|
className: (0, _classnames["default"])("Sqb-TableName purple-name", {
|
|
@@ -935,7 +944,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
935
944
|
}),
|
|
936
945
|
"v-val": v.id || v.val,
|
|
937
946
|
onClick: selectConstant,
|
|
938
|
-
children: (0,
|
|
947
|
+
children: (0, _utils2.getConstantLabel)(store.constantList, v.id || v.val, v.val) || (0, _locale.__)('SqlQueryBuilder.pickConstant')
|
|
939
948
|
}, i)
|
|
940
949
|
}, i);
|
|
941
950
|
}
|
|
@@ -1018,7 +1027,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
1018
1027
|
setIsNext(true);
|
|
1019
1028
|
},
|
|
1020
1029
|
onSelect: function onSelect(fields, quotes) {
|
|
1021
|
-
setCurColumn((0,
|
|
1030
|
+
setCurColumn((0, _utils2.normalizeExpressionAtom)((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, curColumn), {}, {
|
|
1022
1031
|
lhs: fields
|
|
1023
1032
|
}), data, filterCustomType));
|
|
1024
1033
|
setIsNext(true);
|
|
@@ -902,6 +902,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
902
902
|
};
|
|
903
903
|
}, []);
|
|
904
904
|
var store = (0, _useProvider.useStore)();
|
|
905
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
905
906
|
var snapshotMode = Boolean(store.snapshotMode);
|
|
906
907
|
var _props$value = props.value,
|
|
907
908
|
value = _props$value === void 0 ? [] : _props$value,
|
|
@@ -2712,7 +2713,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2712
2713
|
};
|
|
2713
2714
|
};
|
|
2714
2715
|
var showNotExists = function showNotExists(i) {
|
|
2715
|
-
var _caseList$i, _caseList$i2;
|
|
2716
|
+
var _caseList$i, _caseList$i2, _store$preProps4;
|
|
2716
2717
|
var _store$preProps3 = store.preProps,
|
|
2717
2718
|
notExistsToolbar = _store$preProps3.notExistsToolbar,
|
|
2718
2719
|
toolbar = _store$preProps3.toolbar,
|
|
@@ -2727,6 +2728,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2727
2728
|
transparentMask: false,
|
|
2728
2729
|
content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
2729
2730
|
children: (0, _jsxRuntime.jsx)(_index2["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
2731
|
+
showFieldTableAliasController: ((_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
2730
2732
|
popupZIndex: childModalZIndex + 1,
|
|
2731
2733
|
readonly: snapshotMode,
|
|
2732
2734
|
snapshotMode: snapshotMode,
|
|
@@ -2742,14 +2744,14 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2742
2744
|
return;
|
|
2743
2745
|
}
|
|
2744
2746
|
try {
|
|
2745
|
-
var _store$
|
|
2747
|
+
var _store$preProps5;
|
|
2746
2748
|
if ((0, _isEqual["default"])(newList, oldList)) {
|
|
2747
2749
|
o.close();
|
|
2748
2750
|
return;
|
|
2749
2751
|
}
|
|
2750
2752
|
var expression = {
|
|
2751
2753
|
notExists: (0, _cloneDeep["default"])(newList),
|
|
2752
|
-
quotes: (0, _utils2.buildSqlQuery)(newList, caseList[i].type, (_store$
|
|
2754
|
+
quotes: (0, _utils2.buildSqlQuery)(newList, caseList[i].type, (_store$preProps5 = store.preProps) === null || _store$preProps5 === void 0 ? void 0 : _store$preProps5.sqlDialect),
|
|
2753
2755
|
type: caseList[i].type
|
|
2754
2756
|
};
|
|
2755
2757
|
caseList[i] = expression;
|
|
@@ -2765,14 +2767,14 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2765
2767
|
});
|
|
2766
2768
|
};
|
|
2767
2769
|
var showSubQuery = function showSubQuery(i) {
|
|
2768
|
-
var _caseList$i3, _caseList$i4;
|
|
2769
|
-
var _store$
|
|
2770
|
-
subToolbar = _store$
|
|
2771
|
-
notExistsColumns = _store$
|
|
2772
|
-
showFields = _store$
|
|
2773
|
-
isExit = _store$
|
|
2774
|
-
toolbar = _store$
|
|
2775
|
-
other = (0, _objectWithoutProperties2["default"])(_store$
|
|
2770
|
+
var _caseList$i3, _caseList$i4, _store$preProps7;
|
|
2771
|
+
var _store$preProps6 = store.preProps,
|
|
2772
|
+
subToolbar = _store$preProps6.subToolbar,
|
|
2773
|
+
notExistsColumns = _store$preProps6.notExistsColumns,
|
|
2774
|
+
showFields = _store$preProps6.showFields,
|
|
2775
|
+
isExit = _store$preProps6.isExit,
|
|
2776
|
+
toolbar = _store$preProps6.toolbar,
|
|
2777
|
+
other = (0, _objectWithoutProperties2["default"])(_store$preProps6, _excluded3);
|
|
2776
2778
|
var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
|
|
2777
2779
|
var oldList = (0, _cloneDeep["default"])(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
|
|
2778
2780
|
var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
|
|
@@ -2783,6 +2785,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2783
2785
|
transparentMask: false,
|
|
2784
2786
|
content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
2785
2787
|
children: (0, _jsxRuntime.jsx)(_index2["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
2788
|
+
showFieldTableAliasController: ((_store$preProps7 = store.preProps) === null || _store$preProps7 === void 0 ? void 0 : _store$preProps7.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
2786
2789
|
popupZIndex: childModalZIndex + 1,
|
|
2787
2790
|
readonly: snapshotMode,
|
|
2788
2791
|
snapshotMode: snapshotMode,
|
|
@@ -2801,14 +2804,14 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2801
2804
|
return;
|
|
2802
2805
|
}
|
|
2803
2806
|
try {
|
|
2804
|
-
var _store$
|
|
2807
|
+
var _store$preProps8;
|
|
2805
2808
|
if ((0, _isEqual["default"])(newList, oldList)) {
|
|
2806
2809
|
o.close();
|
|
2807
2810
|
return;
|
|
2808
2811
|
}
|
|
2809
2812
|
var expression = {
|
|
2810
2813
|
subQuery: (0, _cloneDeep["default"])(newList),
|
|
2811
|
-
quotes: (0, _utils2.buildSqlQuery)(newList, caseList[i].type, (_store$
|
|
2814
|
+
quotes: (0, _utils2.buildSqlQuery)(newList, caseList[i].type, (_store$preProps8 = store.preProps) === null || _store$preProps8 === void 0 ? void 0 : _store$preProps8.sqlDialect),
|
|
2812
2815
|
type: caseList[i].type
|
|
2813
2816
|
};
|
|
2814
2817
|
caseList[i] = expression;
|
|
@@ -2900,7 +2903,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
2900
2903
|
};
|
|
2901
2904
|
}
|
|
2902
2905
|
if (type === _types.AtomsTypeEnum.FIELD) {
|
|
2903
|
-
var displayName =
|
|
2906
|
+
var displayName = showFieldTableAlias ? (0, _utils2.getAtomDisplayText)(v, {
|
|
2907
|
+
withTableAlias: true,
|
|
2908
|
+
tables: data
|
|
2909
|
+
}) : getFieldDisplayName(v);
|
|
2904
2910
|
return {
|
|
2905
2911
|
className: (0, _classnames["default"])({
|
|
2906
2912
|
notSelected: !displayName
|
|
@@ -3047,6 +3053,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
3047
3053
|
}
|
|
3048
3054
|
if (type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
3049
3055
|
var quotes = (0, _utils2.getAtomDisplayText)(v);
|
|
3056
|
+
var displayQuotes = showFieldTableAlias ? (0, _utils2.aliasDisplayText)(quotes, [v], true, data) || quotes : quotes;
|
|
3050
3057
|
if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
3051
3058
|
var _getAtomDisplayText$s;
|
|
3052
3059
|
var nextList = caseList.slice();
|
|
@@ -3056,13 +3063,13 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
3056
3063
|
}
|
|
3057
3064
|
return {
|
|
3058
3065
|
className: (0, _classnames["default"])('purple-name', {
|
|
3059
|
-
notSelected: !
|
|
3066
|
+
notSelected: !displayQuotes
|
|
3060
3067
|
}),
|
|
3061
3068
|
onClick: function onClick(e) {
|
|
3062
3069
|
return handleExpression(e, index, v);
|
|
3063
3070
|
},
|
|
3064
3071
|
node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
3065
|
-
children: [
|
|
3072
|
+
children: [displayQuotes || (0, _locale.__)('customColumn.selectExpression'), renderDeleteIcon(v, index, groupType)]
|
|
3066
3073
|
})
|
|
3067
3074
|
};
|
|
3068
3075
|
}
|
|
@@ -3085,7 +3092,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
3085
3092
|
return showFunction(e, index);
|
|
3086
3093
|
},
|
|
3087
3094
|
node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
3088
|
-
children: [v.name ? (0, _utils.getQuotes)(v, v.args, formulaList) : (0, _locale.__)('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
|
|
3095
|
+
children: [v.name ? showFieldTableAlias ? (0, _utils2.aliasDisplayText)((0, _utils.getQuotes)(v, v.args, formulaList), [v], true, data) : (0, _utils.getQuotes)(v, v.args, formulaList) : (0, _locale.__)('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
|
|
3089
3096
|
})
|
|
3090
3097
|
};
|
|
3091
3098
|
}
|
|
@@ -45,6 +45,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
45
45
|
originList = _useState4[0],
|
|
46
46
|
setOriginList = _useState4[1];
|
|
47
47
|
var store = (0, _useProvider.useStore)();
|
|
48
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
48
49
|
var _useState5 = (0, _react.useState)(''),
|
|
49
50
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
50
51
|
filterVal = _useState6[0],
|
|
@@ -236,7 +237,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
236
237
|
className: 'no-select mr-2'
|
|
237
238
|
}), (0, _jsxRuntime.jsxs)("span", {
|
|
238
239
|
className: 'Sqb-SelectColumn-name',
|
|
239
|
-
children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
240
|
+
children: [(0, _helper.prefixFieldTableAlias)(v.name, table === null || table === void 0 ? void 0 : table.alias, showFieldTableAlias), v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
240
241
|
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
241
242
|
column: v
|
|
242
243
|
}), store.fieldEnableAlias && !readonly && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
@@ -61,6 +61,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
61
61
|
_ref$readonly = _ref.readonly,
|
|
62
62
|
readonly = _ref$readonly === void 0 ? false : _ref$readonly;
|
|
63
63
|
var store = (0, _useProvider.useStore)();
|
|
64
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
64
65
|
var selectedTableUuid = (_value === null || _value === void 0 || (_value$ = _value[0]) === null || _value$ === void 0 ? void 0 : _value$.tableId) === _helper.SummarizeAlias ? '' : (_value === null || _value === void 0 || (_value$2 = _value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.tableUuid) || '';
|
|
65
66
|
var _useState = (0, _react.useState)(_value),
|
|
66
67
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -513,7 +514,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
513
514
|
className: 'List-item-content',
|
|
514
515
|
children: [(0, _jsxRuntime.jsxs)("h4", {
|
|
515
516
|
className: 'List-item-title ml-2',
|
|
516
|
-
children: [(0, _helper2.replaceTpl)(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
517
|
+
children: [(0, _helper2.prefixFieldTableAlias)((0, _helper2.replaceTpl)(store.fieldNameTpl, v), tableAlias, showFieldTableAlias), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
517
518
|
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
518
519
|
column: v
|
|
519
520
|
})]
|
|
@@ -49,6 +49,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
49
49
|
_ref$multiple = _ref.multiple,
|
|
50
50
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple;
|
|
51
51
|
var store = (0, _useProvider.useStore)();
|
|
52
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
52
53
|
var _useState = (0, _react.useState)(_value),
|
|
53
54
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
54
55
|
value = _useState2[0],
|
|
@@ -320,7 +321,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
320
321
|
className: 'List-item-content',
|
|
321
322
|
children: [(0, _jsxRuntime.jsx)("h4", {
|
|
322
323
|
className: 'List-item-title ml-2',
|
|
323
|
-
children: (0, _helper2.replaceTpl)(store.fieldNameTpl, v)
|
|
324
|
+
children: (0, _helper2.prefixFieldTableAlias)((0, _helper2.replaceTpl)(store.fieldNameTpl, v), tableAlias, showFieldTableAlias)
|
|
324
325
|
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
325
326
|
column: v
|
|
326
327
|
})]
|
|
@@ -50,6 +50,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
50
50
|
_ref$multiple = _ref.multiple,
|
|
51
51
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple;
|
|
52
52
|
var store = (0, _useProvider.useStore)();
|
|
53
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
53
54
|
var _useState = (0, _react.useState)(_value),
|
|
54
55
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
55
56
|
value = _useState2[0],
|
|
@@ -256,7 +257,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
256
257
|
className: 'List-item-content',
|
|
257
258
|
children: [(0, _jsxRuntime.jsx)("h4", {
|
|
258
259
|
className: 'List-item-title ml-2',
|
|
259
|
-
children: (0, _helper2.replaceTpl)(store.fieldNameTpl, v)
|
|
260
|
+
children: (0, _helper2.prefixFieldTableAlias)((0, _helper2.replaceTpl)(store.fieldNameTpl, v), tableAlias, showFieldTableAlias)
|
|
260
261
|
}), (0, _jsxRuntime.jsx)(_columnTypeLabel["default"], {
|
|
261
262
|
column: v
|
|
262
263
|
})]
|
|
@@ -95,6 +95,7 @@ var Metabase = function Metabase(props) {
|
|
|
95
95
|
_props$sqlValidationQ = props.sqlValidationQueryKind,
|
|
96
96
|
sqlValidationQueryKind = _props$sqlValidationQ === void 0 ? 'query' : _props$sqlValidationQ;
|
|
97
97
|
var store = (0, _useProvider.useStore)();
|
|
98
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
98
99
|
var readonlyMode = readonly || store.snapshotMode;
|
|
99
100
|
var _useState = (0, _react.useState)(false),
|
|
100
101
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
@@ -330,9 +331,24 @@ var Metabase = function Metabase(props) {
|
|
|
330
331
|
},
|
|
331
332
|
children: (0, _jsxRuntime.jsxs)("div", {
|
|
332
333
|
className: 'Sqb',
|
|
333
|
-
children: [(0, _jsxRuntime.
|
|
334
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
334
335
|
className: 'Sqb-fun-btns',
|
|
335
|
-
children:
|
|
336
|
+
children: [(0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
337
|
+
title: (0, _locale.__)('SqlQueryBuilder.showFieldTableAliasTip'),
|
|
338
|
+
children: (0, _jsxRuntime.jsxs)("span", {
|
|
339
|
+
className: 'Sqb-field-alias-switch',
|
|
340
|
+
"data-sqb-snapshot-allow": 'true',
|
|
341
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
342
|
+
children: (0, _locale.__)('SqlQueryBuilder.showFieldTableAlias')
|
|
343
|
+
}), (0, _jsxRuntime.jsx)(_pandora.Switch, {
|
|
344
|
+
size: 'small',
|
|
345
|
+
checked: showFieldTableAlias,
|
|
346
|
+
onChange: function onChange(value) {
|
|
347
|
+
return store.setShowFieldTableAlias(Boolean(value));
|
|
348
|
+
}
|
|
349
|
+
})]
|
|
350
|
+
})
|
|
351
|
+
}), copy()]
|
|
336
352
|
}), store.metaList.map(function (v, index) {
|
|
337
353
|
var _v$list;
|
|
338
354
|
if (v.type === 'union' && v.union) {
|
|
@@ -60,7 +60,20 @@
|
|
|
60
60
|
left: var(--sqb-padding-x);
|
|
61
61
|
display: flex;
|
|
62
62
|
justify-content: flex-end;
|
|
63
|
+
align-items: center;
|
|
63
64
|
width: auto;
|
|
65
|
+
z-index: 4;
|
|
66
|
+
}
|
|
67
|
+
&-field-alias-switch {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 6px;
|
|
71
|
+
margin-right: 12px;
|
|
72
|
+
color: #4e5969;
|
|
73
|
+
font-size: 12px;
|
|
74
|
+
line-height: 20px;
|
|
75
|
+
white-space: nowrap;
|
|
76
|
+
user-select: none;
|
|
64
77
|
}
|
|
65
78
|
&-list {
|
|
66
79
|
padding-top: 1.5rem;
|
|
@@ -79,6 +79,7 @@ var JoinData = function JoinData(props) {
|
|
|
79
79
|
var meta = props.meta,
|
|
80
80
|
groupIndex = props.groupIndex;
|
|
81
81
|
var store = (0, _useProvider.useStore)();
|
|
82
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
82
83
|
var filterCustomType = store.filterCustomType;
|
|
83
84
|
var metaKey = meta.metaKey;
|
|
84
85
|
var index = (0, _utils2.findIndex)(store.metaList[groupIndex].list, meta);
|
|
@@ -1016,6 +1017,7 @@ var JoinData = function JoinData(props) {
|
|
|
1016
1017
|
store.setMeta(newMeta, groupIndex);
|
|
1017
1018
|
}
|
|
1018
1019
|
var showSubQuery = function showSubQuery() {
|
|
1020
|
+
var _store$preProps3;
|
|
1019
1021
|
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1020
1022
|
var _store$preProps2 = store.preProps,
|
|
1021
1023
|
subToolbar = _store$preProps2.subToolbar,
|
|
@@ -1033,6 +1035,7 @@ var JoinData = function JoinData(props) {
|
|
|
1033
1035
|
transparentMask: true,
|
|
1034
1036
|
content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1035
1037
|
children: (0, _jsxRuntime.jsx)(_index["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
1038
|
+
showFieldTableAliasController: ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
1036
1039
|
popupZIndex: childModalZIndex + 1,
|
|
1037
1040
|
showSubquery: store._showSubquery,
|
|
1038
1041
|
isExit: isExit,
|
|
@@ -1044,10 +1047,10 @@ var JoinData = function JoinData(props) {
|
|
|
1044
1047
|
value: (0, _cloneDeep["default"])(val),
|
|
1045
1048
|
onOk: function onOk(newList) {
|
|
1046
1049
|
try {
|
|
1047
|
-
var _store$
|
|
1050
|
+
var _store$preProps4;
|
|
1048
1051
|
newMeta[index].subquery = newList;
|
|
1049
1052
|
newMeta[index].table2 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, newList[0].table), {}, {
|
|
1050
|
-
alias: newMeta[index].table2.alias || (0, _helper.getAlias)(newList[0].table.name, newMeta, ((_store$
|
|
1053
|
+
alias: newMeta[index].table2.alias || (0, _helper.getAlias)(newList[0].table.name, newMeta, ((_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.notExistsColumns) || []),
|
|
1051
1054
|
tableUuid: newMeta[index].table2.tableUuid || (0, _helper.uuidv4)('table')
|
|
1052
1055
|
});
|
|
1053
1056
|
var items = (0, _utils2.getSubColumns)(newList);
|
|
@@ -1282,7 +1285,10 @@ var JoinData = function JoinData(props) {
|
|
|
1282
1285
|
"v-index2": index,
|
|
1283
1286
|
onClick: selectMoreJoinColumn,
|
|
1284
1287
|
children: (_items$3 = items[0]) !== null && _items$3 !== void 0 && _items$3.fieldName ? items.map(function (field) {
|
|
1285
|
-
return field
|
|
1288
|
+
return showFieldTableAlias ? (0, _utils2.getAtomDisplayText)(field, {
|
|
1289
|
+
withTableAlias: true,
|
|
1290
|
+
tables: getTableColumns()
|
|
1291
|
+
}) : field.fieldName;
|
|
1286
1292
|
}).join(' || ') : (0, _locale.__)('SqlQueryBuilder.pickTable')
|
|
1287
1293
|
})
|
|
1288
1294
|
})
|
|
@@ -1351,8 +1357,8 @@ var JoinData = function JoinData(props) {
|
|
|
1351
1357
|
}
|
|
1352
1358
|
};
|
|
1353
1359
|
var tableIsError = function tableIsError() {
|
|
1354
|
-
var _store$
|
|
1355
|
-
var aliass = ((_store$
|
|
1360
|
+
var _store$preProps5, _meta$table2;
|
|
1361
|
+
var aliass = ((_store$preProps5 = store.preProps) === null || _store$preProps5 === void 0 || (_store$preProps5 = _store$preProps5.notExistsColumns) === null || _store$preProps5 === void 0 ? void 0 : _store$preProps5.map(function (v) {
|
|
1356
1362
|
return v.alias;
|
|
1357
1363
|
})) || [];
|
|
1358
1364
|
var tableAlias = (_meta$table2 = meta.table2) === null || _meta$table2 === void 0 ? void 0 : _meta$table2.alias;
|
|
@@ -1620,6 +1626,7 @@ var JoinData = function JoinData(props) {
|
|
|
1620
1626
|
}, i);
|
|
1621
1627
|
}
|
|
1622
1628
|
if (v.type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
1629
|
+
var expressionText = showFieldTableAlias ? (0, _utils2.aliasDisplayText)(v.quotes || '', [v], true, getTableColumns()) || v.quotes : v.quotes;
|
|
1623
1630
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
1624
1631
|
className: (0, _classnames["default"])("Sqb-where block"),
|
|
1625
1632
|
children: [i == 0 && (0, _jsxRuntime.jsx)("span", {
|
|
@@ -1631,12 +1638,12 @@ var JoinData = function JoinData(props) {
|
|
|
1631
1638
|
value: v,
|
|
1632
1639
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
1633
1640
|
className: (0, _classnames["default"])("Sqb-TableName purple-name", {
|
|
1634
|
-
notSelected: !
|
|
1641
|
+
notSelected: !expressionText
|
|
1635
1642
|
}),
|
|
1636
1643
|
onClick: function onClick(e) {
|
|
1637
1644
|
return changeExpression(e, i);
|
|
1638
1645
|
},
|
|
1639
|
-
children:
|
|
1646
|
+
children: expressionText || (0, _locale.__)('joinData.selectExpression')
|
|
1640
1647
|
}, i)
|
|
1641
1648
|
})
|
|
1642
1649
|
}), !store.snapshotMode && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
|
|
@@ -1670,7 +1677,7 @@ var JoinData = function JoinData(props) {
|
|
|
1670
1677
|
}, i);
|
|
1671
1678
|
}
|
|
1672
1679
|
if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
1673
|
-
var _store$
|
|
1680
|
+
var _store$preProps6;
|
|
1674
1681
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
1675
1682
|
className: (0, _classnames["default"])(" Sqb-collection-box"),
|
|
1676
1683
|
children: [i == 0 && (0, _jsxRuntime.jsx)("span", {
|
|
@@ -1678,7 +1685,7 @@ var JoinData = function JoinData(props) {
|
|
|
1678
1685
|
children: "on"
|
|
1679
1686
|
}), renderPrependExpressionButton(i), (0, _jsxRuntime.jsx)(_dialog.FormulaList, {
|
|
1680
1687
|
_type: _types.FormulaTypeEnum.JOIN_DATA,
|
|
1681
|
-
otherTypes: (_store$
|
|
1688
|
+
otherTypes: (_store$preProps6 = store.preProps) === null || _store$preProps6 === void 0 ? void 0 : _store$preProps6.otherTypes,
|
|
1682
1689
|
value: v.list,
|
|
1683
1690
|
data: getCollectionTableColumns(),
|
|
1684
1691
|
onChange: function onChange(data, _quotes) {
|
|
@@ -28,6 +28,7 @@ var Sort = function Sort(props) {
|
|
|
28
28
|
var meta = props.meta,
|
|
29
29
|
groupIndex = props.groupIndex;
|
|
30
30
|
var store = (0, _useProvider.useStore)();
|
|
31
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
31
32
|
var sort = meta.sort;
|
|
32
33
|
var index = (0, _utils.findIndex)(store.metaList[groupIndex].list, meta);
|
|
33
34
|
function getColumns() {
|
|
@@ -176,7 +177,10 @@ var Sort = function Sort(props) {
|
|
|
176
177
|
var getName = function getName() {
|
|
177
178
|
var expression = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
178
179
|
return expression.map(function (v) {
|
|
179
|
-
return v
|
|
180
|
+
return showFieldTableAlias ? (0, _utils.getAtomDisplayText)(v, {
|
|
181
|
+
withTableAlias: true,
|
|
182
|
+
tables: getColumns()
|
|
183
|
+
}) : v.fieldName;
|
|
180
184
|
}).join(' || ');
|
|
181
185
|
};
|
|
182
186
|
return (0, _jsxRuntime.jsx)(_Wrapper["default"], {
|
|
@@ -174,6 +174,7 @@ var GroupBy = function GroupBy(props) {
|
|
|
174
174
|
var meta = props.meta,
|
|
175
175
|
groupIndex = props.groupIndex;
|
|
176
176
|
var store = (0, _useProvider.useStore)();
|
|
177
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
177
178
|
var by = meta.by;
|
|
178
179
|
var index = (0, _utils.findIndex)(store.metaList[groupIndex].list, meta);
|
|
179
180
|
var notBySelected = !meta.by.length;
|
|
@@ -571,7 +572,12 @@ var GroupBy = function GroupBy(props) {
|
|
|
571
572
|
})
|
|
572
573
|
})
|
|
573
574
|
})
|
|
574
|
-
}), "".concat(
|
|
575
|
+
}), "".concat((0, _utils.getAliasedQuotes)(v.quotes || '', getAtomsValue(v), showFieldTableAlias, {
|
|
576
|
+
fieldName: v.name || v.realName,
|
|
577
|
+
tableAlias: v.alias,
|
|
578
|
+
fieldType: v.field_type,
|
|
579
|
+
fieldLength: v.field_length
|
|
580
|
+
}, getColumns()), " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && (0, _jsxRuntime.jsx)("span", {
|
|
575
581
|
style: {
|
|
576
582
|
fontSize: 0
|
|
577
583
|
},
|
|
@@ -30,6 +30,7 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
30
30
|
var meta = props.meta,
|
|
31
31
|
groupIndex = props.groupIndex;
|
|
32
32
|
var store = (0, _useProvider.useStore)();
|
|
33
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
33
34
|
var group = meta.group;
|
|
34
35
|
var index = (0, _utils.findIndex)(store.metaList[groupIndex].list, meta);
|
|
35
36
|
var notGroupSelected = !group.length;
|
|
@@ -468,7 +469,12 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
468
469
|
})
|
|
469
470
|
})
|
|
470
471
|
})
|
|
471
|
-
}), "".concat(
|
|
472
|
+
}), "".concat((0, _utils.getAliasedQuotes)(v.quotes || '', getAtomsValue(v), showFieldTableAlias, {
|
|
473
|
+
fieldName: v.name || v.realName,
|
|
474
|
+
tableAlias: v.alias,
|
|
475
|
+
fieldType: v.field_type,
|
|
476
|
+
fieldLength: v.field_length
|
|
477
|
+
}, getColumns()), " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && (0, _jsxRuntime.jsx)("span", {
|
|
472
478
|
style: {
|
|
473
479
|
fontSize: 0
|
|
474
480
|
},
|
|
@@ -205,6 +205,7 @@ var TableData = function TableData(props) {
|
|
|
205
205
|
});
|
|
206
206
|
};
|
|
207
207
|
var showSubQuery = function showSubQuery() {
|
|
208
|
+
var _store$preProps3;
|
|
208
209
|
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
209
210
|
var _store$preProps2 = store.preProps,
|
|
210
211
|
subToolbar = _store$preProps2.subToolbar,
|
|
@@ -222,6 +223,7 @@ var TableData = function TableData(props) {
|
|
|
222
223
|
transparentMask: true,
|
|
223
224
|
content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
224
225
|
children: (0, _jsxRuntime.jsx)(_index["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
|
|
226
|
+
showFieldTableAliasController: ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
225
227
|
popupZIndex: childModalZIndex + 1,
|
|
226
228
|
showSubquery: store._showSubquery,
|
|
227
229
|
isExit: isExit,
|
|
@@ -293,8 +295,8 @@ var TableData = function TableData(props) {
|
|
|
293
295
|
store.setMeta(newMetaList, groupIndex);
|
|
294
296
|
};
|
|
295
297
|
var tableIsError = function tableIsError() {
|
|
296
|
-
var _store$
|
|
297
|
-
var aliass = ((_store$
|
|
298
|
+
var _store$preProps4, _meta$table2;
|
|
299
|
+
var aliass = ((_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 || (_store$preProps4 = _store$preProps4.notExistsColumns) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.map(function (v) {
|
|
298
300
|
return v.alias;
|
|
299
301
|
})) || [];
|
|
300
302
|
var tableAlias = (_meta$table2 = meta.table) === null || _meta$table2 === void 0 ? void 0 : _meta$table2.alias;
|