@gingkoo/pandora-metabase 1.0.158-alpha.21 → 1.0.158-alpha.22
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 +21 -14
- package/lib/cjs/components/dialog/formula-list/index.js +23 -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 +15 -9
- package/lib/cjs/components/modules/sort.js +4 -1
- package/lib/cjs/components/modules/summarize/group-by.js +5 -1
- package/lib/cjs/components/modules/summarize/select-index.js +5 -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 +9 -1
- package/lib/cjs/utils.js +134 -29
- package/lib/es/components/dialog/expression/index.js +10 -3
- package/lib/es/components/dialog/formula-list/index.js +24 -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 +16 -10
- package/lib/es/components/modules/sort.js +5 -2
- package/lib/es/components/modules/summarize/group-by.js +6 -2
- package/lib/es/components/modules/summarize/select-index.js +6 -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 +9 -1
- package/lib/es/utils.js +132 -27
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ import { AtomsTypeEnum, FormulaTypeEnum } from '../../../store/types';
|
|
|
23
23
|
import { ColumnsPopupThemeEnum } from '../../../store/enum';
|
|
24
24
|
import { Select, Input, Modal2, Modal, InputNumber, Space, Button, Checkbox, Tooltip, Toast, Editor } from '@gingkoo/pandora';
|
|
25
25
|
import cloneDeep from 'lodash/cloneDeep';
|
|
26
|
-
import { buildSqlQuery, getAtomDisplayText, getFieldReferenceError, changeCopyField, isExistsError, normalizeAndOrStructure, normalizeLegacySummarizeForSave, splitByUnion, syncAtomQuotes } from '../../../utils';
|
|
26
|
+
import { aliasDisplayText, buildSqlQuery, getAtomDisplayText, getFieldReferenceError, changeCopyField, isExistsError, normalizeAndOrStructure, normalizeLegacySummarizeForSave, splitByUnion, syncAtomQuotes } from '../../../utils';
|
|
27
27
|
import Formula from '../formula';
|
|
28
28
|
import { AddIcon, CloseIcon, UpArrowIcon } from '../../icons';
|
|
29
29
|
import { Expression, SelectColumnMultiple, SelectTable } from '../../dialog';
|
|
@@ -893,6 +893,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
893
893
|
};
|
|
894
894
|
}, []);
|
|
895
895
|
var store = useStore();
|
|
896
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
896
897
|
var snapshotMode = Boolean(store.snapshotMode);
|
|
897
898
|
var _props$value = props.value,
|
|
898
899
|
value = _props$value === void 0 ? [] : _props$value,
|
|
@@ -2703,7 +2704,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2703
2704
|
};
|
|
2704
2705
|
};
|
|
2705
2706
|
var showNotExists = function showNotExists(i) {
|
|
2706
|
-
var _caseList$i, _caseList$i2;
|
|
2707
|
+
var _caseList$i, _caseList$i2, _store$preProps4;
|
|
2707
2708
|
var _store$preProps3 = store.preProps,
|
|
2708
2709
|
notExistsToolbar = _store$preProps3.notExistsToolbar,
|
|
2709
2710
|
toolbar = _store$preProps3.toolbar,
|
|
@@ -2718,6 +2719,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2718
2719
|
transparentMask: false,
|
|
2719
2720
|
content: _jsx(_Fragment, {
|
|
2720
2721
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
2722
|
+
showFieldTableAliasController: ((_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
2721
2723
|
popupZIndex: childModalZIndex + 1,
|
|
2722
2724
|
readonly: snapshotMode,
|
|
2723
2725
|
snapshotMode: snapshotMode,
|
|
@@ -2733,14 +2735,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2733
2735
|
return;
|
|
2734
2736
|
}
|
|
2735
2737
|
try {
|
|
2736
|
-
var _store$
|
|
2738
|
+
var _store$preProps5;
|
|
2737
2739
|
if (isEqual(newList, oldList)) {
|
|
2738
2740
|
o.close();
|
|
2739
2741
|
return;
|
|
2740
2742
|
}
|
|
2741
2743
|
var expression = {
|
|
2742
2744
|
notExists: cloneDeep(newList),
|
|
2743
|
-
quotes: buildSqlQuery(newList, caseList[i].type, (_store$
|
|
2745
|
+
quotes: buildSqlQuery(newList, caseList[i].type, (_store$preProps5 = store.preProps) === null || _store$preProps5 === void 0 ? void 0 : _store$preProps5.sqlDialect),
|
|
2744
2746
|
type: caseList[i].type
|
|
2745
2747
|
};
|
|
2746
2748
|
caseList[i] = expression;
|
|
@@ -2756,14 +2758,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2756
2758
|
});
|
|
2757
2759
|
};
|
|
2758
2760
|
var showSubQuery = function showSubQuery(i) {
|
|
2759
|
-
var _caseList$i3, _caseList$i4;
|
|
2760
|
-
var _store$
|
|
2761
|
-
subToolbar = _store$
|
|
2762
|
-
notExistsColumns = _store$
|
|
2763
|
-
showFields = _store$
|
|
2764
|
-
isExit = _store$
|
|
2765
|
-
toolbar = _store$
|
|
2766
|
-
other = _objectWithoutProperties(_store$
|
|
2761
|
+
var _caseList$i3, _caseList$i4, _store$preProps7;
|
|
2762
|
+
var _store$preProps6 = store.preProps,
|
|
2763
|
+
subToolbar = _store$preProps6.subToolbar,
|
|
2764
|
+
notExistsColumns = _store$preProps6.notExistsColumns,
|
|
2765
|
+
showFields = _store$preProps6.showFields,
|
|
2766
|
+
isExit = _store$preProps6.isExit,
|
|
2767
|
+
toolbar = _store$preProps6.toolbar,
|
|
2768
|
+
other = _objectWithoutProperties(_store$preProps6, _excluded3);
|
|
2767
2769
|
var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
|
|
2768
2770
|
var oldList = cloneDeep(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
|
|
2769
2771
|
var childModalZIndex = getTopLayerZIndex() + 1;
|
|
@@ -2774,6 +2776,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2774
2776
|
transparentMask: false,
|
|
2775
2777
|
content: _jsx(_Fragment, {
|
|
2776
2778
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
2779
|
+
showFieldTableAliasController: ((_store$preProps7 = store.preProps) === null || _store$preProps7 === void 0 ? void 0 : _store$preProps7.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
2777
2780
|
popupZIndex: childModalZIndex + 1,
|
|
2778
2781
|
readonly: snapshotMode,
|
|
2779
2782
|
snapshotMode: snapshotMode,
|
|
@@ -2792,14 +2795,14 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2792
2795
|
return;
|
|
2793
2796
|
}
|
|
2794
2797
|
try {
|
|
2795
|
-
var _store$
|
|
2798
|
+
var _store$preProps8;
|
|
2796
2799
|
if (isEqual(newList, oldList)) {
|
|
2797
2800
|
o.close();
|
|
2798
2801
|
return;
|
|
2799
2802
|
}
|
|
2800
2803
|
var expression = {
|
|
2801
2804
|
subQuery: cloneDeep(newList),
|
|
2802
|
-
quotes: buildSqlQuery(newList, caseList[i].type, (_store$
|
|
2805
|
+
quotes: buildSqlQuery(newList, caseList[i].type, (_store$preProps8 = store.preProps) === null || _store$preProps8 === void 0 ? void 0 : _store$preProps8.sqlDialect),
|
|
2803
2806
|
type: caseList[i].type
|
|
2804
2807
|
};
|
|
2805
2808
|
caseList[i] = expression;
|
|
@@ -2891,7 +2894,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
2891
2894
|
};
|
|
2892
2895
|
}
|
|
2893
2896
|
if (type === AtomsTypeEnum.FIELD) {
|
|
2894
|
-
var displayName =
|
|
2897
|
+
var displayName = showFieldTableAlias ? getAtomDisplayText(v, {
|
|
2898
|
+
withTableAlias: true
|
|
2899
|
+
}) : getFieldDisplayName(v);
|
|
2895
2900
|
return {
|
|
2896
2901
|
className: cx({
|
|
2897
2902
|
notSelected: !displayName
|
|
@@ -3038,6 +3043,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3038
3043
|
}
|
|
3039
3044
|
if (type === AtomsTypeEnum.EXPRESSION) {
|
|
3040
3045
|
var quotes = getAtomDisplayText(v);
|
|
3046
|
+
var displayQuotes = showFieldTableAlias ? aliasDisplayText(quotes, [v], true) || quotes : quotes;
|
|
3041
3047
|
if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
|
|
3042
3048
|
var _getAtomDisplayText$s;
|
|
3043
3049
|
var nextList = caseList.slice();
|
|
@@ -3047,13 +3053,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3047
3053
|
}
|
|
3048
3054
|
return {
|
|
3049
3055
|
className: cx('purple-name', {
|
|
3050
|
-
notSelected: !
|
|
3056
|
+
notSelected: !displayQuotes
|
|
3051
3057
|
}),
|
|
3052
3058
|
onClick: function onClick(e) {
|
|
3053
3059
|
return handleExpression(e, index, v);
|
|
3054
3060
|
},
|
|
3055
3061
|
node: _jsxs(_Fragment, {
|
|
3056
|
-
children: [
|
|
3062
|
+
children: [displayQuotes || __('customColumn.selectExpression'), renderDeleteIcon(v, index, groupType)]
|
|
3057
3063
|
})
|
|
3058
3064
|
};
|
|
3059
3065
|
}
|
|
@@ -3076,7 +3082,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
3076
3082
|
return showFunction(e, index);
|
|
3077
3083
|
},
|
|
3078
3084
|
node: _jsxs(_Fragment, {
|
|
3079
|
-
children: [v.name ? getQuotes(v, v.args, formulaList) : __('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
|
|
3085
|
+
children: [v.name ? showFieldTableAlias ? aliasDisplayText(getQuotes(v, v.args, formulaList), [v], true) : getQuotes(v, v.args, formulaList) : __('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
|
|
3080
3086
|
})
|
|
3081
3087
|
};
|
|
3082
3088
|
}
|
|
@@ -13,7 +13,7 @@ import { TypeEnum } from '../../../store/enum';
|
|
|
13
13
|
import { __ } from '../../../locale';
|
|
14
14
|
import { NotSelectIcon, SelectIcon } from '../../icons';
|
|
15
15
|
import { useStore } from '../../../hooks/use-provider';
|
|
16
|
-
import { getColumnIdFirstKey, isSameColumnByIdFirst, uuidv4 } from '../../../utils/helper';
|
|
16
|
+
import { getColumnIdFirstKey, isSameColumnByIdFirst, prefixFieldTableAlias, uuidv4 } from '../../../utils/helper';
|
|
17
17
|
import { changeFieldAlias, isValidSQLAlias } from '../../../utils';
|
|
18
18
|
import { SearchIcon } from '../../icons';
|
|
19
19
|
import ColumnTypeLabel from '../column-type-label';
|
|
@@ -39,6 +39,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
39
39
|
originList = _useState4[0],
|
|
40
40
|
setOriginList = _useState4[1];
|
|
41
41
|
var store = useStore();
|
|
42
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
42
43
|
var _useState5 = useState(''),
|
|
43
44
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
45
|
filterVal = _useState6[0],
|
|
@@ -230,7 +231,7 @@ var SelectColumn = function SelectColumn(_ref) {
|
|
|
230
231
|
className: 'no-select mr-2'
|
|
231
232
|
}), _jsxs("span", {
|
|
232
233
|
className: 'Sqb-SelectColumn-name',
|
|
233
|
-
children: [v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
234
|
+
children: [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) : '']
|
|
234
235
|
}), _jsx(ColumnTypeLabel, {
|
|
235
236
|
column: v
|
|
236
237
|
}), store.fieldEnableAlias && !readonly && _jsx(Tooltip, {
|
|
@@ -16,7 +16,7 @@ import { __ } from '../../../locale';
|
|
|
16
16
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
17
17
|
import ColumnTypeLabel from '../column-type-label';
|
|
18
18
|
import { useStore } from '../../../hooks/use-provider';
|
|
19
|
-
import { replaceTpl, mergeNameAlias, uuidv4 } from '../../../utils/helper';
|
|
19
|
+
import { replaceTpl, mergeNameAlias, prefixFieldTableAlias, uuidv4 } from '../../../utils/helper';
|
|
20
20
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
21
21
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
22
22
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -55,6 +55,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
55
55
|
_ref$readonly = _ref.readonly,
|
|
56
56
|
readonly = _ref$readonly === void 0 ? false : _ref$readonly;
|
|
57
57
|
var store = useStore();
|
|
58
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
58
59
|
var selectedTableUuid = (_value === null || _value === void 0 || (_value$ = _value[0]) === null || _value$ === void 0 ? void 0 : _value$.tableId) === SummarizeAlias ? '' : (_value === null || _value === void 0 || (_value$2 = _value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.tableUuid) || '';
|
|
59
60
|
var _useState = useState(_value),
|
|
60
61
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -507,7 +508,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
507
508
|
className: 'List-item-content',
|
|
508
509
|
children: [_jsxs("h4", {
|
|
509
510
|
className: 'List-item-title ml-2',
|
|
510
|
-
children: [replaceTpl(store.fieldNameTpl, v), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
511
|
+
children: [prefixFieldTableAlias(replaceTpl(store.fieldNameTpl, v), tableAlias, showFieldTableAlias), v.fieldAlias ? " as ".concat(v.fieldAlias) : '']
|
|
511
512
|
}), _jsx(ColumnTypeLabel, {
|
|
512
513
|
column: v
|
|
513
514
|
})]
|
|
@@ -12,7 +12,7 @@ import { __ } from '../../../locale';
|
|
|
12
12
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
13
13
|
import ColumnTypeLabel from '../column-type-label';
|
|
14
14
|
import { useStore } from '../../../hooks/use-provider';
|
|
15
|
-
import { getColumnIdFirstKey, isSameColumnByIdName,
|
|
15
|
+
import { getColumnIdFirstKey, isSameColumnByIdName, mergeNameAlias, prefixFieldTableAlias, replaceTpl } from '../../../utils/helper';
|
|
16
16
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2, RightArrowIcon } from '../../icons';
|
|
17
17
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
18
18
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -42,6 +42,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
42
42
|
_ref$multiple = _ref.multiple,
|
|
43
43
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple;
|
|
44
44
|
var store = useStore();
|
|
45
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
45
46
|
var _useState = useState(_value),
|
|
46
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
48
|
value = _useState2[0],
|
|
@@ -313,7 +314,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
313
314
|
className: 'List-item-content',
|
|
314
315
|
children: [_jsx("h4", {
|
|
315
316
|
className: 'List-item-title ml-2',
|
|
316
|
-
children: replaceTpl(store.fieldNameTpl, v)
|
|
317
|
+
children: prefixFieldTableAlias(replaceTpl(store.fieldNameTpl, v), tableAlias, showFieldTableAlias)
|
|
317
318
|
}), _jsx(ColumnTypeLabel, {
|
|
318
319
|
column: v
|
|
319
320
|
})]
|
|
@@ -12,7 +12,7 @@ import { __ } from '../../../locale';
|
|
|
12
12
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
13
13
|
import ColumnTypeLabel from '../column-type-label';
|
|
14
14
|
import { useStore } from '../../../hooks/use-provider';
|
|
15
|
-
import { getColumnIdFirstKey, isSameColumnByIdName,
|
|
15
|
+
import { getColumnIdFirstKey, isSameColumnByIdName, mergeNameAlias, prefixFieldTableAlias, replaceTpl } from '../../../utils/helper';
|
|
16
16
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
17
17
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
18
18
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -43,6 +43,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
43
43
|
_ref$multiple = _ref.multiple,
|
|
44
44
|
multiple = _ref$multiple === void 0 ? false : _ref$multiple;
|
|
45
45
|
var store = useStore();
|
|
46
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
46
47
|
var _useState = useState(_value),
|
|
47
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
48
49
|
value = _useState2[0],
|
|
@@ -249,7 +250,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
249
250
|
className: 'List-item-content',
|
|
250
251
|
children: [_jsx("h4", {
|
|
251
252
|
className: 'List-item-title ml-2',
|
|
252
|
-
children: replaceTpl(store.fieldNameTpl, v)
|
|
253
|
+
children: prefixFieldTableAlias(replaceTpl(store.fieldNameTpl, v), tableAlias, showFieldTableAlias)
|
|
253
254
|
}), _jsx(ColumnTypeLabel, {
|
|
254
255
|
column: v
|
|
255
256
|
})]
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
8
8
|
import './index.less';
|
|
9
9
|
import { useEffect, useMemo, useState } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
-
import { Button, Modal, Toast, Space, Tooltip } from '@gingkoo/pandora';
|
|
11
|
+
import { Button, Modal, Toast, Space, Tooltip, Switch } from '@gingkoo/pandora';
|
|
12
12
|
import Styled from 'styled-components';
|
|
13
13
|
import Union from '../modules/union';
|
|
14
14
|
import { splitByUnion, reassembleByUnion, patchData, normalizeLegacySummarizeForSave } from '../../utils';
|
|
@@ -86,6 +86,7 @@ var Metabase = function Metabase(props) {
|
|
|
86
86
|
_props$sqlValidationQ = props.sqlValidationQueryKind,
|
|
87
87
|
sqlValidationQueryKind = _props$sqlValidationQ === void 0 ? 'query' : _props$sqlValidationQ;
|
|
88
88
|
var store = useStore();
|
|
89
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
89
90
|
var readonlyMode = readonly || store.snapshotMode;
|
|
90
91
|
var _useState = useState(false),
|
|
91
92
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -321,9 +322,24 @@ var Metabase = function Metabase(props) {
|
|
|
321
322
|
},
|
|
322
323
|
children: _jsxs("div", {
|
|
323
324
|
className: 'Sqb',
|
|
324
|
-
children: [
|
|
325
|
+
children: [_jsxs("div", {
|
|
325
326
|
className: 'Sqb-fun-btns',
|
|
326
|
-
children:
|
|
327
|
+
children: [_jsx(Tooltip, {
|
|
328
|
+
title: __('SqlQueryBuilder.showFieldTableAliasTip'),
|
|
329
|
+
children: _jsxs("span", {
|
|
330
|
+
className: 'Sqb-field-alias-switch',
|
|
331
|
+
"data-sqb-snapshot-allow": 'true',
|
|
332
|
+
children: [_jsx("span", {
|
|
333
|
+
children: __('SqlQueryBuilder.showFieldTableAlias')
|
|
334
|
+
}), _jsx(Switch, {
|
|
335
|
+
size: 'small',
|
|
336
|
+
checked: showFieldTableAlias,
|
|
337
|
+
onChange: function onChange(value) {
|
|
338
|
+
return store.setShowFieldTableAlias(Boolean(value));
|
|
339
|
+
}
|
|
340
|
+
})]
|
|
341
|
+
})
|
|
342
|
+
}), copy()]
|
|
327
343
|
}), store.metaList.map(function (v, index) {
|
|
328
344
|
var _v$list;
|
|
329
345
|
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;
|
|
@@ -16,7 +16,7 @@ import { uuidv4, getAlias, mergeNameAlias, isSameTableByIdFirst, isSameTableById
|
|
|
16
16
|
import { getTopLayerZIndex } from '../../utils/helper-dom';
|
|
17
17
|
import { getConstantLabel, findNestedMetaIssue } from '../dialog/formula-list/utils';
|
|
18
18
|
import { __ } from '../../locale';
|
|
19
|
-
import { findIndex, getSubColumns, mergeSubQueryColumns, syncSubQueryFieldReferences } from '../../utils';
|
|
19
|
+
import { aliasDisplayText, findIndex, getAtomDisplayText, getSubColumns, mergeSubQueryColumns, syncSubQueryFieldReferences } from '../../utils';
|
|
20
20
|
import { TypeEnum, ColumnsPopupThemeEnum, JoinEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
21
21
|
import { AtomsTypeEnum, ChangeType, FormulaTypeEnum } from '../../store/types';
|
|
22
22
|
import { SummarizeAlias } from '../../store/helper';
|
|
@@ -73,6 +73,7 @@ var JoinData = function JoinData(props) {
|
|
|
73
73
|
var meta = props.meta,
|
|
74
74
|
groupIndex = props.groupIndex;
|
|
75
75
|
var store = useStore();
|
|
76
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
76
77
|
var filterCustomType = store.filterCustomType;
|
|
77
78
|
var metaKey = meta.metaKey;
|
|
78
79
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
@@ -1010,6 +1011,7 @@ var JoinData = function JoinData(props) {
|
|
|
1010
1011
|
store.setMeta(newMeta, groupIndex);
|
|
1011
1012
|
}
|
|
1012
1013
|
var showSubQuery = function showSubQuery() {
|
|
1014
|
+
var _store$preProps3;
|
|
1013
1015
|
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1014
1016
|
var _store$preProps2 = store.preProps,
|
|
1015
1017
|
subToolbar = _store$preProps2.subToolbar,
|
|
@@ -1027,6 +1029,7 @@ var JoinData = function JoinData(props) {
|
|
|
1027
1029
|
transparentMask: true,
|
|
1028
1030
|
content: _jsx(_Fragment, {
|
|
1029
1031
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
1032
|
+
showFieldTableAliasController: ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
1030
1033
|
popupZIndex: childModalZIndex + 1,
|
|
1031
1034
|
showSubquery: store._showSubquery,
|
|
1032
1035
|
isExit: isExit,
|
|
@@ -1038,10 +1041,10 @@ var JoinData = function JoinData(props) {
|
|
|
1038
1041
|
value: cloneDeep(val),
|
|
1039
1042
|
onOk: function onOk(newList) {
|
|
1040
1043
|
try {
|
|
1041
|
-
var _store$
|
|
1044
|
+
var _store$preProps4;
|
|
1042
1045
|
newMeta[index].subquery = newList;
|
|
1043
1046
|
newMeta[index].table2 = _objectSpread(_objectSpread({}, newList[0].table), {}, {
|
|
1044
|
-
alias: newMeta[index].table2.alias || getAlias(newList[0].table.name, newMeta, ((_store$
|
|
1047
|
+
alias: newMeta[index].table2.alias || getAlias(newList[0].table.name, newMeta, ((_store$preProps4 = store.preProps) === null || _store$preProps4 === void 0 ? void 0 : _store$preProps4.notExistsColumns) || []),
|
|
1045
1048
|
tableUuid: newMeta[index].table2.tableUuid || uuidv4('table')
|
|
1046
1049
|
});
|
|
1047
1050
|
var items = getSubColumns(newList);
|
|
@@ -1276,7 +1279,9 @@ var JoinData = function JoinData(props) {
|
|
|
1276
1279
|
"v-index2": index,
|
|
1277
1280
|
onClick: selectMoreJoinColumn,
|
|
1278
1281
|
children: (_items$3 = items[0]) !== null && _items$3 !== void 0 && _items$3.fieldName ? items.map(function (field) {
|
|
1279
|
-
return field
|
|
1282
|
+
return showFieldTableAlias ? getAtomDisplayText(field, {
|
|
1283
|
+
withTableAlias: true
|
|
1284
|
+
}) : field.fieldName;
|
|
1280
1285
|
}).join(' || ') : __('SqlQueryBuilder.pickTable')
|
|
1281
1286
|
})
|
|
1282
1287
|
})
|
|
@@ -1345,8 +1350,8 @@ var JoinData = function JoinData(props) {
|
|
|
1345
1350
|
}
|
|
1346
1351
|
};
|
|
1347
1352
|
var tableIsError = function tableIsError() {
|
|
1348
|
-
var _store$
|
|
1349
|
-
var aliass = ((_store$
|
|
1353
|
+
var _store$preProps5, _meta$table2;
|
|
1354
|
+
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) {
|
|
1350
1355
|
return v.alias;
|
|
1351
1356
|
})) || [];
|
|
1352
1357
|
var tableAlias = (_meta$table2 = meta.table2) === null || _meta$table2 === void 0 ? void 0 : _meta$table2.alias;
|
|
@@ -1614,6 +1619,7 @@ var JoinData = function JoinData(props) {
|
|
|
1614
1619
|
}, i);
|
|
1615
1620
|
}
|
|
1616
1621
|
if (v.type === AtomsTypeEnum.EXPRESSION) {
|
|
1622
|
+
var expressionText = showFieldTableAlias ? aliasDisplayText(v.quotes || '', [v], true) || v.quotes : v.quotes;
|
|
1617
1623
|
return _jsxs("div", {
|
|
1618
1624
|
className: cx("Sqb-where block"),
|
|
1619
1625
|
children: [i == 0 && _jsx("span", {
|
|
@@ -1625,12 +1631,12 @@ var JoinData = function JoinData(props) {
|
|
|
1625
1631
|
value: v,
|
|
1626
1632
|
children: _jsx("div", {
|
|
1627
1633
|
className: cx("Sqb-TableName purple-name", {
|
|
1628
|
-
notSelected: !
|
|
1634
|
+
notSelected: !expressionText
|
|
1629
1635
|
}),
|
|
1630
1636
|
onClick: function onClick(e) {
|
|
1631
1637
|
return changeExpression(e, i);
|
|
1632
1638
|
},
|
|
1633
|
-
children:
|
|
1639
|
+
children: expressionText || __('joinData.selectExpression')
|
|
1634
1640
|
}, i)
|
|
1635
1641
|
})
|
|
1636
1642
|
}), !store.snapshotMode && _jsx(Tooltip, {
|
|
@@ -1664,7 +1670,7 @@ var JoinData = function JoinData(props) {
|
|
|
1664
1670
|
}, i);
|
|
1665
1671
|
}
|
|
1666
1672
|
if (v.type === AtomsTypeEnum.COLLECTION) {
|
|
1667
|
-
var _store$
|
|
1673
|
+
var _store$preProps6;
|
|
1668
1674
|
return _jsxs("div", {
|
|
1669
1675
|
className: cx(" Sqb-collection-box"),
|
|
1670
1676
|
children: [i == 0 && _jsx("span", {
|
|
@@ -1672,7 +1678,7 @@ var JoinData = function JoinData(props) {
|
|
|
1672
1678
|
children: "on"
|
|
1673
1679
|
}), renderPrependExpressionButton(i), _jsx(FormulaList, {
|
|
1674
1680
|
_type: FormulaTypeEnum.JOIN_DATA,
|
|
1675
|
-
otherTypes: (_store$
|
|
1681
|
+
otherTypes: (_store$preProps6 = store.preProps) === null || _store$preProps6 === void 0 ? void 0 : _store$preProps6.otherTypes,
|
|
1676
1682
|
value: v.list,
|
|
1677
1683
|
data: getCollectionTableColumns(),
|
|
1678
1684
|
onChange: function onChange(data, _quotes) {
|
|
@@ -3,7 +3,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import { __ } from '../../locale';
|
|
6
|
-
import { findIndex, getHelper, isError } from '../../utils';
|
|
6
|
+
import { findIndex, getAtomDisplayText, getHelper, isError } from '../../utils';
|
|
7
7
|
import { getAtomListIssue } from '../dialog/formula-list/utils';
|
|
8
8
|
import { ColumnsPopupThemeEnum, TypeEnum, SortEnum, SQL_COLUMN_TYPE } from '../../store/enum';
|
|
9
9
|
import { AtomsTypeEnum } from '../../store/types';
|
|
@@ -21,6 +21,7 @@ var Sort = function Sort(props) {
|
|
|
21
21
|
var meta = props.meta,
|
|
22
22
|
groupIndex = props.groupIndex;
|
|
23
23
|
var store = useStore();
|
|
24
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
24
25
|
var sort = meta.sort;
|
|
25
26
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
26
27
|
function getColumns() {
|
|
@@ -169,7 +170,9 @@ var Sort = function Sort(props) {
|
|
|
169
170
|
var getName = function getName() {
|
|
170
171
|
var expression = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
171
172
|
return expression.map(function (v) {
|
|
172
|
-
return v
|
|
173
|
+
return showFieldTableAlias ? getAtomDisplayText(v, {
|
|
174
|
+
withTableAlias: true
|
|
175
|
+
}) : v.fieldName;
|
|
173
176
|
}).join(' || ');
|
|
174
177
|
};
|
|
175
178
|
return _jsx(Wrapper, {
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import { __ } from '../../../locale';
|
|
11
|
-
import { findIndex, getAtomDisplayText, getHelper } from '../../../utils';
|
|
11
|
+
import { findIndex, getAliasedQuotes, getAtomDisplayText, getHelper } from '../../../utils';
|
|
12
12
|
import { TypeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
|
|
13
13
|
import { MetaSummarize_Enum, AtomsTypeEnum, ChangeType } from '../../../store/types';
|
|
14
14
|
import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
|
|
@@ -168,6 +168,7 @@ var GroupBy = function GroupBy(props) {
|
|
|
168
168
|
var meta = props.meta,
|
|
169
169
|
groupIndex = props.groupIndex;
|
|
170
170
|
var store = useStore();
|
|
171
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
171
172
|
var by = meta.by;
|
|
172
173
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
173
174
|
var notBySelected = !meta.by.length;
|
|
@@ -565,7 +566,10 @@ var GroupBy = function GroupBy(props) {
|
|
|
565
566
|
})
|
|
566
567
|
})
|
|
567
568
|
})
|
|
568
|
-
}), "".concat(v.quotes
|
|
569
|
+
}), "".concat(getAliasedQuotes(v.quotes || '', getAtomsValue(v), showFieldTableAlias, {
|
|
570
|
+
fieldName: v.name || v.realName,
|
|
571
|
+
tableAlias: v.alias
|
|
572
|
+
}), " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && _jsx("span", {
|
|
569
573
|
style: {
|
|
570
574
|
fontSize: 0
|
|
571
575
|
},
|
|
@@ -6,7 +6,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
6
6
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
import cx from 'classnames';
|
|
8
8
|
import { __ } from '../../../locale';
|
|
9
|
-
import { findIndex, getHelper } from '../../../utils';
|
|
9
|
+
import { findIndex, getAliasedQuotes, getHelper } from '../../../utils';
|
|
10
10
|
import { TypeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
|
|
11
11
|
import { summarizeToSql } from '../../../store/helper';
|
|
12
12
|
import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
|
|
@@ -24,6 +24,7 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
24
24
|
var meta = props.meta,
|
|
25
25
|
groupIndex = props.groupIndex;
|
|
26
26
|
var store = useStore();
|
|
27
|
+
var showFieldTableAlias = Boolean(store.showFieldTableAlias);
|
|
27
28
|
var group = meta.group;
|
|
28
29
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
29
30
|
var notGroupSelected = !group.length;
|
|
@@ -462,7 +463,10 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
462
463
|
})
|
|
463
464
|
})
|
|
464
465
|
})
|
|
465
|
-
}), "".concat(v.quotes
|
|
466
|
+
}), "".concat(getAliasedQuotes(v.quotes || '', getAtomsValue(v), showFieldTableAlias, {
|
|
467
|
+
fieldName: v.name || v.realName,
|
|
468
|
+
tableAlias: v.alias
|
|
469
|
+
}), " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), !store.snapshotMode && _jsx("span", {
|
|
466
470
|
style: {
|
|
467
471
|
fontSize: 0
|
|
468
472
|
},
|
|
@@ -198,6 +198,7 @@ var TableData = function TableData(props) {
|
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
200
|
var showSubQuery = function showSubQuery() {
|
|
201
|
+
var _store$preProps3;
|
|
201
202
|
var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
202
203
|
var _store$preProps2 = store.preProps,
|
|
203
204
|
subToolbar = _store$preProps2.subToolbar,
|
|
@@ -215,6 +216,7 @@ var TableData = function TableData(props) {
|
|
|
215
216
|
transparentMask: true,
|
|
216
217
|
content: _jsx(_Fragment, {
|
|
217
218
|
children: _jsx(Metabase, _objectSpread(_objectSpread({}, other), {}, {
|
|
219
|
+
showFieldTableAliasController: ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.showFieldTableAliasController) || store.showFieldTableAliasController,
|
|
218
220
|
popupZIndex: childModalZIndex + 1,
|
|
219
221
|
showSubquery: store._showSubquery,
|
|
220
222
|
isExit: isExit,
|
|
@@ -286,8 +288,8 @@ var TableData = function TableData(props) {
|
|
|
286
288
|
store.setMeta(newMetaList, groupIndex);
|
|
287
289
|
};
|
|
288
290
|
var tableIsError = function tableIsError() {
|
|
289
|
-
var _store$
|
|
290
|
-
var aliass = ((_store$
|
|
291
|
+
var _store$preProps4, _meta$table2;
|
|
292
|
+
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) {
|
|
291
293
|
return v.alias;
|
|
292
294
|
})) || [];
|
|
293
295
|
var tableAlias = (_meta$table2 = meta.table) === null || _meta$table2 === void 0 ? void 0 : _meta$table2.alias;
|