Skip to content

Commit

Permalink
Add support of tooltip for operators
Browse files Browse the repository at this point in the history
  • Loading branch information
ukrbublik committed May 23, 2024
1 parent 0d5e94a commit 7688936
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog
- 6.6.0
- Add JsonLogic Export for SwitchCase (PR #1013)
- Add support of `tooltip` for operator config (PR #1011) (issue #261)
- 6.5.2
- Updated dependencies. `@babel/runtime` is now dep for core package (PR #1051) (issue #964)
- 6.5.1
Expand Down
1 change: 1 addition & 0 deletions CONFIG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ where `AND` and `OR` - available conjuctions (logical operators). You can add `N
|===
|key |required |default |meaning
|label |+ | |Label to be displayed in operators select component
|tooltip | | |Optional tooltip to be displayed in operators list by hovering on item
|reversedOp |+ | |Opposite operator
|isNotOp | |false |Eg. true for operator "!=", false for operator "=="
|cardinality | |1 |Number of right operands (1 for binary, 2 for `between`)
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/modules/widgets/core/FieldSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ const FieldSelect = (props) => {
const dropdownPlacement = config.settings.dropdownPlacement;
const dropdownAlign = dropdownPlacement ? BUILT_IN_PLACEMENTS[dropdownPlacement] : undefined;
const width = isFieldSelected && !showSearch || !selectWidth ? null : selectWidth + SELECT_WIDTH_OFFSET_RIGHT;
let tooltipText = selectedAltLabel || selectedFullLabel || selectedLabel;
let tooltipText = selectedAltLabel || selectedFullLabel;
if (tooltipText == selectedLabel)
tooltipText = selectedKey;
tooltipText = null;

const onChange = (key) => {
setField(key);
Expand Down
4 changes: 2 additions & 2 deletions packages/mui/modules/widgets/core/MuiFieldSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export default ({
}, [readonly, placeholder, items]);

const hasValue = selectedKey != null;
let tooltipText = selectedAltLabel || selectedFullLabel || selectedLabel;
let tooltipText = selectedAltLabel || selectedFullLabel;
if (tooltipText == selectedLabel)
tooltipText = selectedKey;
tooltipText = null;
let res = (
<Select
error={!!errorText}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/modules/components/rule/Field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Field extends Component {
let selectedFullLabel = partsLabels ? partsLabels.join(fieldSeparatorDisplay) : null;
if (selectedFullLabel == selectedLabel || parentField)
selectedFullLabel = null;
const selectedAltLabel = selectedOpts.label2;
const selectedAltLabel = selectedOpts.label2 || selectedOpts.tooltip;

const parentFieldPath = getFieldParts(parentField, config);
const parentFieldConfig = parentField ? getFieldConfig(config, parentField) : null;
Expand Down
8 changes: 7 additions & 1 deletion packages/ui/modules/components/rule/Operator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ export default class Operator extends Component {
const selectedKeys = selectedKey ? [selectedKey] : null;
const selectedPath = selectedKeys;
const selectedLabel = selectedOpts.label;
// tip: label2 is not documented for operators
const selectedAltLabel = selectedOpts.label2 || selectedOpts.tooltip;

return {
placeholder, items,
selectedKey, selectedKeys, selectedPath, selectedLabel, selectedOpts, fieldConfig
selectedKey, selectedKeys, selectedPath, selectedLabel, selectedAltLabel, selectedOpts, fieldConfig
};
}

Expand All @@ -79,10 +81,14 @@ export default class Operator extends Component {
return keys(fields).sort((a, b) => (ops.indexOf(a) - ops.indexOf(b))).map(fieldKey => {
const field = fields[fieldKey];
const label = field.label;
const altLabel = field.label2;
const tooltip = field.tooltip;
return {
key: fieldKey,
path: fieldKey,
label,
altLabel,
tooltip,
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/modules/components/rule/ValueField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class ValueField extends Component {
let selectedFullLabel = partsLabels ? partsLabels.join(fieldSeparatorDisplay) : null;
if (selectedFullLabel == selectedLabel || parentField)
selectedFullLabel = null;
const selectedAltLabel = selectedOpts.label2;
const selectedAltLabel = selectedOpts.label2 || selectedOpts.tooltip;

return {
placeholder,
Expand Down

0 comments on commit 7688936

Please sign in to comment.