@gingkoo/pandora-metabase 1.0.156 → 1.0.157-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/dialog/custom-editor/index.js +61 -5
- package/lib/cjs/components/dialog/expression/index.js +132 -54
- package/lib/cjs/components/dialog/expression/index.less +43 -0
- package/lib/cjs/components/dialog/formula/index.js +3 -1
- package/lib/cjs/components/dialog/formula/utils.d.ts +1 -0
- package/lib/cjs/components/dialog/formula/utils.js +20 -2
- package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/cjs/components/dialog/formula-list/index.js +1119 -151
- package/lib/cjs/components/dialog/formula-list/index.less +362 -46
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +100 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/cjs/components/dialog/select-join/index.js +11 -0
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/cjs/components/dialog/select-summarize/index.js +136 -15
- package/lib/cjs/components/dialog/select-summarize/index.less +34 -1
- package/lib/cjs/components/dialog/select-table/index.d.ts +4 -1
- package/lib/cjs/components/dialog/select-table/index.js +51 -7
- package/lib/cjs/components/dialog/select-table/index.less +20 -0
- package/lib/cjs/components/icons.d.ts +1 -0
- package/lib/cjs/components/icons.js +54 -29
- package/lib/cjs/components/metabase/index.js +8 -0
- package/lib/cjs/components/metabase/index.less +17 -14
- package/lib/cjs/components/modules/components/item-name.js +16 -2
- package/lib/cjs/components/modules/components/meta-icon.js +6 -4
- package/lib/cjs/components/modules/join-data.js +5 -0
- package/lib/cjs/components/modules/summarize/group-by.js +12 -1
- package/lib/cjs/components/modules/summarize/select-index.js +12 -1
- package/lib/cjs/hooks/use-state.js +1 -13
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/locale/en.js +31 -0
- package/lib/cjs/locale/index.js +10 -6
- package/lib/cjs/locale/zh.js +31 -0
- package/lib/cjs/store/enum.d.ts +2 -1
- package/lib/cjs/store/enum.js +1 -0
- package/lib/cjs/store/helper.js +25 -2
- package/lib/cjs/store/types.d.ts +7 -1
- package/lib/cjs/types.d.ts +41 -1
- package/lib/cjs/utils/helper.js +20 -0
- package/lib/cjs/utils/transformSql.js +59 -2
- package/lib/cjs/utils.js +25 -4
- package/lib/es/components/dialog/custom-editor/index.js +62 -6
- package/lib/es/components/dialog/expression/index.js +133 -55
- package/lib/es/components/dialog/expression/index.less +43 -0
- package/lib/es/components/dialog/formula/index.js +4 -2
- package/lib/es/components/dialog/formula/utils.d.ts +1 -0
- package/lib/es/components/dialog/formula/utils.js +18 -1
- package/lib/es/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/es/components/dialog/formula-list/index.js +1121 -153
- package/lib/es/components/dialog/formula-list/index.less +362 -46
- package/lib/es/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/es/components/dialog/formula-list/utils.js +99 -0
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/es/components/dialog/select-join/index.js +12 -1
- package/lib/es/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/es/components/dialog/select-summarize/index.js +140 -19
- package/lib/es/components/dialog/select-summarize/index.less +34 -1
- package/lib/es/components/dialog/select-table/index.d.ts +4 -1
- package/lib/es/components/dialog/select-table/index.js +51 -7
- package/lib/es/components/dialog/select-table/index.less +20 -0
- package/lib/es/components/icons.d.ts +1 -0
- package/lib/es/components/icons.js +53 -28
- package/lib/es/components/metabase/index.js +8 -0
- package/lib/es/components/metabase/index.less +17 -14
- package/lib/es/components/modules/components/item-name.js +16 -2
- package/lib/es/components/modules/components/meta-icon.js +6 -4
- package/lib/es/components/modules/join-data.js +6 -1
- package/lib/es/components/modules/summarize/group-by.js +12 -1
- package/lib/es/components/modules/summarize/select-index.js +12 -1
- package/lib/es/hooks/use-state.js +1 -13
- package/lib/es/index.d.ts +3 -2
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +31 -0
- package/lib/es/locale/index.js +10 -6
- package/lib/es/locale/zh.js +31 -0
- package/lib/es/store/enum.d.ts +2 -1
- package/lib/es/store/enum.js +1 -0
- package/lib/es/store/helper.js +25 -2
- package/lib/es/store/types.d.ts +7 -1
- package/lib/es/types.d.ts +41 -1
- package/lib/es/utils/helper.js +20 -0
- package/lib/es/utils/transformSql.js +59 -2
- package/lib/es/utils.js +25 -4
- package/package.json +1 -1
|
@@ -33,7 +33,10 @@ var BlockTypeEnum = {
|
|
|
33
33
|
exists: 'exists',
|
|
34
34
|
FORMULA: 'FORMULA',
|
|
35
35
|
collection: 'collection',
|
|
36
|
-
andOr: 'andOr'
|
|
36
|
+
andOr: 'andOr',
|
|
37
|
+
caseWhen: 'caseWhen',
|
|
38
|
+
select: 'select',
|
|
39
|
+
subquery: 'subquery'
|
|
37
40
|
};
|
|
38
41
|
var SummarizeAlias = 'source';
|
|
39
42
|
var SQL_GROUP_TYPE = {
|
|
@@ -248,6 +251,18 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
248
251
|
case '不等于':
|
|
249
252
|
_right_condition = "!= ".concat(_rightSql);
|
|
250
253
|
break;
|
|
254
|
+
case '大于':
|
|
255
|
+
_right_condition = "> ".concat(_rightSql);
|
|
256
|
+
break;
|
|
257
|
+
case '小于':
|
|
258
|
+
_right_condition = "< ".concat(_rightSql);
|
|
259
|
+
break;
|
|
260
|
+
case '大于或等于':
|
|
261
|
+
_right_condition = ">= ".concat(_rightSql);
|
|
262
|
+
break;
|
|
263
|
+
case '小于或等于':
|
|
264
|
+
_right_condition = "<= ".concat(_rightSql);
|
|
265
|
+
break;
|
|
251
266
|
case '包含':
|
|
252
267
|
_right_condition = "LIKE '%".concat(condition_1, "%'");
|
|
253
268
|
break;
|
|
@@ -434,19 +449,29 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
434
449
|
case '等于':
|
|
435
450
|
_right_condition = "= ".concat(_condition_4);
|
|
436
451
|
break;
|
|
452
|
+
case '大于':
|
|
453
|
+
_right_condition = "> ".concat(_condition_4);
|
|
454
|
+
break;
|
|
455
|
+
case '小于':
|
|
437
456
|
case '早于':
|
|
438
457
|
_right_condition = "< ".concat(_condition_4);
|
|
439
458
|
break;
|
|
459
|
+
case '大于或等于':
|
|
440
460
|
case '晚于':
|
|
441
461
|
_right_condition = ">= ".concat(_condition_4);
|
|
442
462
|
break;
|
|
463
|
+
case '小于或等于':
|
|
464
|
+
_right_condition = "<= ".concat(_condition_4);
|
|
465
|
+
break;
|
|
443
466
|
case '介于之间':
|
|
444
467
|
_right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
|
|
445
468
|
_left_condition = '';
|
|
446
469
|
break;
|
|
470
|
+
case '为空':
|
|
447
471
|
case '是空的':
|
|
448
472
|
_right_condition = "IS NULL";
|
|
449
473
|
break;
|
|
474
|
+
case '不为空':
|
|
450
475
|
case '不是空的':
|
|
451
476
|
_right_condition = "IS NOT NULL";
|
|
452
477
|
break;
|
|
@@ -489,6 +514,38 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
489
514
|
sql += " ".concat(collectionSql);
|
|
490
515
|
constants.push.apply(constants, _toConsumableArray(collectionConstants));
|
|
491
516
|
}
|
|
517
|
+
if (type === BlockTypeEnum.select) {
|
|
518
|
+
var values = (Array.isArray(item.val) ? item.val : [item.val]).filter(function (value) {
|
|
519
|
+
return value !== null && value !== undefined && value !== '';
|
|
520
|
+
}).map(function (value) {
|
|
521
|
+
return String(value);
|
|
522
|
+
});
|
|
523
|
+
var selectSql = values.join(', ');
|
|
524
|
+
sql += selectSql ? " ".concat(selectSql) : '';
|
|
525
|
+
sql_items.push.apply(sql_items, _toConsumableArray(values));
|
|
526
|
+
}
|
|
527
|
+
if (type === BlockTypeEnum.subquery) {
|
|
528
|
+
if (Array.isArray(item.subQuery) && item.subQuery.length) {
|
|
529
|
+
sql += " (".concat(handleSqlUnion(item.subQuery, db).sql, ")");
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
if (type === BlockTypeEnum.caseWhen) {
|
|
533
|
+
var caseSqlResult = _handleBaseType2Sql9(item.caseAtoms || [], db);
|
|
534
|
+
constants.push.apply(constants, _toConsumableArray(caseSqlResult.constants));
|
|
535
|
+
var whenSql = (item.whenClauses || []).map(function (clause) {
|
|
536
|
+
var whenResult = _handleBaseType2Sql9(clause.whenAtoms || [], db);
|
|
537
|
+
var thenResult = _handleBaseType2Sql9(clause.thenAtoms || [], db);
|
|
538
|
+
constants.push.apply(constants, _toConsumableArray(whenResult.constants).concat(_toConsumableArray(thenResult.constants)));
|
|
539
|
+
var whenCondition = whenResult.sql.trim();
|
|
540
|
+
var thenValue = thenResult.sql.trim();
|
|
541
|
+
return whenCondition && thenValue ? "WHEN ".concat(whenCondition, " THEN ").concat(thenValue) : '';
|
|
542
|
+
}).filter(Boolean).join(' ');
|
|
543
|
+
var elseResult = _handleBaseType2Sql9(item.elseAtoms || [], db);
|
|
544
|
+
constants.push.apply(constants, _toConsumableArray(elseResult.constants));
|
|
545
|
+
var caseExpression = caseSqlResult.sql.trim();
|
|
546
|
+
var elseSql = elseResult.sql.trim();
|
|
547
|
+
sql += " CASE".concat(caseExpression ? " ".concat(caseExpression) : '').concat(whenSql ? " ".concat(whenSql) : '').concat(elseSql ? " ELSE ".concat(elseSql) : '', " END");
|
|
548
|
+
}
|
|
492
549
|
if (type === BlockTypeEnum.andOr) {
|
|
493
550
|
var itemsSql = normalizeAndOrItems(item).map(function (logicItem, index) {
|
|
494
551
|
var _handleBaseType2Sql8 = _handleBaseType2Sql9(logicItem.atoms || [], db),
|
|
@@ -749,7 +806,7 @@ var handleSqlUnion = function handleSqlUnion(metas) {
|
|
|
749
806
|
unionMetas.forEach(function (it) {
|
|
750
807
|
if (Array.isArray(it.subquery) && it.subquery.length) {
|
|
751
808
|
var u_data = handleSqlStruct(it.subquery, db);
|
|
752
|
-
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db),
|
|
809
|
+
var _sqlStruct2text2 = _sqlStruct2text3(u_data, 0, db, noFields),
|
|
753
810
|
u_sqltext = _sqlStruct2text2.sql,
|
|
754
811
|
u_fields = _sqlStruct2text2.fields;
|
|
755
812
|
union_fields.push(u_fields);
|
package/lib/es/utils.js
CHANGED
|
@@ -938,10 +938,10 @@ var buildExpressionQuotes = function buildExpressionQuotes(item) {
|
|
|
938
938
|
if (condition === '在') {
|
|
939
939
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is' : '是', " ").concat(firstVal));
|
|
940
940
|
}
|
|
941
|
-
if (condition === '是空的') {
|
|
941
|
+
if (condition === '为空' || condition === '是空的') {
|
|
942
942
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is empty' : '为空'));
|
|
943
943
|
}
|
|
944
|
-
if (condition === '不是空的') {
|
|
944
|
+
if (condition === '不为空' || condition === '不是空的') {
|
|
945
945
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'not empty' : '不为空'));
|
|
946
946
|
}
|
|
947
947
|
if (condition === '当前') {
|
|
@@ -1231,15 +1231,27 @@ export var changeTableAlias = function changeTableAlias(list, curObj) {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
if (v.type === TypeEnum.summarize) {
|
|
1233
1233
|
v.group.map(function (group) {
|
|
1234
|
+
var _group$orderBy;
|
|
1234
1235
|
var groupAtoms = group.atoms;
|
|
1236
|
+
var shouldRefreshSql = false;
|
|
1235
1237
|
if (groupAtoms && groupAtoms.length > 0) {
|
|
1236
1238
|
group.atoms = _changeAlias(groupAtoms, {
|
|
1237
1239
|
uuid: tableUuid,
|
|
1238
1240
|
alias: alias
|
|
1239
1241
|
}, AliasType.table);
|
|
1240
|
-
|
|
1242
|
+
shouldRefreshSql = true;
|
|
1241
1243
|
} else if (group.tableUuid === tableUuid) {
|
|
1242
1244
|
group.alias = alias;
|
|
1245
|
+
shouldRefreshSql = true;
|
|
1246
|
+
}
|
|
1247
|
+
if ((_group$orderBy = group.orderBy) !== null && _group$orderBy !== void 0 && _group$orderBy.length) {
|
|
1248
|
+
group.orderBy = _changeAlias(group.orderBy, {
|
|
1249
|
+
uuid: tableUuid,
|
|
1250
|
+
alias: alias
|
|
1251
|
+
}, AliasType.table);
|
|
1252
|
+
shouldRefreshSql = true;
|
|
1253
|
+
}
|
|
1254
|
+
if (shouldRefreshSql) {
|
|
1243
1255
|
group.sql = summarizeToSql(v.group, group).sql;
|
|
1244
1256
|
}
|
|
1245
1257
|
});
|
|
@@ -1317,12 +1329,21 @@ export var changeFieldAlias = function changeFieldAlias(list, curObj) {
|
|
|
1317
1329
|
if (v.type === TypeEnum.rowLimit) {}
|
|
1318
1330
|
if (v.type === TypeEnum.summarize) {
|
|
1319
1331
|
v.group.map(function (group) {
|
|
1332
|
+
var _group$orderBy2;
|
|
1320
1333
|
var groupAtoms = group.atoms;
|
|
1334
|
+
var shouldRefreshSql = false;
|
|
1321
1335
|
if (groupAtoms && groupAtoms.length > 0) {
|
|
1322
1336
|
group.atoms = _changeAlias(groupAtoms, aliasTarget, AliasType.field);
|
|
1323
|
-
|
|
1337
|
+
shouldRefreshSql = true;
|
|
1324
1338
|
} else if (isAliasTargetSummarizeRecord(group, aliasTarget)) {
|
|
1325
1339
|
group.fieldAlias = alias;
|
|
1340
|
+
shouldRefreshSql = true;
|
|
1341
|
+
}
|
|
1342
|
+
if ((_group$orderBy2 = group.orderBy) !== null && _group$orderBy2 !== void 0 && _group$orderBy2.length) {
|
|
1343
|
+
group.orderBy = _changeAlias(group.orderBy, aliasTarget, AliasType.field);
|
|
1344
|
+
shouldRefreshSql = true;
|
|
1345
|
+
}
|
|
1346
|
+
if (shouldRefreshSql) {
|
|
1326
1347
|
group.sql = summarizeToSql(v.group, group).sql;
|
|
1327
1348
|
}
|
|
1328
1349
|
});
|