Closed rovico closed 6 years ago
Thank you for the detailed bug report, it really helps. I try to do all of the suggestions you listed and fix the source maps this week.
This issue should be fixed from version 0.2.2. Please reopen this issue if you are still having issues.
I'm submitting a...
Current behavior
When the first (or only) field in fields list is not default (external component) and I click "Add Rule" button, I see following exception in console.log (String numbers are wrong, because of wrong js map files in 0.2.0):
It happens because addRule() method of QueryBuilderComponent is trying to get firs element of operatorMap[field.type]:
operator: this.operatorMap[field.type][0]
but this.operatorMap[field.type] is undefined.
I found two ways of workaround about this issue: I. The first is to set my own addRule() implementation in my config (config.addRule = (parent) => {...code...}), but in this case i cannot access to fields and operatorMap properties of QueryBuilderComponent and need to create my own; II. The second is to set operatorMap input like this:
operatorMap = { combo: ['=', '<=', '>', '>=', '<'] }
But in this case if the first field in fields list is not in this custom operatorMap, I'm getting the same issue; To avoid it i have to write all operators for each default field type.Expected behavior
I. Check if field type exists in operatorMap and throw an error with clear description II. May be add "defaultOperator":
this.operatorMap[field.type] ? this.operatorMap[field.type][0] : defaultOperator
III. Make operatorMap extendable on component init (and not extend it when component is called recursive) IV. Add info about operatorMap for custom fields in documentationMinimal reproduction of the problem with instructions
Just add custom (non-default) field as first in fields list.
What is the motivation / use case for changing the behavior?
Environment
P.S. : Javascrit map files in last release (0.2.0) are wrong and therefore it is very hard to debug...