Skip to content

Commit 0a54e42

Browse files
authored
Use func arg type in field selection (#666)
1 parent 043048c commit 0a54e42

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Added config `removeIncompleteRulesOnLoad` (default false) (PR #661) (issue #642)
44
- Fix error when using same field for comparison as argument of function (PR #662) (issue #612)
55
- Set missing `id` in `fixPathsInTree()` (PR #665) (issue #664)
6+
- Use func arg type in field selection (PR #666) (issue #615)
67
- 5.1.1
78
- Fix value null instead of undefined in JSON (PR #657) (issue #653)
89
- 5.1.0

modules/components/rule/ValueField.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default class ValueField extends PureComponent {
3333

3434
onPropsChanged(nextProps) {
3535
const prevProps = this.props;
36-
const keysForItems = ["config", "field", "operator", "isFuncArg", "placeholder"];
37-
const keysForMeta = ["config", "field", "operator", "value", "parentField"];
36+
const keysForItems = ["config", "field", "operator", "isFuncArg", "parentField"];
37+
const keysForMeta = ["config", "field", "operator", "value", "placeholder", "isFuncArg", "parentField"];
3838
const needUpdateItems = !this.items || keysForItems.map(k => (nextProps[k] !== prevProps[k])).filter(ch => ch).length > 0;
3939
const needUpdateMeta = !this.meta || keysForMeta.map(k => (nextProps[k] !== prevProps[k])).filter(ch => ch).length > 0;
4040

@@ -46,15 +46,14 @@ export default class ValueField extends PureComponent {
4646
}
4747
}
4848

49-
getItems({config, field, operator, parentField, isFuncArg}) {
49+
getItems({config, field, operator, parentField, isFuncArg, fieldDefinition}) {
5050
const {canCompareFieldWithField} = config.settings;
51-
5251
const fieldSeparator = config.settings.fieldSeparator;
5352
const parentFieldPath = typeof parentField == "string" ? parentField.split(fieldSeparator) : parentField;
5453
const parentFieldConfig = parentField ? getFieldConfig(config, parentField) : null;
5554
const sourceFields = parentField ? parentFieldConfig && parentFieldConfig.subfields : config.fields;
5655

57-
const filteredFields = this.filterFields(config, sourceFields, field, parentField, parentFieldPath, operator, canCompareFieldWithField, isFuncArg);
56+
const filteredFields = this.filterFields(config, sourceFields, field, parentField, parentFieldPath, operator, canCompareFieldWithField, isFuncArg, fieldDefinition);
5857
const items = this.buildOptions(parentFieldPath, config, filteredFields, parentFieldPath);
5958
return items;
6059
}
@@ -87,13 +86,15 @@ export default class ValueField extends PureComponent {
8786
};
8887
}
8988

90-
filterFields(config, fields, leftFieldFullkey, parentField, parentFieldPath, operator, canCompareFieldWithField, isFuncArg) {
89+
filterFields(config, fields, leftFieldFullkey, parentField, parentFieldPath, operator, canCompareFieldWithField, isFuncArg, fieldDefinition) {
9190
fields = clone(fields);
9291
const fieldSeparator = config.settings.fieldSeparator;
9392
const leftFieldConfig = getFieldConfig(config, leftFieldFullkey);
9493
let expectedType;
9594
const widget = getWidgetForFieldOp(config, leftFieldFullkey, operator, "value");
96-
if (widget) {
95+
if (isFuncArg && fieldDefinition) {
96+
expectedType = fieldDefinition.type;
97+
} else if (widget) {
9798
let widgetConfig = config.widgets[widget];
9899
let widgetType = widgetConfig.type;
99100
//expectedType = leftFieldConfig.type;

0 commit comments

Comments
 (0)