@gingkoo/pandora-metabase 1.0.124 → 1.0.125
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/utils.js +16 -0
- package/lib/cjs/components/dialog/formula-list/index.js +21 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +2 -0
- package/lib/cjs/store/types.d.ts +12 -0
- package/lib/es/components/dialog/formula/utils.js +16 -0
- package/lib/es/components/dialog/formula-list/index.js +21 -1
- package/lib/es/components/dialog/formula-list/utils.js +2 -0
- package/lib/es/store/types.d.ts +12 -0
- package/package.json +1 -1
|
@@ -69,6 +69,22 @@ var getQuotes = exports.getQuotes = function getQuotes(fun, _args, formulaList)
|
|
|
69
69
|
return vv === null || vv === void 0 ? void 0 : vv.quotes;
|
|
70
70
|
} else if (vv !== null && vv !== void 0 && vv.fieldName) {
|
|
71
71
|
return vv === null || vv === void 0 ? void 0 : vv.fieldName;
|
|
72
|
+
} else if ((vv === null || vv === void 0 ? void 0 : vv.type) === _types.AtomsTypeEnum.SELECT) {
|
|
73
|
+
var displayField = vv.displayField || 'value';
|
|
74
|
+
var getOptionText = function getOptionText(value) {
|
|
75
|
+
var _ref, _option$displayField;
|
|
76
|
+
var option = (vv.options || []).find(function (currentOption) {
|
|
77
|
+
return currentOption.value === value;
|
|
78
|
+
});
|
|
79
|
+
if (!option) return value || '';
|
|
80
|
+
return String((_ref = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref !== void 0 ? _ref : '');
|
|
81
|
+
};
|
|
82
|
+
if (Array.isArray(vv.val)) {
|
|
83
|
+
return vv.val.map(function (currentValue) {
|
|
84
|
+
return getOptionText(currentValue);
|
|
85
|
+
}).join(', ');
|
|
86
|
+
}
|
|
87
|
+
return getOptionText(vv.val || '');
|
|
72
88
|
} else {
|
|
73
89
|
return vv.val;
|
|
74
90
|
}
|
|
@@ -240,6 +240,23 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
240
240
|
nextList[index] = nextItem;
|
|
241
241
|
setCaseList(nextList);
|
|
242
242
|
};
|
|
243
|
+
function getSelectDisplayText(item) {
|
|
244
|
+
var displayField = item.displayField || 'value';
|
|
245
|
+
var getOptionText = function getOptionText(value) {
|
|
246
|
+
var _ref2, _option$displayField;
|
|
247
|
+
var option = (item.options || []).find(function (currentOption) {
|
|
248
|
+
return currentOption.value === value;
|
|
249
|
+
});
|
|
250
|
+
if (!option) return value || '';
|
|
251
|
+
return String((_ref2 = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
252
|
+
};
|
|
253
|
+
if (Array.isArray(item.val)) {
|
|
254
|
+
return item.val.map(function (currentValue) {
|
|
255
|
+
return getOptionText(String(currentValue));
|
|
256
|
+
}).join(', ');
|
|
257
|
+
}
|
|
258
|
+
return getOptionText(String(item.val || ''));
|
|
259
|
+
}
|
|
243
260
|
function getItemDisplayText(v) {
|
|
244
261
|
if (!v) return '';
|
|
245
262
|
if (v.quotes) return v.quotes;
|
|
@@ -271,6 +288,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
271
288
|
}).join(' ');
|
|
272
289
|
return "".concat(v.operator || 'and', " ( ").concat(listText, " )").replace(/\s+/g, ' ').trim();
|
|
273
290
|
}
|
|
291
|
+
if (v.type === _types.AtomsTypeEnum.SELECT) {
|
|
292
|
+
return getSelectDisplayText(v);
|
|
293
|
+
}
|
|
274
294
|
if (Array.isArray(v.val)) {
|
|
275
295
|
return v.val.join(', ');
|
|
276
296
|
}
|
|
@@ -1330,7 +1350,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
|
|
|
1330
1350
|
value: v.val,
|
|
1331
1351
|
triggerElement: function triggerElement() {
|
|
1332
1352
|
return renderTokenContent((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
1333
|
-
children: [!v.val && (0, _locale.__)('customColumn.
|
|
1353
|
+
children: [!v.val && (v.placeholder || (0, _locale.__)('customColumn.pleaseSelect')), getSelectDisplayText(v), !v.fixed && renderDeleteIcon(v, index, groupType)]
|
|
1334
1354
|
}));
|
|
1335
1355
|
},
|
|
1336
1356
|
onChange: function onChange(val) {
|
|
@@ -234,6 +234,8 @@ var getTemplateItem = exports.getTemplateItem = function getTemplateItem(type, i
|
|
|
234
234
|
options: item.options || [],
|
|
235
235
|
multiple: item.multiple || false,
|
|
236
236
|
fixed: item.fixed || false,
|
|
237
|
+
placeholder: item.placeholder || '',
|
|
238
|
+
displayField: item.displayField || 'value',
|
|
237
239
|
quotes: '',
|
|
238
240
|
type: type
|
|
239
241
|
};
|
package/lib/cjs/store/types.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export interface AtomsConstant {
|
|
|
146
146
|
val: string;
|
|
147
147
|
type: AtomsTypeEnum.CONSTANT;
|
|
148
148
|
}
|
|
149
|
+
export type SelectOptionDisplayField = 'label' | 'value';
|
|
149
150
|
export interface AtomsOprator {
|
|
150
151
|
val: string;
|
|
151
152
|
type: AtomsTypeEnum.OPERATOR;
|
|
@@ -168,6 +169,8 @@ export interface AtomsSelect {
|
|
|
168
169
|
val: string | string[] | null;
|
|
169
170
|
multiple?: boolean;
|
|
170
171
|
fixed?: boolean;
|
|
172
|
+
placeholder?: string;
|
|
173
|
+
displayField?: SelectOptionDisplayField;
|
|
171
174
|
type: AtomsTypeEnum.SELECT;
|
|
172
175
|
}
|
|
173
176
|
export type AtomsItem = AtomsSubQuery | AtomsNotExists | AtomsExists | AtomsJoinDefault | AtomsExpression | AtomsCaseWhen | AtomsAndOr | AtomsFormula | AtomsField | AtomsInputString | AtomsInputStringList | AtomsInputNumberList | AtomsInputNumber | AtomsOprator | AtomsConstant | AtomsUnknown | AtomsCollection | AtomsSelect;
|
|
@@ -396,6 +399,15 @@ export interface FormulaTemplatesItem {
|
|
|
396
399
|
args: {
|
|
397
400
|
type: AtomsTypeEnum;
|
|
398
401
|
check?: string | null;
|
|
402
|
+
options?: {
|
|
403
|
+
label: string;
|
|
404
|
+
value: string;
|
|
405
|
+
}[];
|
|
406
|
+
default?: string | string[];
|
|
407
|
+
multiple?: boolean;
|
|
408
|
+
fixed?: boolean;
|
|
409
|
+
placeholder?: string;
|
|
410
|
+
displayField?: SelectOptionDisplayField;
|
|
399
411
|
}[];
|
|
400
412
|
arity?: Arity;
|
|
401
413
|
output?: string;
|
|
@@ -61,6 +61,22 @@ export var getQuotes = function getQuotes(fun, _args, formulaList) {
|
|
|
61
61
|
return vv === null || vv === void 0 ? void 0 : vv.quotes;
|
|
62
62
|
} else if (vv !== null && vv !== void 0 && vv.fieldName) {
|
|
63
63
|
return vv === null || vv === void 0 ? void 0 : vv.fieldName;
|
|
64
|
+
} else if ((vv === null || vv === void 0 ? void 0 : vv.type) === AtomsTypeEnum.SELECT) {
|
|
65
|
+
var displayField = vv.displayField || 'value';
|
|
66
|
+
var getOptionText = function getOptionText(value) {
|
|
67
|
+
var _ref, _option$displayField;
|
|
68
|
+
var option = (vv.options || []).find(function (currentOption) {
|
|
69
|
+
return currentOption.value === value;
|
|
70
|
+
});
|
|
71
|
+
if (!option) return value || '';
|
|
72
|
+
return String((_ref = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref !== void 0 ? _ref : '');
|
|
73
|
+
};
|
|
74
|
+
if (Array.isArray(vv.val)) {
|
|
75
|
+
return vv.val.map(function (currentValue) {
|
|
76
|
+
return getOptionText(currentValue);
|
|
77
|
+
}).join(', ');
|
|
78
|
+
}
|
|
79
|
+
return getOptionText(vv.val || '');
|
|
64
80
|
} else {
|
|
65
81
|
return vv.val;
|
|
66
82
|
}
|
|
@@ -231,6 +231,23 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
231
231
|
nextList[index] = nextItem;
|
|
232
232
|
setCaseList(nextList);
|
|
233
233
|
};
|
|
234
|
+
function getSelectDisplayText(item) {
|
|
235
|
+
var displayField = item.displayField || 'value';
|
|
236
|
+
var getOptionText = function getOptionText(value) {
|
|
237
|
+
var _ref2, _option$displayField;
|
|
238
|
+
var option = (item.options || []).find(function (currentOption) {
|
|
239
|
+
return currentOption.value === value;
|
|
240
|
+
});
|
|
241
|
+
if (!option) return value || '';
|
|
242
|
+
return String((_ref2 = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
243
|
+
};
|
|
244
|
+
if (Array.isArray(item.val)) {
|
|
245
|
+
return item.val.map(function (currentValue) {
|
|
246
|
+
return getOptionText(String(currentValue));
|
|
247
|
+
}).join(', ');
|
|
248
|
+
}
|
|
249
|
+
return getOptionText(String(item.val || ''));
|
|
250
|
+
}
|
|
234
251
|
function getItemDisplayText(v) {
|
|
235
252
|
if (!v) return '';
|
|
236
253
|
if (v.quotes) return v.quotes;
|
|
@@ -262,6 +279,9 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
262
279
|
}).join(' ');
|
|
263
280
|
return "".concat(v.operator || 'and', " ( ").concat(listText, " )").replace(/\s+/g, ' ').trim();
|
|
264
281
|
}
|
|
282
|
+
if (v.type === AtomsTypeEnum.SELECT) {
|
|
283
|
+
return getSelectDisplayText(v);
|
|
284
|
+
}
|
|
265
285
|
if (Array.isArray(v.val)) {
|
|
266
286
|
return v.val.join(', ');
|
|
267
287
|
}
|
|
@@ -1321,7 +1341,7 @@ var FormulaList = forwardRef(function (props, ref) {
|
|
|
1321
1341
|
value: v.val,
|
|
1322
1342
|
triggerElement: function triggerElement() {
|
|
1323
1343
|
return renderTokenContent(_jsxs(_Fragment, {
|
|
1324
|
-
children: [!v.val && __('customColumn.
|
|
1344
|
+
children: [!v.val && (v.placeholder || __('customColumn.pleaseSelect')), getSelectDisplayText(v), !v.fixed && renderDeleteIcon(v, index, groupType)]
|
|
1325
1345
|
}));
|
|
1326
1346
|
},
|
|
1327
1347
|
onChange: function onChange(val) {
|
|
@@ -226,6 +226,8 @@ export var getTemplateItem = function getTemplateItem(type, item) {
|
|
|
226
226
|
options: item.options || [],
|
|
227
227
|
multiple: item.multiple || false,
|
|
228
228
|
fixed: item.fixed || false,
|
|
229
|
+
placeholder: item.placeholder || '',
|
|
230
|
+
displayField: item.displayField || 'value',
|
|
229
231
|
quotes: '',
|
|
230
232
|
type: type
|
|
231
233
|
};
|
package/lib/es/store/types.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export interface AtomsConstant {
|
|
|
146
146
|
val: string;
|
|
147
147
|
type: AtomsTypeEnum.CONSTANT;
|
|
148
148
|
}
|
|
149
|
+
export type SelectOptionDisplayField = 'label' | 'value';
|
|
149
150
|
export interface AtomsOprator {
|
|
150
151
|
val: string;
|
|
151
152
|
type: AtomsTypeEnum.OPERATOR;
|
|
@@ -168,6 +169,8 @@ export interface AtomsSelect {
|
|
|
168
169
|
val: string | string[] | null;
|
|
169
170
|
multiple?: boolean;
|
|
170
171
|
fixed?: boolean;
|
|
172
|
+
placeholder?: string;
|
|
173
|
+
displayField?: SelectOptionDisplayField;
|
|
171
174
|
type: AtomsTypeEnum.SELECT;
|
|
172
175
|
}
|
|
173
176
|
export type AtomsItem = AtomsSubQuery | AtomsNotExists | AtomsExists | AtomsJoinDefault | AtomsExpression | AtomsCaseWhen | AtomsAndOr | AtomsFormula | AtomsField | AtomsInputString | AtomsInputStringList | AtomsInputNumberList | AtomsInputNumber | AtomsOprator | AtomsConstant | AtomsUnknown | AtomsCollection | AtomsSelect;
|
|
@@ -396,6 +399,15 @@ export interface FormulaTemplatesItem {
|
|
|
396
399
|
args: {
|
|
397
400
|
type: AtomsTypeEnum;
|
|
398
401
|
check?: string | null;
|
|
402
|
+
options?: {
|
|
403
|
+
label: string;
|
|
404
|
+
value: string;
|
|
405
|
+
}[];
|
|
406
|
+
default?: string | string[];
|
|
407
|
+
multiple?: boolean;
|
|
408
|
+
fixed?: boolean;
|
|
409
|
+
placeholder?: string;
|
|
410
|
+
displayField?: SelectOptionDisplayField;
|
|
399
411
|
}[];
|
|
400
412
|
arity?: Arity;
|
|
401
413
|
output?: string;
|