@gingkoo/pandora-metabase 1.0.137-alpha.3 → 1.0.137-alpha.4

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.
@@ -29,7 +29,7 @@ var _helperDom = require("../../../utils/helper-dom");
29
29
  var _templateObject;
30
30
  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); }
31
31
  var VisualBox = _styledComponents["default"].div.attrs({
32
- className: 'visual-box'
32
+ className: 'visual-box scroller'
33
33
  })(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])([""])));
34
34
  var CaseEditor = _react["default"].forwardRef(function (props, ref) {
35
35
  var _store$formulaTemplat, _fun$args;
@@ -162,7 +162,7 @@ var CaseWhenGroup = function CaseWhenGroup(_ref) {
162
162
  className: 'Sqb-CaseBranchIndex',
163
163
  children: branchIndex + 1
164
164
  }), (0, _jsxRuntime.jsx)("div", {
165
- className: 'Sqb-CaseBranch-body',
165
+ className: 'Sqb-CaseBranch-body scroller-x',
166
166
  children: renderBranchContent((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
167
167
  children: [(0, _jsxRuntime.jsxs)("div", {
168
168
  className: 'Sqb-CaseSection Sqb-CaseSection-condition',
@@ -233,7 +233,7 @@ var CaseWhenGroup = function CaseWhenGroup(_ref) {
233
233
  className: 'Sqb-CaseBranchIndex Sqb-CaseBranchIndex--else',
234
234
  "aria-hidden": 'true'
235
235
  }), (0, _jsxRuntime.jsx)("div", {
236
- className: 'Sqb-CaseBranch-body',
236
+ className: 'Sqb-CaseBranch-body scroller-x',
237
237
  children: renderBranchContent((0, _jsxRuntime.jsxs)("div", {
238
238
  className: 'Sqb-CaseSection Sqb-CaseSection-result Sqb-CaseSection-else',
239
239
  children: [(0, _jsxRuntime.jsx)("span", {
@@ -496,7 +496,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
496
496
  children: (0, _jsxRuntime.jsxs)("div", {
497
497
  className: 'Sqb-FormulaListZoomEditor',
498
498
  children: [(0, _jsxRuntime.jsx)("div", {
499
- className: 'Sqb-FormulaListZoomEditor-body',
499
+ className: 'Sqb-FormulaListZoomEditor-body scroller scroller-x',
500
500
  children: (0, _jsxRuntime.jsx)("div", {
501
501
  className: 'Sqb-NotebookCell Sqb-FormulaListZoomEditor-cell',
502
502
  children: (0, _jsxRuntime.jsx)(_CaseWhenGroup["default"], {
@@ -658,7 +658,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
658
658
  children: (0, _jsxRuntime.jsxs)("div", {
659
659
  className: 'Sqb-FormulaListZoomEditor',
660
660
  children: [(0, _jsxRuntime.jsx)("div", {
661
- className: 'Sqb-FormulaListZoomEditor-body Sqb-FormulaListZoomEditor-body--formulaList',
661
+ className: 'Sqb-FormulaListZoomEditor-body Sqb-FormulaListZoomEditor-body--formulaList scroller scroller-x',
662
662
  children: (0, _jsxRuntime.jsx)(FormulaList, {
663
663
  ref: ref,
664
664
  value: draftList,
@@ -1649,8 +1649,8 @@
1649
1649
  width: 100%;
1650
1650
  min-width: 100%;
1651
1651
  box-sizing: border-box;
1652
- padding-left: var(--sqb-item-shell-margin-x, 14px);
1653
- padding-right: var(--sqb-item-shell-margin-x, 14px);
1652
+ padding: var(--sqb-item-shell-margin-x, 14px);
1653
+ // padding: var(--sqb-item-shell-margin-x, 14px);
1654
1654
  }
1655
1655
 
1656
1656
  .Sqb-FormulaListZoomEditor-body .Sqb-FormulaListZoomEditor-cell {
@@ -1736,6 +1736,14 @@
1736
1736
  padding-bottom: 4px;
1737
1737
  }
1738
1738
 
1739
+ .Sqb-FormulaListZoomEditor-body
1740
+ .Sqb-CaseWhenGroup:not(.Sqb-CaseWhenGroup--nested)
1741
+ > .Sqb-FormulaGroup-row
1742
+ > .Sqb-CaseBranch-body:has(.Sqb-CaseWhenGroup--nested) {
1743
+ overflow: visible;
1744
+ padding-bottom: 0;
1745
+ }
1746
+
1739
1747
  .Sqb-FormulaListZoomEditor-body
1740
1748
  .Sqb-CaseWhenGroup:not(.Sqb-CaseWhenGroup--nested)
1741
1749
  > .Sqb-FormulaGroup-row
@@ -2163,8 +2171,7 @@
2163
2171
  border-color: rgba(80, 158, 227, 0.88);
2164
2172
  }
2165
2173
 
2166
- .Sqb-FormulaGroup.logic-group
2167
- > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested),
2174
+ .Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested),
2168
2175
  .Sqb-FormulaGroup.logic-group
2169
2176
  > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
2170
2177
  > .Sqb-NestedFormulaList,
@@ -2195,8 +2202,7 @@
2195
2202
  box-sizing: border-box;
2196
2203
  }
2197
2204
 
2198
- .Sqb-FormulaGroup.logic-group
2199
- > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested) {
2205
+ .Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested) {
2200
2206
  flex: 1 1 auto;
2201
2207
  }
2202
2208
 
@@ -96,15 +96,15 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
96
96
  }
97
97
  }, [_value]);
98
98
  var getFieldTableKey = function getFieldTableKey(tableId, tableUuid) {
99
- return tableId || tableUuid || '';
99
+ return tableUuid || tableId || '';
100
100
  };
101
101
  var isSameSelectedTable = function isSameSelectedTable(field, tableId, tableUuid) {
102
- if (field.tableId && tableId) {
103
- return field.tableId === tableId;
104
- }
105
102
  if (field.tableUuid && tableUuid) {
106
103
  return field.tableUuid === tableUuid;
107
104
  }
105
+ if (field.tableId && tableId) {
106
+ return field.tableId === tableId;
107
+ }
108
108
  return false;
109
109
  };
110
110
  var getSelectedFieldKey = function getSelectedFieldKey(field) {
@@ -1,3 +1,39 @@
1
+ .scroller::-webkit-scrollbar {
2
+ width: 4px;
3
+ height: 100%;
4
+ background: transparent;
5
+ }
6
+
7
+ .scroller::-webkit-scrollbar-thumb {
8
+ background: rgba(100, 100, 100, 0.4);
9
+ border-radius: 2px;
10
+
11
+ &:hover {
12
+ background: rgba(100, 100, 100, 0.7);
13
+ }
14
+ }
15
+
16
+ .scroller-x::-webkit-scrollbar {
17
+ width: 100%;
18
+ height: 8px;
19
+ background: transparent;
20
+ }
21
+
22
+ .scroller.scroller-x::-webkit-scrollbar {
23
+ width: 4px;
24
+ height: 8px;
25
+ background: transparent;
26
+ }
27
+
28
+ .scroller-x::-webkit-scrollbar-thumb {
29
+ background: rgba(100, 100, 100, 0.4);
30
+ border-radius: 2px;
31
+
32
+ &:hover {
33
+ background: rgba(100, 100, 100, 0.7);
34
+ }
35
+ }
36
+
1
37
  .mx-4 {
2
38
  margin-left: 1rem;
3
39
  margin-right: 1rem;
@@ -24,7 +24,7 @@ var _useProvider = require("../../hooks/use-provider");
24
24
  var _storage = _interopRequireDefault(require("../../utils/storage"));
25
25
  var _templateObject;
26
26
  var VisualBox = _styledComponents["default"].div.attrs({
27
- className: 'visual-box'
27
+ className: 'visual-box scroller'
28
28
  })(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])([""])));
29
29
  var Metabase = function Metabase(props) {
30
30
  var _props$btnText = props.btnText,
@@ -996,7 +996,8 @@ var JoinData = function JoinData(props) {
996
996
  var _store$preProps3;
997
997
  newMeta[index].subquery = newList;
998
998
  newMeta[index].table2 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, newList[0].table), {}, {
999
- alias: newMeta[index].table2.alias || (0, _helper.getAlias)(newList[0].table.name, newMeta, ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.notExistsColumns) || [])
999
+ alias: newMeta[index].table2.alias || (0, _helper.getAlias)(newList[0].table.name, newMeta, ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.notExistsColumns) || []),
1000
+ tableUuid: newMeta[index].table2.tableUuid || (0, _helper.uuidv4)('table')
1000
1001
  });
1001
1002
  var items = (0, _utils2.getSubColumns)(newList);
1002
1003
  var subQueryTable = newMeta[index].table2;
@@ -119,11 +119,7 @@ var isSameColumnByIdFirst = exports.isSameColumnByIdFirst = function isSameColum
119
119
  var leftTableUuid = normalizeId(left.tableUuid);
120
120
  var rightTableUuid = normalizeId(right.tableUuid);
121
121
  if (hasBoth(leftTableUuid, rightTableUuid) && leftTableUuid !== rightTableUuid) {
122
- var leftTableName = normalizeId(left.tableName || left.table);
123
- var rightTableName = normalizeId(right.tableName || right.table);
124
- if (!hasBoth(leftTableName, rightTableName) || leftTableName !== rightTableName) {
125
- return false;
126
- }
122
+ return false;
127
123
  }
128
124
  var leftFieldId = normalizeId(left.fieldId || left.id);
129
125
  var rightFieldId = normalizeId(right.fieldId || right.id);
@@ -4,6 +4,7 @@ import { DataType } from './components/dialog/select-column-multiple';
4
4
  export declare const findIndex: <T>(arr: T[], item: T) => number;
5
5
  export declare const findMetaKey: <T>(arr: T[], item: T) => number;
6
6
  export declare const getMetaTabels: (data: MetaListType[]) => any;
7
+ export declare const getSubQueryColumnInstanceUuid: (column: any, tableUuid?: string) => string;
7
8
  export declare const getColumnsTables: (data: DataType[]) => any;
8
9
  interface HelperResultType {
9
10
  ExistAboveGroupBy: boolean;
package/lib/cjs/utils.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.changeTableAlias = exports.changeFieldAlias = exports.changeExistsCopyField = exports.changeCopyField = exports.buildSqlQuery = void 0;
8
8
  exports.containsSubset = containsSubset;
9
- exports.isExistsError = exports.isError = exports.isCanPaste = exports.getSubColumns = exports.getObjTem = exports.getMetaTabels = exports.getHelper = exports.getColumnsTables = exports.findMetaKey = exports.findIndex = void 0;
9
+ exports.isExistsError = exports.isError = exports.isCanPaste = exports.getSubQueryColumnInstanceUuid = exports.getSubColumns = exports.getObjTem = exports.getMetaTabels = exports.getHelper = exports.getColumnsTables = exports.findMetaKey = exports.findIndex = void 0;
10
10
  exports.isValidSQLAlias = isValidSQLAlias;
11
11
  exports.patchData = exports.normalizeLegacySummarizeForSave = exports.metaIsCheck = exports.mergeSubQueryColumns = void 0;
12
12
  exports.reassembleByUnion = reassembleByUnion;
@@ -54,6 +54,15 @@ var SUB_QUERY_OUTPUT_COLUMN_KEY = '__subQueryOutputColumn';
54
54
  var isSubQueryOutputColumn = function isSubQueryOutputColumn(column) {
55
55
  return Boolean((column === null || column === void 0 ? void 0 : column.summarizeType) && (column === null || column === void 0 ? void 0 : column[SUB_QUERY_OUTPUT_COLUMN_KEY]));
56
56
  };
57
+ var getSubQueryColumnSourceKey = function getSubQueryColumnSourceKey(column) {
58
+ var columnMeta = column;
59
+ return [column.datasourceId || '', column.tableUuid || '', column.tableId || '', column.table || columnMeta.tableName || '', columnMeta.fieldId || column.id || '', column.name || '', column.realName || ''].join('|');
60
+ };
61
+ var getSubQueryColumnInstanceUuid = exports.getSubQueryColumnInstanceUuid = function getSubQueryColumnInstanceUuid(column) {
62
+ var tableUuid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
63
+ var sourceKey = getSubQueryColumnSourceKey(column);
64
+ return [tableUuid || column.tableUuid || '', column.summarizeType || '', sourceKey].join('|');
65
+ };
57
66
  var getColumnsTables = exports.getColumnsTables = function getColumnsTables(data) {
58
67
  var obj = {};
59
68
  data.map(function (v) {
@@ -151,7 +160,8 @@ var normalizeSubQueryColumn = function normalizeSubQueryColumn(column) {
151
160
  name_zh: column.name_zh || column.quotes || '',
152
161
  id: column.id || column.fieldId || outputName,
153
162
  realName: column.realName || column.name || '',
154
- fieldAlias: ''
163
+ fieldAlias: '',
164
+ fieldUuid: column.fieldUuid || getSubQueryColumnInstanceUuid(column)
155
165
  });
156
166
  };
157
167
  var getOuterSubQueryFieldAlias = function getOuterSubQueryFieldAlias(existingCol, newCol) {
@@ -185,6 +195,20 @@ var isSameSubQueryOutputColumn = function isSameSubQueryOutputColumn(oldCol, new
185
195
  var newIdentity = getSubQueryOutputIdentity(newCol);
186
196
  return Boolean(oldIdentity && newIdentity && oldIdentity === newIdentity);
187
197
  };
198
+ var isSameColumnTableInstance = function isSameColumnTableInstance(oldCol, newCol) {
199
+ var oldColumn = oldCol;
200
+ var newColumn = newCol;
201
+ if (oldColumn.tableUuid && newColumn.tableUuid) {
202
+ return oldColumn.tableUuid === newColumn.tableUuid;
203
+ }
204
+ if (oldColumn.datasourceId && newColumn.datasourceId && oldColumn.datasourceId !== newColumn.datasourceId) {
205
+ return false;
206
+ }
207
+ if (oldColumn.tableId && newColumn.tableId && oldColumn.tableId !== newColumn.tableId) {
208
+ return false;
209
+ }
210
+ return true;
211
+ };
188
212
  var mergeSubQueryColumns = exports.mergeSubQueryColumns = function mergeSubQueryColumns(columns) {
189
213
  var oldColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
190
214
  var isSelectFields = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -192,6 +216,9 @@ var mergeSubQueryColumns = exports.mergeSubQueryColumns = function mergeSubQuery
192
216
  var newColumn = newCol;
193
217
  var existingCol = oldColumns.find(function (oldCol) {
194
218
  var oldColumn = oldCol;
219
+ if (!isSameColumnTableInstance(oldCol, newCol)) {
220
+ return false;
221
+ }
195
222
  if (oldColumn.fieldUuid && newColumn.fieldUuid) {
196
223
  return oldColumn.fieldUuid === newColumn.fieldUuid;
197
224
  }
@@ -768,8 +795,8 @@ var syncAtomQuotesList = function syncAtomQuotesList(items) {
768
795
  return items.map(syncAtomQuotes);
769
796
  };
770
797
  var isSameAliasTargetTable = function isSameAliasTargetTable(item, target) {
771
- if (target.tableUuid && item.tableUuid && item.tableUuid === target.tableUuid) {
772
- return true;
798
+ if (target.tableUuid && item.tableUuid) {
799
+ return item.tableUuid === target.tableUuid;
773
800
  }
774
801
  if (target.datasourceId && item.datasourceId && item.datasourceId !== target.datasourceId) {
775
802
  return false;
@@ -780,15 +807,32 @@ var isSameAliasTargetTable = function isSameAliasTargetTable(item, target) {
780
807
  return Boolean(target.tableName && item.tableName && item.tableName === target.tableName);
781
808
  };
782
809
  var isAliasTargetField = function isAliasTargetField(item, target) {
810
+ var sameTable = isSameAliasTargetTable(item, target);
783
811
  if (target.uuid && item.fieldUuid && item.fieldUuid === target.uuid) {
784
- return true;
812
+ return sameTable || !(target.tableUuid || target.tableId || target.tableName);
785
813
  }
786
- var sameTable = isSameAliasTargetTable(item, target);
787
814
  if (target.fieldId && item.fieldId && item.fieldId === target.fieldId) {
788
815
  return sameTable || !target.tableId;
789
816
  }
790
817
  return Boolean(target.fieldName && item.fieldName && item.fieldName === target.fieldName && sameTable);
791
818
  };
819
+ var isAliasTargetSummarizeRecord = function isAliasTargetSummarizeRecord(record, target) {
820
+ return isAliasTargetField({
821
+ fieldName: record.name || '',
822
+ fieldNameZh: record.name_zh || '',
823
+ fieldAlias: record.fieldAlias || '',
824
+ fieldUuid: record.fieldUuid || '',
825
+ fieldId: record.fieldId || record.id || '',
826
+ tableName: record.table || '',
827
+ tableNameZh: '',
828
+ tableId: record.tableId || '',
829
+ tableAlias: record.alias || '',
830
+ tableUuid: record.tableUuid || '',
831
+ datasourceName: record.datasourceName || '',
832
+ datasourceId: record.datasourceId || '',
833
+ type: _types.AtomsTypeEnum.FIELD
834
+ }, target);
835
+ };
792
836
  var _changeAlias = function changeAlias(items, val, type) {
793
837
  return items.map(function (v) {
794
838
  var nextItem;
@@ -1018,7 +1062,7 @@ var changeFieldAlias = exports.changeFieldAlias = function changeFieldAlias(list
1018
1062
  if (groupAtoms && groupAtoms.length > 0) {
1019
1063
  group.atoms = _changeAlias(groupAtoms, aliasTarget, AliasType.field);
1020
1064
  group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
1021
- } else if (group.fieldUuid === uuid) {
1065
+ } else if (isAliasTargetSummarizeRecord(group, aliasTarget)) {
1022
1066
  group.fieldAlias = alias;
1023
1067
  group.sql = (0, _helper.summarizeToSql)(v.group, group).sql;
1024
1068
  }
@@ -1027,7 +1071,7 @@ var changeFieldAlias = exports.changeFieldAlias = function changeFieldAlias(list
1027
1071
  if (by.atoms && by.atoms.length > 0) {
1028
1072
  by.atoms = _changeAlias(by.atoms, aliasTarget, AliasType.field);
1029
1073
  by.sql = (0, _helper.summarizeByToSql)(by);
1030
- } else if (by.fieldUuid === uuid) {
1074
+ } else if (isAliasTargetSummarizeRecord(by, aliasTarget)) {
1031
1075
  by.fieldAlias = alias;
1032
1076
  by.sql = (0, _helper.summarizeByToSql)(by);
1033
1077
  }
@@ -20,7 +20,7 @@ import cloneDeep from 'lodash/cloneDeep';
20
20
  import { useStore } from '../../../hooks/use-provider';
21
21
  import { getTopLayerZIndex } from '../../../utils/helper-dom';
22
22
  var VisualBox = Styled.div.attrs({
23
- className: 'visual-box'
23
+ className: 'visual-box scroller'
24
24
  })(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
25
25
  var CaseEditor = React.forwardRef(function (props, ref) {
26
26
  var _store$formulaTemplat, _fun$args;
@@ -155,7 +155,7 @@ var CaseWhenGroup = function CaseWhenGroup(_ref) {
155
155
  className: 'Sqb-CaseBranchIndex',
156
156
  children: branchIndex + 1
157
157
  }), _jsx("div", {
158
- className: 'Sqb-CaseBranch-body',
158
+ className: 'Sqb-CaseBranch-body scroller-x',
159
159
  children: renderBranchContent(_jsxs(_Fragment, {
160
160
  children: [_jsxs("div", {
161
161
  className: 'Sqb-CaseSection Sqb-CaseSection-condition',
@@ -226,7 +226,7 @@ var CaseWhenGroup = function CaseWhenGroup(_ref) {
226
226
  className: 'Sqb-CaseBranchIndex Sqb-CaseBranchIndex--else',
227
227
  "aria-hidden": 'true'
228
228
  }), _jsx("div", {
229
- className: 'Sqb-CaseBranch-body',
229
+ className: 'Sqb-CaseBranch-body scroller-x',
230
230
  children: renderBranchContent(_jsxs("div", {
231
231
  className: 'Sqb-CaseSection Sqb-CaseSection-result Sqb-CaseSection-else',
232
232
  children: [_jsx("span", {
@@ -487,7 +487,7 @@ var FormulaList = forwardRef(function (props, ref) {
487
487
  children: _jsxs("div", {
488
488
  className: 'Sqb-FormulaListZoomEditor',
489
489
  children: [_jsx("div", {
490
- className: 'Sqb-FormulaListZoomEditor-body',
490
+ className: 'Sqb-FormulaListZoomEditor-body scroller scroller-x',
491
491
  children: _jsx("div", {
492
492
  className: 'Sqb-NotebookCell Sqb-FormulaListZoomEditor-cell',
493
493
  children: _jsx(CaseWhenGroup, {
@@ -649,7 +649,7 @@ var FormulaList = forwardRef(function (props, ref) {
649
649
  children: _jsxs("div", {
650
650
  className: 'Sqb-FormulaListZoomEditor',
651
651
  children: [_jsx("div", {
652
- className: 'Sqb-FormulaListZoomEditor-body Sqb-FormulaListZoomEditor-body--formulaList',
652
+ className: 'Sqb-FormulaListZoomEditor-body Sqb-FormulaListZoomEditor-body--formulaList scroller scroller-x',
653
653
  children: _jsx(FormulaList, {
654
654
  ref: ref,
655
655
  value: draftList,
@@ -1649,8 +1649,8 @@
1649
1649
  width: 100%;
1650
1650
  min-width: 100%;
1651
1651
  box-sizing: border-box;
1652
- padding-left: var(--sqb-item-shell-margin-x, 14px);
1653
- padding-right: var(--sqb-item-shell-margin-x, 14px);
1652
+ padding: var(--sqb-item-shell-margin-x, 14px);
1653
+ // padding: var(--sqb-item-shell-margin-x, 14px);
1654
1654
  }
1655
1655
 
1656
1656
  .Sqb-FormulaListZoomEditor-body .Sqb-FormulaListZoomEditor-cell {
@@ -1736,6 +1736,14 @@
1736
1736
  padding-bottom: 4px;
1737
1737
  }
1738
1738
 
1739
+ .Sqb-FormulaListZoomEditor-body
1740
+ .Sqb-CaseWhenGroup:not(.Sqb-CaseWhenGroup--nested)
1741
+ > .Sqb-FormulaGroup-row
1742
+ > .Sqb-CaseBranch-body:has(.Sqb-CaseWhenGroup--nested) {
1743
+ overflow: visible;
1744
+ padding-bottom: 0;
1745
+ }
1746
+
1739
1747
  .Sqb-FormulaListZoomEditor-body
1740
1748
  .Sqb-CaseWhenGroup:not(.Sqb-CaseWhenGroup--nested)
1741
1749
  > .Sqb-FormulaGroup-row
@@ -2163,8 +2171,7 @@
2163
2171
  border-color: rgba(80, 158, 227, 0.88);
2164
2172
  }
2165
2173
 
2166
- .Sqb-FormulaGroup.logic-group
2167
- > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested),
2174
+ .Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested),
2168
2175
  .Sqb-FormulaGroup.logic-group
2169
2176
  > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
2170
2177
  > .Sqb-NestedFormulaList,
@@ -2195,8 +2202,7 @@
2195
2202
  box-sizing: border-box;
2196
2203
  }
2197
2204
 
2198
- .Sqb-FormulaGroup.logic-group
2199
- > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested) {
2205
+ .Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested) {
2200
2206
  flex: 1 1 auto;
2201
2207
  }
2202
2208
 
@@ -90,15 +90,15 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
90
90
  }
91
91
  }, [_value]);
92
92
  var getFieldTableKey = function getFieldTableKey(tableId, tableUuid) {
93
- return tableId || tableUuid || '';
93
+ return tableUuid || tableId || '';
94
94
  };
95
95
  var isSameSelectedTable = function isSameSelectedTable(field, tableId, tableUuid) {
96
- if (field.tableId && tableId) {
97
- return field.tableId === tableId;
98
- }
99
96
  if (field.tableUuid && tableUuid) {
100
97
  return field.tableUuid === tableUuid;
101
98
  }
99
+ if (field.tableId && tableId) {
100
+ return field.tableId === tableId;
101
+ }
102
102
  return false;
103
103
  };
104
104
  var getSelectedFieldKey = function getSelectedFieldKey(field) {
@@ -1,3 +1,39 @@
1
+ .scroller::-webkit-scrollbar {
2
+ width: 4px;
3
+ height: 100%;
4
+ background: transparent;
5
+ }
6
+
7
+ .scroller::-webkit-scrollbar-thumb {
8
+ background: rgba(100, 100, 100, 0.4);
9
+ border-radius: 2px;
10
+
11
+ &:hover {
12
+ background: rgba(100, 100, 100, 0.7);
13
+ }
14
+ }
15
+
16
+ .scroller-x::-webkit-scrollbar {
17
+ width: 100%;
18
+ height: 8px;
19
+ background: transparent;
20
+ }
21
+
22
+ .scroller.scroller-x::-webkit-scrollbar {
23
+ width: 4px;
24
+ height: 8px;
25
+ background: transparent;
26
+ }
27
+
28
+ .scroller-x::-webkit-scrollbar-thumb {
29
+ background: rgba(100, 100, 100, 0.4);
30
+ border-radius: 2px;
31
+
32
+ &:hover {
33
+ background: rgba(100, 100, 100, 0.7);
34
+ }
35
+ }
36
+
1
37
  .mx-4 {
2
38
  margin-left: 1rem;
3
39
  margin-right: 1rem;
@@ -17,7 +17,7 @@ import Popup from '../popup';
17
17
  import { useStore } from '../../hooks/use-provider';
18
18
  import storage from '../../utils/storage';
19
19
  var VisualBox = Styled.div.attrs({
20
- className: 'visual-box'
20
+ className: 'visual-box scroller'
21
21
  })(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
22
22
  var Metabase = function Metabase(props) {
23
23
  var _props$btnText = props.btnText,
@@ -991,7 +991,8 @@ var JoinData = function JoinData(props) {
991
991
  var _store$preProps3;
992
992
  newMeta[index].subquery = newList;
993
993
  newMeta[index].table2 = _objectSpread(_objectSpread({}, newList[0].table), {}, {
994
- alias: newMeta[index].table2.alias || getAlias(newList[0].table.name, newMeta, ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.notExistsColumns) || [])
994
+ alias: newMeta[index].table2.alias || getAlias(newList[0].table.name, newMeta, ((_store$preProps3 = store.preProps) === null || _store$preProps3 === void 0 ? void 0 : _store$preProps3.notExistsColumns) || []),
995
+ tableUuid: newMeta[index].table2.tableUuid || uuidv4('table')
995
996
  });
996
997
  var items = getSubColumns(newList);
997
998
  var subQueryTable = newMeta[index].table2;
@@ -112,11 +112,7 @@ export var isSameColumnByIdFirst = function isSameColumnByIdFirst() {
112
112
  var leftTableUuid = normalizeId(left.tableUuid);
113
113
  var rightTableUuid = normalizeId(right.tableUuid);
114
114
  if (hasBoth(leftTableUuid, rightTableUuid) && leftTableUuid !== rightTableUuid) {
115
- var leftTableName = normalizeId(left.tableName || left.table);
116
- var rightTableName = normalizeId(right.tableName || right.table);
117
- if (!hasBoth(leftTableName, rightTableName) || leftTableName !== rightTableName) {
118
- return false;
119
- }
115
+ return false;
120
116
  }
121
117
  var leftFieldId = normalizeId(left.fieldId || left.id);
122
118
  var rightFieldId = normalizeId(right.fieldId || right.id);
package/lib/es/utils.d.ts CHANGED
@@ -4,6 +4,7 @@ import { DataType } from './components/dialog/select-column-multiple';
4
4
  export declare const findIndex: <T>(arr: T[], item: T) => number;
5
5
  export declare const findMetaKey: <T>(arr: T[], item: T) => number;
6
6
  export declare const getMetaTabels: (data: MetaListType[]) => any;
7
+ export declare const getSubQueryColumnInstanceUuid: (column: any, tableUuid?: string) => string;
7
8
  export declare const getColumnsTables: (data: DataType[]) => any;
8
9
  interface HelperResultType {
9
10
  ExistAboveGroupBy: boolean;
package/lib/es/utils.js CHANGED
@@ -40,6 +40,15 @@ var SUB_QUERY_OUTPUT_COLUMN_KEY = '__subQueryOutputColumn';
40
40
  var isSubQueryOutputColumn = function isSubQueryOutputColumn(column) {
41
41
  return Boolean((column === null || column === void 0 ? void 0 : column.summarizeType) && (column === null || column === void 0 ? void 0 : column[SUB_QUERY_OUTPUT_COLUMN_KEY]));
42
42
  };
43
+ var getSubQueryColumnSourceKey = function getSubQueryColumnSourceKey(column) {
44
+ var columnMeta = column;
45
+ return [column.datasourceId || '', column.tableUuid || '', column.tableId || '', column.table || columnMeta.tableName || '', columnMeta.fieldId || column.id || '', column.name || '', column.realName || ''].join('|');
46
+ };
47
+ export var getSubQueryColumnInstanceUuid = function getSubQueryColumnInstanceUuid(column) {
48
+ var tableUuid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
49
+ var sourceKey = getSubQueryColumnSourceKey(column);
50
+ return [tableUuid || column.tableUuid || '', column.summarizeType || '', sourceKey].join('|');
51
+ };
43
52
  export var getColumnsTables = function getColumnsTables(data) {
44
53
  var obj = {};
45
54
  data.map(function (v) {
@@ -137,7 +146,8 @@ var normalizeSubQueryColumn = function normalizeSubQueryColumn(column) {
137
146
  name_zh: column.name_zh || column.quotes || '',
138
147
  id: column.id || column.fieldId || outputName,
139
148
  realName: column.realName || column.name || '',
140
- fieldAlias: ''
149
+ fieldAlias: '',
150
+ fieldUuid: column.fieldUuid || getSubQueryColumnInstanceUuid(column)
141
151
  });
142
152
  };
143
153
  var getOuterSubQueryFieldAlias = function getOuterSubQueryFieldAlias(existingCol, newCol) {
@@ -171,6 +181,20 @@ var isSameSubQueryOutputColumn = function isSameSubQueryOutputColumn(oldCol, new
171
181
  var newIdentity = getSubQueryOutputIdentity(newCol);
172
182
  return Boolean(oldIdentity && newIdentity && oldIdentity === newIdentity);
173
183
  };
184
+ var isSameColumnTableInstance = function isSameColumnTableInstance(oldCol, newCol) {
185
+ var oldColumn = oldCol;
186
+ var newColumn = newCol;
187
+ if (oldColumn.tableUuid && newColumn.tableUuid) {
188
+ return oldColumn.tableUuid === newColumn.tableUuid;
189
+ }
190
+ if (oldColumn.datasourceId && newColumn.datasourceId && oldColumn.datasourceId !== newColumn.datasourceId) {
191
+ return false;
192
+ }
193
+ if (oldColumn.tableId && newColumn.tableId && oldColumn.tableId !== newColumn.tableId) {
194
+ return false;
195
+ }
196
+ return true;
197
+ };
174
198
  export var mergeSubQueryColumns = function mergeSubQueryColumns(columns) {
175
199
  var oldColumns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
176
200
  var isSelectFields = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -178,6 +202,9 @@ export var mergeSubQueryColumns = function mergeSubQueryColumns(columns) {
178
202
  var newColumn = newCol;
179
203
  var existingCol = oldColumns.find(function (oldCol) {
180
204
  var oldColumn = oldCol;
205
+ if (!isSameColumnTableInstance(oldCol, newCol)) {
206
+ return false;
207
+ }
181
208
  if (oldColumn.fieldUuid && newColumn.fieldUuid) {
182
209
  return oldColumn.fieldUuid === newColumn.fieldUuid;
183
210
  }
@@ -754,8 +781,8 @@ var syncAtomQuotesList = function syncAtomQuotesList(items) {
754
781
  return items.map(syncAtomQuotes);
755
782
  };
756
783
  var isSameAliasTargetTable = function isSameAliasTargetTable(item, target) {
757
- if (target.tableUuid && item.tableUuid && item.tableUuid === target.tableUuid) {
758
- return true;
784
+ if (target.tableUuid && item.tableUuid) {
785
+ return item.tableUuid === target.tableUuid;
759
786
  }
760
787
  if (target.datasourceId && item.datasourceId && item.datasourceId !== target.datasourceId) {
761
788
  return false;
@@ -766,15 +793,32 @@ var isSameAliasTargetTable = function isSameAliasTargetTable(item, target) {
766
793
  return Boolean(target.tableName && item.tableName && item.tableName === target.tableName);
767
794
  };
768
795
  var isAliasTargetField = function isAliasTargetField(item, target) {
796
+ var sameTable = isSameAliasTargetTable(item, target);
769
797
  if (target.uuid && item.fieldUuid && item.fieldUuid === target.uuid) {
770
- return true;
798
+ return sameTable || !(target.tableUuid || target.tableId || target.tableName);
771
799
  }
772
- var sameTable = isSameAliasTargetTable(item, target);
773
800
  if (target.fieldId && item.fieldId && item.fieldId === target.fieldId) {
774
801
  return sameTable || !target.tableId;
775
802
  }
776
803
  return Boolean(target.fieldName && item.fieldName && item.fieldName === target.fieldName && sameTable);
777
804
  };
805
+ var isAliasTargetSummarizeRecord = function isAliasTargetSummarizeRecord(record, target) {
806
+ return isAliasTargetField({
807
+ fieldName: record.name || '',
808
+ fieldNameZh: record.name_zh || '',
809
+ fieldAlias: record.fieldAlias || '',
810
+ fieldUuid: record.fieldUuid || '',
811
+ fieldId: record.fieldId || record.id || '',
812
+ tableName: record.table || '',
813
+ tableNameZh: '',
814
+ tableId: record.tableId || '',
815
+ tableAlias: record.alias || '',
816
+ tableUuid: record.tableUuid || '',
817
+ datasourceName: record.datasourceName || '',
818
+ datasourceId: record.datasourceId || '',
819
+ type: AtomsTypeEnum.FIELD
820
+ }, target);
821
+ };
778
822
  var _changeAlias = function changeAlias(items, val, type) {
779
823
  return items.map(function (v) {
780
824
  var nextItem;
@@ -1004,7 +1048,7 @@ export var changeFieldAlias = function changeFieldAlias(list, curObj) {
1004
1048
  if (groupAtoms && groupAtoms.length > 0) {
1005
1049
  group.atoms = _changeAlias(groupAtoms, aliasTarget, AliasType.field);
1006
1050
  group.sql = summarizeToSql(v.group, group).sql;
1007
- } else if (group.fieldUuid === uuid) {
1051
+ } else if (isAliasTargetSummarizeRecord(group, aliasTarget)) {
1008
1052
  group.fieldAlias = alias;
1009
1053
  group.sql = summarizeToSql(v.group, group).sql;
1010
1054
  }
@@ -1013,7 +1057,7 @@ export var changeFieldAlias = function changeFieldAlias(list, curObj) {
1013
1057
  if (by.atoms && by.atoms.length > 0) {
1014
1058
  by.atoms = _changeAlias(by.atoms, aliasTarget, AliasType.field);
1015
1059
  by.sql = summarizeByToSql(by);
1016
- } else if (by.fieldUuid === uuid) {
1060
+ } else if (isAliasTargetSummarizeRecord(by, aliasTarget)) {
1017
1061
  by.fieldAlias = alias;
1018
1062
  by.sql = summarizeByToSql(by);
1019
1063
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.137-alpha.3",
3
+ "version": "1.0.137-alpha.4",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",