@gingkoo/pandora-metabase 1.0.157-alpha.8 → 1.0.157-alpha.9
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.
- package/lib/cjs/components/dialog/expression/index.js +21 -18
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +1 -0
- package/lib/cjs/components/dialog/formula-list/utils.js +2 -2
- package/lib/cjs/utils/transformSql.js +2 -0
- package/lib/cjs/utils.js +2 -2
- package/lib/es/components/dialog/expression/index.js +22 -19
- package/lib/es/components/dialog/formula-list/utils.d.ts +1 -0
- package/lib/es/components/dialog/formula-list/utils.js +1 -1
- package/lib/es/utils/transformSql.js +2 -0
- package/lib/es/utils.js +2 -2
- package/package.json +1 -1
|
@@ -144,9 +144,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
144
144
|
if (~['无需结果'].indexOf(condition)) {
|
|
145
145
|
return false;
|
|
146
146
|
}
|
|
147
|
-
if (
|
|
147
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
148
148
|
return false;
|
|
149
149
|
}
|
|
150
|
+
if (!rhsVal.length) return true;
|
|
150
151
|
var isOk = rhsVal.every(function (v) {
|
|
151
152
|
if (v.type === _types.AtomsTypeEnum.INPUT_STRING || v.type === _types.AtomsTypeEnum.INPUT_NUMBER || v.type === _types.AtomsTypeEnum.CONSTANT) {
|
|
152
153
|
return v.val || v.val === 0;
|
|
@@ -206,6 +207,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
206
207
|
早于: 'filter.earlierThan',
|
|
207
208
|
晚于: 'filter.laterThan',
|
|
208
209
|
是空的: 'filter.isEmpty',
|
|
210
|
+
不是空的: 'filter.notEmpty',
|
|
209
211
|
In: 'filter.within',
|
|
210
212
|
'Not In': 'filter.withnotin',
|
|
211
213
|
无需结果: 'filter.notresults',
|
|
@@ -213,7 +215,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
213
215
|
}[v];
|
|
214
216
|
};
|
|
215
217
|
function generateQuotes(val, curColumn) {
|
|
216
|
-
|
|
218
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
219
|
+
var lhsName = getQuotesName(curColumn.lhs);
|
|
220
|
+
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
221
|
+
if (_locale.isEn) {
|
|
222
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? 'is empty' : 'not empty');
|
|
223
|
+
}
|
|
224
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? '为空' : '不为空');
|
|
225
|
+
}
|
|
226
|
+
var _val = val[0] || {
|
|
227
|
+
val: '',
|
|
228
|
+
type: _types.AtomsTypeEnum.INPUT_STRING
|
|
229
|
+
};
|
|
217
230
|
var firstVal = '',
|
|
218
231
|
secondVal = '';
|
|
219
232
|
if (_val.type === _types.AtomsTypeEnum.INPUT_STRING) {
|
|
@@ -275,18 +288,6 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
275
288
|
} else {
|
|
276
289
|
quotes = getQuotesName(curColumn.lhs) + ' 是 ' + firstVal;
|
|
277
290
|
}
|
|
278
|
-
} else if (condition === '是空的') {
|
|
279
|
-
if (_locale.isEn) {
|
|
280
|
-
quotes = getQuotesName(curColumn.lhs) + ' is empty';
|
|
281
|
-
} else {
|
|
282
|
-
quotes = getQuotesName(curColumn.lhs) + ' 为空';
|
|
283
|
-
}
|
|
284
|
-
} else if (condition === '不是空的') {
|
|
285
|
-
if (_locale.isEn) {
|
|
286
|
-
quotes = getQuotesName(curColumn.lhs) + ' not empty';
|
|
287
|
-
} else {
|
|
288
|
-
quotes = getQuotesName(curColumn.lhs) + ' 不为空';
|
|
289
|
-
}
|
|
290
291
|
} else if (condition === '当前') {
|
|
291
292
|
if (firstVal === '天') {
|
|
292
293
|
if (_locale.isEn) {
|
|
@@ -350,7 +351,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
350
351
|
if (isCustom) {
|
|
351
352
|
conditions = ['无需结果'].concat((0, _toConsumableArray2["default"])(conditions));
|
|
352
353
|
}
|
|
353
|
-
|
|
354
|
+
var isCompatibleDateEmptyCondition = type === _enum.SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
|
|
355
|
+
if (!conditions.includes(condition) && !isCompatibleDateEmptyCondition) {
|
|
354
356
|
setDefaultVal(conditions[0]);
|
|
355
357
|
}
|
|
356
358
|
return {
|
|
@@ -360,6 +362,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
360
362
|
};
|
|
361
363
|
}
|
|
362
364
|
function renderFilter(type, conditionText) {
|
|
365
|
+
if (_utils.EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
363
368
|
var _val = rhsVal[0];
|
|
364
369
|
var firstVal = '',
|
|
365
370
|
secondVal = '';
|
|
@@ -373,9 +378,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
373
378
|
firstVal = _val.val[0] || '';
|
|
374
379
|
secondVal = _val.val[1] || '';
|
|
375
380
|
}
|
|
376
|
-
if (
|
|
377
|
-
return null;
|
|
378
|
-
} else if (conditionText === '介于之间') {
|
|
381
|
+
if (conditionText === '介于之间') {
|
|
379
382
|
if (type === _enum.SQL_GROUP_TYPE.NUMBER) {
|
|
380
383
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
381
384
|
style: {
|
|
@@ -6,6 +6,7 @@ type ExpressionTable = {
|
|
|
6
6
|
tableUuid?: string;
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
|
+
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
9
10
|
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
10
11
|
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
11
12
|
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.operatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = void 0;
|
|
7
|
+
exports.operatorList = exports.normalizeExpressionAtoms = exports.normalizeExpressionAtom = exports.isOk = exports.insertTemplateAt = exports.getTemplateItem = exports.getExpressionDatabaseType = exports.getConstantLabel = exports.customTypes = exports.EMPTY_RHS_CONDITIONS = void 0;
|
|
8
8
|
exports.validateExpressionIntegrity = validateExpressionIntegrity;
|
|
9
9
|
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createForOfIteratorHelper"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
@@ -12,7 +12,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof
|
|
|
12
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
13
13
|
var _locale = require("../../../locale");
|
|
14
14
|
var _types = require("../../../store/types");
|
|
15
|
-
var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
15
|
+
var EMPTY_RHS_CONDITIONS = exports.EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
16
16
|
var isSameValue = function isSameValue(left, right) {
|
|
17
17
|
return left !== undefined && left !== null && left !== '' && right !== undefined && right !== null && right !== '' && String(left) === String(right);
|
|
18
18
|
};
|
|
@@ -454,9 +454,11 @@ var _handleBaseType2Sql9 = exports.handleBaseType2Sql = function handleBaseType2
|
|
|
454
454
|
_right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
|
|
455
455
|
_left_condition = '';
|
|
456
456
|
break;
|
|
457
|
+
case '为空':
|
|
457
458
|
case '是空的':
|
|
458
459
|
_right_condition = "IS NULL";
|
|
459
460
|
break;
|
|
461
|
+
case '不为空':
|
|
460
462
|
case '不是空的':
|
|
461
463
|
_right_condition = "IS NOT NULL";
|
|
462
464
|
break;
|
package/lib/cjs/utils.js
CHANGED
|
@@ -951,10 +951,10 @@ var buildExpressionQuotes = function buildExpressionQuotes(item) {
|
|
|
951
951
|
if (condition === '在') {
|
|
952
952
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'is' : '是', " ").concat(firstVal));
|
|
953
953
|
}
|
|
954
|
-
if (condition === '是空的') {
|
|
954
|
+
if (condition === '为空' || condition === '是空的') {
|
|
955
955
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'is empty' : '为空'));
|
|
956
956
|
}
|
|
957
|
-
if (condition === '不是空的') {
|
|
957
|
+
if (condition === '不为空' || condition === '不是空的') {
|
|
958
958
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(_locale.isEn ? 'not empty' : '不为空'));
|
|
959
959
|
}
|
|
960
960
|
if (condition === '当前') {
|
|
@@ -19,7 +19,7 @@ import SelectColumnMultiple from '../select-column-multiple';
|
|
|
19
19
|
import { LeftArrowIcon } from '../../icons';
|
|
20
20
|
import { useStore } from '../../../hooks/use-provider';
|
|
21
21
|
import cloneDeep from 'lodash/cloneDeep';
|
|
22
|
-
import { getConstantLabel, normalizeExpressionAtom } from '../formula-list/utils';
|
|
22
|
+
import { EMPTY_RHS_CONDITIONS, getConstantLabel, normalizeExpressionAtom } from '../formula-list/utils';
|
|
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', '正则匹配'];
|
|
@@ -136,9 +136,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
136
136
|
if (~['无需结果'].indexOf(condition)) {
|
|
137
137
|
return false;
|
|
138
138
|
}
|
|
139
|
-
if (
|
|
139
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
140
140
|
return false;
|
|
141
141
|
}
|
|
142
|
+
if (!rhsVal.length) return true;
|
|
142
143
|
var isOk = rhsVal.every(function (v) {
|
|
143
144
|
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.INPUT_NUMBER || v.type === AtomsTypeEnum.CONSTANT) {
|
|
144
145
|
return v.val || v.val === 0;
|
|
@@ -198,6 +199,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
198
199
|
早于: 'filter.earlierThan',
|
|
199
200
|
晚于: 'filter.laterThan',
|
|
200
201
|
是空的: 'filter.isEmpty',
|
|
202
|
+
不是空的: 'filter.notEmpty',
|
|
201
203
|
In: 'filter.within',
|
|
202
204
|
'Not In': 'filter.withnotin',
|
|
203
205
|
无需结果: 'filter.notresults',
|
|
@@ -205,7 +207,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
205
207
|
}[v];
|
|
206
208
|
};
|
|
207
209
|
function generateQuotes(val, curColumn) {
|
|
208
|
-
|
|
210
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
211
|
+
var lhsName = getQuotesName(curColumn.lhs);
|
|
212
|
+
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
213
|
+
if (isEn) {
|
|
214
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? 'is empty' : 'not empty');
|
|
215
|
+
}
|
|
216
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? '为空' : '不为空');
|
|
217
|
+
}
|
|
218
|
+
var _val = val[0] || {
|
|
219
|
+
val: '',
|
|
220
|
+
type: AtomsTypeEnum.INPUT_STRING
|
|
221
|
+
};
|
|
209
222
|
var firstVal = '',
|
|
210
223
|
secondVal = '';
|
|
211
224
|
if (_val.type === AtomsTypeEnum.INPUT_STRING) {
|
|
@@ -267,18 +280,6 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
267
280
|
} else {
|
|
268
281
|
quotes = getQuotesName(curColumn.lhs) + ' 是 ' + firstVal;
|
|
269
282
|
}
|
|
270
|
-
} else if (condition === '是空的') {
|
|
271
|
-
if (isEn) {
|
|
272
|
-
quotes = getQuotesName(curColumn.lhs) + ' is empty';
|
|
273
|
-
} else {
|
|
274
|
-
quotes = getQuotesName(curColumn.lhs) + ' 为空';
|
|
275
|
-
}
|
|
276
|
-
} else if (condition === '不是空的') {
|
|
277
|
-
if (isEn) {
|
|
278
|
-
quotes = getQuotesName(curColumn.lhs) + ' not empty';
|
|
279
|
-
} else {
|
|
280
|
-
quotes = getQuotesName(curColumn.lhs) + ' 不为空';
|
|
281
|
-
}
|
|
282
283
|
} else if (condition === '当前') {
|
|
283
284
|
if (firstVal === '天') {
|
|
284
285
|
if (isEn) {
|
|
@@ -342,7 +343,8 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
342
343
|
if (isCustom) {
|
|
343
344
|
conditions = ['无需结果'].concat(_toConsumableArray(conditions));
|
|
344
345
|
}
|
|
345
|
-
|
|
346
|
+
var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
|
|
347
|
+
if (!conditions.includes(condition) && !isCompatibleDateEmptyCondition) {
|
|
346
348
|
setDefaultVal(conditions[0]);
|
|
347
349
|
}
|
|
348
350
|
return {
|
|
@@ -352,6 +354,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
352
354
|
};
|
|
353
355
|
}
|
|
354
356
|
function renderFilter(type, conditionText) {
|
|
357
|
+
if (EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
355
360
|
var _val = rhsVal[0];
|
|
356
361
|
var firstVal = '',
|
|
357
362
|
secondVal = '';
|
|
@@ -365,9 +370,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
365
370
|
firstVal = _val.val[0] || '';
|
|
366
371
|
secondVal = _val.val[1] || '';
|
|
367
372
|
}
|
|
368
|
-
if (
|
|
369
|
-
return null;
|
|
370
|
-
} else if (conditionText === '介于之间') {
|
|
373
|
+
if (conditionText === '介于之间') {
|
|
371
374
|
if (type === SQL_GROUP_TYPE.NUMBER) {
|
|
372
375
|
return _jsxs("div", {
|
|
373
376
|
style: {
|
|
@@ -6,6 +6,7 @@ type ExpressionTable = {
|
|
|
6
6
|
tableUuid?: string;
|
|
7
7
|
columns?: any[];
|
|
8
8
|
};
|
|
9
|
+
export declare const EMPTY_RHS_CONDITIONS: Set<string>;
|
|
9
10
|
export declare const getExpressionDatabaseType: (expression: AtomsExpression, tables?: ExpressionTable[]) => string;
|
|
10
11
|
export declare const normalizeExpressionAtom: (expression: AtomsExpression, tables?: ExpressionTable[]) => AtomsExpression;
|
|
11
12
|
export declare const normalizeExpressionAtoms: (atoms?: AtomsItem[], tables?: ExpressionTable[]) => AtomsItem[];
|
|
@@ -4,7 +4,7 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
5
|
import { __ } from '../../../locale';
|
|
6
6
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
7
|
-
var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
7
|
+
export var EMPTY_RHS_CONDITIONS = new Set(['为空', '不为空', '是空的', '不是空的']);
|
|
8
8
|
var isSameValue = function isSameValue(left, right) {
|
|
9
9
|
return left !== undefined && left !== null && left !== '' && right !== undefined && right !== null && right !== '' && String(left) === String(right);
|
|
10
10
|
};
|
|
@@ -447,9 +447,11 @@ var _handleBaseType2Sql9 = function handleBaseType2Sql(list) {
|
|
|
447
447
|
_right_condition = "(".concat(_left_condition, " >= ").concat(_condition_4, " AND ").concat(_left_condition, " < ").concat(_condition_5, ")");
|
|
448
448
|
_left_condition = '';
|
|
449
449
|
break;
|
|
450
|
+
case '为空':
|
|
450
451
|
case '是空的':
|
|
451
452
|
_right_condition = "IS NULL";
|
|
452
453
|
break;
|
|
454
|
+
case '不为空':
|
|
453
455
|
case '不是空的':
|
|
454
456
|
_right_condition = "IS NOT NULL";
|
|
455
457
|
break;
|
package/lib/es/utils.js
CHANGED
|
@@ -938,10 +938,10 @@ var buildExpressionQuotes = function buildExpressionQuotes(item) {
|
|
|
938
938
|
if (condition === '在') {
|
|
939
939
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is' : '是', " ").concat(firstVal));
|
|
940
940
|
}
|
|
941
|
-
if (condition === '是空的') {
|
|
941
|
+
if (condition === '为空' || condition === '是空的') {
|
|
942
942
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'is empty' : '为空'));
|
|
943
943
|
}
|
|
944
|
-
if (condition === '不是空的') {
|
|
944
|
+
if (condition === '不为空' || condition === '不是空的') {
|
|
945
945
|
return normalizeAtomQuotes("".concat(lhsText, " ").concat(isEn ? 'not empty' : '不为空'));
|
|
946
946
|
}
|
|
947
947
|
if (condition === '当前') {
|