@gingkoo/pandora-metabase 1.0.157 → 1.0.158-alpha.1

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.
@@ -32,13 +32,14 @@ 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
34
  var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
35
- var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
35
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '为空', '不为空'];
36
36
  var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
37
37
  var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
38
38
  var LEGACY_DATE_CONDITION_MAP = {
39
39
  早于: '小于',
40
40
  晚于: '大于或等于'
41
41
  };
42
+ var LEGACY_EMPTY_CONDITIONS = new Set(['是空的', '不是空的']);
42
43
  var typeList = [{
43
44
  key: _enum.SQL_COLUMN_TYPE.STRING,
44
45
  label: _enum.SQL_COLUMN_TYPE.STRING
@@ -361,8 +362,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
361
362
  if (isCustom) {
362
363
  conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
363
364
  }
364
- var isCompatibleDateEmptyCondition = type === _enum.SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
365
- if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
365
+ var isLegacyEmptyCondition = LEGACY_EMPTY_CONDITIONS.has(condition);
366
+ if (!conditions.includes(condition) && !nextCondition && !isLegacyEmptyCondition) {
366
367
  setDefaultVal(conditions[0], type);
367
368
  }
368
369
  return {
@@ -78,11 +78,9 @@ var sanitizeAliasPart = function sanitizeAliasPart() {
78
78
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
79
79
  return value.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
80
80
  };
81
- var buildAutoGroupByAlias = function buildAutoGroupByAlias(tableAlias, fieldName, itemIndex) {
81
+ var buildAutoGroupByAlias = function buildAutoGroupByAlias(fieldName, itemIndex) {
82
82
  var fallbackAlias = "group_by_".concat(itemIndex + 1);
83
- var aliasPrefix = sanitizeAliasPart(tableAlias);
84
- var aliasField = sanitizeAliasPart(fieldName);
85
- var autoAlias = (aliasPrefix && aliasField ? "".concat(aliasPrefix, "__").concat(aliasField) : aliasField || aliasPrefix) || fallbackAlias;
83
+ var autoAlias = sanitizeAliasPart(fieldName) || fallbackAlias;
86
84
  if (!/^[a-zA-Z]/.test(autoAlias)) {
87
85
  autoAlias = "a_".concat(autoAlias.replace(/^[^a-zA-Z]+/, ''));
88
86
  }
@@ -485,7 +483,6 @@ var GroupBy = function GroupBy(props) {
485
483
  return _getFirstField(atoms) || getField(record);
486
484
  };
487
485
  var normalizeByRecord = function normalizeByRecord(record, itemIndex, metaList) {
488
- var _store$preProps;
489
486
  var atoms = getAtomsValue(record);
490
487
  var firstField = _getFirstField(atoms);
491
488
  var nextRecord = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, record), {}, {
@@ -508,7 +505,14 @@ var GroupBy = function GroupBy(props) {
508
505
  nextRecord.datasourceName = firstField.datasourceName || nextRecord.datasourceName;
509
506
  nextRecord.database_type = firstField.database_type || nextRecord.database_type;
510
507
  }
511
- var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? buildAutoGroupByAlias((0, _helper.getAlias)(firstField.tableAlias || nextRecord.alias, metaList, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), firstField.fieldName, itemIndex) : "group_by_".concat(itemIndex + 1);
508
+ var usedAliases = meta.by.filter(function (_, idx) {
509
+ return idx !== itemIndex;
510
+ }).map(function (item) {
511
+ return item.fieldAlias;
512
+ }).filter(function (alias) {
513
+ return Boolean(alias);
514
+ });
515
+ var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? (0, _helper.getAlias)(buildAutoGroupByAlias(firstField.fieldName, itemIndex), [], [], usedAliases) : "group_by_".concat(itemIndex + 1);
512
516
  nextRecord.fieldAlias = nextRecord.fieldAlias || defaultFieldAlias;
513
517
  nextRecord.fieldUuid = nextRecord.fieldUuid || (0, _helper.uuidv4)('field');
514
518
  nextRecord.sql = (0, _helper2.summarizeByToSql)(nextRecord);
@@ -277,9 +277,11 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
277
277
  _right_condition = "NOT LIKE '%".concat(condition_1, "%'");
278
278
  break;
279
279
  case '为空':
280
+ case '是空的':
280
281
  _right_condition = "IS NULL";
281
282
  break;
282
283
  case '不为空':
284
+ case '不是空的':
283
285
  _right_condition = "IS NOT NULL";
284
286
  break;
285
287
  case '以...开始':
@@ -359,9 +361,11 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
359
361
  _right_condition = "<= ".concat(_condition_3);
360
362
  break;
361
363
  case '为空':
364
+ case '是空的':
362
365
  _right_condition = "IS NULL";
363
366
  break;
364
367
  case '不为空':
368
+ case '不是空的':
365
369
  _right_condition = "IS NOT NULL";
366
370
  break;
367
371
  case '以...开始':
package/lib/cjs/utils.js CHANGED
@@ -574,6 +574,7 @@ var getExpressionConditionText = function getExpressionConditionText(condition)
574
574
  早于: 'filter.earlierThan',
575
575
  晚于: 'filter.laterThan',
576
576
  是空的: 'filter.isEmpty',
577
+ 不是空的: 'filter.notEmpty',
577
578
  In: 'filter.within',
578
579
  'Not In': 'filter.withnotin',
579
580
  无需结果: 'filter.notresults',
@@ -24,13 +24,14 @@ 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
26
  var STRING_LIST = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '为空', '不为空', '以...开始', '以...结束', '不以...开始', '不以...结束', 'In', 'Not In', '正则匹配'];
27
- var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '是空的', '不为空'];
27
+ var DATE_LIST = ['等于', '大于', '小于', '大于或等于', '小于或等于', '介于之间', '为空', '不为空'];
28
28
  var DATE_VALUE_CONDITIONS = ['等于', '大于', '小于', '大于或等于', '小于或等于', '早于', '晚于', '在'];
29
29
  var SWITCH_VALUE_TYPE_CONDITIONS = ['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于'];
30
30
  var LEGACY_DATE_CONDITION_MAP = {
31
31
  早于: '小于',
32
32
  晚于: '大于或等于'
33
33
  };
34
+ var LEGACY_EMPTY_CONDITIONS = new Set(['是空的', '不是空的']);
34
35
  var typeList = [{
35
36
  key: SQL_COLUMN_TYPE.STRING,
36
37
  label: SQL_COLUMN_TYPE.STRING
@@ -353,8 +354,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
353
354
  if (isCustom) {
354
355
  conditions = ['无需结果'].concat(_toConsumableArray(conditions));
355
356
  }
356
- var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
357
- if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
357
+ var isLegacyEmptyCondition = LEGACY_EMPTY_CONDITIONS.has(condition);
358
+ if (!conditions.includes(condition) && !nextCondition && !isLegacyEmptyCondition) {
358
359
  setDefaultVal(conditions[0], type);
359
360
  }
360
361
  return {
@@ -72,11 +72,9 @@ var sanitizeAliasPart = function sanitizeAliasPart() {
72
72
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
73
73
  return value.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').replace(/^_+|_+$/g, '');
74
74
  };
75
- var buildAutoGroupByAlias = function buildAutoGroupByAlias(tableAlias, fieldName, itemIndex) {
75
+ var buildAutoGroupByAlias = function buildAutoGroupByAlias(fieldName, itemIndex) {
76
76
  var fallbackAlias = "group_by_".concat(itemIndex + 1);
77
- var aliasPrefix = sanitizeAliasPart(tableAlias);
78
- var aliasField = sanitizeAliasPart(fieldName);
79
- var autoAlias = (aliasPrefix && aliasField ? "".concat(aliasPrefix, "__").concat(aliasField) : aliasField || aliasPrefix) || fallbackAlias;
77
+ var autoAlias = sanitizeAliasPart(fieldName) || fallbackAlias;
80
78
  if (!/^[a-zA-Z]/.test(autoAlias)) {
81
79
  autoAlias = "a_".concat(autoAlias.replace(/^[^a-zA-Z]+/, ''));
82
80
  }
@@ -479,7 +477,6 @@ var GroupBy = function GroupBy(props) {
479
477
  return _getFirstField(atoms) || getField(record);
480
478
  };
481
479
  var normalizeByRecord = function normalizeByRecord(record, itemIndex, metaList) {
482
- var _store$preProps;
483
480
  var atoms = getAtomsValue(record);
484
481
  var firstField = _getFirstField(atoms);
485
482
  var nextRecord = _objectSpread(_objectSpread({}, record), {}, {
@@ -502,7 +499,14 @@ var GroupBy = function GroupBy(props) {
502
499
  nextRecord.datasourceName = firstField.datasourceName || nextRecord.datasourceName;
503
500
  nextRecord.database_type = firstField.database_type || nextRecord.database_type;
504
501
  }
505
- var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? buildAutoGroupByAlias(getAlias(firstField.tableAlias || nextRecord.alias, metaList, ((_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.notExistsColumns) || []), firstField.fieldName, itemIndex) : "group_by_".concat(itemIndex + 1);
502
+ var usedAliases = meta.by.filter(function (_, idx) {
503
+ return idx !== itemIndex;
504
+ }).map(function (item) {
505
+ return item.fieldAlias;
506
+ }).filter(function (alias) {
507
+ return Boolean(alias);
508
+ });
509
+ var defaultFieldAlias = firstField !== null && firstField !== void 0 && firstField.fieldName ? getAlias(buildAutoGroupByAlias(firstField.fieldName, itemIndex), [], [], usedAliases) : "group_by_".concat(itemIndex + 1);
506
510
  nextRecord.fieldAlias = nextRecord.fieldAlias || defaultFieldAlias;
507
511
  nextRecord.fieldUuid = nextRecord.fieldUuid || uuidv4('field');
508
512
  nextRecord.sql = summarizeByToSql(nextRecord);
@@ -270,9 +270,11 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
270
270
  _right_condition = "NOT LIKE '%".concat(condition_1, "%'");
271
271
  break;
272
272
  case '为空':
273
+ case '是空的':
273
274
  _right_condition = "IS NULL";
274
275
  break;
275
276
  case '不为空':
277
+ case '不是空的':
276
278
  _right_condition = "IS NOT NULL";
277
279
  break;
278
280
  case '以...开始':
@@ -352,9 +354,11 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
352
354
  _right_condition = "<= ".concat(_condition_3);
353
355
  break;
354
356
  case '为空':
357
+ case '是空的':
355
358
  _right_condition = "IS NULL";
356
359
  break;
357
360
  case '不为空':
361
+ case '不是空的':
358
362
  _right_condition = "IS NOT NULL";
359
363
  break;
360
364
  case '以...开始':
package/lib/es/utils.js CHANGED
@@ -560,6 +560,7 @@ var getExpressionConditionText = function getExpressionConditionText(condition)
560
560
  早于: 'filter.earlierThan',
561
561
  晚于: 'filter.laterThan',
562
562
  是空的: 'filter.isEmpty',
563
+ 不是空的: 'filter.notEmpty',
563
564
  In: 'filter.within',
564
565
  'Not In': 'filter.withnotin',
565
566
  无需结果: 'filter.notresults',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gingkoo/pandora-metabase",
3
- "version": "1.0.157",
3
+ "version": "1.0.158-alpha.1",
4
4
  "description": "",
5
5
  "main": "lib/es/index.js",
6
6
  "module": "lib/es/index.js",