@gingkoo/pandora-metabase 1.0.156 → 1.0.157-alpha.10
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/custom-editor/index.js +61 -5
- package/lib/cjs/components/dialog/expression/index.js +132 -54
- package/lib/cjs/components/dialog/expression/index.less +43 -0
- package/lib/cjs/components/dialog/formula/index.js +3 -1
- package/lib/cjs/components/dialog/formula/utils.d.ts +1 -0
- package/lib/cjs/components/dialog/formula/utils.js +20 -2
- package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/cjs/components/dialog/formula-list/index.js +1119 -151
- package/lib/cjs/components/dialog/formula-list/index.less +362 -46
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +100 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/cjs/components/dialog/select-join/index.js +11 -0
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/cjs/components/dialog/select-summarize/index.js +136 -15
- package/lib/cjs/components/dialog/select-summarize/index.less +34 -1
- package/lib/cjs/components/dialog/select-table/index.d.ts +4 -1
- package/lib/cjs/components/dialog/select-table/index.js +51 -7
- package/lib/cjs/components/dialog/select-table/index.less +20 -0
- package/lib/cjs/components/icons.d.ts +1 -0
- package/lib/cjs/components/icons.js +54 -29
- package/lib/cjs/components/metabase/index.js +8 -0
- package/lib/cjs/components/metabase/index.less +17 -14
- package/lib/cjs/components/modules/components/item-name.js +16 -2
- package/lib/cjs/components/modules/components/meta-icon.js +6 -4
- package/lib/cjs/components/modules/join-data.js +5 -0
- package/lib/cjs/components/modules/summarize/group-by.js +12 -1
- package/lib/cjs/components/modules/summarize/select-index.js +12 -1
- package/lib/cjs/hooks/use-state.js +1 -13
- package/lib/cjs/index.d.ts +3 -2
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/locale/en.js +31 -0
- package/lib/cjs/locale/index.js +10 -6
- package/lib/cjs/locale/zh.js +31 -0
- package/lib/cjs/store/enum.d.ts +2 -1
- package/lib/cjs/store/enum.js +1 -0
- package/lib/cjs/store/helper.js +25 -2
- package/lib/cjs/store/types.d.ts +7 -1
- package/lib/cjs/types.d.ts +41 -1
- package/lib/cjs/utils/helper.js +20 -0
- package/lib/cjs/utils/transformSql.js +59 -2
- package/lib/cjs/utils.js +25 -4
- package/lib/es/components/dialog/custom-editor/index.js +62 -6
- package/lib/es/components/dialog/expression/index.js +133 -55
- package/lib/es/components/dialog/expression/index.less +43 -0
- package/lib/es/components/dialog/formula/index.js +4 -2
- package/lib/es/components/dialog/formula/utils.d.ts +1 -0
- package/lib/es/components/dialog/formula/utils.js +18 -1
- package/lib/es/components/dialog/formula-list/index.d.ts +2 -0
- package/lib/es/components/dialog/formula-list/index.js +1121 -153
- package/lib/es/components/dialog/formula-list/index.less +362 -46
- package/lib/es/components/dialog/formula-list/utils.d.ts +13 -1
- package/lib/es/components/dialog/formula-list/utils.js +99 -0
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/es/components/dialog/select-column-multiple/index.js +4 -2
- package/lib/es/components/dialog/select-join/index.js +12 -1
- package/lib/es/components/dialog/select-summarize/index.d.ts +4 -0
- package/lib/es/components/dialog/select-summarize/index.js +140 -19
- package/lib/es/components/dialog/select-summarize/index.less +34 -1
- package/lib/es/components/dialog/select-table/index.d.ts +4 -1
- package/lib/es/components/dialog/select-table/index.js +51 -7
- package/lib/es/components/dialog/select-table/index.less +20 -0
- package/lib/es/components/icons.d.ts +1 -0
- package/lib/es/components/icons.js +53 -28
- package/lib/es/components/metabase/index.js +8 -0
- package/lib/es/components/metabase/index.less +17 -14
- package/lib/es/components/modules/components/item-name.js +16 -2
- package/lib/es/components/modules/components/meta-icon.js +6 -4
- package/lib/es/components/modules/join-data.js +6 -1
- package/lib/es/components/modules/summarize/group-by.js +12 -1
- package/lib/es/components/modules/summarize/select-index.js +12 -1
- package/lib/es/hooks/use-state.js +1 -13
- package/lib/es/index.d.ts +3 -2
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +31 -0
- package/lib/es/locale/index.js +10 -6
- package/lib/es/locale/zh.js +31 -0
- package/lib/es/store/enum.d.ts +2 -1
- package/lib/es/store/enum.js +1 -0
- package/lib/es/store/helper.js +25 -2
- package/lib/es/store/types.d.ts +7 -1
- package/lib/es/types.d.ts +41 -1
- package/lib/es/utils/helper.js +20 -0
- package/lib/es/utils/transformSql.js +59 -2
- package/lib/es/utils.js +25 -4
- package/package.json +1 -1
|
@@ -19,12 +19,17 @@ 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 } 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', '正则匹配'];
|
|
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 LEGACY_DATE_CONDITION_MAP = {
|
|
30
|
+
早于: '小于',
|
|
31
|
+
晚于: '大于或等于'
|
|
32
|
+
};
|
|
28
33
|
var typeList = [{
|
|
29
34
|
key: SQL_COLUMN_TYPE.STRING,
|
|
30
35
|
label: SQL_COLUMN_TYPE.STRING
|
|
@@ -35,6 +40,18 @@ var typeList = [{
|
|
|
35
40
|
key: SQL_COLUMN_TYPE.DATE,
|
|
36
41
|
label: SQL_COLUMN_TYPE.DATE
|
|
37
42
|
}];
|
|
43
|
+
var getExpressionEditorType = function getExpressionEditorType(value) {
|
|
44
|
+
var _value$rhs;
|
|
45
|
+
var inputAtom = (_value$rhs = value.rhs) === null || _value$rhs === void 0 ? void 0 : _value$rhs[0];
|
|
46
|
+
if ((inputAtom === null || inputAtom === void 0 ? void 0 : inputAtom.type) === AtomsTypeEnum.INPUT_NUMBER) return SQL_COLUMN_TYPE.FLOAT;
|
|
47
|
+
if ((inputAtom === null || inputAtom === void 0 ? void 0 : inputAtom.type) === AtomsTypeEnum.INPUT_STRING) {
|
|
48
|
+
return inputAtom.format ? SQL_COLUMN_TYPE.DATE : SQL_COLUMN_TYPE.STRING;
|
|
49
|
+
}
|
|
50
|
+
if ((inputAtom === null || inputAtom === void 0 ? void 0 : inputAtom.type) === AtomsTypeEnum.INPUT_STRING_LIST && inputAtom.format) {
|
|
51
|
+
return SQL_COLUMN_TYPE.DATE;
|
|
52
|
+
}
|
|
53
|
+
return value.database_type || SQL_COLUMN_TYPE.STRING;
|
|
54
|
+
};
|
|
38
55
|
var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
39
56
|
var _value$lhs;
|
|
40
57
|
var _ref$data = _ref.data,
|
|
@@ -49,19 +66,20 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
49
66
|
_ref$filterCustomType = _ref.filterCustomType,
|
|
50
67
|
filterCustomType = _ref$filterCustomType === void 0 ? false : _ref$filterCustomType,
|
|
51
68
|
parentPopupChannel = _ref.parentPopupChannel;
|
|
52
|
-
var
|
|
69
|
+
var normalizedInitialValue = normalizeExpressionAtom(value, data);
|
|
70
|
+
var _useState = useState(normalizedInitialValue),
|
|
53
71
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
72
|
curColumn = _useState2[0],
|
|
55
73
|
setCurColumn = _useState2[1];
|
|
56
|
-
var _useState3 = useState(
|
|
74
|
+
var _useState3 = useState(normalizedInitialValue.condition || ''),
|
|
57
75
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
76
|
condition = _useState4[0],
|
|
59
77
|
setCondition = _useState4[1];
|
|
60
|
-
var _useState5 = useState(cloneDeep(
|
|
78
|
+
var _useState5 = useState(cloneDeep(normalizedInitialValue.rhs || [])),
|
|
61
79
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
62
80
|
rhsVal = _useState6[0],
|
|
63
81
|
setRhsVal = _useState6[1];
|
|
64
|
-
var _useState7 = useState(
|
|
82
|
+
var _useState7 = useState(filterCustomType ? getExpressionEditorType(normalizedInitialValue) : normalizedInitialValue.database_type || SQL_COLUMN_TYPE.STRING),
|
|
65
83
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
66
84
|
special_type = _useState8[0],
|
|
67
85
|
setSpecial_type = _useState8[1];
|
|
@@ -123,12 +141,13 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
123
141
|
if (~['无需结果'].indexOf(condition)) {
|
|
124
142
|
return false;
|
|
125
143
|
}
|
|
126
|
-
if (
|
|
144
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
127
145
|
return false;
|
|
128
146
|
}
|
|
147
|
+
if (!rhsVal.length) return true;
|
|
129
148
|
var isOk = rhsVal.every(function (v) {
|
|
130
|
-
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.CONSTANT) {
|
|
131
|
-
return v.val;
|
|
149
|
+
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.INPUT_NUMBER || v.type === AtomsTypeEnum.CONSTANT) {
|
|
150
|
+
return v.val || v.val === 0;
|
|
132
151
|
}
|
|
133
152
|
if (v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
134
153
|
return v.val.every(function (vv) {
|
|
@@ -185,6 +204,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
185
204
|
早于: 'filter.earlierThan',
|
|
186
205
|
晚于: 'filter.laterThan',
|
|
187
206
|
是空的: 'filter.isEmpty',
|
|
207
|
+
不是空的: 'filter.notEmpty',
|
|
188
208
|
In: 'filter.within',
|
|
189
209
|
'Not In': 'filter.withnotin',
|
|
190
210
|
无需结果: 'filter.notresults',
|
|
@@ -192,12 +212,26 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
192
212
|
}[v];
|
|
193
213
|
};
|
|
194
214
|
function generateQuotes(val, curColumn) {
|
|
195
|
-
|
|
215
|
+
if (EMPTY_RHS_CONDITIONS.has(condition)) {
|
|
216
|
+
var lhsName = getQuotesName(curColumn.lhs);
|
|
217
|
+
var isEmptyCondition = condition === '为空' || condition === '是空的';
|
|
218
|
+
if (isEn) {
|
|
219
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? 'is empty' : 'not empty');
|
|
220
|
+
}
|
|
221
|
+
return "".concat(lhsName, " ").concat(isEmptyCondition ? '为空' : '不为空');
|
|
222
|
+
}
|
|
223
|
+
var _val = val[0] || {
|
|
224
|
+
val: '',
|
|
225
|
+
type: AtomsTypeEnum.INPUT_STRING
|
|
226
|
+
};
|
|
196
227
|
var firstVal = '',
|
|
197
228
|
secondVal = '';
|
|
198
229
|
if (_val.type === AtomsTypeEnum.INPUT_STRING) {
|
|
199
230
|
firstVal = _val.val;
|
|
200
231
|
}
|
|
232
|
+
if (_val.type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
233
|
+
firstVal = _val.val || _val.val === 0 ? String(_val.val) : '';
|
|
234
|
+
}
|
|
201
235
|
if (_val.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
202
236
|
firstVal = _val.val[0] || '';
|
|
203
237
|
secondVal = _val.val[1] || '';
|
|
@@ -251,18 +285,6 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
251
285
|
} else {
|
|
252
286
|
quotes = getQuotesName(curColumn.lhs) + ' 是 ' + firstVal;
|
|
253
287
|
}
|
|
254
|
-
} else if (condition === '是空的') {
|
|
255
|
-
if (isEn) {
|
|
256
|
-
quotes = getQuotesName(curColumn.lhs) + ' is empty';
|
|
257
|
-
} else {
|
|
258
|
-
quotes = getQuotesName(curColumn.lhs) + ' 为空';
|
|
259
|
-
}
|
|
260
|
-
} else if (condition === '不是空的') {
|
|
261
|
-
if (isEn) {
|
|
262
|
-
quotes = getQuotesName(curColumn.lhs) + ' not empty';
|
|
263
|
-
} else {
|
|
264
|
-
quotes = getQuotesName(curColumn.lhs) + ' 不为空';
|
|
265
|
-
}
|
|
266
288
|
} else if (condition === '当前') {
|
|
267
289
|
if (firstVal === '天') {
|
|
268
290
|
if (isEn) {
|
|
@@ -295,13 +317,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
295
317
|
}
|
|
296
318
|
function addFilter() {
|
|
297
319
|
if (disabled) return void 0;
|
|
298
|
-
var
|
|
299
|
-
|
|
320
|
+
var databaseType = filterCustomType ? special_type : normalizeExpressionAtom(curColumn, data).database_type;
|
|
321
|
+
var nextExpression = normalizeExpressionAtom(_objectSpread(_objectSpread({}, curColumn), {}, {
|
|
300
322
|
formula: formula,
|
|
301
323
|
rhs: rhsVal,
|
|
302
324
|
condition: condition,
|
|
303
|
-
|
|
304
|
-
|
|
325
|
+
database_type: databaseType
|
|
326
|
+
}), filterCustomType ? [] : data);
|
|
327
|
+
var quotes = generateQuotes(nextExpression.rhs, nextExpression);
|
|
328
|
+
typeof onChange === 'function' && onChange(_objectSpread(_objectSpread({}, nextExpression), {}, {
|
|
329
|
+
quotes: quotes
|
|
305
330
|
}));
|
|
306
331
|
}
|
|
307
332
|
function goPrevPage() {
|
|
@@ -320,11 +345,16 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
320
345
|
conditions = DATE_LIST;
|
|
321
346
|
type = SQL_GROUP_TYPE.DATE;
|
|
322
347
|
}
|
|
348
|
+
var nextCondition = LEGACY_DATE_CONDITION_MAP[condition];
|
|
349
|
+
if (type === SQL_GROUP_TYPE.DATE && nextCondition) {
|
|
350
|
+
setCondition(nextCondition);
|
|
351
|
+
}
|
|
323
352
|
if (isCustom) {
|
|
324
353
|
conditions = ['无需结果'].concat(_toConsumableArray(conditions));
|
|
325
354
|
}
|
|
326
|
-
|
|
327
|
-
|
|
355
|
+
var isCompatibleDateEmptyCondition = type === SQL_GROUP_TYPE.DATE && (condition === '为空' || condition === '不是空的');
|
|
356
|
+
if (!conditions.includes(condition) && !nextCondition && !isCompatibleDateEmptyCondition) {
|
|
357
|
+
setDefaultVal(conditions[0], type);
|
|
328
358
|
}
|
|
329
359
|
return {
|
|
330
360
|
columnType: columnType,
|
|
@@ -333,19 +363,23 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
333
363
|
};
|
|
334
364
|
}
|
|
335
365
|
function renderFilter(type, conditionText) {
|
|
366
|
+
if (EMPTY_RHS_CONDITIONS.has(conditionText)) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
336
369
|
var _val = rhsVal[0];
|
|
337
370
|
var firstVal = '',
|
|
338
371
|
secondVal = '';
|
|
339
372
|
if (_val.type === AtomsTypeEnum.INPUT_STRING) {
|
|
340
373
|
firstVal = _val.val;
|
|
341
374
|
}
|
|
375
|
+
if (_val.type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
376
|
+
firstVal = _val.val || _val.val === 0 ? String(_val.val) : '';
|
|
377
|
+
}
|
|
342
378
|
if (_val.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
343
379
|
firstVal = _val.val[0] || '';
|
|
344
380
|
secondVal = _val.val[1] || '';
|
|
345
381
|
}
|
|
346
|
-
if (
|
|
347
|
-
return null;
|
|
348
|
-
} else if (conditionText === '介于之间') {
|
|
382
|
+
if (conditionText === '介于之间') {
|
|
349
383
|
if (type === SQL_GROUP_TYPE.NUMBER) {
|
|
350
384
|
return _jsxs("div", {
|
|
351
385
|
style: {
|
|
@@ -474,7 +508,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
474
508
|
})
|
|
475
509
|
})]
|
|
476
510
|
});
|
|
477
|
-
} else if (
|
|
511
|
+
} else if (type === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.filter(function (v) {
|
|
512
|
+
return v !== '等于';
|
|
513
|
+
}).indexOf(conditionText)) {
|
|
478
514
|
var _rhsVal$3, _rhsVal$4;
|
|
479
515
|
var _dateVal = ((_rhsVal$3 = rhsVal[0]) === null || _rhsVal$3 === void 0 ? void 0 : _rhsVal$3.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].val : undefined;
|
|
480
516
|
var _dateFormat = ((_rhsVal$4 = rhsVal[0]) === null || _rhsVal$4 === void 0 ? void 0 : _rhsVal$4.type) === AtomsTypeEnum.INPUT_STRING ? rhsVal[0].format : undefined;
|
|
@@ -555,14 +591,36 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
555
591
|
})
|
|
556
592
|
});
|
|
557
593
|
} else if (~['等于', '不等于', '大于', '小于', '大于或等于', '小于或等于', '包含', '不包含', '以...开始', '以...结束', '不以...开始', '不以...结束', '正则匹配'].indexOf(conditionText)) {
|
|
594
|
+
if (_val.type === AtomsTypeEnum.INPUT_NUMBER) {
|
|
595
|
+
return _jsx("div", {
|
|
596
|
+
className: 'filter-value-control',
|
|
597
|
+
children: _jsx(InputNumber, {
|
|
598
|
+
className: 'filter-number-input',
|
|
599
|
+
placeholder: __('filter.enterANumber'),
|
|
600
|
+
value: firstVal,
|
|
601
|
+
onChange: function onChange(val) {
|
|
602
|
+
var newVal = rhsVal.slice();
|
|
603
|
+
newVal[0] = _objectSpread(_objectSpread({}, newVal[0]), {}, {
|
|
604
|
+
type: AtomsTypeEnum.INPUT_NUMBER,
|
|
605
|
+
val: val === null || val === undefined || val === '' ? Number.NaN : Number(val)
|
|
606
|
+
});
|
|
607
|
+
setRhsVal(newVal);
|
|
608
|
+
}
|
|
609
|
+
})
|
|
610
|
+
});
|
|
611
|
+
}
|
|
558
612
|
return _jsx("div", {
|
|
613
|
+
className: 'filter-value-control',
|
|
559
614
|
children: _jsx(Input, {
|
|
560
615
|
className: 'input',
|
|
561
616
|
placeholder: __('filter.pleaseEnter'),
|
|
562
617
|
value: firstVal || '',
|
|
563
618
|
onInput: function onInput(e) {
|
|
564
619
|
var newVal = rhsVal.slice();
|
|
565
|
-
newVal[0]
|
|
620
|
+
newVal[0] = _objectSpread(_objectSpread({}, newVal[0]), {}, {
|
|
621
|
+
type: AtomsTypeEnum.INPUT_STRING,
|
|
622
|
+
val: e.target.value
|
|
623
|
+
});
|
|
566
624
|
setRhsVal(newVal);
|
|
567
625
|
}
|
|
568
626
|
})
|
|
@@ -598,7 +656,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
598
656
|
});
|
|
599
657
|
};
|
|
600
658
|
var onRepeat = function onRepeat(e) {
|
|
659
|
+
var _rhsVal$7;
|
|
601
660
|
setParentClosable(false);
|
|
661
|
+
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;
|
|
602
662
|
store.setPopup2({
|
|
603
663
|
visible: true,
|
|
604
664
|
node: e.currentTarget,
|
|
@@ -606,7 +666,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
606
666
|
content: _jsx(SelectList, {
|
|
607
667
|
value: '',
|
|
608
668
|
list: [{
|
|
609
|
-
value:
|
|
669
|
+
value: inputAtomType,
|
|
610
670
|
label: __('customColumn.input')
|
|
611
671
|
}, {
|
|
612
672
|
value: AtomsTypeEnum.CONSTANT,
|
|
@@ -617,11 +677,15 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
617
677
|
}],
|
|
618
678
|
onChange: function onChange(type) {
|
|
619
679
|
closePopup2();
|
|
620
|
-
if (type === AtomsTypeEnum.INPUT_STRING || type === AtomsTypeEnum.CONSTANT) {
|
|
621
|
-
|
|
680
|
+
if (type === AtomsTypeEnum.INPUT_STRING || type === AtomsTypeEnum.INPUT_NUMBER || type === AtomsTypeEnum.CONSTANT) {
|
|
681
|
+
var nextInput = type === AtomsTypeEnum.INPUT_NUMBER ? {
|
|
682
|
+
val: Number.NaN,
|
|
683
|
+
type: AtomsTypeEnum.INPUT_NUMBER
|
|
684
|
+
} : {
|
|
622
685
|
val: '',
|
|
623
686
|
type: type
|
|
624
|
-
}
|
|
687
|
+
};
|
|
688
|
+
setRhsVal([nextInput]);
|
|
625
689
|
}
|
|
626
690
|
if (type === AtomsTypeEnum.FIELD) {
|
|
627
691
|
setRhsVal([{
|
|
@@ -790,16 +854,25 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
790
854
|
onVisibleChange: setDropdownClosable,
|
|
791
855
|
getPopupContainer: getCurrentPopupContainer,
|
|
792
856
|
onChange: function onChange(key) {
|
|
857
|
+
var _rhsVal$8;
|
|
793
858
|
setCondition('');
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
859
|
+
setSpecial_type(key);
|
|
860
|
+
var currentValue = (_rhsVal$8 = rhsVal[0]) === null || _rhsVal$8 === void 0 ? void 0 : _rhsVal$8.val;
|
|
861
|
+
if (key === SQL_COLUMN_TYPE.FLOAT) {
|
|
862
|
+
var numberValue = Number(currentValue);
|
|
863
|
+
setRhsVal([{
|
|
864
|
+
type: AtomsTypeEnum.INPUT_NUMBER,
|
|
865
|
+
val: currentValue !== '' && Number.isFinite(numberValue) ? numberValue : Number.NaN
|
|
866
|
+
}]);
|
|
867
|
+
} else {
|
|
868
|
+
var _rhsVal$9;
|
|
869
|
+
setRhsVal([_objectSpread({
|
|
870
|
+
type: AtomsTypeEnum.INPUT_STRING,
|
|
871
|
+
val: currentValue === undefined || currentValue === null ? '' : String(currentValue)
|
|
872
|
+
}, key === SQL_COLUMN_TYPE.DATE ? {
|
|
873
|
+
format: ((_rhsVal$9 = rhsVal[0]) === null || _rhsVal$9 === void 0 ? void 0 : _rhsVal$9.format) || 'YYYY-MM-DD HH:mm'
|
|
874
|
+
} : {})]);
|
|
875
|
+
}
|
|
803
876
|
},
|
|
804
877
|
droplist: typeList,
|
|
805
878
|
children: _jsxs(Button, {
|
|
@@ -816,7 +889,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
816
889
|
getPopupContainer: getCurrentPopupContainer,
|
|
817
890
|
onChange: function onChange(key) {
|
|
818
891
|
setCurColumn(_objectSpread({}, curColumn));
|
|
819
|
-
setDefaultVal(key);
|
|
892
|
+
setDefaultVal(key, fieldType);
|
|
820
893
|
},
|
|
821
894
|
droplist: menu,
|
|
822
895
|
children: _jsxs(Button, {
|
|
@@ -856,12 +929,12 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
856
929
|
}, i)
|
|
857
930
|
}, i);
|
|
858
931
|
}
|
|
859
|
-
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
932
|
+
if (v.type === AtomsTypeEnum.INPUT_STRING || v.type === AtomsTypeEnum.INPUT_NUMBER || v.type === AtomsTypeEnum.INPUT_STRING_LIST) {
|
|
860
933
|
return _jsx(React.Fragment, {
|
|
861
934
|
children: renderFilter(fieldType, condition)
|
|
862
935
|
}, i);
|
|
863
936
|
}
|
|
864
|
-
}), ~['等于', '不等于'
|
|
937
|
+
}), ~['等于', '不等于'].indexOf(condition) || fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(condition) ? _jsx(Tooltip, {
|
|
865
938
|
title: __('SqlQueryBuilder.switch'),
|
|
866
939
|
children: _jsx(Button, {
|
|
867
940
|
primary: true,
|
|
@@ -885,8 +958,10 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
885
958
|
})]
|
|
886
959
|
});
|
|
887
960
|
}
|
|
888
|
-
function setDefaultVal(_condition) {
|
|
961
|
+
function setDefaultVal(_condition, fieldType) {
|
|
962
|
+
var _rhsVal$0;
|
|
889
963
|
setCondition(_condition);
|
|
964
|
+
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;
|
|
890
965
|
if (~['前', '下一个'].indexOf(_condition)) {
|
|
891
966
|
setRhsVal([{
|
|
892
967
|
val: ['30', '天'],
|
|
@@ -903,14 +978,17 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
903
978
|
val: '天',
|
|
904
979
|
type: AtomsTypeEnum.INPUT_STRING
|
|
905
980
|
}]);
|
|
906
|
-
} else if (
|
|
981
|
+
} else if (fieldType === SQL_GROUP_TYPE.DATE && ~DATE_VALUE_CONDITIONS.indexOf(_condition)) {
|
|
907
982
|
setRhsVal([{
|
|
908
983
|
val: moment().format('YYYY-MM-DD HH:mm'),
|
|
909
984
|
type: AtomsTypeEnum.INPUT_STRING,
|
|
910
985
|
format: 'YYYY-MM-DD HH:mm'
|
|
911
986
|
}]);
|
|
912
987
|
} else {
|
|
913
|
-
setRhsVal([{
|
|
988
|
+
setRhsVal(inputAtomType === AtomsTypeEnum.INPUT_NUMBER ? [{
|
|
989
|
+
val: Number.NaN,
|
|
990
|
+
type: AtomsTypeEnum.INPUT_NUMBER
|
|
991
|
+
}] : [{
|
|
914
992
|
val: '',
|
|
915
993
|
type: AtomsTypeEnum.INPUT_STRING
|
|
916
994
|
}]);
|
|
@@ -928,9 +1006,9 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
928
1006
|
setIsNext(true);
|
|
929
1007
|
},
|
|
930
1008
|
onSelect: function onSelect(fields, quotes) {
|
|
931
|
-
setCurColumn(_objectSpread(_objectSpread({}, curColumn), {}, {
|
|
1009
|
+
setCurColumn(normalizeExpressionAtom(_objectSpread(_objectSpread({}, curColumn), {}, {
|
|
932
1010
|
lhs: fields
|
|
933
|
-
}));
|
|
1011
|
+
}), data));
|
|
934
1012
|
setIsNext(true);
|
|
935
1013
|
}
|
|
936
1014
|
})
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
.content {
|
|
61
61
|
padding: 0.5rem;
|
|
62
62
|
display: flex;
|
|
63
|
+
gap: 8px;
|
|
63
64
|
justify-content: space-between;
|
|
64
65
|
align-items: center;
|
|
65
66
|
&_l {
|
|
@@ -180,6 +181,48 @@
|
|
|
180
181
|
.w_300 {
|
|
181
182
|
width: 300px;
|
|
182
183
|
}
|
|
184
|
+
.filter-value-control {
|
|
185
|
+
flex: 1;
|
|
186
|
+
min-width: 0;
|
|
187
|
+
|
|
188
|
+
> .input,
|
|
189
|
+
> .filter-number-input {
|
|
190
|
+
width: 100%;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.filter-number-input {
|
|
194
|
+
height: 40px;
|
|
195
|
+
padding: 0;
|
|
196
|
+
border: 0;
|
|
197
|
+
border-radius: 4px;
|
|
198
|
+
background: transparent;
|
|
199
|
+
|
|
200
|
+
&.pd-Input,
|
|
201
|
+
.pd-Input,
|
|
202
|
+
.pd-Input-inner-wrapper {
|
|
203
|
+
width: 100%;
|
|
204
|
+
height: 40px;
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
border-radius: 4px;
|
|
207
|
+
font-size: 16px;
|
|
208
|
+
color: #4c5773;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.pd-Input-inner-wrapper {
|
|
212
|
+
padding: 0 34px 0 20px;
|
|
213
|
+
border: 1px solid #f0f0f0;
|
|
214
|
+
outline: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.pd-Input {
|
|
218
|
+
height: 100%;
|
|
219
|
+
padding: 0;
|
|
220
|
+
border: 0;
|
|
221
|
+
background: transparent;
|
|
222
|
+
box-shadow: none;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
183
226
|
.input {
|
|
184
227
|
border: 1px solid #f0f0f0;
|
|
185
228
|
font-size: 16px;
|
|
@@ -12,7 +12,7 @@ import { AddIcon, CloseIcon } from '../../icons';
|
|
|
12
12
|
import { isOk } from '../formula-list/utils';
|
|
13
13
|
import ItemName from '../../modules/components/item-name';
|
|
14
14
|
import { __ } from '../../../locale';
|
|
15
|
-
import { getTemArgs, getObjTem, getParamActions, getQuotes, formulaName, formulaIsError } from './utils';
|
|
15
|
+
import { getTemArgs, getObjTem, getParamActions, getQuotes, formulaName, formulaIsError, normalizeFormulaArgs } from './utils';
|
|
16
16
|
import Styled from 'styled-components';
|
|
17
17
|
import { AtomsTypeEnum, FormulaTypeEnum } from '../../../store/types';
|
|
18
18
|
import { Select, Button } from '@gingkoo/pandora';
|
|
@@ -35,7 +35,8 @@ var CaseEditor = React.forwardRef(function (props, ref) {
|
|
|
35
35
|
readonly = _props$readonly === void 0 ? false : _props$readonly;
|
|
36
36
|
var _useState = useState(function () {
|
|
37
37
|
return _objectSpread(_objectSpread({}, value), {}, {
|
|
38
|
-
id: value.id || value.name
|
|
38
|
+
id: value.id || value.name,
|
|
39
|
+
args: normalizeFormulaArgs(value.args || [])
|
|
39
40
|
});
|
|
40
41
|
}),
|
|
41
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -92,6 +93,7 @@ var CaseEditor = React.forwardRef(function (props, ref) {
|
|
|
92
93
|
arity: effectiveArity,
|
|
93
94
|
id: currentFormulaKey,
|
|
94
95
|
name: (currentFormulaTemplate === null || currentFormulaTemplate === void 0 ? void 0 : currentFormulaTemplate.name) || fun.name,
|
|
96
|
+
args: normalizeFormulaArgs(fun.args || []),
|
|
95
97
|
quotes: getQuotes(fun, fun.args, formulaList)
|
|
96
98
|
})));
|
|
97
99
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Arity, AtomsItem, AtomsCollection } from '../../../store/types';
|
|
2
2
|
export declare const getObjTem: (arr: any[]) => any;
|
|
3
3
|
export declare const getTemArgs: (temArgs: any[], arity?: Arity) => AtomsCollection[];
|
|
4
|
+
export declare const normalizeFormulaArgs: (args?: AtomsItem[]) => AtomsCollection[];
|
|
4
5
|
export declare function getParamActions(params: AtomsItem[], arity?: Arity): {
|
|
5
6
|
canAdd: boolean;
|
|
6
7
|
canDel: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import { AtomsTypeEnum } from '../../../store/types';
|
|
2
3
|
import { getTemplateItem } from '../formula-list/utils';
|
|
3
4
|
export var getObjTem = function getObjTem(arr) {
|
|
@@ -35,6 +36,21 @@ export var getTemArgs = function getTemArgs(temArgs, arity) {
|
|
|
35
36
|
}
|
|
36
37
|
return _temArgs;
|
|
37
38
|
};
|
|
39
|
+
export var normalizeFormulaArgs = function normalizeFormulaArgs() {
|
|
40
|
+
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
41
|
+
return args.map(function (arg) {
|
|
42
|
+
if ((arg === null || arg === void 0 ? void 0 : arg.type) === AtomsTypeEnum.COLLECTION) {
|
|
43
|
+
return _objectSpread(_objectSpread({}, arg), {}, {
|
|
44
|
+
list: arg.list || []
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
type: AtomsTypeEnum.COLLECTION,
|
|
49
|
+
quotes: '',
|
|
50
|
+
list: arg ? [arg] : []
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
};
|
|
38
54
|
export function getParamActions(params, arity) {
|
|
39
55
|
var len = (params === null || params === void 0 ? void 0 : params.length) || 0;
|
|
40
56
|
if (!arity) {
|
|
@@ -55,7 +71,8 @@ export var formulaName = function formulaName(fun, formulaList) {
|
|
|
55
71
|
return (obj === null || obj === void 0 ? void 0 : obj.name) || fun.name;
|
|
56
72
|
};
|
|
57
73
|
export var getQuotes = function getQuotes(fun, _args, formulaList) {
|
|
58
|
-
var
|
|
74
|
+
var _normalizeFormulaArgs;
|
|
75
|
+
var quotes = (_normalizeFormulaArgs = normalizeFormulaArgs(_args)) === null || _normalizeFormulaArgs === void 0 ? void 0 : _normalizeFormulaArgs.map(function (v) {
|
|
59
76
|
var quotes = v.list.map(function (vv, i) {
|
|
60
77
|
if (vv !== null && vv !== void 0 && vv.quotes) {
|
|
61
78
|
return vv === null || vv === void 0 ? void 0 : vv.quotes;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './index.less';
|
|
3
3
|
import { AtomsItem } from '../../../store/types';
|
|
4
|
+
import type { FormulaSqlTableScopeItem } from '../../../types';
|
|
4
5
|
interface PropsType {
|
|
5
6
|
customTypes?: any[];
|
|
6
7
|
otherTypes?: any[];
|
|
@@ -17,6 +18,7 @@ interface PropsType {
|
|
|
17
18
|
enableCopy?: boolean;
|
|
18
19
|
enableZoom?: boolean;
|
|
19
20
|
parentPopupChannel?: 'primary' | 'secondary';
|
|
21
|
+
onAddSql?: (sql: string, availableTables?: any[], tableScope?: FormulaSqlTableScopeItem[]) => Promise<void | (() => void)> | void | (() => void);
|
|
20
22
|
}
|
|
21
23
|
declare const FormulaList: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<unknown>>;
|
|
22
24
|
export default FormulaList;
|