@gingkoo/pandora-metabase 1.0.126 → 1.0.128

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.
Files changed (65) hide show
  1. package/lib/cjs/components/dialog/expression/index.js +15 -5
  2. package/lib/cjs/components/dialog/expression/index.less +31 -16
  3. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +14 -5
  4. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +236 -62
  5. package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +3 -2
  6. package/lib/cjs/components/dialog/formula-list/LogicGroup.js +19 -11
  7. package/lib/cjs/components/dialog/formula-list/index.d.ts +1 -0
  8. package/lib/cjs/components/dialog/formula-list/index.js +658 -174
  9. package/lib/cjs/components/dialog/formula-list/index.less +1438 -145
  10. package/lib/cjs/components/dialog/formula-list/utils.js +50 -19
  11. package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +1 -0
  12. package/lib/cjs/components/dialog/select-column-multiple/index.js +42 -22
  13. package/lib/cjs/components/dialog/select-summarize/index.js +10 -2
  14. package/lib/cjs/components/dialog/select-table/index.d.ts +2 -1
  15. package/lib/cjs/components/dialog/select-table/index.js +197 -52
  16. package/lib/cjs/components/dialog/select-table/index.less +45 -2
  17. package/lib/cjs/components/metabase/index.less +156 -39
  18. package/lib/cjs/components/modules/custom-column.js +7 -3
  19. package/lib/cjs/components/modules/filter.js +6 -3
  20. package/lib/cjs/components/modules/join-data.js +67 -16
  21. package/lib/cjs/components/modules/permission-table.js +8 -4
  22. package/lib/cjs/components/modules/sort.js +2 -1
  23. package/lib/cjs/components/modules/summarize/group-by.js +20 -6
  24. package/lib/cjs/components/modules/summarize/select-index.js +9 -5
  25. package/lib/cjs/components/modules/table-data.js +26 -5
  26. package/lib/cjs/hooks/use-state.js +143 -17
  27. package/lib/cjs/index.js +7 -1
  28. package/lib/cjs/store/types.d.ts +14 -7
  29. package/lib/cjs/types.d.ts +8 -0
  30. package/lib/cjs/utils/transformSql.js +44 -21
  31. package/lib/cjs/utils.d.ts +2 -2
  32. package/lib/cjs/utils.js +349 -58
  33. package/lib/es/components/dialog/expression/index.js +15 -5
  34. package/lib/es/components/dialog/expression/index.less +31 -16
  35. package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +14 -5
  36. package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +238 -64
  37. package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +3 -2
  38. package/lib/es/components/dialog/formula-list/LogicGroup.js +19 -11
  39. package/lib/es/components/dialog/formula-list/index.d.ts +1 -0
  40. package/lib/es/components/dialog/formula-list/index.js +660 -176
  41. package/lib/es/components/dialog/formula-list/index.less +1438 -145
  42. package/lib/es/components/dialog/formula-list/utils.js +50 -19
  43. package/lib/es/components/dialog/select-column-multiple/index.d.ts +1 -0
  44. package/lib/es/components/dialog/select-column-multiple/index.js +42 -22
  45. package/lib/es/components/dialog/select-summarize/index.js +10 -2
  46. package/lib/es/components/dialog/select-table/index.d.ts +2 -1
  47. package/lib/es/components/dialog/select-table/index.js +197 -52
  48. package/lib/es/components/dialog/select-table/index.less +45 -2
  49. package/lib/es/components/metabase/index.less +156 -39
  50. package/lib/es/components/modules/custom-column.js +7 -3
  51. package/lib/es/components/modules/filter.js +6 -3
  52. package/lib/es/components/modules/join-data.js +67 -16
  53. package/lib/es/components/modules/permission-table.js +8 -4
  54. package/lib/es/components/modules/sort.js +2 -1
  55. package/lib/es/components/modules/summarize/group-by.js +21 -7
  56. package/lib/es/components/modules/summarize/select-index.js +10 -6
  57. package/lib/es/components/modules/table-data.js +26 -5
  58. package/lib/es/hooks/use-state.js +143 -17
  59. package/lib/es/index.js +7 -1
  60. package/lib/es/store/types.d.ts +14 -7
  61. package/lib/es/types.d.ts +8 -0
  62. package/lib/es/utils/transformSql.js +45 -22
  63. package/lib/es/utils.d.ts +2 -2
  64. package/lib/es/utils.js +350 -59
  65. package/package.json +1 -1
@@ -101,7 +101,7 @@ var JoinData = function JoinData(props) {
101
101
  return _context.abrupt("return");
102
102
  case 1:
103
103
  _context.next = 2;
104
- return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table2.datasourceId);
104
+ return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table2.datasourceId, meta.table2.datasourceType);
105
105
  case 2:
106
106
  tables = _context.sent;
107
107
  names = (tables === null || tables === void 0 ? void 0 : tables.map(function (v) {
@@ -143,6 +143,7 @@ var JoinData = function JoinData(props) {
143
143
  name_zh: prevGroupBy.alias,
144
144
  datasourceId: '',
145
145
  datasourceName: '',
146
+ datasourceType: '',
146
147
  columns: []
147
148
  };
148
149
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group = prevGroupBy.group) !== null && _prevGroupBy$group !== void 0 && _prevGroupBy$group.length) {
@@ -187,6 +188,7 @@ var JoinData = function JoinData(props) {
187
188
  tableUuid: v.table2.tableUuid || uuidv4('table'),
188
189
  datasourceId: v.table2.datasourceId,
189
190
  datasourceName: v.table2.datasourceName,
191
+ datasourceType: v.table2.datasourceType,
190
192
  columns: v.columns || []
191
193
  };
192
194
  }));
@@ -202,7 +204,8 @@ var JoinData = function JoinData(props) {
202
204
  tableUuid: v.table.tableUuid || uuidv4('table'),
203
205
  columns: v.columns,
204
206
  datasourceId: v.table.datasourceId,
205
- datasourceName: v.table.datasourceName
207
+ datasourceName: v.table.datasourceName,
208
+ datasourceType: v.table.datasourceType
206
209
  }));
207
210
  } else if (v.type === TypeEnum.joinData) {
208
211
  mo.push({
@@ -213,7 +216,8 @@ var JoinData = function JoinData(props) {
213
216
  tableUuid: v.table2.tableUuid || uuidv4('table'),
214
217
  columns: v.columns,
215
218
  datasourceId: v.table2.datasourceId,
216
- datasourceName: v.table2.datasourceName
219
+ datasourceName: v.table2.datasourceName,
220
+ datasourceType: v.table2.datasourceType
217
221
  });
218
222
  }
219
223
  return mo;
@@ -229,6 +233,7 @@ var JoinData = function JoinData(props) {
229
233
  tableUuid: meta.table2.tableUuid || uuidv4('table'),
230
234
  datasourceId: meta.table2.datasourceId,
231
235
  datasourceName: meta.table2.datasourceName,
236
+ datasourceType: meta.table2.datasourceType,
232
237
  columns: meta.columns
233
238
  }]);
234
239
  var newMeta = store.metaList[groupIndex].list.slice();
@@ -253,6 +258,7 @@ var JoinData = function JoinData(props) {
253
258
  name_zh: prevGroupBy.alias,
254
259
  datasourceId: '',
255
260
  datasourceName: '',
261
+ datasourceType: '',
256
262
  columns: []
257
263
  };
258
264
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group2 = prevGroupBy.group) !== null && _prevGroupBy$group2 !== void 0 && _prevGroupBy$group2.length) {
@@ -297,6 +303,7 @@ var JoinData = function JoinData(props) {
297
303
  tableUuid: v.table2.tableUuid || uuidv4('table'),
298
304
  datasourceId: v.table2.datasourceId,
299
305
  datasourceName: v.table2.datasourceName,
306
+ datasourceType: v.table2.datasourceType,
300
307
  columns: v.columns || []
301
308
  };
302
309
  }));
@@ -312,7 +319,8 @@ var JoinData = function JoinData(props) {
312
319
  tableUuid: v.table.tableUuid || uuidv4('table'),
313
320
  columns: v.columns,
314
321
  datasourceId: v.table.datasourceId,
315
- datasourceName: v.table.datasourceName
322
+ datasourceName: v.table.datasourceName,
323
+ datasourceType: v.table.datasourceType
316
324
  }));
317
325
  } else if (v.type === TypeEnum.joinData) {
318
326
  mo.push({
@@ -323,7 +331,8 @@ var JoinData = function JoinData(props) {
323
331
  tableUuid: v.table2.tableUuid || uuidv4('table'),
324
332
  columns: v.columns,
325
333
  datasourceId: v.table2.datasourceId,
326
- datasourceName: v.table2.datasourceName
334
+ datasourceName: v.table2.datasourceName,
335
+ datasourceType: v.table2.datasourceType
327
336
  });
328
337
  }
329
338
  return mo;
@@ -337,6 +346,7 @@ var JoinData = function JoinData(props) {
337
346
  tableUuid: meta.table2.tableUuid || uuidv4('table'),
338
347
  datasourceId: meta.table2.datasourceId,
339
348
  datasourceName: meta.table2.datasourceName,
349
+ datasourceType: meta.table2.datasourceType,
340
350
  columns: meta.columns
341
351
  }]);
342
352
  return data;
@@ -381,7 +391,8 @@ var JoinData = function JoinData(props) {
381
391
  name: prevGroupBy.alias,
382
392
  name_zh: prevGroupBy.alias,
383
393
  datasourceId: '',
384
- datasourceName: ''
394
+ datasourceName: '',
395
+ datasourceType: ''
385
396
  };
386
397
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group3 = prevGroupBy.group) !== null && _prevGroupBy$group3 !== void 0 && _prevGroupBy$group3.length) {}
387
398
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$by3 = prevGroupBy.by) !== null && _prevGroupBy$by3 !== void 0 && _prevGroupBy$by3.length) {}
@@ -401,6 +412,7 @@ var JoinData = function JoinData(props) {
401
412
  tableUuid: v.table2.tableUuid || uuidv4('table'),
402
413
  datasourceId: v.table2.datasourceId,
403
414
  datasourceName: v.table2.datasourceName,
415
+ datasourceType: v.table2.datasourceType,
404
416
  columns: []
405
417
  };
406
418
  }));
@@ -416,7 +428,8 @@ var JoinData = function JoinData(props) {
416
428
  tableUuid: v.table.tableUuid || uuidv4('table'),
417
429
  columns: [],
418
430
  datasourceId: v.table.datasourceId,
419
- datasourceName: v.table.datasourceName
431
+ datasourceName: v.table.datasourceName,
432
+ datasourceType: v.table.datasourceType
420
433
  });
421
434
  } else if (v.type === TypeEnum.joinData) {
422
435
  mo.push({
@@ -427,7 +440,8 @@ var JoinData = function JoinData(props) {
427
440
  tableUuid: v.table2.tableUuid || uuidv4('table'),
428
441
  columns: [],
429
442
  datasourceId: v.table2.datasourceId,
430
- datasourceName: v.table2.datasourceName
443
+ datasourceName: v.table2.datasourceName,
444
+ datasourceType: v.table2.datasourceType
431
445
  });
432
446
  }
433
447
  return mo;
@@ -463,6 +477,7 @@ var JoinData = function JoinData(props) {
463
477
  alias: meta.table2.alias,
464
478
  datasourceId: meta.table2.datasourceId,
465
479
  datasourceName: meta.table2.datasourceName,
480
+ datasourceType: meta.table2.datasourceType,
466
481
  tableUuid: meta.table2.tableUuid || ''
467
482
  };
468
483
  !meta.readonly && store.setPopup({
@@ -473,9 +488,25 @@ var JoinData = function JoinData(props) {
473
488
  tableFlat: store.tableFlat,
474
489
  data: store.sourceList,
475
490
  value: value,
491
+ onDatasourceTypeChange: function onDatasourceTypeChange(data) {
492
+ var newMeta = cloneDeep(store.metaList[groupIndex].list);
493
+ var joinMeta = newMeta[index];
494
+ joinMeta.table2 = _objectSpread(_objectSpread(_objectSpread({}, joinMeta.table2), data), {}, {
495
+ datasourceType: data.datasourceType
496
+ });
497
+ joinMeta.columns = joinMeta.columns.map(function (column) {
498
+ return _objectSpread(_objectSpread({}, column), {}, {
499
+ datasourceType: data.datasourceType
500
+ });
501
+ });
502
+ store.setMeta(newMeta, groupIndex, {
503
+ obj: data,
504
+ type: ChangeType.table2
505
+ });
506
+ },
476
507
  onChange: function onChange(data) {
477
508
  var tableName = data.name;
478
- if (meta.table2.name !== tableName || meta.table2.datasourceId !== data.datasourceId) {
509
+ if (meta.table2.name !== tableName || meta.table2.datasourceId !== data.datasourceId || meta.table2.datasourceType !== data.datasourceType) {
479
510
  var _store$preProps;
480
511
  var newMeta = cloneDeep(store.metaList[groupIndex].list);
481
512
  var alias = getAlias(tableName, newMeta, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []);
@@ -487,7 +518,8 @@ var JoinData = function JoinData(props) {
487
518
  fieldUuid: '',
488
519
  quotes: '',
489
520
  datasourceId: data.datasourceId,
490
- datasourceName: data.datasourceName
521
+ datasourceName: data.datasourceName,
522
+ datasourceType: data.datasourceType
491
523
  });
492
524
  newMeta[index].table2 = _table2;
493
525
  initExpressions(newMeta);
@@ -525,6 +557,7 @@ var JoinData = function JoinData(props) {
525
557
  tableUuid: '',
526
558
  datasourceName: '',
527
559
  datasourceId: '',
560
+ datasourceType: '',
528
561
  type: AtomsTypeEnum.FIELD
529
562
  }],
530
563
  condition: '',
@@ -541,6 +574,7 @@ var JoinData = function JoinData(props) {
541
574
  tableUuid: '',
542
575
  datasourceName: '',
543
576
  datasourceId: '',
577
+ datasourceType: '',
544
578
  type: AtomsTypeEnum.FIELD
545
579
  }],
546
580
  type: AtomsTypeEnum.JOIN_DEFAULT
@@ -585,6 +619,7 @@ var JoinData = function JoinData(props) {
585
619
  alias: prevGroupBy.alias,
586
620
  datasourceId: '',
587
621
  datasourceName: '',
622
+ datasourceType: '',
588
623
  columns: []
589
624
  };
590
625
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group4 = prevGroupBy.group) !== null && _prevGroupBy$group4 !== void 0 && _prevGroupBy$group4.length) {
@@ -629,6 +664,7 @@ var JoinData = function JoinData(props) {
629
664
  tableUuid: v.table2.tableUuid || uuidv4('table'),
630
665
  datasourceId: v.table2.datasourceId,
631
666
  datasourceName: v.table2.datasourceName,
667
+ datasourceType: v.table2.datasourceType,
632
668
  columns: v.columns
633
669
  };
634
670
  }));
@@ -644,7 +680,8 @@ var JoinData = function JoinData(props) {
644
680
  tableUuid: v.table.tableUuid || uuidv4('table'),
645
681
  columns: v.columns,
646
682
  datasourceId: v.table.datasourceId,
647
- datasourceName: v.table.datasourceName
683
+ datasourceName: v.table.datasourceName,
684
+ datasourceType: v.table.datasourceType
648
685
  });
649
686
  } else if (v.type === TypeEnum.joinData) {
650
687
  mo.push({
@@ -655,7 +692,8 @@ var JoinData = function JoinData(props) {
655
692
  tableUuid: v.table2.tableUuid || uuidv4('table'),
656
693
  columns: v.columns,
657
694
  datasourceId: v.table2.datasourceId,
658
- datasourceName: v.table2.datasourceName
695
+ datasourceName: v.table2.datasourceName,
696
+ datasourceType: v.table2.datasourceType
659
697
  });
660
698
  }
661
699
  return mo;
@@ -676,6 +714,7 @@ var JoinData = function JoinData(props) {
676
714
  tableUuid: meta.table2.tableUuid || uuidv4('table'),
677
715
  datasourceId: meta.table2.datasourceId,
678
716
  datasourceName: meta.table2.datasourceName,
717
+ datasourceType: meta.table2.datasourceType,
679
718
  columns: meta.columns
680
719
  }];
681
720
  }
@@ -704,6 +743,7 @@ var JoinData = function JoinData(props) {
704
743
  alias: prevGroupBy.alias,
705
744
  datasourceId: '',
706
745
  datasourceName: '',
746
+ datasourceType: '',
707
747
  columns: []
708
748
  };
709
749
  if (prevGroupBy !== null && prevGroupBy !== void 0 && (_prevGroupBy$group5 = prevGroupBy.group) !== null && _prevGroupBy$group5 !== void 0 && _prevGroupBy$group5.length) {
@@ -748,6 +788,7 @@ var JoinData = function JoinData(props) {
748
788
  tableUuid: v.table2.tableUuid || uuidv4('table'),
749
789
  datasourceId: v.table2.datasourceId,
750
790
  datasourceName: v.table2.datasourceName,
791
+ datasourceType: v.table2.datasourceType,
751
792
  columns: v.columns
752
793
  };
753
794
  }));
@@ -763,7 +804,8 @@ var JoinData = function JoinData(props) {
763
804
  tableUuid: v.table.tableUuid || uuidv4('table'),
764
805
  columns: v.columns,
765
806
  datasourceId: v.table.datasourceId,
766
- datasourceName: v.table.datasourceName
807
+ datasourceName: v.table.datasourceName,
808
+ datasourceType: v.table.datasourceType
767
809
  });
768
810
  } else if (v.type === TypeEnum.joinData) {
769
811
  mo.push({
@@ -774,7 +816,8 @@ var JoinData = function JoinData(props) {
774
816
  tableUuid: v.table2.tableUuid || uuidv4('table'),
775
817
  columns: v.columns,
776
818
  datasourceId: v.table2.datasourceId,
777
- datasourceName: v.table2.datasourceName
819
+ datasourceName: v.table2.datasourceName,
820
+ datasourceType: v.table2.datasourceType
778
821
  });
779
822
  }
780
823
  return mo;
@@ -795,6 +838,7 @@ var JoinData = function JoinData(props) {
795
838
  tableUuid: meta.table2.tableUuid || uuidv4('table'),
796
839
  datasourceId: meta.table2.datasourceId,
797
840
  datasourceName: meta.table2.datasourceName,
841
+ datasourceType: meta.table2.datasourceType,
798
842
  columns: meta.columns
799
843
  }];
800
844
  }
@@ -823,6 +867,7 @@ var JoinData = function JoinData(props) {
823
867
  tableUuid: '',
824
868
  datasourceName: '',
825
869
  datasourceId: '',
870
+ datasourceType: '',
826
871
  type: AtomsTypeEnum.FIELD
827
872
  }];
828
873
  store.setMeta(newMeta, groupIndex, {
@@ -919,6 +964,7 @@ var JoinData = function JoinData(props) {
919
964
  tableUuid: '',
920
965
  datasourceName: '',
921
966
  datasourceId: '',
967
+ datasourceType: '',
922
968
  type: AtomsTypeEnum.FIELD
923
969
  }];
924
970
  }
@@ -983,10 +1029,13 @@ var JoinData = function JoinData(props) {
983
1029
  });
984
1030
  });
985
1031
  newMeta[index].columns = newColumns.map(function (newCol) {
1032
+ var _existingCol$select;
986
1033
  var existingCol = newMeta[index].columns.find(function (oldCol) {
987
- return oldCol.name === newCol.name;
1034
+ return newCol.fieldUuid && oldCol.fieldUuid === newCol.fieldUuid || newCol.fieldAlias && oldCol.fieldAlias === newCol.fieldAlias || oldCol.name === newCol.name;
1035
+ });
1036
+ var _column = _objectSpread(_objectSpread({}, newCol), {}, {
1037
+ select: (_existingCol$select = existingCol === null || existingCol === void 0 ? void 0 : existingCol.select) !== null && _existingCol$select !== void 0 ? _existingCol$select : newCol.select
988
1038
  });
989
- var _column = existingCol ? existingCol : newCol;
990
1039
  _column.select = store.isSelectFields || _column.select;
991
1040
  return _column;
992
1041
  });
@@ -1106,6 +1155,7 @@ var JoinData = function JoinData(props) {
1106
1155
  tableUuid: '',
1107
1156
  datasourceName: '',
1108
1157
  datasourceId: '',
1158
+ datasourceType: '',
1109
1159
  type: AtomsTypeEnum.FIELD
1110
1160
  }],
1111
1161
  condition: '',
@@ -1122,6 +1172,7 @@ var JoinData = function JoinData(props) {
1122
1172
  tableUuid: '',
1123
1173
  datasourceName: '',
1124
1174
  datasourceId: '',
1175
+ datasourceType: '',
1125
1176
  type: AtomsTypeEnum.FIELD
1126
1177
  }],
1127
1178
  type: type
@@ -35,7 +35,8 @@ var PermissionTable = function PermissionTable(props) {
35
35
  tableUuid: uuidv4('table'),
36
36
  alias: prevGroupBy.alias,
37
37
  datasourceId: '',
38
- datasourceName: ''
38
+ datasourceName: '',
39
+ datasourceType: ''
39
40
  };
40
41
  data = [_data];
41
42
  var joinData = prevList.filter(function (v) {
@@ -52,7 +53,8 @@ var PermissionTable = function PermissionTable(props) {
52
53
  tableUuid: v.table2.tableUuid,
53
54
  id: v.table2.id,
54
55
  datasourceId: v.table2.datasourceId,
55
- datasourceName: v.table2.datasourceName
56
+ datasourceName: v.table2.datasourceName,
57
+ datasourceType: v.table2.datasourceType
56
58
  };
57
59
  }));
58
60
  }
@@ -66,7 +68,8 @@ var PermissionTable = function PermissionTable(props) {
66
68
  id: v.table.id,
67
69
  tableUuid: v.table.tableUuid,
68
70
  datasourceId: v.table.datasourceId,
69
- datasourceName: v.table.datasourceName
71
+ datasourceName: v.table.datasourceName,
72
+ datasourceType: v.table.datasourceType
70
73
  });
71
74
  } else if (v.type === TypeEnum.joinData) {
72
75
  mo.push({
@@ -76,7 +79,8 @@ var PermissionTable = function PermissionTable(props) {
76
79
  id: v.table2.id,
77
80
  tableUuid: v.table2.tableUuid,
78
81
  datasourceId: v.table2.datasourceId,
79
- datasourceName: v.table2.datasourceName
82
+ datasourceName: v.table2.datasourceName,
83
+ datasourceType: v.table2.datasourceType
80
84
  });
81
85
  }
82
86
  return mo;
@@ -83,7 +83,8 @@ var Sort = function Sort(props) {
83
83
  id: v.table2.id,
84
84
  columns: v.columns,
85
85
  datasourceId: v.table2.datasourceId,
86
- datasourceName: v.table2.datasourceName
86
+ datasourceName: v.table2.datasourceName,
87
+ datasourceType: v.table2.datasourceType
87
88
  };
88
89
  } else {
89
90
  return {
@@ -14,7 +14,7 @@ import { TypeEnum, SQL_COLUMN_TYPE } from '../../../store/enum';
14
14
  import { MetaSummarize_Enum, AtomsTypeEnum, ChangeType } from '../../../store/types';
15
15
  import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
16
16
  import { uuidv4, getAlias } from '../../../utils/helper';
17
- import { isExistsError, isValidSQLAlias } from '../../../utils';
17
+ import { changeFieldAlias, isExistsError, isValidSQLAlias } from '../../../utils';
18
18
  import ItemName from '../components/item-name';
19
19
  import { AddIcon, CloseIcon } from '../../icons';
20
20
  import FormulaList from '../../dialog/formula-list';
@@ -39,7 +39,13 @@ var _getSummaryText = function getSummaryText() {
39
39
  return [lhs, item.condition, rhs].filter(Boolean).join(' ').trim();
40
40
  }
41
41
  if (item.type === AtomsTypeEnum.AND_OR) {
42
- return "".concat(item.operator || 'and', " ( ").concat(_getSummaryText(item.list || []), " )").replace(/\s+/g, ' ').trim();
42
+ var hasBinarySides = Array.isArray(item.leftAtoms) || Array.isArray(item.rightAtoms);
43
+ if (hasBinarySides) {
44
+ var leftText = _getSummaryText(item.leftAtoms || []);
45
+ var rightText = _getSummaryText(item.rightAtoms || []);
46
+ return "( ".concat(leftText, " ").concat(item.operator || 'and', " ").concat(rightText, " )").replace(/\s+/g, ' ').trim();
47
+ }
48
+ return "".concat(item.operator || 'and', " ( ").concat(_getSummaryText(item.atoms || []), " )").replace(/\s+/g, ' ').trim();
43
49
  }
44
50
  if (item.type === AtomsTypeEnum.CASE_WHEN) {
45
51
  return item.quotes || 'case when';
@@ -96,6 +102,7 @@ var GroupByEditor = function GroupByEditor(_ref) {
96
102
  tableUuid: value.tableUuid || '',
97
103
  datasourceName: value.datasourceName || '',
98
104
  datasourceId: value.datasourceId || '',
105
+ datasourceType: value.datasourceType || '',
99
106
  type: AtomsTypeEnum.FIELD
100
107
  };
101
108
  return [fieldAtom];
@@ -215,6 +222,7 @@ var GroupBy = function GroupBy(props) {
215
222
  tableUuid: v.table2.tableUuid,
216
223
  datasourceId: v.table2.datasourceId,
217
224
  datasourceName: v.table2.datasourceName,
225
+ datasourceType: v.table2.datasourceType,
218
226
  columns: v.columns
219
227
  };
220
228
  }));
@@ -230,6 +238,7 @@ var GroupBy = function GroupBy(props) {
230
238
  tableUuid: v.table.tableUuid,
231
239
  datasourceId: v.table.datasourceId,
232
240
  datasourceName: v.table.datasourceName,
241
+ datasourceType: v.table.datasourceType,
233
242
  columns: v.columns
234
243
  };
235
244
  } else if (v.type === TypeEnum.joinData) {
@@ -241,6 +250,7 @@ var GroupBy = function GroupBy(props) {
241
250
  tableUuid: v.table2.tableUuid,
242
251
  datasourceId: v.table2.datasourceId,
243
252
  datasourceName: v.table2.datasourceName,
253
+ datasourceType: v.table2.datasourceType,
244
254
  columns: v.columns
245
255
  };
246
256
  } else {
@@ -299,6 +309,7 @@ var GroupBy = function GroupBy(props) {
299
309
  quotes: '',
300
310
  datasourceId: '',
301
311
  datasourceName: '',
312
+ datasourceType: '',
302
313
  atoms: [],
303
314
  summarizeType: MetaSummarize_Enum.BY
304
315
  };
@@ -359,6 +370,7 @@ var GroupBy = function GroupBy(props) {
359
370
  newMeta = store.metaList[groupIndex].list.slice();
360
371
  newMeta[index].by[i].fieldAlias = fieldAlias;
361
372
  newMeta[index].by[i].sql = summarizeByToSql(newMeta[index].by[i]);
373
+ newMeta = changeFieldAlias(newMeta, newMeta[index].by[i]);
362
374
  store.setMeta(newMeta, groupIndex, {
363
375
  obj: newMeta[index].by,
364
376
  type: ChangeType.by
@@ -384,7 +396,8 @@ var GroupBy = function GroupBy(props) {
384
396
  tableUuid: v.tableUuid,
385
397
  alias: v.alias,
386
398
  datasourceName: '',
387
- datasourceId: ''
399
+ datasourceId: '',
400
+ datasourceType: ''
388
401
  });
389
402
  });
390
403
  };
@@ -403,6 +416,7 @@ var GroupBy = function GroupBy(props) {
403
416
  tableUuid: v.tableUuid,
404
417
  datasourceName: '',
405
418
  datasourceId: '',
419
+ datasourceType: '',
406
420
  type: AtomsTypeEnum.FIELD
407
421
  });
408
422
  };
@@ -426,13 +440,13 @@ var GroupBy = function GroupBy(props) {
426
440
  if (_found) return _found;
427
441
  }
428
442
  if (item.type === AtomsTypeEnum.AND_OR) {
429
- var _found2 = _getFirstField(item.list || []);
443
+ var _found2 = _getFirstField([].concat(_toConsumableArray(item.leftAtoms || []), _toConsumableArray(item.rightAtoms || []), _toConsumableArray(item.atoms || [])));
430
444
  if (_found2) return _found2;
431
445
  }
432
446
  if (item.type === AtomsTypeEnum.CASE_WHEN) {
433
- var _found3 = _getFirstField(item.caseValue || []) || (item.branches || []).map(function (branch) {
434
- return _getFirstField([].concat(_toConsumableArray(branch.when || []), _toConsumableArray(branch.then || [])));
435
- }).find(Boolean) || _getFirstField(item.elseValue || []);
447
+ var _found3 = _getFirstField(item.caseAtoms || []) || (item.whenClauses || []).map(function (branch) {
448
+ return _getFirstField([].concat(_toConsumableArray(branch.whenAtoms || []), _toConsumableArray(branch.thenAtoms || [])));
449
+ }).find(Boolean) || _getFirstField(item.elseAtoms || []);
436
450
  if (_found3) return _found3;
437
451
  }
438
452
  if (item.type === AtomsTypeEnum.EXISTS || item.type === AtomsTypeEnum.NOT_EXISTS) {
@@ -13,7 +13,7 @@ import { summarizeToSql } from '../../../store/helper';
13
13
  import { Tooltip, Button, Modal, Input, Toast } from '@gingkoo/pandora';
14
14
  import { uuidv4 } from '../../../utils/helper';
15
15
  import { MetaSummarize_Enum, AtomsTypeEnum, ChangeType } from '../../../store/types';
16
- import { isExistsError, isValidSQLAlias } from '../../../utils';
16
+ import { changeFieldAlias, isExistsError, isValidSQLAlias } from '../../../utils';
17
17
  import ItemName from '../components/item-name';
18
18
  import { AddIcon, CloseIcon } from '../../icons';
19
19
  import { SelectSummarize } from '../../dialog';
@@ -198,6 +198,7 @@ var SelectIndex = function SelectIndex(props) {
198
198
  quotes: '',
199
199
  datasourceId: '',
200
200
  datasourceName: '',
201
+ datasourceType: '',
201
202
  summarizeType: MetaSummarize_Enum.GROUP
202
203
  };
203
204
  store.setPopup2({
@@ -275,6 +276,7 @@ var SelectIndex = function SelectIndex(props) {
275
276
  newMeta = store.metaList[groupIndex].list.slice();
276
277
  newMeta[index].group[i].fieldAlias = fieldAlias;
277
278
  newMeta[index].group[i].sql = newMeta[index].group[i].sql.split('AS ')[0] + "AS ".concat(fieldAlias);
279
+ newMeta = changeFieldAlias(newMeta, newMeta[index].group[i]);
278
280
  store.setMeta(newMeta, groupIndex, {
279
281
  obj: newMeta[index].group,
280
282
  type: ChangeType.group
@@ -300,7 +302,8 @@ var SelectIndex = function SelectIndex(props) {
300
302
  tableUuid: v.tableUuid,
301
303
  alias: v.alias,
302
304
  datasourceName: '',
303
- datasourceId: ''
305
+ datasourceId: '',
306
+ datasourceType: ''
304
307
  });
305
308
  });
306
309
  };
@@ -319,6 +322,7 @@ var SelectIndex = function SelectIndex(props) {
319
322
  tableUuid: v.tableUuid,
320
323
  datasourceName: '',
321
324
  datasourceId: '',
325
+ datasourceType: '',
322
326
  type: AtomsTypeEnum.FIELD
323
327
  });
324
328
  };
@@ -345,13 +349,13 @@ var SelectIndex = function SelectIndex(props) {
345
349
  if (_found) return _found;
346
350
  }
347
351
  if (item.type === AtomsTypeEnum.AND_OR) {
348
- var _found2 = _getFirstField(item.list || []);
352
+ var _found2 = _getFirstField([].concat(_toConsumableArray(item.leftAtoms || []), _toConsumableArray(item.rightAtoms || []), _toConsumableArray(item.atoms || [])));
349
353
  if (_found2) return _found2;
350
354
  }
351
355
  if (item.type === AtomsTypeEnum.CASE_WHEN) {
352
- var _found3 = _getFirstField(item.caseValue || []) || (item.branches || []).map(function (branch) {
353
- return _getFirstField([].concat(_toConsumableArray(branch.when || []), _toConsumableArray(branch.then || [])));
354
- }).find(Boolean) || _getFirstField(item.elseValue || []);
356
+ var _found3 = _getFirstField(item.caseAtoms || []) || (item.whenClauses || []).map(function (branch) {
357
+ return _getFirstField([].concat(_toConsumableArray(branch.whenAtoms || []), _toConsumableArray(branch.thenAtoms || [])));
358
+ }).find(Boolean) || _getFirstField(item.elseAtoms || []);
355
359
  if (_found3) return _found3;
356
360
  }
357
361
  if (item.type === AtomsTypeEnum.EXISTS || item.type === AtomsTypeEnum.NOT_EXISTS) {
@@ -53,7 +53,7 @@ var TableData = function TableData(props) {
53
53
  return _context.abrupt("return");
54
54
  case 1:
55
55
  _context.next = 2;
56
- return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table.datasourceId);
56
+ return store === null || store === void 0 ? void 0 : store.fetchDataset(meta.table.datasourceId, meta.table.datasourceType);
57
57
  case 2:
58
58
  tables = _context.sent;
59
59
  names = (tables === null || tables === void 0 ? void 0 : tables.map(function (v) {
@@ -88,8 +88,25 @@ var TableData = function TableData(props) {
88
88
  data: store.sourceList,
89
89
  sourceTable: store.sourceTable || [],
90
90
  value: meta.table,
91
+ onDatasourceTypeChange: function onDatasourceTypeChange(data) {
92
+ var newMetas = store.metaList[groupIndex].list.slice();
93
+ var newMetaList = newMetas[0];
94
+ newMetaList.table = _objectSpread(_objectSpread(_objectSpread({}, newMetaList.table), data), {}, {
95
+ datasourceType: data.datasourceType
96
+ });
97
+ newMetaList.columns = newMetaList.columns.map(function (column) {
98
+ return _objectSpread(_objectSpread({}, column), {}, {
99
+ datasourceType: data.datasourceType
100
+ });
101
+ });
102
+ newMetas[0] = newMetaList;
103
+ store.setMeta(newMetas, groupIndex, {
104
+ obj: data,
105
+ type: ChangeType.datasource
106
+ });
107
+ },
91
108
  onChange: function onChange(data) {
92
- if (meta.table.datasourceId !== data.datasourceId || meta.table.name !== data.name) {
109
+ if (meta.table.datasourceId !== data.datasourceId || meta.table.datasourceType !== data.datasourceType || meta.table.name !== data.name) {
93
110
  var _store$preProps;
94
111
  var newMetaList = store.metaList[groupIndex].list.slice()[0];
95
112
  newMetaList.table = _objectSpread(_objectSpread({}, data), {}, {
@@ -223,10 +240,13 @@ var TableData = function TableData(props) {
223
240
  });
224
241
  });
225
242
  newMetaList.columns = newColumns.map(function (newCol) {
243
+ var _existingCol$select;
226
244
  var existingCol = newMetaList.columns.find(function (oldCol) {
227
- return oldCol.name === newCol.name;
245
+ return newCol.fieldUuid && oldCol.fieldUuid === newCol.fieldUuid || newCol.fieldAlias && oldCol.fieldAlias === newCol.fieldAlias || oldCol.name === newCol.name;
246
+ });
247
+ var _column = _objectSpread(_objectSpread({}, newCol), {}, {
248
+ select: (_existingCol$select = existingCol === null || existingCol === void 0 ? void 0 : existingCol.select) !== null && _existingCol$select !== void 0 ? _existingCol$select : newCol.select
228
249
  });
229
- var _column = existingCol ? existingCol : newCol;
230
250
  _column.select = store.isSelectFields || _column.select;
231
251
  return _column;
232
252
  });
@@ -258,7 +278,8 @@ var TableData = function TableData(props) {
258
278
  id: '',
259
279
  alias: '',
260
280
  datasourceName: '',
261
- datasourceId: ''
281
+ datasourceId: '',
282
+ datasourceType: ''
262
283
  };
263
284
  store.setMeta(newMetaList, groupIndex);
264
285
  };