@gingkoo/pandora-metabase 1.0.137 → 1.0.138
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/formula/index.js +1 -1
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +2 -2
- package/lib/cjs/components/dialog/formula-list/index.js +2 -2
- package/lib/cjs/components/dialog/formula-list/index.less +108 -2
- package/lib/cjs/components/dialog/formula-list/utils.js +6 -0
- package/lib/cjs/components/dialog/select-column-multiple/index.js +79 -34
- package/lib/cjs/components/metabase/helper.less +36 -0
- package/lib/cjs/components/metabase/index.js +1 -1
- package/lib/cjs/components/modules/join-data.js +64 -65
- package/lib/cjs/utils/helper.js +1 -5
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +112 -48
- package/lib/es/components/dialog/formula/index.js +1 -1
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +2 -2
- package/lib/es/components/dialog/formula-list/index.js +2 -2
- package/lib/es/components/dialog/formula-list/index.less +108 -2
- package/lib/es/components/dialog/formula-list/utils.js +6 -0
- package/lib/es/components/dialog/select-column-multiple/index.js +80 -35
- package/lib/es/components/metabase/helper.less +36 -0
- package/lib/es/components/metabase/index.js +1 -1
- package/lib/es/components/modules/join-data.js +64 -65
- package/lib/es/utils/helper.js +1 -5
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +111 -47
- package/package.json +1 -1
package/lib/cjs/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/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
|
|
772
|
-
return
|
|
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
|
|
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
|
|
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
|
|
1074
|
+
} else if (isAliasTargetSummarizeRecord(by, aliasTarget)) {
|
|
1031
1075
|
by.fieldAlias = alias;
|
|
1032
1076
|
by.sql = (0, _helper.summarizeByToSql)(by);
|
|
1033
1077
|
}
|
|
@@ -1250,12 +1294,60 @@ var hasLoadedColumnData = function hasLoadedColumnData() {
|
|
|
1250
1294
|
return Array.isArray(table === null || table === void 0 ? void 0 : table.columns) && table.columns.length > 0;
|
|
1251
1295
|
});
|
|
1252
1296
|
};
|
|
1297
|
+
var normalizeIdentityValue = function normalizeIdentityValue(val) {
|
|
1298
|
+
if (val === undefined || val === null) return '';
|
|
1299
|
+
return "".concat(val);
|
|
1300
|
+
};
|
|
1301
|
+
var isSourceLikeDatasource = function isSourceLikeDatasource(datasourceId) {
|
|
1302
|
+
return !datasourceId || datasourceId === 'source';
|
|
1303
|
+
};
|
|
1304
|
+
var isSameErrorCheckTable = function isSameErrorCheckTable(table, item) {
|
|
1305
|
+
var itemDatasourceId = normalizeIdentityValue(item.datasourceId);
|
|
1306
|
+
var tableDatasourceId = normalizeIdentityValue(table.datasourceId);
|
|
1307
|
+
if (!isSourceLikeDatasource(itemDatasourceId) && !isSourceLikeDatasource(tableDatasourceId) && itemDatasourceId !== tableDatasourceId) {
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1310
|
+
var itemTableId = normalizeIdentityValue(item.tableId);
|
|
1311
|
+
var tableId = normalizeIdentityValue(table.id);
|
|
1312
|
+
if (itemTableId && tableId && itemTableId !== tableId) {
|
|
1313
|
+
return false;
|
|
1314
|
+
}
|
|
1315
|
+
var itemTableAlias = normalizeIdentityValue(item.tableAlias);
|
|
1316
|
+
var tableAlias = normalizeIdentityValue(table.alias);
|
|
1317
|
+
if (itemTableAlias && tableAlias && itemTableAlias !== tableAlias) {
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1320
|
+
var itemTableName = normalizeIdentityValue(item.tableName);
|
|
1321
|
+
var tableName = normalizeIdentityValue(table.name);
|
|
1322
|
+
return Boolean(itemTableId && tableId && itemTableId === tableId || itemTableAlias && tableAlias && itemTableAlias === tableAlias || item.tableUuid && table.tableUuid && item.tableUuid === table.tableUuid || itemTableName && tableName && itemTableName === tableName);
|
|
1323
|
+
};
|
|
1324
|
+
var isSameErrorCheckColumn = function isSameErrorCheckColumn(field, item) {
|
|
1325
|
+
if ((0, _helper2.isSameColumnByIdFirst)(field, item)) {
|
|
1326
|
+
return true;
|
|
1327
|
+
}
|
|
1328
|
+
if (!(field !== null && field !== void 0 && field.summarizeType)) {
|
|
1329
|
+
return false;
|
|
1330
|
+
}
|
|
1331
|
+
var itemValues = [item.fieldId, item.id, item.fieldUuid, item.fieldName, item.fieldAlias].map(normalizeIdentityValue).filter(Boolean);
|
|
1332
|
+
var fieldValues = [field.fieldId, field.id, field.fieldUuid, field.fieldName, field.name, field.fieldAlias, field.realName].map(normalizeIdentityValue).filter(Boolean);
|
|
1333
|
+
return itemValues.some(function (value) {
|
|
1334
|
+
return fieldValues.includes(value);
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
var getErrorCheckFields = function getErrorCheckFields(item, data) {
|
|
1338
|
+
var tables = data.filter(function (table) {
|
|
1339
|
+
return isSameErrorCheckTable(table, item);
|
|
1340
|
+
});
|
|
1341
|
+
if (!tables.length) return null;
|
|
1342
|
+
return tables.flatMap(function (table) {
|
|
1343
|
+
return table.columns || [];
|
|
1344
|
+
});
|
|
1345
|
+
};
|
|
1253
1346
|
var _isError = exports.isError = function isError(item) {
|
|
1254
1347
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1255
1348
|
if (!hasLoadedColumnData(data)) {
|
|
1256
1349
|
return false;
|
|
1257
1350
|
}
|
|
1258
|
-
var tables = getColumnsTables(data);
|
|
1259
1351
|
if (!item) {
|
|
1260
1352
|
return false;
|
|
1261
1353
|
}
|
|
@@ -1265,49 +1357,21 @@ var _isError = exports.isError = function isError(item) {
|
|
|
1265
1357
|
});
|
|
1266
1358
|
}
|
|
1267
1359
|
if (item.type === _types.AtomsTypeEnum.FIELD) {
|
|
1268
|
-
var
|
|
1269
|
-
_item$tableId
|
|
1270
|
-
tableId = _item$tableId === void 0 ? '' : _item$tableId,
|
|
1271
|
-
_item$tableAlias = item.tableAlias,
|
|
1272
|
-
tableAlias = _item$tableAlias === void 0 ? '' : _item$tableAlias,
|
|
1273
|
-
fieldName = item.fieldName,
|
|
1274
|
-
fieldId = item.fieldId;
|
|
1275
|
-
var _datasourceId = datasourceId || 'source';
|
|
1276
|
-
if (tableId === 'source') {
|
|
1277
|
-
_datasourceId = 'source';
|
|
1278
|
-
}
|
|
1360
|
+
var _item$tableId = item.tableId,
|
|
1361
|
+
tableId = _item$tableId === void 0 ? '' : _item$tableId;
|
|
1279
1362
|
if (!tableId) {
|
|
1280
1363
|
return false;
|
|
1281
1364
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
if (!fields) {
|
|
1286
|
-
return true;
|
|
1287
|
-
} else if (!fields.length) {
|
|
1288
|
-
return false;
|
|
1289
|
-
} else {
|
|
1290
|
-
return fields.every(function (field) {
|
|
1291
|
-
return !(0, _helper2.isSameColumnByIdFirst)((0, _objectSpread6["default"])((0, _objectSpread6["default"])({}, field), {}, {
|
|
1292
|
-
datasourceId: _datasourceId,
|
|
1293
|
-
tableId: tableId
|
|
1294
|
-
}), item);
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
} else {
|
|
1298
|
-
var _tables$_datasourceId2, _fields$some;
|
|
1299
|
-
var _fields = tables === null || tables === void 0 || (_tables$_datasourceId2 = tables[_datasourceId]) === null || _tables$_datasourceId2 === void 0 ? void 0 : _tables$_datasourceId2[tableId + tableAlias];
|
|
1300
|
-
if (_fields && !_fields.length) {
|
|
1301
|
-
return false;
|
|
1302
|
-
}
|
|
1303
|
-
var hasField = (_fields$some = _fields === null || _fields === void 0 ? void 0 : _fields.some(function (v) {
|
|
1304
|
-
return (0, _helper2.isSameColumnByIdFirst)((0, _objectSpread6["default"])((0, _objectSpread6["default"])({}, v), {}, {
|
|
1305
|
-
datasourceId: _datasourceId,
|
|
1306
|
-
tableId: tableId
|
|
1307
|
-
}), item);
|
|
1308
|
-
})) !== null && _fields$some !== void 0 ? _fields$some : false;
|
|
1309
|
-
return !hasField;
|
|
1365
|
+
var fields = getErrorCheckFields(item, data);
|
|
1366
|
+
if (!fields) {
|
|
1367
|
+
return true;
|
|
1310
1368
|
}
|
|
1369
|
+
if (!fields.length) {
|
|
1370
|
+
return false;
|
|
1371
|
+
}
|
|
1372
|
+
return !fields.some(function (field) {
|
|
1373
|
+
return isSameErrorCheckColumn(field, item);
|
|
1374
|
+
});
|
|
1311
1375
|
}
|
|
1312
1376
|
if (item.type === _types.AtomsTypeEnum.EXPRESSION) {
|
|
1313
1377
|
var lhsHasError = _isError(item.lhs, data);
|
|
@@ -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
|
|
1653
|
-
padding
|
|
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
|
|
@@ -2162,3 +2170,101 @@
|
|
|
2162
2170
|
background: rgba(80, 158, 227, 0.88);
|
|
2163
2171
|
border-color: rgba(80, 158, 227, 0.88);
|
|
2164
2172
|
}
|
|
2173
|
+
|
|
2174
|
+
.Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested),
|
|
2175
|
+
.Sqb-FormulaGroup.logic-group
|
|
2176
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2177
|
+
> .Sqb-NestedFormulaList,
|
|
2178
|
+
.Sqb-FormulaGroup.logic-group
|
|
2179
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2180
|
+
> .Sqb-NestedFormulaList
|
|
2181
|
+
> .Sqb-NotebookCell,
|
|
2182
|
+
.Sqb-FormulaGroup.logic-group
|
|
2183
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2184
|
+
> .Sqb-NestedFormulaList
|
|
2185
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded,
|
|
2186
|
+
.Sqb-FormulaGroup.logic-group
|
|
2187
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2188
|
+
> .Sqb-NestedFormulaList
|
|
2189
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded
|
|
2190
|
+
> .Sqb-Filter-item.item-composite,
|
|
2191
|
+
.Sqb-FormulaGroup.logic-group
|
|
2192
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2193
|
+
> .Sqb-NestedFormulaList
|
|
2194
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded
|
|
2195
|
+
> .Sqb-Filter-item.item-composite
|
|
2196
|
+
> .Sqb-Filter-item-node,
|
|
2197
|
+
.Sqb-FormulaGroup.logic-group
|
|
2198
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2199
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested {
|
|
2200
|
+
min-width: 0;
|
|
2201
|
+
max-width: 100%;
|
|
2202
|
+
box-sizing: border-box;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
.Sqb-FormulaGroup.logic-group > .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested) {
|
|
2206
|
+
flex: 1 1 auto;
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
.Sqb-FormulaGroup.logic-group
|
|
2210
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2211
|
+
> .Sqb-NestedFormulaList,
|
|
2212
|
+
.Sqb-FormulaGroup.logic-group
|
|
2213
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2214
|
+
> .Sqb-NestedFormulaList
|
|
2215
|
+
> .Sqb-NotebookCell,
|
|
2216
|
+
.Sqb-FormulaGroup.logic-group
|
|
2217
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2218
|
+
> .Sqb-NestedFormulaList
|
|
2219
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded,
|
|
2220
|
+
.Sqb-FormulaGroup.logic-group
|
|
2221
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2222
|
+
> .Sqb-NestedFormulaList
|
|
2223
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded
|
|
2224
|
+
> .Sqb-Filter-item.item-composite,
|
|
2225
|
+
.Sqb-FormulaGroup.logic-group
|
|
2226
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2227
|
+
> .Sqb-NestedFormulaList
|
|
2228
|
+
> .Sqb-NotebookCell.Sqb-NotebookCell--embedded
|
|
2229
|
+
> .Sqb-Filter-item.item-composite
|
|
2230
|
+
> .Sqb-Filter-item-node,
|
|
2231
|
+
.Sqb-FormulaGroup.logic-group
|
|
2232
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2233
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested {
|
|
2234
|
+
flex: 1 1 auto;
|
|
2235
|
+
width: 100%;
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
.Sqb-FormulaGroup.logic-group
|
|
2239
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2240
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested
|
|
2241
|
+
> .Sqb-FormulaGroup-row.row-when,
|
|
2242
|
+
.Sqb-FormulaGroup.logic-group
|
|
2243
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2244
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested
|
|
2245
|
+
> .Sqb-FormulaGroup-row.row-else {
|
|
2246
|
+
grid-template-columns:
|
|
2247
|
+
var(--sqb-case-index-column) minmax(0, 1fr)
|
|
2248
|
+
var(--sqb-case-action-column);
|
|
2249
|
+
width: 100%;
|
|
2250
|
+
min-width: 0;
|
|
2251
|
+
max-width: 100%;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
.Sqb-FormulaGroup.logic-group
|
|
2255
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2256
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested
|
|
2257
|
+
> .Sqb-FormulaGroup-row.row-when
|
|
2258
|
+
> .Sqb-CaseBranch-body,
|
|
2259
|
+
.Sqb-FormulaGroup.logic-group
|
|
2260
|
+
> .Sqb-LogicGroup-content:has(.Sqb-CaseWhenGroup--nested)
|
|
2261
|
+
.Sqb-CaseWhenGroup.Sqb-CaseWhenGroup--nested
|
|
2262
|
+
> .Sqb-FormulaGroup-row.row-else
|
|
2263
|
+
> .Sqb-CaseBranch-body {
|
|
2264
|
+
width: 100%;
|
|
2265
|
+
min-width: 0;
|
|
2266
|
+
max-width: 100%;
|
|
2267
|
+
overflow-x: auto;
|
|
2268
|
+
overflow-y: hidden;
|
|
2269
|
+
padding-bottom: 4px;
|
|
2270
|
+
}
|
|
@@ -100,6 +100,12 @@ export var customTypes = [{
|
|
|
100
100
|
}, {
|
|
101
101
|
value: AtomsTypeEnum.EXPRESSION,
|
|
102
102
|
label: __('customColumn.expression')
|
|
103
|
+
}, {
|
|
104
|
+
value: AtomsTypeEnum.CASE_WHEN,
|
|
105
|
+
label: __('customColumn.caseWhen')
|
|
106
|
+
}, {
|
|
107
|
+
value: AtomsTypeEnum.AND_OR,
|
|
108
|
+
label: __('customColumn.andOr')
|
|
103
109
|
}, {
|
|
104
110
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
105
111
|
label: __('customColumn.input')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
4
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -14,7 +15,7 @@ import { AtomsTypeEnum } from '../../../store/types';
|
|
|
14
15
|
import { __ } from '../../../locale';
|
|
15
16
|
import { NUMBER_GROUP, DATE_GROUP } from '../const';
|
|
16
17
|
import { useStore } from '../../../hooks/use-provider';
|
|
17
|
-
import {
|
|
18
|
+
import { replaceTpl, mergeNameAlias, uuidv4 } from '../../../utils/helper';
|
|
18
19
|
import { SearchIcon, TableIcon, CircleIcon, LetterAaIcon, CalendarIcon, WellIcon, ForeignKeyIcon, UpArrowIcon2, DownArrowIcon2 } from '../../icons';
|
|
19
20
|
export var DATE_GROUP_MAP = new Map([['分', '分'], ['时', '时'], ['天', '天'], ['周', '周'], ['月', '月'], ['季度', '季度'], ['一小时内的分钟数', '一小时内的分钟数'], ['一天内的小时数', '一天内的小时数'], ['一周内的天数', '一周内的天数'], ['一月内的天数', '一月内的天数'], ['一年内的天数', '一年内的天数'], ['一年的星期数', '一年的星期数'], ['一年的月数', '一年的月数']]);
|
|
20
21
|
export var NUMBER_GROUP_MAP = new Map([['自动间隔', '自动分组'], ['10个刻度间隔', '10 刻度间隔'], ['间隔50', '50 刻度间隔'], ['间隔100', '100 刻度间隔'], ['无间隔', '']]);
|
|
@@ -89,32 +90,74 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
89
90
|
setCurTable(selectedTableUuid);
|
|
90
91
|
}
|
|
91
92
|
}, [_value]);
|
|
92
|
-
var
|
|
93
|
-
|
|
93
|
+
var normalizeIdentityValue = function normalizeIdentityValue(val) {
|
|
94
|
+
if (val === undefined || val === null) return '';
|
|
95
|
+
return "".concat(val);
|
|
94
96
|
};
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
var isSourceLikeDatasource = function isSourceLikeDatasource(datasourceId) {
|
|
98
|
+
var normalizedDatasourceId = normalizeIdentityValue(datasourceId);
|
|
99
|
+
return !normalizedDatasourceId || normalizedDatasourceId === SummarizeAlias;
|
|
100
|
+
};
|
|
101
|
+
var getFieldTableKey = function getFieldTableKey(tableId, tableUuid, tableAlias, datasourceId) {
|
|
102
|
+
var normalizedTableId = normalizeIdentityValue(tableId);
|
|
103
|
+
var normalizedTableAlias = normalizeIdentityValue(tableAlias);
|
|
104
|
+
var normalizedTableUuid = normalizeIdentityValue(tableUuid);
|
|
105
|
+
var normalizedDatasourceId = normalizeIdentityValue(datasourceId);
|
|
106
|
+
var datasourceKey = isSourceLikeDatasource(normalizedDatasourceId) ? '' : normalizedDatasourceId;
|
|
107
|
+
if (normalizedTableId) {
|
|
108
|
+
return "".concat(datasourceKey, "|id:").concat(normalizedTableId, "|alias:").concat(normalizedTableAlias);
|
|
98
109
|
}
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
110
|
+
if (normalizedTableUuid) {
|
|
111
|
+
return "".concat(datasourceKey, "|uuid:").concat(normalizedTableUuid);
|
|
101
112
|
}
|
|
102
|
-
return
|
|
113
|
+
return datasourceKey;
|
|
103
114
|
};
|
|
104
|
-
var
|
|
105
|
-
if (!
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
|
|
115
|
+
var isSameSelectedTable = function isSameSelectedTable(field, tableItem) {
|
|
116
|
+
if (!tableItem) return false;
|
|
117
|
+
var fieldDatasourceId = normalizeIdentityValue(field.datasourceId);
|
|
118
|
+
var tableDatasourceId = normalizeIdentityValue(tableItem.datasourceId);
|
|
119
|
+
if (fieldDatasourceId && tableDatasourceId && !isSourceLikeDatasource(fieldDatasourceId) && !isSourceLikeDatasource(tableDatasourceId) && fieldDatasourceId !== tableDatasourceId) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
var fieldTableId = normalizeIdentityValue(field.tableId);
|
|
123
|
+
var tableId = normalizeIdentityValue(tableItem.id);
|
|
124
|
+
if (fieldTableId && tableId) {
|
|
125
|
+
if (fieldTableId !== tableId) return false;
|
|
126
|
+
var fieldTableAlias = normalizeIdentityValue(field.tableAlias);
|
|
127
|
+
var tableAlias = normalizeIdentityValue(tableItem.alias);
|
|
128
|
+
if (fieldTableAlias && tableAlias) {
|
|
129
|
+
return fieldTableAlias === tableAlias;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
var fieldTableUuid = normalizeIdentityValue(field.tableUuid);
|
|
134
|
+
var tableUuid = normalizeIdentityValue(tableItem.tableUuid);
|
|
135
|
+
return Boolean(fieldTableUuid && tableUuid && fieldTableUuid === tableUuid);
|
|
109
136
|
};
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
return
|
|
137
|
+
var getFieldStableValues = function getFieldStableValues(field) {
|
|
138
|
+
var includeAlias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
139
|
+
if (!field) return [];
|
|
140
|
+
return [field.fieldId, field.id, field.fieldName].concat(_toConsumableArray(includeAlias ? [field.fieldAlias] : [])).map(normalizeIdentityValue).filter(Boolean);
|
|
141
|
+
};
|
|
142
|
+
var getColumnStableValues = function getColumnStableValues(column) {
|
|
143
|
+
var includeAlias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
144
|
+
if (!column) return [];
|
|
145
|
+
return [column.id, column.fieldId, column.fieldName, column.name, column.realName].concat(_toConsumableArray(includeAlias ? [column.fieldAlias] : [])).map(normalizeIdentityValue).filter(Boolean);
|
|
146
|
+
};
|
|
147
|
+
var isSameSelectedField = function isSameSelectedField(field, column) {
|
|
148
|
+
var includeAlias = Boolean(column.summarizeType);
|
|
149
|
+
var fieldValues = getFieldStableValues(field, includeAlias);
|
|
150
|
+
var columnValues = getColumnStableValues(column, includeAlias);
|
|
151
|
+
if (fieldValues.some(function (value) {
|
|
152
|
+
return columnValues.includes(value);
|
|
153
|
+
})) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
return Boolean(field.fieldUuid && column.fieldUuid && field.fieldUuid === column.fieldUuid);
|
|
114
157
|
};
|
|
115
|
-
var isActive = function isActive(
|
|
158
|
+
var isActive = function isActive(column, tableItem) {
|
|
116
159
|
return (value === null || value === void 0 ? void 0 : value.filter(function (v) {
|
|
117
|
-
return isSameSelectedTable(v,
|
|
160
|
+
return isSameSelectedTable(v, tableItem) && isSameSelectedField(v, column);
|
|
118
161
|
}).length) > 0;
|
|
119
162
|
};
|
|
120
163
|
useEffect(function () {
|
|
@@ -168,14 +211,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
168
211
|
};
|
|
169
212
|
var getMatchedColumnByField = function getMatchedColumnByField(field, tableItem) {
|
|
170
213
|
if (!tableItem) return null;
|
|
171
|
-
var tableId = tableItem.id || '';
|
|
172
|
-
var tableUuid = tableItem.tableUuid || '';
|
|
173
214
|
return (tableItem.columns || []).find(function (column) {
|
|
174
|
-
return
|
|
175
|
-
tableId: tableId,
|
|
176
|
-
tableUuid: tableUuid,
|
|
177
|
-
datasourceId: tableItem.datasourceId || ''
|
|
178
|
-
}), field);
|
|
215
|
+
return isSameSelectedField(field, column);
|
|
179
216
|
}) || null;
|
|
180
217
|
};
|
|
181
218
|
var syncSelectedFieldByColumn = function syncSelectedFieldByColumn(field, column, tableItem) {
|
|
@@ -200,7 +237,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
200
237
|
useEffect(function () {
|
|
201
238
|
var syncedValue = (_value || []).map(function (field) {
|
|
202
239
|
var tableItem = data.find(function (item) {
|
|
203
|
-
return isSameSelectedTable(field, item
|
|
240
|
+
return isSameSelectedTable(field, item);
|
|
204
241
|
});
|
|
205
242
|
var matchedColumn = getMatchedColumnByField(field, tableItem);
|
|
206
243
|
return matchedColumn ? syncSelectedFieldByColumn(field, matchedColumn, tableItem) : field;
|
|
@@ -220,7 +257,12 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
220
257
|
return;
|
|
221
258
|
}
|
|
222
259
|
var isHas = (value === null || value === void 0 ? void 0 : value.filter(function (v) {
|
|
223
|
-
return val && isSameSelectedTable(v,
|
|
260
|
+
return val && isSameSelectedTable(v, {
|
|
261
|
+
id: val.tableId,
|
|
262
|
+
tableUuid: val.tableUuid,
|
|
263
|
+
alias: val.tableAlias,
|
|
264
|
+
datasourceId: val.datasourceId
|
|
265
|
+
}) && isSameSelectedField(v, val);
|
|
224
266
|
}).length) > 0;
|
|
225
267
|
var _value = value.slice();
|
|
226
268
|
if (tableUuid != selectedTable) {
|
|
@@ -228,22 +270,26 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
228
270
|
}
|
|
229
271
|
if (!isHas && val) {
|
|
230
272
|
_value = _value.filter(function (v) {
|
|
231
|
-
var hasTableKey = getFieldTableKey(v.tableId, v.tableUuid);
|
|
273
|
+
var hasTableKey = getFieldTableKey(v.tableId, v.tableUuid, v.tableAlias, v.datasourceId);
|
|
232
274
|
var isLegacySameField = !hasTableKey && (v.fieldId && v.fieldId === val.fieldId || v.fieldName && v.fieldName === val.fieldName);
|
|
233
275
|
return !isLegacySameField;
|
|
234
276
|
});
|
|
235
277
|
_value.push(val);
|
|
236
278
|
} else {
|
|
237
279
|
_value = _value.filter(function (v) {
|
|
238
|
-
return !(val && isSameSelectedTable(v,
|
|
280
|
+
return !(val && isSameSelectedTable(v, {
|
|
281
|
+
id: val.tableId,
|
|
282
|
+
tableUuid: val.tableUuid,
|
|
283
|
+
alias: val.tableAlias,
|
|
284
|
+
datasourceId: val.datasourceId
|
|
285
|
+
}) && isSameSelectedField(v, val));
|
|
239
286
|
});
|
|
240
287
|
}
|
|
241
288
|
var curTableItem = data.find(function (v) {
|
|
242
289
|
return v.tableUuid === tableUuid;
|
|
243
290
|
});
|
|
244
|
-
var curTableId = (curTableItem === null || curTableItem === void 0 ? void 0 : curTableItem.id) || '';
|
|
245
291
|
_value = _value.map(function (item2) {
|
|
246
|
-
if (!isSameSelectedTable(item2,
|
|
292
|
+
if (!isSameSelectedTable(item2, curTableItem)) return null;
|
|
247
293
|
var matchedColumn = getMatchedColumnByField(item2, curTableItem);
|
|
248
294
|
return matchedColumn ? syncSelectedFieldByColumn(item2, matchedColumn, curTableItem) : null;
|
|
249
295
|
}).filter(Boolean);
|
|
@@ -394,7 +440,6 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
394
440
|
_v$database_type = v.database_type,
|
|
395
441
|
database_type = _v$database_type === void 0 ? '' : _v$database_type,
|
|
396
442
|
name = v.name;
|
|
397
|
-
var columnKey = getColumnKey(v, isSummarize, tableId || '', tableUuid);
|
|
398
443
|
var fieldAlias = isSummarize ? v.fieldAlias || name || '' : v.fieldAlias || '';
|
|
399
444
|
var fieldName = name || '';
|
|
400
445
|
var fieldId = v.id || '';
|
|
@@ -410,7 +455,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
|
|
|
410
455
|
className: cx("Sqb-List-section"),
|
|
411
456
|
children: _jsx("div", {
|
|
412
457
|
className: cx("Sqb-List-item mx-2", {
|
|
413
|
-
active: isActive(
|
|
458
|
+
active: isActive(v, tableItem)
|
|
414
459
|
}),
|
|
415
460
|
onClick: function onClick() {
|
|
416
461
|
changeValue(tableUuid, {
|