@gingkoo/pandora-metabase 1.0.92 → 1.0.93

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.
@@ -40,7 +40,7 @@ var _excluded = ["notExistsToolbar", "toolbar"],
40
40
  _excluded2 = ["subToolbar", "notExistsColumns", "showFields", "isExit", "toolbar"]; // import './index.less';
41
41
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
42
42
  var FormulaList = (0, _react.forwardRef)(function (props, ref) {
43
- var _storage$_metabaseCop, _caseList2;
43
+ var _storage$_metabaseCop, _store$operatorList, _caseList2;
44
44
  // 响应 storage._metabaseCopyItems 变化,保证粘贴按钮能实时显示
45
45
  var _useState = (0, _react.useState)((_storage["default"] === null || _storage["default"] === void 0 || (_storage$_metabaseCop = _storage["default"]._metabaseCopyItems) === null || _storage$_metabaseCop === void 0 ? void 0 : _storage$_metabaseCop.length) || 0),
46
46
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -68,7 +68,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
68
68
  _props$customTypes = props.customTypes,
69
69
  _customTypes = _props$customTypes === void 0 ? _utils3.customTypes : _props$customTypes,
70
70
  _props$operatorList = props.operatorList,
71
- _operatorList = _props$operatorList === void 0 ? store.operatorList : _props$operatorList,
71
+ _operatorList = _props$operatorList === void 0 ? ((_store$operatorList = store.operatorList) === null || _store$operatorList === void 0 ? void 0 : _store$operatorList.length) > 0 ? store.operatorList : _utils3.operatorList : _props$operatorList,
72
72
  _props$isCustom = props.isCustom,
73
73
  isCustom = _props$isCustom === void 0 ? false : _props$isCustom,
74
74
  _props$showPreview = props.showPreview,
@@ -755,24 +755,35 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
755
755
  });
756
756
  } else if (type === _types.AtomsTypeEnum.CONSTANT) {
757
757
  //常量
758
- return (0, _jsxRuntime.jsxs)("div", {
759
- className: (0, _classnames["default"])("Sqb-TableName", {
760
- notSelected: !v.val
761
- }),
762
- "v-index": index,
763
- "v-val": v.id || v.val,
764
- onClick: selectConstant,
765
- children: [v.val || v.id ? (0, _utils3.getConstantLabel)(store.constantList, v.id || v.val) : (0, _locale.__)('SqlQueryBuilder.pickConstant'), (0, _jsxRuntime.jsx)("span", {
766
- style: {
767
- fontSize: 0
768
- },
769
- onClick: function onClick(e) {
770
- return handleDel(e, index);
771
- },
772
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
773
- })]
758
+ return (0, _jsxRuntime.jsx)(_itemName["default"], {
759
+ isError: !(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val),
760
+ message: "\u5E38\u91CF\u5B57\u6BB5\u672A\u80FD\u6B63\u786E\u5BF9\u5E94",
761
+ children: (0, _jsxRuntime.jsxs)("div", {
762
+ className: (0, _classnames["default"])("Sqb-TableName", {
763
+ notSelected: !v.val
764
+ }),
765
+ "v-index": index,
766
+ "v-val": v.id || v.val,
767
+ onClick: selectConstant,
768
+ children: [(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val, v.val) || (0, _locale.__)('SqlQueryBuilder.pickConstant'), (0, _jsxRuntime.jsx)("span", {
769
+ style: {
770
+ fontSize: 0
771
+ },
772
+ onClick: function onClick(e) {
773
+ return handleDel(e, index);
774
+ },
775
+ children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
776
+ })]
777
+ })
774
778
  }, index);
775
779
  } else if (type === _types.AtomsTypeEnum.EXPRESSION) {
780
+ if (v.condition === '早于' && v.rhs.length === 2) {
781
+ var _caseList$index$quote;
782
+ var _caseList = caseList.slice();
783
+ _caseList[index].rhs = [_caseList[index].rhs[0]];
784
+ _caseList[index].quotes = (_caseList$index$quote = _caseList[index].quotes.split(' || ')) === null || _caseList$index$quote === void 0 ? void 0 : _caseList$index$quote[0];
785
+ setCaseList(_caseList);
786
+ }
776
787
  // 表达式
777
788
  return (0, _jsxRuntime.jsx)(_itemName["default"], {
778
789
  isError: (0, _utils2.isError)(v, data),
@@ -26,4 +26,4 @@ export declare function validateExpressionIntegrity(list: AtomsItem[]): {
26
26
  isCase?: boolean;
27
27
  isOver?: boolean;
28
28
  };
29
- export declare const getConstantLabel: (list: any[], val: string) => any;
29
+ export declare const getConstantLabel: (list: any[], val: string, defaultVal?: string) => any;
@@ -467,10 +467,10 @@ function validateExpressionIntegrity(list) {
467
467
  isError: false
468
468
  };
469
469
  }
470
- var getConstantLabel = exports.getConstantLabel = function getConstantLabel(list, val) {
470
+ var getConstantLabel = exports.getConstantLabel = function getConstantLabel(list, val, defaultVal) {
471
471
  var _list$filter;
472
472
  var _list = (0, _toConsumableArray2["default"])(list);
473
473
  return ((_list$filter = _list.filter(function (v) {
474
474
  return v.value === val;
475
- })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || '';
475
+ })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || defaultVal || '';
476
476
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface HeaderProps {
3
3
  children: React.ReactNode;
4
4
  isError: boolean;
5
+ message?: string;
5
6
  }
6
7
  declare const ItemName: (props: HeaderProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export default ItemName;
@@ -10,11 +10,12 @@ var _pandoraIcons = require("@gingkoo/pandora-icons");
10
10
  var _locale = require("../../../locale");
11
11
  var ItemName = function ItemName(props) {
12
12
  var children = props.children,
13
- isError = props.isError;
13
+ isError = props.isError,
14
+ message = props.message;
14
15
  return (0, _jsxRuntime.jsx)(_pandora.Badge, {
15
16
  offset: [-8, 0],
16
17
  count: isError ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
17
- title: (0, _locale.__)('metabase.verify'),
18
+ title: message || (0, _locale.__)('metabase.verify'),
18
19
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
19
20
  className: 'isError',
20
21
  style: {
package/lib/cjs/utils.js CHANGED
@@ -734,7 +734,8 @@ var _isError = exports.isError = function isError(item, data) {
734
734
  tableId = _item$tableId === void 0 ? '' : _item$tableId,
735
735
  _item$tableAlias = item.tableAlias,
736
736
  tableAlias = _item$tableAlias === void 0 ? '' : _item$tableAlias,
737
- fieldName = item.fieldName;
737
+ fieldName = item.fieldName,
738
+ fieldId = item.fieldId;
738
739
  var _datasourceId = datasourceId || 'source'; // 默认为source
739
740
  if (tableId === 'source') {
740
741
  _datasourceId = 'source';
@@ -750,13 +751,13 @@ var _isError = exports.isError = function isError(item, data) {
750
751
  } else {
751
752
  var _tables$_datasourceId2;
752
753
  return tables === null || tables === void 0 || (_tables$_datasourceId2 = tables[_datasourceId]) === null || _tables$_datasourceId2 === void 0 || (_tables$_datasourceId2 = _tables$_datasourceId2[tableId]) === null || _tables$_datasourceId2 === void 0 ? void 0 : _tables$_datasourceId2.every(function (field) {
753
- return field.name !== fieldName;
754
+ return field.name !== fieldName || field.id !== fieldId;
754
755
  });
755
756
  }
756
757
  } else {
757
758
  var _tables$_datasourceId3;
758
759
  var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId + tableAlias]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
759
- return v.name === fieldName;
760
+ return v.name === fieldName && v.id === fieldId;
760
761
  })) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
761
762
  return !hasField; // 注意:返回 true 表示“有错误”
762
763
  }
@@ -32,7 +32,7 @@ import ItemName from '../../modules/components/item-name';
32
32
  import DiffViewer from '../diff-viewer';
33
33
  import storage from '../../../utils/storage';
34
34
  var FormulaList = forwardRef(function (props, ref) {
35
- var _storage$_metabaseCop, _caseList2;
35
+ var _storage$_metabaseCop, _store$operatorList, _caseList2;
36
36
  // 响应 storage._metabaseCopyItems 变化,保证粘贴按钮能实时显示
37
37
  var _useState = useState((storage === null || storage === void 0 || (_storage$_metabaseCop = storage._metabaseCopyItems) === null || _storage$_metabaseCop === void 0 ? void 0 : _storage$_metabaseCop.length) || 0),
38
38
  _useState2 = _slicedToArray(_useState, 2),
@@ -60,7 +60,7 @@ var FormulaList = forwardRef(function (props, ref) {
60
60
  _props$customTypes = props.customTypes,
61
61
  _customTypes = _props$customTypes === void 0 ? customTypes : _props$customTypes,
62
62
  _props$operatorList = props.operatorList,
63
- _operatorList = _props$operatorList === void 0 ? store.operatorList : _props$operatorList,
63
+ _operatorList = _props$operatorList === void 0 ? ((_store$operatorList = store.operatorList) === null || _store$operatorList === void 0 ? void 0 : _store$operatorList.length) > 0 ? store.operatorList : __operatorList : _props$operatorList,
64
64
  _props$isCustom = props.isCustom,
65
65
  isCustom = _props$isCustom === void 0 ? false : _props$isCustom,
66
66
  _props$showPreview = props.showPreview,
@@ -747,24 +747,35 @@ var FormulaList = forwardRef(function (props, ref) {
747
747
  });
748
748
  } else if (type === AtomsTypeEnum.CONSTANT) {
749
749
  //常量
750
- return _jsxs("div", {
751
- className: cx("Sqb-TableName", {
752
- notSelected: !v.val
753
- }),
754
- "v-index": index,
755
- "v-val": v.id || v.val,
756
- onClick: selectConstant,
757
- children: [v.val || v.id ? getConstantLabel(store.constantList, v.id || v.val) : __('SqlQueryBuilder.pickConstant'), _jsx("span", {
758
- style: {
759
- fontSize: 0
760
- },
761
- onClick: function onClick(e) {
762
- return handleDel(e, index);
763
- },
764
- children: _jsx(CloseIcon, {})
765
- })]
750
+ return _jsx(ItemName, {
751
+ isError: !getConstantLabel(store.constantList, v.id || v.val),
752
+ message: "\u5E38\u91CF\u5B57\u6BB5\u672A\u80FD\u6B63\u786E\u5BF9\u5E94",
753
+ children: _jsxs("div", {
754
+ className: cx("Sqb-TableName", {
755
+ notSelected: !v.val
756
+ }),
757
+ "v-index": index,
758
+ "v-val": v.id || v.val,
759
+ onClick: selectConstant,
760
+ children: [getConstantLabel(store.constantList, v.id || v.val, v.val) || __('SqlQueryBuilder.pickConstant'), _jsx("span", {
761
+ style: {
762
+ fontSize: 0
763
+ },
764
+ onClick: function onClick(e) {
765
+ return handleDel(e, index);
766
+ },
767
+ children: _jsx(CloseIcon, {})
768
+ })]
769
+ })
766
770
  }, index);
767
771
  } else if (type === AtomsTypeEnum.EXPRESSION) {
772
+ if (v.condition === '早于' && v.rhs.length === 2) {
773
+ var _caseList$index$quote;
774
+ var _caseList = caseList.slice();
775
+ _caseList[index].rhs = [_caseList[index].rhs[0]];
776
+ _caseList[index].quotes = (_caseList$index$quote = _caseList[index].quotes.split(' || ')) === null || _caseList$index$quote === void 0 ? void 0 : _caseList$index$quote[0];
777
+ setCaseList(_caseList);
778
+ }
768
779
  // 表达式
769
780
  return _jsx(ItemName, {
770
781
  isError: isError(v, data),
@@ -26,4 +26,4 @@ export declare function validateExpressionIntegrity(list: AtomsItem[]): {
26
26
  isCase?: boolean;
27
27
  isOver?: boolean;
28
28
  };
29
- export declare const getConstantLabel: (list: any[], val: string) => any;
29
+ export declare const getConstantLabel: (list: any[], val: string, defaultVal?: string) => any;
@@ -460,10 +460,10 @@ export function validateExpressionIntegrity(list) {
460
460
  isError: false
461
461
  };
462
462
  }
463
- export var getConstantLabel = function getConstantLabel(list, val) {
463
+ export var getConstantLabel = function getConstantLabel(list, val, defaultVal) {
464
464
  var _list$filter;
465
465
  var _list = _toConsumableArray(list);
466
466
  return ((_list$filter = _list.filter(function (v) {
467
467
  return v.value === val;
468
- })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || '';
468
+ })) === null || _list$filter === void 0 || (_list$filter = _list$filter[0]) === null || _list$filter === void 0 ? void 0 : _list$filter.label) || defaultVal || '';
469
469
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  interface HeaderProps {
3
3
  children: React.ReactNode;
4
4
  isError: boolean;
5
+ message?: string;
5
6
  }
6
7
  declare const ItemName: (props: HeaderProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export default ItemName;
@@ -4,11 +4,12 @@ import { ExclamationCircleFill } from '@gingkoo/pandora-icons';
4
4
  import { __ } from '../../../locale';
5
5
  var ItemName = function ItemName(props) {
6
6
  var children = props.children,
7
- isError = props.isError;
7
+ isError = props.isError,
8
+ message = props.message;
8
9
  return _jsx(Badge, {
9
10
  offset: [-8, 0],
10
11
  count: isError ? _jsx(Tooltip, {
11
- title: __('metabase.verify'),
12
+ title: message || __('metabase.verify'),
12
13
  children: _jsx(Button, {
13
14
  className: 'isError',
14
15
  style: {
package/lib/es/utils.js CHANGED
@@ -723,7 +723,8 @@ var _isError = function isError(item, data) {
723
723
  tableId = _item$tableId === void 0 ? '' : _item$tableId,
724
724
  _item$tableAlias = item.tableAlias,
725
725
  tableAlias = _item$tableAlias === void 0 ? '' : _item$tableAlias,
726
- fieldName = item.fieldName;
726
+ fieldName = item.fieldName,
727
+ fieldId = item.fieldId;
727
728
  var _datasourceId = datasourceId || 'source'; // 默认为source
728
729
  if (tableId === 'source') {
729
730
  _datasourceId = 'source';
@@ -739,13 +740,13 @@ var _isError = function isError(item, data) {
739
740
  } else {
740
741
  var _tables$_datasourceId2;
741
742
  return tables === null || tables === void 0 || (_tables$_datasourceId2 = tables[_datasourceId]) === null || _tables$_datasourceId2 === void 0 || (_tables$_datasourceId2 = _tables$_datasourceId2[tableId]) === null || _tables$_datasourceId2 === void 0 ? void 0 : _tables$_datasourceId2.every(function (field) {
742
- return field.name !== fieldName;
743
+ return field.name !== fieldName || field.id !== fieldId;
743
744
  });
744
745
  }
745
746
  } else {
746
747
  var _tables$_datasourceId3;
747
748
  var hasField = (tables === null || tables === void 0 || (_tables$_datasourceId3 = tables[_datasourceId]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3[tableId + tableAlias]) === null || _tables$_datasourceId3 === void 0 || (_tables$_datasourceId3 = _tables$_datasourceId3.filter(function (v) {
748
- return v.name === fieldName;
749
+ return v.name === fieldName && v.id === fieldId;
749
750
  })) === null || _tables$_datasourceId3 === void 0 ? void 0 : _tables$_datasourceId3.length) > 0;
750
751
  return !hasField; // 注意:返回 true 表示“有错误”
751
752
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",