Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadFromJsonLogic is not working as expected. #1187

Open
themonk-e opened this issue Jan 20, 2025 · 8 comments
Open

loadFromJsonLogic is not working as expected. #1187

themonk-e opened this issue Jan 20, 2025 · 8 comments

Comments

@themonk-e
Copy link

I have requirement of allowing the users to edit the rules. So I need load back the json to the query builder using loadfromJsonLogic().

I tried with the example you have provided in the readme.

Image

The method loadFromJsonLogic() has a return type of ImmutableTree|undefined which is causing the issue. Is there any resolve for this?

@ukrbublik
Copy link
Owner

It's a simple type issue.
You can resolve eg. with QbUtils.loadFromJsonLogic!(...) or QbUtils.loadFromJsonLogic(...) as ImmutableTree
Or

const initialTreeFromJsonLogic = QbUtils.loadFromJsonLogic();
if (initialTreeFromJsonLogic) {
  // ...
}

@themonk-e
Copy link
Author

Thanks. Following that I have been stuck in the loadFromJsonLogic

Image

Here am dynamically setting the fields and loading the hardcoded JSON with using loadFromJsonLogic. This for the "EDIT" functionality of my application.

Image

This how it comes out. even though the JSON has the RHS values it is not appearing during the execution.

I'm doing something wrong in this, can you help on this?

@ukrbublik
Copy link
Owner

Did you override valueSourcesInfo in settings?
Did you override valueSources: ["value"] for your fields (LastName, DateOfBirth) ?

@themonk-e
Copy link
Author

No I did not override that

@themonk-e
Copy link
Author

Image

the above is the config before setting fields.

Image

after updation of fields

@themonk-e
Copy link
Author

video_20250122_181421.mp4

something unusual happening. ID one is having the fields like LastName DateOfBirth. When ID 1 is chosen it RHS is not appearing. But when choose 2. RHS appears. but the LHS is not changed. And ID 2 doesnt have the fields like LastName and DateOfBirth at all.

Am I making any mistakes in the states?

@ukrbublik
Copy link
Owner

Please create a full reproducible demo in codesandbox.io

@themonk-e
Copy link
Author

https://codesandbox.io/p/github/themonk-e/ReactRuleBuilder/sandbox

I have replicated the setup. In my requirement, we have a Windows application that will host this React Query Builder. The Windows application will provide the fields JSON to the React app. Here, I have simulated this behavior using a list of objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants