@gingkoo/pandora-metabase 1.0.121 → 1.0.122
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/formula-list/index.js +9 -45
- package/lib/cjs/components/dialog/formula-list/index.less +58 -7
- package/lib/cjs/components/dialog/formula-list/utils.js +6 -0
- package/lib/cjs/components/dialog/select-summarize/index.js +21 -2
- package/lib/cjs/components/modules/summarize/select-index.js +19 -1
- package/lib/es/components/dialog/formula-list/index.js +9 -45
- package/lib/es/components/dialog/formula-list/index.less +58 -7
- package/lib/es/components/dialog/formula-list/utils.js +6 -0
- package/lib/es/components/dialog/select-summarize/index.js +21 -2
- package/lib/es/components/modules/summarize/select-index.js +19 -1
- package/package.json +1 -1
|
@@ -607,10 +607,13 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
607
607
|
return item.type === _types.AtomsTypeEnum.OPERATOR && LOGIC_REQUIRED_OPERATORS.includes(item.val || '');
|
|
608
608
|
};
|
|
609
609
|
var canDeleteItem = function canDeleteItem(item, groupType) {
|
|
610
|
+
if (groupType === 'caseWhen') {
|
|
611
|
+
return !isFixedCaseOperator(item);
|
|
612
|
+
}
|
|
610
613
|
if (groupType === 'logic') {
|
|
611
614
|
return !isRequiredLogicOperator(item);
|
|
612
615
|
}
|
|
613
|
-
return
|
|
616
|
+
return true;
|
|
614
617
|
};
|
|
615
618
|
var canShowInsertArrows = function canShowInsertArrows(item, groupType) {
|
|
616
619
|
if (groupType === 'caseWhen') {
|
|
@@ -619,7 +622,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
619
622
|
if (groupType === 'logic') {
|
|
620
623
|
return !isRequiredLogicOperator(item);
|
|
621
624
|
}
|
|
622
|
-
return
|
|
625
|
+
return true;
|
|
623
626
|
};
|
|
624
627
|
(0, _react.useEffect)(function () {
|
|
625
628
|
var _errorInfo = (0, _utils3.validateExpressionIntegrity)(caseList);
|
|
@@ -1207,45 +1210,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1207
1210
|
};
|
|
1208
1211
|
}
|
|
1209
1212
|
if (type === _types.AtomsTypeEnum.OPERATOR) {
|
|
1210
|
-
if (isFixedCaseOperator(v)) {
|
|
1211
|
-
return {
|
|
1212
|
-
raw: true,
|
|
1213
|
-
node: (0, _jsxRuntime.jsx)("span", {
|
|
1214
|
-
className: 'Sqb-CaseKeyword',
|
|
1215
|
-
children: v.val
|
|
1216
|
-
})
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
if (groupType === 'logic' && isFixedLogicOperator(v)) {
|
|
1220
|
-
return {
|
|
1221
|
-
raw: true,
|
|
1222
|
-
node: (0, _jsxRuntime.jsx)("span", {
|
|
1223
|
-
className: 'Sqb-CaseKeyword',
|
|
1224
|
-
children: v.val
|
|
1225
|
-
})
|
|
1226
|
-
};
|
|
1227
|
-
}
|
|
1228
|
-
if (groupType === 'logic' && ['and', 'or'].includes(v.val)) {
|
|
1229
|
-
var nextLogicOperator = v.val === 'and' ? 'or' : 'and';
|
|
1230
|
-
return {
|
|
1231
|
-
className: (0, _classnames["default"])({
|
|
1232
|
-
'logic-operator': true,
|
|
1233
|
-
'logic-and': v.val === 'and',
|
|
1234
|
-
'logic-or': v.val === 'or'
|
|
1235
|
-
}),
|
|
1236
|
-
onClick: function onClick() {
|
|
1237
|
-
handleConstant(nextLogicOperator, index);
|
|
1238
|
-
},
|
|
1239
|
-
node: renderTokenContent(v.val)
|
|
1240
|
-
};
|
|
1241
|
-
}
|
|
1242
1213
|
return {
|
|
1243
1214
|
className: (0, _classnames["default"])('operator-trigger', {
|
|
1244
|
-
notSelected: !v.val
|
|
1245
|
-
'flow-operator': ['case', 'when', 'then', 'else', 'end'].includes(v.val),
|
|
1246
|
-
'logic-operator': ['and', 'or'].includes(v.val),
|
|
1247
|
-
'logic-and': v.val === 'and',
|
|
1248
|
-
'logic-or': v.val === 'or'
|
|
1215
|
+
notSelected: !v.val
|
|
1249
1216
|
}),
|
|
1250
1217
|
node: (0, _jsxRuntime.jsx)(_pandora.Select, {
|
|
1251
1218
|
triggerProps: getSelectTriggerProps(),
|
|
@@ -1346,9 +1313,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1346
1313
|
if (type === _types.AtomsTypeEnum.SELECT) {
|
|
1347
1314
|
return {
|
|
1348
1315
|
className: (0, _classnames["default"])('operator-trigger', {
|
|
1349
|
-
notSelected: !v.val
|
|
1350
|
-
'flow-operator': v.val === 'caseWhen',
|
|
1351
|
-
'logic-operator': v.val === 'andOr'
|
|
1316
|
+
notSelected: !v.val
|
|
1352
1317
|
}),
|
|
1353
1318
|
node: (0, _jsxRuntime.jsx)(_pandora.Select, {
|
|
1354
1319
|
triggerProps: getSelectTriggerProps(),
|
|
@@ -1437,7 +1402,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1437
1402
|
var showCheckbox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1438
1403
|
var itemContent = itemDom(v, i, groupType);
|
|
1439
1404
|
var isCompositeAtom = v.type === _types.AtomsTypeEnum.CASE_WHEN || v.type === _types.AtomsTypeEnum.AND_OR;
|
|
1440
|
-
var isPassiveCaseKeyword = groupType === 'caseWhen' && isFixedCaseOperator(v) || groupType === 'logic' && isFixedLogicOperator(v);
|
|
1441
1405
|
return (0, _jsxRuntime.jsx)(_react["default"].Fragment, {
|
|
1442
1406
|
children: (0, _jsxRuntime.jsxs)("div", {
|
|
1443
1407
|
className: (0, _classnames["default"])('Sqb-Filter-item', (0, _defineProperty2["default"])({
|
|
@@ -1450,11 +1414,11 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1450
1414
|
'group-logic-child': groupType === 'logic'
|
|
1451
1415
|
}, extraClassName || '', !!extraClassName)),
|
|
1452
1416
|
onMouseEnter: function onMouseEnter(e) {
|
|
1453
|
-
if (isCheck
|
|
1417
|
+
if (isCheck) return;
|
|
1454
1418
|
setInd(i);
|
|
1455
1419
|
},
|
|
1456
1420
|
onMouseLeave: function onMouseLeave() {
|
|
1457
|
-
if (isCheck
|
|
1421
|
+
if (isCheck) return;
|
|
1458
1422
|
setInd(-1);
|
|
1459
1423
|
},
|
|
1460
1424
|
children: [copyDom(i), canShowInsertArrows(v, groupType) && selectOperator({
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
--sqb-item-gap-y: 8px;
|
|
27
27
|
--sqb-arrow-offset-left: -30px;
|
|
28
28
|
--sqb-arrow-offset-right: -20px;
|
|
29
|
+
--sqb-check-offset: 28px;
|
|
30
|
+
--sqb-check-inner-offset: 20px;
|
|
29
31
|
position: relative;
|
|
30
32
|
margin: 0 var(--sqb-item-shell-margin-x) var(--sqb-item-gap-y);
|
|
31
33
|
&-content {
|
|
@@ -49,15 +51,24 @@
|
|
|
49
51
|
}
|
|
50
52
|
.openCheck {
|
|
51
53
|
.Sqb-TableName {
|
|
52
|
-
padding-left:
|
|
54
|
+
padding-left: var(--sqb-check-offset);
|
|
53
55
|
|
|
54
56
|
.item-del {
|
|
55
57
|
display: none;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
.Sqb-TableName.operator-trigger {
|
|
62
|
+
padding-left: 8px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.Sqb-TableName.operator-trigger > * {
|
|
66
|
+
padding-left: var(--sqb-check-inner-offset);
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
.formula-node-group {
|
|
60
|
-
padding-left:
|
|
71
|
+
padding-left: var(--sqb-check-offset);
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
.formula-node-group {
|
|
@@ -227,6 +238,33 @@
|
|
|
227
238
|
border: 0;
|
|
228
239
|
pointer-events: none;
|
|
229
240
|
}
|
|
241
|
+
|
|
242
|
+
.Sqb-TableName.operator-trigger {
|
|
243
|
+
padding: 8px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.Sqb-TableName.operator-trigger > * {
|
|
247
|
+
display: inline-flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
min-height: 0;
|
|
250
|
+
width: 100%;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.Sqb-TokenContent {
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
min-height: 0;
|
|
257
|
+
width: 100%;
|
|
258
|
+
padding: 0;
|
|
259
|
+
line-height: 1.2;
|
|
260
|
+
box-sizing: border-box;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.Sqb-TokenContent .item-del {
|
|
264
|
+
display: inline-flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
margin-left: 8px;
|
|
267
|
+
}
|
|
230
268
|
}
|
|
231
269
|
.Sqb-NotebookCell {
|
|
232
270
|
position: relative;
|
|
@@ -533,7 +571,7 @@
|
|
|
533
571
|
|
|
534
572
|
.Sqb-FormulaGroup-row.row-case {
|
|
535
573
|
margin-bottom: 4px;
|
|
536
|
-
align-items:
|
|
574
|
+
align-items: center;
|
|
537
575
|
gap: 6px;
|
|
538
576
|
}
|
|
539
577
|
|
|
@@ -543,14 +581,14 @@
|
|
|
543
581
|
margin-left: 12px;
|
|
544
582
|
padding-left: 10px;
|
|
545
583
|
border-left: 2px solid rgba(80, 158, 227, 0.22);
|
|
546
|
-
align-items:
|
|
584
|
+
align-items: center;
|
|
547
585
|
gap: 6px;
|
|
548
586
|
}
|
|
549
587
|
|
|
550
588
|
.Sqb-FormulaGroup-row.row-when {
|
|
551
589
|
display: flex;
|
|
552
590
|
flex-wrap: wrap;
|
|
553
|
-
align-items:
|
|
591
|
+
align-items: center;
|
|
554
592
|
}
|
|
555
593
|
|
|
556
594
|
.Sqb-CaseRow-actions {
|
|
@@ -626,7 +664,10 @@
|
|
|
626
664
|
|
|
627
665
|
.Sqb-FormulaGroup.flow-group .Sqb-CaseKeyword {
|
|
628
666
|
flex: 0 0 auto;
|
|
629
|
-
|
|
667
|
+
display: inline-flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
min-height: 28px;
|
|
670
|
+
line-height: 1;
|
|
630
671
|
padding: 0;
|
|
631
672
|
font-size: 11px;
|
|
632
673
|
font-weight: 500;
|
|
@@ -698,10 +739,20 @@
|
|
|
698
739
|
}
|
|
699
740
|
|
|
700
741
|
.Sqb-FormulaGroup.logic-group .Sqb-CaseKeyword {
|
|
701
|
-
|
|
742
|
+
display: inline-flex;
|
|
743
|
+
align-items: center;
|
|
744
|
+
min-height: 28px;
|
|
745
|
+
line-height: 1;
|
|
702
746
|
padding: 0;
|
|
703
747
|
}
|
|
704
748
|
|
|
749
|
+
.Sqb-FormulaGroup.flow-group .Sqb-NestedFormulaList,
|
|
750
|
+
.Sqb-FormulaGroup.flow-group .Sqb-NestedFormulaList .Sqb-NotebookCell,
|
|
751
|
+
.Sqb-LogicGroup-content .Sqb-NestedFormulaList,
|
|
752
|
+
.Sqb-LogicGroup-content .Sqb-NestedFormulaList .Sqb-NotebookCell {
|
|
753
|
+
vertical-align: middle;
|
|
754
|
+
}
|
|
755
|
+
|
|
705
756
|
.Sqb-FormulaGroup.logic-group .Sqb-TableName.logic-operator {
|
|
706
757
|
min-height: 28px;
|
|
707
758
|
padding: 0 10px;
|
|
@@ -108,6 +108,12 @@ var customTypes = exports.customTypes = [{
|
|
|
108
108
|
}, {
|
|
109
109
|
value: _types.AtomsTypeEnum.EXPRESSION,
|
|
110
110
|
label: (0, _locale.__)('customColumn.expression')
|
|
111
|
+
}, {
|
|
112
|
+
value: _types.AtomsTypeEnum.CASE_WHEN,
|
|
113
|
+
label: (0, _locale.__)('customColumn.caseWhen')
|
|
114
|
+
}, {
|
|
115
|
+
value: _types.AtomsTypeEnum.AND_OR,
|
|
116
|
+
label: (0, _locale.__)('customColumn.andOr')
|
|
111
117
|
}, {
|
|
112
118
|
value: _types.AtomsTypeEnum.INPUT_STRING,
|
|
113
119
|
label: (0, _locale.__)('customColumn.input')
|
|
@@ -90,6 +90,9 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
90
90
|
condition = _useState2[0],
|
|
91
91
|
setCondition = _useState2[1];
|
|
92
92
|
var _useState3 = (0, _react.useState)(function () {
|
|
93
|
+
if (Special.includes(value.condition)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
93
96
|
if (Array.isArray(value.atoms) && value.atoms.length) {
|
|
94
97
|
return value.atoms;
|
|
95
98
|
}
|
|
@@ -150,10 +153,25 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
150
153
|
}).filter(Boolean).join(' ').replace(/\s+/g, ' ').trim();
|
|
151
154
|
}
|
|
152
155
|
function handleSelect(condition, record) {
|
|
156
|
+
var isSpecialCondition = Special.includes(condition);
|
|
153
157
|
var quotesPrefix = (0, _locale.__)(localeMap[QuotesMap.get(condition)]);
|
|
154
|
-
var formulaSummary = getFormulaSummary(record.atoms || atoms);
|
|
158
|
+
var formulaSummary = isSpecialCondition ? '' : getFormulaSummary(record.atoms || atoms);
|
|
155
159
|
var quotes = [quotesPrefix, formulaSummary].filter(Boolean).join(' ').trim();
|
|
156
|
-
onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])(
|
|
160
|
+
onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, isSpecialCondition ? {
|
|
161
|
+
atoms: undefined,
|
|
162
|
+
name: '',
|
|
163
|
+
id: '',
|
|
164
|
+
realName: '',
|
|
165
|
+
name_zh: '',
|
|
166
|
+
table: '',
|
|
167
|
+
tableId: '',
|
|
168
|
+
tableUuid: '',
|
|
169
|
+
alias: '',
|
|
170
|
+
fieldAlias: '',
|
|
171
|
+
fieldUuid: '',
|
|
172
|
+
datasourceId: '',
|
|
173
|
+
datasourceName: ''
|
|
174
|
+
} : {}), record), {}, {
|
|
157
175
|
condition: condition,
|
|
158
176
|
quotes: quotes
|
|
159
177
|
}));
|
|
@@ -250,6 +268,7 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
250
268
|
}),
|
|
251
269
|
onClick: function onClick() {
|
|
252
270
|
if (~Special.indexOf(v.name)) {
|
|
271
|
+
setAtoms([]);
|
|
253
272
|
handleSelect(v.name, {});
|
|
254
273
|
} else {
|
|
255
274
|
var _value$atoms;
|
|
@@ -33,6 +33,16 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
33
33
|
var index = (0, _utils.findIndex)(store.metaList[groupIndex].list, meta);
|
|
34
34
|
var notGroupSelected = !group.length;
|
|
35
35
|
var summarizeWithoutArgument = ['总行数', '累积行数'];
|
|
36
|
+
var summarizeWithoutArgumentMessage = '该基础指标已存在';
|
|
37
|
+
var isNoArgumentMetric = function isNoArgumentMetric(condition) {
|
|
38
|
+
return !!condition && summarizeWithoutArgument.includes(condition);
|
|
39
|
+
};
|
|
40
|
+
var hasDuplicateNoArgumentMetric = function hasDuplicateNoArgumentMetric(nextGroup, condition, excludeIndex) {
|
|
41
|
+
if (!isNoArgumentMetric(condition)) return false;
|
|
42
|
+
return nextGroup.some(function (item, itemIndex) {
|
|
43
|
+
return itemIndex !== excludeIndex && item.condition === condition;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
36
46
|
function getColumns() {
|
|
37
47
|
var _getHelper = (0, _utils.getHelper)(store.metaList[groupIndex].list, meta),
|
|
38
48
|
ExistAboveGroupBy = _getHelper.ExistAboveGroupBy,
|
|
@@ -147,6 +157,10 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
147
157
|
value: value,
|
|
148
158
|
ignoreGroupByType: store.ignoreGroupByType,
|
|
149
159
|
onChange: function onChange(data) {
|
|
160
|
+
if (hasDuplicateNoArgumentMetric(newMeta[index].group, data.condition, i)) {
|
|
161
|
+
_pandora.Toast.warning(summarizeWithoutArgumentMessage);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
150
164
|
newMeta[index].group.splice(i, 1, normalizeGroupRecord(data));
|
|
151
165
|
newMeta[index].group = newMeta[index].group.map(function (v) {
|
|
152
166
|
var _summarizeToSql = (0, _helper.summarizeToSql)(newMeta[index].group, v),
|
|
@@ -195,6 +209,10 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
195
209
|
value: value,
|
|
196
210
|
ignoreGroupByType: store.ignoreGroupByType,
|
|
197
211
|
onChange: function onChange(data) {
|
|
212
|
+
if (hasDuplicateNoArgumentMetric(newMeta[index].group, data.condition)) {
|
|
213
|
+
_pandora.Toast.warning(summarizeWithoutArgumentMessage);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
198
216
|
newMeta[index].group.push(normalizeGroupRecord(data));
|
|
199
217
|
newMeta[index].group = newMeta[index].group.map(function (v) {
|
|
200
218
|
var _summarizeToSql2 = (0, _helper.summarizeToSql)(newMeta[index].group, v),
|
|
@@ -356,8 +374,8 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
356
374
|
};
|
|
357
375
|
var getAtomsValue = function getAtomsValue(record) {
|
|
358
376
|
var _record$atoms;
|
|
359
|
-
if ((_record$atoms = record.atoms) !== null && _record$atoms !== void 0 && _record$atoms.length) return record.atoms;
|
|
360
377
|
if (!isFormulaMetric(record)) return [];
|
|
378
|
+
if ((_record$atoms = record.atoms) !== null && _record$atoms !== void 0 && _record$atoms.length) return record.atoms;
|
|
361
379
|
var field = getField(record);
|
|
362
380
|
return field.fieldName ? [field] : [];
|
|
363
381
|
};
|
|
@@ -598,10 +598,13 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
598
598
|
return item.type === AtomsTypeEnum.OPERATOR && LOGIC_REQUIRED_OPERATORS.includes(item.val || '');
|
|
599
599
|
};
|
|
600
600
|
var canDeleteItem = function canDeleteItem(item, groupType) {
|
|
601
|
+
if (groupType === 'caseWhen') {
|
|
602
|
+
return !isFixedCaseOperator(item);
|
|
603
|
+
}
|
|
601
604
|
if (groupType === 'logic') {
|
|
602
605
|
return !isRequiredLogicOperator(item);
|
|
603
606
|
}
|
|
604
|
-
return
|
|
607
|
+
return true;
|
|
605
608
|
};
|
|
606
609
|
var canShowInsertArrows = function canShowInsertArrows(item, groupType) {
|
|
607
610
|
if (groupType === 'caseWhen') {
|
|
@@ -610,7 +613,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
610
613
|
if (groupType === 'logic') {
|
|
611
614
|
return !isRequiredLogicOperator(item);
|
|
612
615
|
}
|
|
613
|
-
return
|
|
616
|
+
return true;
|
|
614
617
|
};
|
|
615
618
|
useEffect(function () {
|
|
616
619
|
var _errorInfo = validateExpressionIntegrity(caseList);
|
|
@@ -1198,45 +1201,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1198
1201
|
};
|
|
1199
1202
|
}
|
|
1200
1203
|
if (type === AtomsTypeEnum.OPERATOR) {
|
|
1201
|
-
if (isFixedCaseOperator(v)) {
|
|
1202
|
-
return {
|
|
1203
|
-
raw: true,
|
|
1204
|
-
node: _jsx("span", {
|
|
1205
|
-
className: 'Sqb-CaseKeyword',
|
|
1206
|
-
children: v.val
|
|
1207
|
-
})
|
|
1208
|
-
};
|
|
1209
|
-
}
|
|
1210
|
-
if (groupType === 'logic' && isFixedLogicOperator(v)) {
|
|
1211
|
-
return {
|
|
1212
|
-
raw: true,
|
|
1213
|
-
node: _jsx("span", {
|
|
1214
|
-
className: 'Sqb-CaseKeyword',
|
|
1215
|
-
children: v.val
|
|
1216
|
-
})
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
if (groupType === 'logic' && ['and', 'or'].includes(v.val)) {
|
|
1220
|
-
var nextLogicOperator = v.val === 'and' ? 'or' : 'and';
|
|
1221
|
-
return {
|
|
1222
|
-
className: cx({
|
|
1223
|
-
'logic-operator': true,
|
|
1224
|
-
'logic-and': v.val === 'and',
|
|
1225
|
-
'logic-or': v.val === 'or'
|
|
1226
|
-
}),
|
|
1227
|
-
onClick: function onClick() {
|
|
1228
|
-
handleConstant(nextLogicOperator, index);
|
|
1229
|
-
},
|
|
1230
|
-
node: renderTokenContent(v.val)
|
|
1231
|
-
};
|
|
1232
|
-
}
|
|
1233
1204
|
return {
|
|
1234
1205
|
className: cx('operator-trigger', {
|
|
1235
|
-
notSelected: !v.val
|
|
1236
|
-
'flow-operator': ['case', 'when', 'then', 'else', 'end'].includes(v.val),
|
|
1237
|
-
'logic-operator': ['and', 'or'].includes(v.val),
|
|
1238
|
-
'logic-and': v.val === 'and',
|
|
1239
|
-
'logic-or': v.val === 'or'
|
|
1206
|
+
notSelected: !v.val
|
|
1240
1207
|
}),
|
|
1241
1208
|
node: _jsx(Select, {
|
|
1242
1209
|
triggerProps: getSelectTriggerProps(),
|
|
@@ -1337,9 +1304,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1337
1304
|
if (type === AtomsTypeEnum.SELECT) {
|
|
1338
1305
|
return {
|
|
1339
1306
|
className: cx('operator-trigger', {
|
|
1340
|
-
notSelected: !v.val
|
|
1341
|
-
'flow-operator': v.val === 'caseWhen',
|
|
1342
|
-
'logic-operator': v.val === 'andOr'
|
|
1307
|
+
notSelected: !v.val
|
|
1343
1308
|
}),
|
|
1344
1309
|
node: _jsx(Select, {
|
|
1345
1310
|
triggerProps: getSelectTriggerProps(),
|
|
@@ -1428,7 +1393,6 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1428
1393
|
var showCheckbox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1429
1394
|
var itemContent = itemDom(v, i, groupType);
|
|
1430
1395
|
var isCompositeAtom = v.type === AtomsTypeEnum.CASE_WHEN || v.type === AtomsTypeEnum.AND_OR;
|
|
1431
|
-
var isPassiveCaseKeyword = groupType === 'caseWhen' && isFixedCaseOperator(v) || groupType === 'logic' && isFixedLogicOperator(v);
|
|
1432
1396
|
return _jsx(React.Fragment, {
|
|
1433
1397
|
children: _jsxs("div", {
|
|
1434
1398
|
className: cx('Sqb-Filter-item', _defineProperty({
|
|
@@ -1441,11 +1405,11 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1441
1405
|
'group-logic-child': groupType === 'logic'
|
|
1442
1406
|
}, extraClassName || '', !!extraClassName)),
|
|
1443
1407
|
onMouseEnter: function onMouseEnter(e) {
|
|
1444
|
-
if (isCheck
|
|
1408
|
+
if (isCheck) return;
|
|
1445
1409
|
setInd(i);
|
|
1446
1410
|
},
|
|
1447
1411
|
onMouseLeave: function onMouseLeave() {
|
|
1448
|
-
if (isCheck
|
|
1412
|
+
if (isCheck) return;
|
|
1449
1413
|
setInd(-1);
|
|
1450
1414
|
},
|
|
1451
1415
|
children: [copyDom(i), canShowInsertArrows(v, groupType) && selectOperator({
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
--sqb-item-gap-y: 8px;
|
|
27
27
|
--sqb-arrow-offset-left: -30px;
|
|
28
28
|
--sqb-arrow-offset-right: -20px;
|
|
29
|
+
--sqb-check-offset: 28px;
|
|
30
|
+
--sqb-check-inner-offset: 20px;
|
|
29
31
|
position: relative;
|
|
30
32
|
margin: 0 var(--sqb-item-shell-margin-x) var(--sqb-item-gap-y);
|
|
31
33
|
&-content {
|
|
@@ -49,15 +51,24 @@
|
|
|
49
51
|
}
|
|
50
52
|
.openCheck {
|
|
51
53
|
.Sqb-TableName {
|
|
52
|
-
padding-left:
|
|
54
|
+
padding-left: var(--sqb-check-offset);
|
|
53
55
|
|
|
54
56
|
.item-del {
|
|
55
57
|
display: none;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
61
|
+
.Sqb-TableName.operator-trigger {
|
|
62
|
+
padding-left: 8px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.Sqb-TableName.operator-trigger > * {
|
|
66
|
+
padding-left: var(--sqb-check-inner-offset);
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
.formula-node-group {
|
|
60
|
-
padding-left:
|
|
71
|
+
padding-left: var(--sqb-check-offset);
|
|
61
72
|
}
|
|
62
73
|
|
|
63
74
|
.formula-node-group {
|
|
@@ -227,6 +238,33 @@
|
|
|
227
238
|
border: 0;
|
|
228
239
|
pointer-events: none;
|
|
229
240
|
}
|
|
241
|
+
|
|
242
|
+
.Sqb-TableName.operator-trigger {
|
|
243
|
+
padding: 8px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.Sqb-TableName.operator-trigger > * {
|
|
247
|
+
display: inline-flex;
|
|
248
|
+
align-items: center;
|
|
249
|
+
min-height: 0;
|
|
250
|
+
width: 100%;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.Sqb-TokenContent {
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
align-items: center;
|
|
256
|
+
min-height: 0;
|
|
257
|
+
width: 100%;
|
|
258
|
+
padding: 0;
|
|
259
|
+
line-height: 1.2;
|
|
260
|
+
box-sizing: border-box;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.Sqb-TokenContent .item-del {
|
|
264
|
+
display: inline-flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
margin-left: 8px;
|
|
267
|
+
}
|
|
230
268
|
}
|
|
231
269
|
.Sqb-NotebookCell {
|
|
232
270
|
position: relative;
|
|
@@ -533,7 +571,7 @@
|
|
|
533
571
|
|
|
534
572
|
.Sqb-FormulaGroup-row.row-case {
|
|
535
573
|
margin-bottom: 4px;
|
|
536
|
-
align-items:
|
|
574
|
+
align-items: center;
|
|
537
575
|
gap: 6px;
|
|
538
576
|
}
|
|
539
577
|
|
|
@@ -543,14 +581,14 @@
|
|
|
543
581
|
margin-left: 12px;
|
|
544
582
|
padding-left: 10px;
|
|
545
583
|
border-left: 2px solid rgba(80, 158, 227, 0.22);
|
|
546
|
-
align-items:
|
|
584
|
+
align-items: center;
|
|
547
585
|
gap: 6px;
|
|
548
586
|
}
|
|
549
587
|
|
|
550
588
|
.Sqb-FormulaGroup-row.row-when {
|
|
551
589
|
display: flex;
|
|
552
590
|
flex-wrap: wrap;
|
|
553
|
-
align-items:
|
|
591
|
+
align-items: center;
|
|
554
592
|
}
|
|
555
593
|
|
|
556
594
|
.Sqb-CaseRow-actions {
|
|
@@ -626,7 +664,10 @@
|
|
|
626
664
|
|
|
627
665
|
.Sqb-FormulaGroup.flow-group .Sqb-CaseKeyword {
|
|
628
666
|
flex: 0 0 auto;
|
|
629
|
-
|
|
667
|
+
display: inline-flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
min-height: 28px;
|
|
670
|
+
line-height: 1;
|
|
630
671
|
padding: 0;
|
|
631
672
|
font-size: 11px;
|
|
632
673
|
font-weight: 500;
|
|
@@ -698,10 +739,20 @@
|
|
|
698
739
|
}
|
|
699
740
|
|
|
700
741
|
.Sqb-FormulaGroup.logic-group .Sqb-CaseKeyword {
|
|
701
|
-
|
|
742
|
+
display: inline-flex;
|
|
743
|
+
align-items: center;
|
|
744
|
+
min-height: 28px;
|
|
745
|
+
line-height: 1;
|
|
702
746
|
padding: 0;
|
|
703
747
|
}
|
|
704
748
|
|
|
749
|
+
.Sqb-FormulaGroup.flow-group .Sqb-NestedFormulaList,
|
|
750
|
+
.Sqb-FormulaGroup.flow-group .Sqb-NestedFormulaList .Sqb-NotebookCell,
|
|
751
|
+
.Sqb-LogicGroup-content .Sqb-NestedFormulaList,
|
|
752
|
+
.Sqb-LogicGroup-content .Sqb-NestedFormulaList .Sqb-NotebookCell {
|
|
753
|
+
vertical-align: middle;
|
|
754
|
+
}
|
|
755
|
+
|
|
705
756
|
.Sqb-FormulaGroup.logic-group .Sqb-TableName.logic-operator {
|
|
706
757
|
min-height: 28px;
|
|
707
758
|
padding: 0 10px;
|
|
@@ -100,6 +100,12 @@ export var customTypes = [{
|
|
|
100
100
|
}, {
|
|
101
101
|
value: AtomsTypeEnum.EXPRESSION,
|
|
102
102
|
label: __('customColumn.expression')
|
|
103
|
+
}, {
|
|
104
|
+
value: AtomsTypeEnum.CASE_WHEN,
|
|
105
|
+
label: __('customColumn.caseWhen')
|
|
106
|
+
}, {
|
|
107
|
+
value: AtomsTypeEnum.AND_OR,
|
|
108
|
+
label: __('customColumn.andOr')
|
|
103
109
|
}, {
|
|
104
110
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
105
111
|
label: __('customColumn.input')
|
|
@@ -83,6 +83,9 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
83
83
|
condition = _useState2[0],
|
|
84
84
|
setCondition = _useState2[1];
|
|
85
85
|
var _useState3 = useState(function () {
|
|
86
|
+
if (Special.includes(value.condition)) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
86
89
|
if (Array.isArray(value.atoms) && value.atoms.length) {
|
|
87
90
|
return value.atoms;
|
|
88
91
|
}
|
|
@@ -143,10 +146,25 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
143
146
|
}).filter(Boolean).join(' ').replace(/\s+/g, ' ').trim();
|
|
144
147
|
}
|
|
145
148
|
function handleSelect(condition, record) {
|
|
149
|
+
var isSpecialCondition = Special.includes(condition);
|
|
146
150
|
var quotesPrefix = __(localeMap[QuotesMap.get(condition)]);
|
|
147
|
-
var formulaSummary = getFormulaSummary(record.atoms || atoms);
|
|
151
|
+
var formulaSummary = isSpecialCondition ? '' : getFormulaSummary(record.atoms || atoms);
|
|
148
152
|
var quotes = [quotesPrefix, formulaSummary].filter(Boolean).join(' ').trim();
|
|
149
|
-
onChange(_objectSpread(_objectSpread({},
|
|
153
|
+
onChange(_objectSpread(_objectSpread(_objectSpread({}, isSpecialCondition ? {
|
|
154
|
+
atoms: undefined,
|
|
155
|
+
name: '',
|
|
156
|
+
id: '',
|
|
157
|
+
realName: '',
|
|
158
|
+
name_zh: '',
|
|
159
|
+
table: '',
|
|
160
|
+
tableId: '',
|
|
161
|
+
tableUuid: '',
|
|
162
|
+
alias: '',
|
|
163
|
+
fieldAlias: '',
|
|
164
|
+
fieldUuid: '',
|
|
165
|
+
datasourceId: '',
|
|
166
|
+
datasourceName: ''
|
|
167
|
+
} : {}), record), {}, {
|
|
150
168
|
condition: condition,
|
|
151
169
|
quotes: quotes
|
|
152
170
|
}));
|
|
@@ -243,6 +261,7 @@ var SelectSummarize = function SelectSummarize(_ref) {
|
|
|
243
261
|
}),
|
|
244
262
|
onClick: function onClick() {
|
|
245
263
|
if (~Special.indexOf(v.name)) {
|
|
264
|
+
setAtoms([]);
|
|
246
265
|
handleSelect(v.name, {});
|
|
247
266
|
} else {
|
|
248
267
|
var _value$atoms;
|
|
@@ -27,6 +27,16 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
27
27
|
var index = findIndex(store.metaList[groupIndex].list, meta);
|
|
28
28
|
var notGroupSelected = !group.length;
|
|
29
29
|
var summarizeWithoutArgument = ['总行数', '累积行数'];
|
|
30
|
+
var summarizeWithoutArgumentMessage = '该基础指标已存在';
|
|
31
|
+
var isNoArgumentMetric = function isNoArgumentMetric(condition) {
|
|
32
|
+
return !!condition && summarizeWithoutArgument.includes(condition);
|
|
33
|
+
};
|
|
34
|
+
var hasDuplicateNoArgumentMetric = function hasDuplicateNoArgumentMetric(nextGroup, condition, excludeIndex) {
|
|
35
|
+
if (!isNoArgumentMetric(condition)) return false;
|
|
36
|
+
return nextGroup.some(function (item, itemIndex) {
|
|
37
|
+
return itemIndex !== excludeIndex && item.condition === condition;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
30
40
|
function getColumns() {
|
|
31
41
|
var _getHelper = getHelper(store.metaList[groupIndex].list, meta),
|
|
32
42
|
ExistAboveGroupBy = _getHelper.ExistAboveGroupBy,
|
|
@@ -141,6 +151,10 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
141
151
|
value: value,
|
|
142
152
|
ignoreGroupByType: store.ignoreGroupByType,
|
|
143
153
|
onChange: function onChange(data) {
|
|
154
|
+
if (hasDuplicateNoArgumentMetric(newMeta[index].group, data.condition, i)) {
|
|
155
|
+
Toast.warning(summarizeWithoutArgumentMessage);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
144
158
|
newMeta[index].group.splice(i, 1, normalizeGroupRecord(data));
|
|
145
159
|
newMeta[index].group = newMeta[index].group.map(function (v) {
|
|
146
160
|
var _summarizeToSql = summarizeToSql(newMeta[index].group, v),
|
|
@@ -189,6 +203,10 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
189
203
|
value: value,
|
|
190
204
|
ignoreGroupByType: store.ignoreGroupByType,
|
|
191
205
|
onChange: function onChange(data) {
|
|
206
|
+
if (hasDuplicateNoArgumentMetric(newMeta[index].group, data.condition)) {
|
|
207
|
+
Toast.warning(summarizeWithoutArgumentMessage);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
192
210
|
newMeta[index].group.push(normalizeGroupRecord(data));
|
|
193
211
|
newMeta[index].group = newMeta[index].group.map(function (v) {
|
|
194
212
|
var _summarizeToSql2 = summarizeToSql(newMeta[index].group, v),
|
|
@@ -350,8 +368,8 @@ var SelectIndex = function SelectIndex(props) {
|
|
|
350
368
|
};
|
|
351
369
|
var getAtomsValue = function getAtomsValue(record) {
|
|
352
370
|
var _record$atoms;
|
|
353
|
-
if ((_record$atoms = record.atoms) !== null && _record$atoms !== void 0 && _record$atoms.length) return record.atoms;
|
|
354
371
|
if (!isFormulaMetric(record)) return [];
|
|
372
|
+
if ((_record$atoms = record.atoms) !== null && _record$atoms !== void 0 && _record$atoms.length) return record.atoms;
|
|
355
373
|
var field = getField(record);
|
|
356
374
|
return field.fieldName ? [field] : [];
|
|
357
375
|
};
|