@gingkoo/pandora-metabase 1.0.157-alpha.9 → 1.0.157

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.
@@ -31,8 +31,14 @@ var _itemName = _interopRequireDefault(require("../../modules/components/item-na
31
31
  var _dateFormatPicker = require("./date-format-picker");
32
32
  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); }
33
33
  var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
34
- var STRING_LIST = ['等于', '不等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
35
- var DATE_LIST = ['等于', '早于', '晚于', '介于之间', '是空的', '不为空'];
34
+ var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
35
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
36
+ var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
37
+ var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
38
+ var LEGACY_DATE_CONDITION_MAP = {
39
+ 早于: '小于',
40
+ 晚于: '大于或等于'
41
+ };
36
42
  var typeList = [{
37
43
  key: _enum.SQL_COLUMN_TYPE.STRING,
38
44
  label: _enum.SQL_COLUMN_TYPE.STRING
@@ -348,12 +354,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
348
354
  conditions = DATE_LIST;
349
355
  type = _enum.SQL_GROUP_TYPE.DATE;
350
356
  }
357
+ var nextCondition = LEGACY_DATE_CONDITION_MAP[condition];
358
+ if (type === _enum.SQL_GROUP_TYPE.DATE && nextCondition) {
359
+ setCondition(nextCondition);
360
+ }
351
361
  if (isCustom) {
352
362
  conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
353
363
  }
354
364
  var isCompatibleDateEmptyCondition = type === _enum.SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
355
- if (!conditions.includes(condition) && !isCompatibleDateEmptyCondition) {
356
- setDefaultVal(conditions[0]);
365
+ if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
366
+ setDefaultVal(conditions[0], type);
357
367
  }
358
368
  return {
359
369
  columnType: columnType,
@@ -507,7 +517,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
507
517
  })
508
518
  })]
509
519
  });
510
- } else if (~['早于', '晚于', '在'].indexOf(conditionText)) {
520
+ } else if (type === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.filter(function (v) {
521
+ return v !== '等于';
522
+ }).indexOf(conditionText)) {
511
523
  var _rhsVal$3, _rhsVal$4;
512
524
  var _dateVal = ((_rhsVal$3 = rhsVal[0]) === null || _rhsVal$3 === void 0 ? void 0 : _rhsVal$3.type) === _types.AtomsTypeEnum.INPUT_STRING ? rhsVal[0].val : undefined;
513
525
  var _dateFormat = ((_rhsVal$4 = rhsVal[0]) === null || _rhsVal$4 === void 0 ? void 0 : _rhsVal$4.type) === _types.AtomsTypeEnum.INPUT_STRING ? rhsVal[0].format : undefined;
@@ -652,10 +664,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
652
664
  })
653
665
  });
654
666
  };
655
- var onRepeat = function onRepeat(e) {
667
+ var onRepeat = function onRepeat(e, fieldType) {
656
668
  var _rhsVal$7;
657
669
  setParentClosable(false);
658
- var inputAtomType = ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
670
+ var inputAtomType = fieldType === _enum.SQL_GROUP_TYPE.NUMBER || ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
659
671
  store.setPopup2({
660
672
  visible: true,
661
673
  node: e.currentTarget,
@@ -886,7 +898,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
886
898
  getPopupContainer: getCurrentPopupContainer,
887
899
  onChange: function onChange(key) {
888
900
  setCurColumn((0, _objectSpread2["default"])({}, curColumn));
889
- setDefaultVal(key);
901
+ setDefaultVal(key, fieldType);
890
902
  },
891
903
  droplist: menu,
892
904
  children: (0, _jsxRuntime.jsxs)(_pandora.Button, {
@@ -931,14 +943,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
931
943
  children: renderFilter(fieldType, condition)
932
944
  }, i);
933
945
  }
934
- }), ~['等于', '不等于', '早于', '晚于'].indexOf(condition) ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
946
+ }), ~SWITCH_VALUE_TYPE_CONDITIONS.indexOf(condition) || fieldType === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(condition) ? (0, _jsxRuntime.jsx)(_pandora.Tooltip, {
935
947
  title: (0, _locale.__)('SqlQueryBuilder.switch'),
936
948
  children: (0, _jsxRuntime.jsx)(_pandora.Button, {
937
949
  primary: true,
938
950
  ghost: true,
939
951
  className: 'ml-2 operator-icon',
940
952
  icon: (0, _jsxRuntime.jsx)(_pandoraIcons.Repeat, {}),
941
- onClick: onRepeat
953
+ onClick: function onClick(e) {
954
+ return onRepeat(e, fieldType);
955
+ }
942
956
  })
943
957
  }) : '']
944
958
  }), (0, _jsxRuntime.jsx)("div", {
@@ -955,7 +969,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
955
969
  })]
956
970
  });
957
971
  }
958
- function setDefaultVal(_condition) {
972
+ function setDefaultVal(_condition, fieldType) {
959
973
  var _rhsVal$0;
960
974
  setCondition(_condition);
961
975
  var inputAtomType = ((_rhsVal$0 = rhsVal[0]) === null || _rhsVal$0 === void 0 ? void 0 : _rhsVal$0.type) === _types.AtomsTypeEnum.INPUT_NUMBER ? _types.AtomsTypeEnum.INPUT_NUMBER : _types.AtomsTypeEnum.INPUT_STRING;
@@ -975,7 +989,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
975
989
  val: '天',
976
990
  type: _types.AtomsTypeEnum.INPUT_STRING
977
991
  }]);
978
- } else if (~['早于', '晚于', '在'].indexOf(_condition)) {
992
+ } else if (fieldType === _enum.SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(_condition)) {
979
993
  setRhsVal([{
980
994
  val: (0, _dayjs["default"])().format('YYYY-MM-DD HH:mm'),
981
995
  type: _types.AtomsTypeEnum.INPUT_STRING,
@@ -2952,7 +2952,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
2952
2952
  }
2953
2953
  if (type === _types.AtomsTypeEnum.EXPRESSION) {
2954
2954
  var quotes = (0, _utils2.getAtomDisplayText)(v);
2955
- if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
2955
+ if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
2956
2956
  var _getAtomDisplayText$s;
2957
2957
  var nextList = caseList.slice();
2958
2958
  nextList[index].rhs = [nextList[index].rhs[0]];
@@ -258,6 +258,18 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
258
258
  case '不等于':
259
259
  _right_condition = "!= ".concat(_rightSql);
260
260
  break;
261
+ case '大于':
262
+ _right_condition = "> ".concat(_rightSql);
263
+ break;
264
+ case '小于':
265
+ _right_condition = "< ".concat(_rightSql);
266
+ break;
267
+ case '大于或等于':
268
+ _right_condition = ">= ".concat(_rightSql);
269
+ break;
270
+ case '小于或等于':
271
+ _right_condition = "<= ".concat(_rightSql);
272
+ break;
261
273
  case '包含':
262
274
  _right_condition = "LIKE '%".concat(condition_1, "%'");
263
275
  break;
@@ -444,12 +456,20 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
444
456
  case '等于':
445
457
  _right_condition = "= ".concat(_condition_4);
446
458
  break;
459
+ case '大于':
460
+ _right_condition = "> ".concat(_condition_4);
461
+ break;
462
+ case '小于':
447
463
  case '早于':
448
464
  _right_condition = "< ".concat(_condition_4);
449
465
  break;
466
+ case '大于或等于':
450
467
  case '晚于':
451
468
  _right_condition = ">= ".concat(_condition_4);
452
469
  break;
470
+ case '小于或等于':
471
+ _right_condition = "<= ".concat(_condition_4);
472
+ break;
453
473
  case '介于之间':
454
474
  _right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
455
475
  _left_condition = '';
@@ -23,8 +23,14 @@ import { EMPTY_RHS_CONDITIONS, getConstantLabel, normalizeExpressionAtom } from
23
23
  import ItemName from '../../modules/components/item-name';
24
24
  import { DateFormatPicker, DateRangeFormatPicker } from './date-format-picker';
25
25
  var NUMBER_LIST = ['等于', '不等于', '大于', '小于', '介于之间', '大于或等于', '小于或等于', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
26
- var STRING_LIST = ['等于', '不等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
27
- var DATE_LIST = ['等于', '早于', '晚于', '介于之间', '是空的', '不为空'];
26
+ var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
27
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
28
+ var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
29
+ var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
30
+ var LEGACY_DATE_CONDITION_MAP = {
31
+ 早于: '小于',
32
+ 晚于: '大于或等于'
33
+ };
28
34
  var typeList = [{
29
35
  key: SQL_COLUMN_TYPE.STRING,
30
36
  label: SQL_COLUMN_TYPE.STRING
@@ -340,12 +346,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
340
346
  conditions = DATE_LIST;
341
347
  type = SQL_GROUP_TYPE.DATE;
342
348
  }
349
+ var nextCondition = LEGACY_DATE_CONDITION_MAP[condition];
350
+ if (type === SQL_GROUP_TYPE.DATE && nextCondition) {
351
+ setCondition(nextCondition);
352
+ }
343
353
  if (isCustom) {
344
354
  conditions = ['无需结果'].concat(_toConsumableArray(conditions));
345
355
  }
346
356
  var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
347
- if (!conditions.includes(condition) && !isCompatibleDateEmptyCondition) {
348
- setDefaultVal(conditions[0]);
357
+ if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
358
+ setDefaultVal(conditions[0], type);
349
359
  }
350
360
  return {
351
361
  columnType: columnType,
@@ -499,7 +509,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
499
509
  })
500
510
  })]
501
511
  });
502
- } else if (~['早于', '晚于', '在'].indexOf(conditionText)) {
512
+ } else if (type === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.filter(function (v) {
513
+ return v !== '等于';
514
+ }).indexOf(conditionText)) {
503
515
  var _rhsVal$3, _rhsVal$4;
504
516
  var _dateVal = ((_rhsVal$3 = rhsVal[0]) === null || _rhsVal$3 === void 0 ? void 0 : _rhsVal$3.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].val : undefined;
505
517
  var _dateFormat = ((_rhsVal$4 = rhsVal[0]) === null || _rhsVal$4 === void 0 ? void 0 : _rhsVal$4.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].format : undefined;
@@ -644,10 +656,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
644
656
  })
645
657
  });
646
658
  };
647
- var onRepeat = function onRepeat(e) {
659
+ var onRepeat = function onRepeat(e, fieldType) {
648
660
  var _rhsVal$7;
649
661
  setParentClosable(false);
650
- var inputAtomType = ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
662
+ var inputAtomType = fieldType === SQL_GROUP_TYPE.NUMBER || ((_rhsVal$7 = rhsVal[0]) === null || _rhsVal$7 === void 0 ? void 0 : _rhsVal$7.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
651
663
  store.setPopup2({
652
664
  visible: true,
653
665
  node: e.currentTarget,
@@ -878,7 +890,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
878
890
  getPopupContainer: getCurrentPopupContainer,
879
891
  onChange: function onChange(key) {
880
892
  setCurColumn(_objectSpread({}, curColumn));
881
- setDefaultVal(key);
893
+ setDefaultVal(key, fieldType);
882
894
  },
883
895
  droplist: menu,
884
896
  children: _jsxs(Button, {
@@ -923,14 +935,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
923
935
  children: renderFilter(fieldType, condition)
924
936
  }, i);
925
937
  }
926
- }), ~['等于', '不等于', '早于', '晚于'].indexOf(condition) ? _jsx(Tooltip, {
938
+ }), ~SWITCH_VALUE_TYPE_CONDITIONS.indexOf(condition) || fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(condition) ? _jsx(Tooltip, {
927
939
  title: __('SqlQueryBuilder.switch'),
928
940
  children: _jsx(Button, {
929
941
  primary: true,
930
942
  ghost: true,
931
943
  className: 'ml-2 operator-icon',
932
944
  icon: _jsx(Repeat, {}),
933
- onClick: onRepeat
945
+ onClick: function onClick(e) {
946
+ return onRepeat(e, fieldType);
947
+ }
934
948
  })
935
949
  }) : '']
936
950
  }), _jsx("div", {
@@ -947,7 +961,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
947
961
  })]
948
962
  });
949
963
  }
950
- function setDefaultVal(_condition) {
964
+ function setDefaultVal(_condition, fieldType) {
951
965
  var _rhsVal$0;
952
966
  setCondition(_condition);
953
967
  var inputAtomType = ((_rhsVal$0 = rhsVal[0]) === null || _rhsVal$0 === void 0 ? void 0 : _rhsVal$0.type) === AtomsTypeEnum.INPUT_NUMBER ? AtomsTypeEnum.INPUT_NUMBER : AtomsTypeEnum.INPUT_STRING;
@@ -967,7 +981,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
967
981
  val: '天',
968
982
  type: AtomsTypeEnum.INPUT_STRING
969
983
  }]);
970
- } else if (~['早于', '晚于', '在'].indexOf(_condition)) {
984
+ } else if (fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(_condition)) {
971
985
  setRhsVal([{
972
986
  val: moment().format('YYYY-MM-DD HH:mm'),
973
987
  type: AtomsTypeEnum.INPUT_STRING,
@@ -2943,7 +2943,7 @@ var FormulaList = forwardRef(function (props, ref) {
2943
2943
  }
2944
2944
  if (type === AtomsTypeEnum.EXPRESSION) {
2945
2945
  var quotes = getAtomDisplayText(v);
2946
- if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
2946
+ if (~['大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
2947
2947
  var _getAtomDisplayText$s;
2948
2948
  var nextList = caseList.slice();
2949
2949
  nextList[index].rhs = [nextList[index].rhs[0]];
@@ -251,6 +251,18 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
251
251
  case '不等于':
252
252
  _right_condition = "!= ".concat(_rightSql);
253
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;
254
266
  case '包含':
255
267
  _right_condition = "LIKE '%".concat(condition_1, "%'");
256
268
  break;
@@ -437,12 +449,20 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
437
449
  case '等于':
438
450
  _right_condition = "= ".concat(_condition_4);
439
451
  break;
452
+ case '大于':
453
+ _right_condition = "> ".concat(_condition_4);
454
+ break;
455
+ case '小于':
440
456
  case '早于':
441
457
  _right_condition = "< ".concat(_condition_4);
442
458
  break;
459
+ case '大于或等于':
443
460
  case '晚于':
444
461
  _right_condition = ">= ".concat(_condition_4);
445
462
  break;
463
+ case '小于或等于':
464
+ _right_condition = "<= ".concat(_condition_4);
465
+ break;
446
466
  case '介于之间':
447
467
  _right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
448
468
  _left_condition = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.157-alpha.9",
3
+ "version": "1.0.157",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",