Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ValueEditor should display two inputs when operator is "between" or "notBetween" #428

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

Closed
jakeboone02 opened this issue Dec 20, 2022 · 5 comments · Fixed by #431 or #455
Closed

ValueEditor should display two inputs when operator is "between" or "notBetween" #428

jakeboone02 opened this issue Dec 20, 2022 · 5 comments · Fixed by #431 or #455
Milestone

Comments

@jakeboone02
Copy link
Member

From discussion #427.

Questions:

  • Should there be a separator, like "and"? So it would read as "Field between X and Y" instead of just "Field between X Y". If so:
    • Should it be a full-blown component or just a translatable string?
    • What class(es) should be added by default?
    • Should it be hidden by default, or "" instead of "and"?
    • Should it be configurable by field?
  • Is the listsAsArrays prop enough to manage the way the handleOnChange prop is called from within the default component?
    • Do we need a parseNumbers-ish prop for <QueryBuilder /> that attempts to set value to a number?

Similar enhancements (plus add/remove controls for a dynamic list of value editors) are needed for "in"/"notIn".

@keerthankrishna
Copy link

keerthankrishna commented Dec 21, 2022

This is my thought..

  • If "between" is used 2 text input boxes would get rendered next to each other having a class that is customizable. Maybe, it can take the same class style as rule-value (but have a different name like rule-between-value ?)
  • The seperator like "and" could be used in the SQL or other query outputs but instead of taking comma seperated values, it will take values from the 2 text input boxes. If the "and" is used (Field between X and Y), it will be as close as possible to query language rather than using Field between X Y
  • I'm not sure what you mean by full-blown component and translatable string here
  • I would assume it should show "" by default and when user inputs the values in the 2 input text boxes, it will render the "and" and show the values
  • I would say, it should be configurable by field

I am still thinking about the answers for the last 2 questions.

@jakeboone02 jakeboone02 linked a pull request Dec 22, 2022 that will close this issue
@jakeboone02
Copy link
Member Author

I started PR #431 that implements the two-input variation for the default ValueEditor (and the Bootstrap counterpart as well...others to come later) when the operator is "between" or "notBetween".

You can try out the new build here: https://codesandbox.io/s/react-querybuilder-pr-431-test-cyj6rp?file=/src/App.tsx

As to your questions:

  • If "between" is used 2 text input boxes would get rendered next to each other having a class that is customizable. Maybe, it can take the same class style as rule-value (but have a different name like rule-between-value ?)

The wrapper element has the rule-value class, and each input has the rule-value-list-item class. The new class is named that in case we consider adding support for "in"/"notIn" later.

  • The seperator like "and" could be used in the SQL or other query outputs but instead of taking comma seperated values, it will take values from the 2 text input boxes. If the "and" is used (Field between X and Y), it will be as close as possible to query language rather than using Field between X Y

I added a getValueEditorSeparator prop which takes a field and operator and should return a ReactNode (element, string, etc.) that gets inserted in between the two inputs. Usage:

<QueryBuilder
  getValueEditorSeparator={(fld, op) => "and"}
/>
// OR
<QueryBuilder
  getValueEditorSeparator={(fld, op) => (<span className="my-class">and</span>)}
/>
  • I'm not sure what you mean by full-blown component and translatable string here

I went with "component"--see previous bullet.

  • I would assume it should show "" by default and when user inputs the values in the 2 input text boxes, it will render the "and" and show the values

It's not dynamic, it either displays for the given field/operator combination or it doesn't.

  • I would say, it should be configurable by field

...and operator! :)

Have a go with the CodeSandbox and let me know what you think.

@keerthankrishna
Copy link

This looks perfect.. I will play around a bit with the CodeSandbox version you created. Thank you so very much @jakeboone02 !

@jakeboone02 jakeboone02 added this to the v6 milestone Jan 9, 2023
@keerthankrishna
Copy link

@jakeboone02 - This was deployed to v6 on Jan 09th right ?

@jakeboone02
Copy link
Member Author

@jakeboone02 - This was deployed to v6 on Jan 09th right ?

I don't remember when it was originally published but yes, it's in v6. See #455.

@jakeboone02 jakeboone02 linked a pull request Feb 15, 2023 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants