react-awesome-query-builder
react-awesome-query-builder copied to clipboard
Custom Operator Without a field
Is your feature request related to a problem? Please describe. I am trying to make a custom operator, that doesn't actually rely on a field. The only way I've been able to do this is make a field definition that is the same name as my custom operator. Then when i select that field in the builder, it uses the custom operator. This works okay, from a user experience except the jsonLogic generated from the builder doesn't make much sense, because then the operator has this additional field set. I can do a hacky work around to remove this field, but it doesn't seem ideal.
Here is an image showing the builder. So in this case 'Time Diff' is the operator. It is both a field and the it is also the operator. the label is just set to 'Is' to make the UX a bit smoother. And then I was able to have all these custom fields added to TimeDiff, and i can set these values as an array.
The issue is when i convert this to jsonLogic, i get this in the logic; {"timeDiff":[{"var":"timeDiffField"},["CURRENT",false,false,0,0,0]]} It would be perfect if it was just: {"timeDiff":["CURRENT",false,false,0,0,0]}}
Describe the solution you'd like I want to be able to add a custom operator that does not rely on also having a field.
Describe alternatives you've considered My current workout solution is to just use it as is, but when i send the jsonlogic to our API, i will rip out the extra var field in the logic, and when retrieving from the api, I will need to add in this extra var field to display it in the builder.