ukrbublik / react-awesome-query-builder

User-friendly query builder for React
https://ukrbublik.github.io/react-awesome-query-builder
MIT License
2.02k stars 504 forks source link

Jsonlogic export removing unnecessary groups #1074

Closed Tupsu-jy closed 5 months ago

Tupsu-jy commented 5 months ago

Currently, JSONLogic export removes unnecessary groups that are empty or have only one rule, altering the query structure between saves to backend and imports without user intervention. I feel like this is not ideal situation as the user might be surprised or confused by unexpected changes.

I propose adding a setting on keeping these groups during jsonlogic exports, ensuring query consistency throughout the roundtrip of being exported and imported. This setting would default to false but can be enabled as needed.

Changes would only need to be made to jsonlogic export, as the jsonlogic import already handles such groups without issue. I don't know how spel export and import works.

I could make this change myself, if that's okay. Might this cause any problems, or is there a particular reason for the existing behavior that I might be overlooking?

ukrbublik commented 5 months ago

I could make this change myself, if that's okay

Feel free to open PR for this. Should not cause problems for import

Tupsu-jy commented 5 months ago

Ok. I'll make changes as proposed.

Thanks for quick response