@gingkoo/pandora-metabase 1.0.53 → 1.0.55

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.
@@ -192,7 +192,7 @@ var SelectColumn = function SelectColumn(_ref) {
192
192
  children: (0, _jsxRuntime.jsx)(_icons.SelectIcon, {})
193
193
  }) : (0, _jsxRuntime.jsx)("div", {
194
194
  className: 'no-select mr-2'
195
- }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
195
+ }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', store.fieldEnableAlias && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
196
196
  title: (0, _locale.__)('SqlQueryBuilder.alias'),
197
197
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
198
198
  className: ':Sqb-TableName-as',
@@ -307,11 +307,12 @@ var sortList = function sortList(arr) {
307
307
  });
308
308
  };
309
309
  var NextDom = function NextDom(props) {
310
+ var _store$metaList;
310
311
  var meta = props.meta,
311
312
  groupIndex = props.groupIndex;
312
313
  var store = (0, _useProvider.useStore)();
313
314
  // @ts-ignore
314
- if (!store.metaList[groupIndex].list[0].table.name) return null;
315
+ if (!((_store$metaList = store.metaList) !== null && _store$metaList !== void 0 && (_store$metaList = _store$metaList[groupIndex]) !== null && _store$metaList !== void 0 && (_store$metaList = _store$metaList.list) !== null && _store$metaList !== void 0 && (_store$metaList = _store$metaList[0]) !== null && _store$metaList !== void 0 && (_store$metaList = _store$metaList.table) !== null && _store$metaList !== void 0 && _store$metaList.name)) return null;
315
316
  var available = findNextIcon(store, props);
316
317
  if (!store.showToolbar(_enum.TypeEnum.permissionTable)) {
317
318
  available = available.filter(function (v) {
@@ -320,7 +321,8 @@ var NextDom = function NextDom(props) {
320
321
  }
321
322
  var size = judgeSize(store, props, available.length, groupIndex);
322
323
  function handleClick(type) {
323
- var index = store.metaList[groupIndex].list.indexOf(meta);
324
+ var _store$metaList2;
325
+ var index = (_store$metaList2 = store.metaList) === null || _store$metaList2 === void 0 || (_store$metaList2 = _store$metaList2[groupIndex]) === null || _store$metaList2 === void 0 || (_store$metaList2 = _store$metaList2.list) === null || _store$metaList2 === void 0 ? void 0 : _store$metaList2.indexOf(meta);
324
326
  store.addMeta(type, index + 1, groupIndex);
325
327
  }
326
328
  var MetaIconDom = metaIcon(size, handleClick);
@@ -1118,7 +1118,11 @@ var JoinData = function JoinData(props) {
1118
1118
  return oldCol.name === newCol.name;
1119
1119
  });
1120
1120
  // 如果存在,返回旧列;否则返回新列
1121
- return existingCol ? existingCol : newCol;
1121
+ // return existingCol ? existingCol : newCol;
1122
+ var _column = existingCol ? existingCol : newCol;
1123
+ _column.select = store.isSelectFields || _column.select;
1124
+ // 如果存在,返回旧列;否则返回新列
1125
+ return _column;
1122
1126
  });
1123
1127
  // (newMeta[index] as MetaJoin).columns = newColumns;
1124
1128
  initExpressions();
@@ -1466,61 +1470,149 @@ var JoinData = function JoinData(props) {
1466
1470
  onClick: function onClick() {
1467
1471
  showSubQuery(meta.subquery);
1468
1472
  },
1469
- children: [subQuerySelected && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
1470
- title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
1471
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
1472
- danger: tableIsError(),
1473
- className: (0, _classnames["default"])(':Sqb-TableName-as', {
1474
- isError: tableIsError()
1475
- }),
1476
- shape: 'circle',
1477
- style: isDel ? {
1478
- fontSize: 18,
1479
- backgroundColor: '#fff',
1480
- width: 'auto',
1481
- height: 'auto'
1482
- } : {},
1483
- iconOnly: true,
1484
- primary: !isDel,
1485
- icon: isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : 'As',
1486
- size: 'small',
1487
- onClick: function onClick(e) {
1488
- var _meta$table4;
1489
- e.stopPropagation();
1490
- onChangeTableAlias(((_meta$table4 = meta.table2) === null || _meta$table4 === void 0 ? void 0 : _meta$table4.alias) || '');
1491
- }
1492
- })
1493
- }), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table5 = meta.table2) !== null && _meta$table5 !== void 0 && _meta$table5.alias ? "as ".concat((_meta$table6 = meta.table2) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) : '', " ") : (0, _locale.__)('SqlQueryBuilder.setSubQuery')]
1473
+ children: [subQuerySelected && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1474
+ children: function () {
1475
+ var showButton = store.tableEnableAlias || tableIsError() && isDel;
1476
+ var icon = isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
1477
+ return showButton ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
1478
+ title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
1479
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
1480
+ danger: tableIsError(),
1481
+ className: (0, _classnames["default"])(':Sqb-TableName-as', {
1482
+ isError: tableIsError()
1483
+ }),
1484
+ shape: 'circle',
1485
+ style: isDel ? {
1486
+ fontSize: 18,
1487
+ backgroundColor: '#fff',
1488
+ width: 'auto',
1489
+ height: 'auto'
1490
+ } : {},
1491
+ iconOnly: true,
1492
+ primary: !isDel,
1493
+ icon: icon,
1494
+ size: 'small',
1495
+ onClick: function onClick(e) {
1496
+ if (store.tableEnableAlias) {
1497
+ var _meta$table4;
1498
+ e.stopPropagation();
1499
+ onChangeTableAlias(((_meta$table4 = meta.table2) === null || _meta$table4 === void 0 ? void 0 : _meta$table4.alias) || '');
1500
+ }
1501
+ }
1502
+ })
1503
+ }) : null;
1504
+ }()
1505
+ })
1506
+ // <Tooltip
1507
+ // title={__(
1508
+ // tableIsError()
1509
+ // ? isDel
1510
+ // ? 'metabase.verify'
1511
+ // : 'SqlQueryBuilder.repeatAlias'
1512
+ // : 'SqlQueryBuilder.alias',
1513
+ // )}
1514
+ // >
1515
+ // <Button
1516
+ // danger={tableIsError()}
1517
+ // className={cx(':Sqb-TableName-as', {
1518
+ // isError: tableIsError(),
1519
+ // })}
1520
+ // shape='circle'
1521
+ // style={
1522
+ // isDel
1523
+ // ? {
1524
+ // fontSize: 18,
1525
+ // backgroundColor: '#fff',
1526
+ // width: 'auto',
1527
+ // height: 'auto',
1528
+ // }
1529
+ // : {}
1530
+ // }
1531
+ // iconOnly
1532
+ // primary={!isDel}
1533
+ // icon={isDel ? <ExclamationCircleFill /> : 'As'}
1534
+ // size='small'
1535
+ // onClick={(e) => {
1536
+ // e.stopPropagation();
1537
+ // onChangeTableAlias(meta.table2?.alias || '');
1538
+ // }}
1539
+ // ></Button>
1540
+ // </Tooltip>
1541
+ , subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table5 = meta.table2) !== null && _meta$table5 !== void 0 && _meta$table5.alias ? "as ".concat((_meta$table6 = meta.table2) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) : '', " ") : (0, _locale.__)('SqlQueryBuilder.setSubQuery')]
1494
1542
  }) : (0, _jsxRuntime.jsxs)("div", {
1495
1543
  className: (0, _classnames["default"])("Sqb-TableName", {
1496
1544
  notSelected: !table2Selected
1497
1545
  }),
1498
1546
  onClick: selectTable,
1499
- children: [table2Selected && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
1500
- title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
1501
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
1502
- danger: tableIsError(),
1503
- className: (0, _classnames["default"])(':Sqb-TableName-as', {
1504
- isError: tableIsError()
1505
- }),
1506
- shape: 'circle',
1507
- style: isDel ? {
1508
- fontSize: 18,
1509
- backgroundColor: '#fff',
1510
- width: 'auto',
1511
- height: 'auto'
1512
- } : {},
1513
- iconOnly: true,
1514
- primary: !isDel,
1515
- icon: isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : 'As',
1516
- size: 'small',
1517
- onClick: function onClick(e) {
1518
- var _meta$table7;
1519
- e.stopPropagation();
1520
- onChangeTableAlias(((_meta$table7 = meta.table2) === null || _meta$table7 === void 0 ? void 0 : _meta$table7.alias) || '');
1521
- }
1522
- })
1523
- }), table2Selected ? "".concat(meta.table2.datasourceName, ".").concat(meta.table2.name, " ").concat((_meta$table8 = meta.table2) !== null && _meta$table8 !== void 0 && _meta$table8.alias ? "as ".concat((_meta$table9 = meta.table2) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.alias) : '') : (0, _locale.__)('SqlQueryBuilder.pickTable')]
1547
+ children: [table2Selected && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
1548
+ children: function () {
1549
+ var showButton = store.tableEnableAlias || tableIsError() && isDel;
1550
+ var icon = isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
1551
+ return showButton ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
1552
+ title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
1553
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
1554
+ danger: tableIsError(),
1555
+ className: (0, _classnames["default"])(':Sqb-TableName-as', {
1556
+ isError: tableIsError()
1557
+ }),
1558
+ shape: 'circle',
1559
+ style: isDel ? {
1560
+ fontSize: 18,
1561
+ backgroundColor: '#fff',
1562
+ width: 'auto',
1563
+ height: 'auto'
1564
+ } : {},
1565
+ iconOnly: true,
1566
+ primary: !isDel,
1567
+ icon: icon,
1568
+ size: 'small',
1569
+ onClick: function onClick(e) {
1570
+ if (store.tableEnableAlias) {
1571
+ var _meta$table7;
1572
+ e.stopPropagation();
1573
+ onChangeTableAlias(((_meta$table7 = meta.table2) === null || _meta$table7 === void 0 ? void 0 : _meta$table7.alias) || '');
1574
+ }
1575
+ }
1576
+ })
1577
+ }) : null;
1578
+ }()
1579
+ })
1580
+ // <Tooltip
1581
+ // title={__(
1582
+ // tableIsError()
1583
+ // ? isDel
1584
+ // ? 'metabase.verify'
1585
+ // : 'SqlQueryBuilder.repeatAlias'
1586
+ // : 'SqlQueryBuilder.alias',
1587
+ // )}
1588
+ // >
1589
+ // <Button
1590
+ // danger={tableIsError()}
1591
+ // className={cx(':Sqb-TableName-as', {
1592
+ // isError: tableIsError(),
1593
+ // })}
1594
+ // shape='circle'
1595
+ // style={
1596
+ // isDel
1597
+ // ? {
1598
+ // fontSize: 18,
1599
+ // backgroundColor: '#fff',
1600
+ // width: 'auto',
1601
+ // height: 'auto',
1602
+ // }
1603
+ // : {}
1604
+ // }
1605
+ // iconOnly
1606
+ // primary={!isDel}
1607
+ // icon={isDel ? <ExclamationCircleFill /> : 'As'}
1608
+ // size='small'
1609
+ // onClick={(e) => {
1610
+ // e.stopPropagation();
1611
+ // onChangeTableAlias(meta.table2?.alias || '');
1612
+ // }}
1613
+ // ></Button>
1614
+ // </Tooltip>
1615
+ , table2Selected ? "".concat(meta.table2.datasourceName, ".").concat(meta.table2.name, " ").concat((_meta$table8 = meta.table2) !== null && _meta$table8 !== void 0 && _meta$table8.alias ? "as ".concat((_meta$table9 = meta.table2) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.alias) : '') : (0, _locale.__)('SqlQueryBuilder.pickTable')]
1524
1616
  }), store.showSubquery && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
1525
1617
  title: (0, _locale.__)('SqlQueryBuilder.switchSubQuery'),
1526
1618
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
@@ -328,19 +328,21 @@ var GroupBy = function GroupBy(props) {
328
328
  onClick: function onClick(e) {
329
329
  return handleUpdate(e, i);
330
330
  },
331
- children: [v.quotes && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
332
- title: (0, _locale.__)('SqlQueryBuilder.alias'),
333
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
334
- className: ':Sqb-TableName-as :Sqb-TableName green-name',
335
- shape: 'circle',
336
- iconOnly: true,
337
- primary: true,
338
- icon: 'As',
339
- size: 'small',
340
- onClick: function onClick(e) {
341
- e.stopPropagation();
342
- onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
343
- }
331
+ children: [v.quotes && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
332
+ children: store.fieldEnableAlias && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
333
+ title: (0, _locale.__)('SqlQueryBuilder.alias'),
334
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
335
+ className: ':Sqb-TableName-as :Sqb-TableName green-name',
336
+ shape: 'circle',
337
+ iconOnly: true,
338
+ primary: true,
339
+ icon: 'As',
340
+ size: 'small',
341
+ onClick: function onClick(e) {
342
+ e.stopPropagation();
343
+ onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
344
+ }
345
+ })
344
346
  })
345
347
  }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), (0, _jsxRuntime.jsx)("span", {
346
348
  style: {
@@ -329,19 +329,21 @@ var SelectIndex = function SelectIndex(props) {
329
329
  onClick: function onClick(e) {
330
330
  return handleUpdate(e, i);
331
331
  },
332
- children: [v.quotes && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
333
- title: (0, _locale.__)('SqlQueryBuilder.alias'),
334
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
335
- className: ':Sqb-TableName-as :Sqb-TableName green-name',
336
- shape: 'circle',
337
- iconOnly: true,
338
- primary: true,
339
- icon: 'As',
340
- size: 'small',
341
- onClick: function onClick(e) {
342
- e.stopPropagation();
343
- onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
344
- }
332
+ children: [v.quotes && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
333
+ children: store.fieldEnableAlias && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
334
+ title: (0, _locale.__)('SqlQueryBuilder.alias'),
335
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
336
+ className: ':Sqb-TableName-as :Sqb-TableName green-name',
337
+ shape: 'circle',
338
+ iconOnly: true,
339
+ primary: true,
340
+ icon: 'As',
341
+ size: 'small',
342
+ onClick: function onClick(e) {
343
+ e.stopPropagation();
344
+ onChangeFieldAlias((v === null || v === void 0 ? void 0 : v.fieldAlias) || '', i);
345
+ }
346
+ })
345
347
  })
346
348
  }), "".concat(v.quotes, " ").concat(v.fieldAlias ? "as ".concat(v.fieldAlias) : ''), (0, _jsxRuntime.jsx)("span", {
347
349
  style: {
@@ -221,8 +221,10 @@ var TableData = function TableData(props) {
221
221
  var existingCol = newMetaList.columns.find(function (oldCol) {
222
222
  return oldCol.name === newCol.name;
223
223
  });
224
+ var _column = existingCol ? existingCol : newCol;
225
+ _column.select = store.isSelectFields || _column.select;
224
226
  // 如果存在,返回旧列;否则返回新列
225
- return existingCol ? existingCol : newCol;
227
+ return _column;
226
228
  });
227
229
  // (newMeta[index] as MetaJoin).expressions = [];
228
230
  var newMetas = store.metaList[groupIndex].list.slice();
@@ -290,61 +292,113 @@ var TableData = function TableData(props) {
290
292
  onClick: function onClick() {
291
293
  showSubQuery(meta.subquery);
292
294
  },
293
- children: [subQuerySelected && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
294
- title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
295
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
296
- danger: tableIsError(),
297
- className: (0, _classnames["default"])(':Sqb-TableName-as', {
298
- isError: tableIsError()
299
- }),
300
- shape: 'circle',
301
- style: isDel ? {
302
- fontSize: 18,
303
- backgroundColor: '#fff',
304
- width: 'auto',
305
- height: 'auto'
306
- } : {},
307
- iconOnly: true,
308
- primary: !isDel,
309
- icon: isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : 'As',
310
- size: 'small',
311
- onClick: function onClick(e) {
312
- var _meta$table4;
313
- e.stopPropagation();
314
- onChangeTableAlias(((_meta$table4 = meta.table) === null || _meta$table4 === void 0 ? void 0 : _meta$table4.alias) || '');
315
- }
316
- })
295
+ children: [subQuerySelected && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
296
+ children: function () {
297
+ var showButton = store.tableEnableAlias || tableIsError() && isDel;
298
+ var icon = isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
299
+ return showButton ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
300
+ title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
301
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
302
+ danger: tableIsError(),
303
+ className: (0, _classnames["default"])(':Sqb-TableName-as', {
304
+ isError: tableIsError()
305
+ }),
306
+ shape: 'circle',
307
+ style: isDel ? {
308
+ fontSize: 18,
309
+ backgroundColor: '#fff',
310
+ width: 'auto',
311
+ height: 'auto'
312
+ } : {},
313
+ iconOnly: true,
314
+ primary: !isDel,
315
+ icon: icon,
316
+ size: 'small',
317
+ onClick: function onClick(e) {
318
+ if (store.tableEnableAlias) {
319
+ var _meta$table4;
320
+ e.stopPropagation();
321
+ onChangeTableAlias(((_meta$table4 = meta.table) === null || _meta$table4 === void 0 ? void 0 : _meta$table4.alias) || '');
322
+ }
323
+ }
324
+ })
325
+ }) : null;
326
+ }()
317
327
  }), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table5 = meta.table) !== null && _meta$table5 !== void 0 && _meta$table5.alias ? "as ".concat((_meta$table6 = meta.table) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) : '', " ") : (0, _locale.__)('SqlQueryBuilder.setSubQuery')]
318
328
  }) : (0, _jsxRuntime.jsxs)("div", {
319
329
  className: (0, _classnames["default"])("Sqb-TableName", {
320
330
  notSelected: !selected
321
331
  }),
322
332
  onClick: selectTable,
323
- children: [selected && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
324
- title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
325
- children: (0, _jsxRuntime.jsx)(_pandora.Button, {
326
- danger: tableIsError(),
327
- className: (0, _classnames["default"])(':Sqb-TableName-as', {
328
- isError: tableIsError()
329
- }),
330
- shape: 'circle',
331
- style: isDel ? {
332
- fontSize: 18,
333
- backgroundColor: '#fff',
334
- width: 'auto',
335
- height: 'auto'
336
- } : {},
337
- iconOnly: true,
338
- primary: !isDel,
339
- icon: isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : 'As',
340
- size: 'small',
341
- onClick: function onClick(e) {
342
- var _meta$table7;
343
- e.stopPropagation();
344
- onChangeTableAlias(((_meta$table7 = meta.table) === null || _meta$table7 === void 0 ? void 0 : _meta$table7.alias) || '');
345
- }
346
- })
347
- }), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table8 = meta.table) !== null && _meta$table8 !== void 0 && _meta$table8.alias ? "as ".concat((_meta$table9 = meta.table) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.alias) : '') : (0, _locale.__)('SqlQueryBuilder.pickTable')]
333
+ children: [selected && (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
334
+ children: function () {
335
+ var showButton = store.tableEnableAlias || tableIsError() && isDel;
336
+ var icon = isDel ? (0, _jsxRuntime.jsx)(_pandoraIcons.ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
337
+ return showButton ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
338
+ title: (0, _locale.__)(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
339
+ children: (0, _jsxRuntime.jsx)(_pandora.Button, {
340
+ danger: tableIsError(),
341
+ className: (0, _classnames["default"])(':Sqb-TableName-as', {
342
+ isError: tableIsError()
343
+ }),
344
+ shape: 'circle',
345
+ style: isDel ? {
346
+ fontSize: 18,
347
+ backgroundColor: '#fff',
348
+ width: 'auto',
349
+ height: 'auto'
350
+ } : {},
351
+ iconOnly: true,
352
+ primary: !isDel,
353
+ icon: icon,
354
+ size: 'small',
355
+ onClick: function onClick(e) {
356
+ if (store.tableEnableAlias) {
357
+ var _meta$table7;
358
+ e.stopPropagation();
359
+ onChangeTableAlias(((_meta$table7 = meta.table) === null || _meta$table7 === void 0 ? void 0 : _meta$table7.alias) || '');
360
+ }
361
+ }
362
+ })
363
+ }) : null;
364
+ }()
365
+ })
366
+ // <Tooltip
367
+ // title={__(
368
+ // tableIsError()
369
+ // ? isDel
370
+ // ? 'metabase.verify'
371
+ // : 'SqlQueryBuilder.repeatAlias'
372
+ // : 'SqlQueryBuilder.alias',
373
+ // )}
374
+ // >
375
+ // <Button
376
+ // danger={tableIsError()}
377
+ // className={cx(':Sqb-TableName-as', {
378
+ // isError: tableIsError(),
379
+ // })}
380
+ // shape='circle'
381
+ // style={
382
+ // isDel
383
+ // ? {
384
+ // fontSize: 18,
385
+ // backgroundColor: '#fff',
386
+ // width: 'auto',
387
+ // height: 'auto',
388
+ // }
389
+ // : {}
390
+ // }
391
+ // iconOnly
392
+ // primary={!isDel}
393
+ // icon={isDel ? <ExclamationCircleFill /> : 'As'}
394
+ // size='small'
395
+ // onClick={(e) => {
396
+ // e.stopPropagation();
397
+ // onChangeTableAlias(meta.table?.alias || '');
398
+ // }}
399
+ // ></Button>
400
+ // </Tooltip>
401
+ , selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table8 = meta.table) !== null && _meta$table8 !== void 0 && _meta$table8.alias ? "as ".concat((_meta$table9 = meta.table) === null || _meta$table9 === void 0 ? void 0 : _meta$table9.alias) : '') : (0, _locale.__)('SqlQueryBuilder.pickTable')]
348
402
  }), store.showSubquery && (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
349
403
  title: (0, _locale.__)('SqlQueryBuilder.switchSubQuery'),
350
404
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
@@ -133,6 +133,18 @@ var useStore = function useStore() {
133
133
  _useState38 = (0, _slicedToArray2["default"])(_useState37, 2),
134
134
  isExit = _useState38[0],
135
135
  setIsExit = _useState38[1]; // 是否是notExit
136
+ var _useState39 = (0, _react.useState)(true),
137
+ _useState40 = (0, _slicedToArray2["default"])(_useState39, 2),
138
+ tableEnableAlias = _useState40[0],
139
+ setTableEnableAlias = _useState40[1]; // 表名是否开启别名
140
+ var _useState41 = (0, _react.useState)(true),
141
+ _useState42 = (0, _slicedToArray2["default"])(_useState41, 2),
142
+ fieldEnableAlias = _useState42[0],
143
+ setFieldEnableAlias = _useState42[1]; // 字段名是否开启别名
144
+ var _useState43 = (0, _react.useState)(true),
145
+ _useState44 = (0, _slicedToArray2["default"])(_useState43, 2),
146
+ isSelectFields = _useState44[0],
147
+ setIsSelectFields = _useState44[1]; // 是否默认勾选字段
136
148
  // 外层ref
137
149
  var popupContainer = (0, _react.useRef)();
138
150
  // const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
@@ -271,7 +283,7 @@ var useStore = function useStore() {
271
283
  var obj = {};
272
284
  obj = oldObj[v.id] || {};
273
285
  return (0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, obj), v), {}, {
274
- select: select,
286
+ select: isSelectFields || select,
275
287
  fieldUuid: obj.fieldUuid || v.fieldUuid || (0, _helper.uuidv4)('field')
276
288
  });
277
289
  });
@@ -609,7 +621,13 @@ var useStore = function useStore() {
609
621
  formulaTemplates: formulaTemplates,
610
622
  setFormulaTemplates: setFormulaTemplates,
611
623
  isExit: isExit,
612
- setIsExit: setIsExit
624
+ setIsExit: setIsExit,
625
+ tableEnableAlias: tableEnableAlias,
626
+ setTableEnableAlias: setTableEnableAlias,
627
+ fieldEnableAlias: fieldEnableAlias,
628
+ setFieldEnableAlias: setFieldEnableAlias,
629
+ isSelectFields: isSelectFields,
630
+ setIsSelectFields: setIsSelectFields
613
631
  };
614
632
  };
615
633
  var _default = exports["default"] = useStore;
package/lib/cjs/index.js CHANGED
@@ -43,6 +43,8 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
43
43
  value = _props$value === void 0 ? [] : _props$value,
44
44
  _props$sourceList = props.sourceList,
45
45
  sourceList = _props$sourceList === void 0 ? [] : _props$sourceList,
46
+ _props$exitSourceList = props.exitSourceList,
47
+ exitSourceList = _props$exitSourceList === void 0 ? [] : _props$exitSourceList,
46
48
  _props$showSubquery = props.showSubquery,
47
49
  showSubquery = _props$showSubquery === void 0 ? true : _props$showSubquery,
48
50
  _props$subShowSubquer = props.subShowSubquery,
@@ -54,7 +56,13 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
54
56
  _props$filterCustomTy = props.filterCustomType,
55
57
  filterCustomType = _props$filterCustomTy === void 0 ? false : _props$filterCustomTy,
56
58
  _props$isExit = props.isExit,
57
- isExit = _props$isExit === void 0 ? false : _props$isExit;
59
+ isExit = _props$isExit === void 0 ? false : _props$isExit,
60
+ _props$tableEnableAli = props.tableEnableAlias,
61
+ tableEnableAlias = _props$tableEnableAli === void 0 ? true : _props$tableEnableAli,
62
+ _props$fieldEnableAli = props.fieldEnableAlias,
63
+ fieldEnableAlias = _props$fieldEnableAli === void 0 ? true : _props$fieldEnableAli,
64
+ _props$isSelectFields = props.isSelectFields,
65
+ isSelectFields = _props$isSelectFields === void 0 ? true : _props$isSelectFields;
58
66
  var store = (0, _useState["default"])();
59
67
  (0, _react.useEffect)(function () {
60
68
  getTables && store.setFetchDatasetFn(getTables);
@@ -68,8 +76,8 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
68
76
  store.setPreData(_value);
69
77
  }, [value]);
70
78
  (0, _react.useEffect)(function () {
71
- store.setSourceList(sourceList);
72
- }, [sourceList]);
79
+ store.setSourceList(isExit && exitSourceList && Array.from(exitSourceList).length > 0 ? exitSourceList || sourceList : sourceList);
80
+ }, [sourceList, exitSourceList, isExit]);
73
81
  (0, _react.useEffect)(function () {
74
82
  store.setShowFields(showFields);
75
83
  store.setFieldNameTpl(fieldNameTpl || '${name}');
@@ -82,7 +90,10 @@ var SqlVisionBuilder = _react["default"].forwardRef(function (props, ref) {
82
90
  store.setIgnoreGroupByType(ignoreGroupByType);
83
91
  store.setfilterCustomType(filterCustomType);
84
92
  store.setIsExit(isExit);
85
- }, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit]);
93
+ store.setTableEnableAlias(tableEnableAlias);
94
+ store.setFieldEnableAlias(fieldEnableAlias);
95
+ store.setIsSelectFields(isSelectFields);
96
+ }, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, isSelectFields]);
86
97
  _react["default"].useImperativeHandle(ref, function () {
87
98
  return {
88
99
  // setDatasource: (list) => {
@@ -25,6 +25,7 @@ export interface MetabaseProps {
25
25
  onOk?: (params: any) => void;
26
26
  value?: MetaListType[];
27
27
  sourceList?: DatasourceType[];
28
+ exitSourceList?: DatasourceType[];
28
29
  showSubquery?: boolean;
29
30
  subShowSubquery?: boolean;
30
31
  constantList?: OptionItem[];
@@ -34,6 +35,9 @@ export interface MetabaseProps {
34
35
  notExistsColumns?: DataType[];
35
36
  formulaTemplates?: FormulaTemplatesItem[];
36
37
  isExit?: boolean;
38
+ tableEnableAlias?: boolean;
39
+ fieldEnableAlias?: boolean;
40
+ isSelectFields?: boolean;
37
41
  }
38
42
  export interface OptionItem {
39
43
  value?: string;
@@ -185,7 +185,7 @@ var SelectColumn = function SelectColumn(_ref) {
185
185
  children: _jsx(SelectIcon, {})
186
186
  }) : _jsx("div", {
187
187
  className: 'no-select mr-2'
188
- }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', _jsx(Tooltip, {
188
+ }), v.name, v.name_zh ? " \uFF08".concat(v.name_zh, "\uFF09") : '', v.fieldAlias ? " as ".concat(v.fieldAlias) : '', store.fieldEnableAlias && _jsx(Tooltip, {
189
189
  title: __('SqlQueryBuilder.alias'),
190
190
  children: _jsx(Button, {
191
191
  className: ':Sqb-TableName-as',