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

Function in LHS #287

Closed
VietAn98 opened this issue Sep 10, 2020 · 31 comments · Fixed by #900
Closed

Function in LHS #287

VietAn98 opened this issue Sep 10, 2020 · 31 comments · Fixed by #900

Comments

@VietAn98
Copy link

VietAn98 commented Sep 10, 2020

I want the queryString look like this:
lowercase(process.Name) == 'abc.exe'
but currently, all I can do is:
process.Name == lowercase('abc.exe')

The problem is that I don't know how to make the first field to have the property "valueSources" so that I can create the queryString look like lowercase(process.Name) == 'abc.exe'

So it would be great if I can customize the positions of fields or select "valueSources" property in the first field (currently "valueSources" can just be chosen in the value field which is after the operators field)

If you know how to do this, please help me ^^ thank you

Note: Sorry for my english if you find it difficult to understand what I try to talk about ;(

@ukrbublik
Copy link
Owner

What about creating new operator for this?
Example:
https://codesandbox.io/s/quirky-solomon-9vhnp?file=/src/demo/config_simple.js
See ci_equal (I used lowercase on both field and value to create case insensitive equal)

@VietAn98
Copy link
Author

Thanks for replying!
I'll try your solution

@malizo35
Copy link

I want the queryString look like this:
lowercase(process.Name) == 'abc.exe'
but currently, all I can do is:
process.Name == lowercase('abc.exe')

The problem is that I don't know how to make the first field to have the property "valueSources" so that I can create the queryString look like lowercase(process.Name) == 'abc.exe'

So it would be great if I can customize the positions of fields or select "valueSources" property in the first field (currently "valueSources" can just be chosen in the value field which is after the operators field)

If you know how to do this, please help me ^^ thank you

Note: Sorry for my english if you find it difficult to understand what I try to talk about ;(

I'm facing the same problem (kind of).

What about creating new operator for this?
Example:
https://codesandbox.io/s/quirky-solomon-9vhnp?file=/src/demo/config_simple.js
See ci_equal (I used lowercase on both field and value to create case insensitive equal)

But what if users want to select function in first box and UI will show as when we select (valueSources == func) => then select operators => then input value...would it be possible to use either a function or a text box just as we can do in value field?

@ukrbublik
Copy link
Owner

When I think about function in LHS and how it would be like, UI seems overbloated as for me.

Can you please draw simple draft how it should look like and behave in your opinion?

@malizo35
Copy link

malizo35 commented Sep 10, 2020

so this is what I thought it could be, hope it helps
Untitled

yes it seems kinda overbloated but not very in my opinion
maybe it can be hard as coding @@

@ukrbublik
Copy link
Owner

Seems possible to do.
I'll try to implement when I have free time but can't promise when )

@malizo35
Copy link

that would be great, while waiting maybe I'll use this solution (https://codesandbox.io/s/quirky-solomon-9vhnp?file=/src/demo/config_simple.js) temporarily, ill keep track of your update

@ukrbublik ukrbublik changed the title Change fields' position Function in LHS Oct 25, 2021
@andres99x
Copy link

andres99x commented Oct 27, 2021

Hi guys.
I'm facing the same challenges and wanted to know if any of you found a solution besides the one proposed in the example.
Thanks!

@ukrbublik
Copy link
Owner

ukrbublik commented Oct 27, 2021

@andres99x I don't think there is a proper workaround. It's a complex feature, one of most requested ones.
Before I start to implement it, I wonder what would be better UI/UX for this:

  1. Add button Add function near Add rule. Difference between them - first will start rule with a function rather then with a field.
  2. Add three dots before field selector (just like one there is before value editor - "Select value source") that open popup to change LHS source - field/function/value.

@andres99x
Copy link

@ukrbublik thanks for you prompt reply, i understand it's a complex feature.
If I may put my two cents in, I don't see a reason to differentiate between Add function and Add rule, in my mind a rule is still a rule regardless of what it starts with, be it a field, function or value.

@meniga-marcin
Copy link

We are looking into the same issue of using function or a value as the Left Hand Side of the comparison.

@ukrbublik Apart from the UI/UX doubts do you see any risks in implementing this feature? Or do you have a plan/idea on how to approach this feature request?

@ukrbublik
Copy link
Owner

@meniga-marcin I have a plan to implement this feature, but it requires free time.

Can you please describe the need of value in LHS?
I don't see reason to compare value with value. So in my opinion LHS can be field/function, RHS can be field/value/function.

Let's say, you want 5 < a. What's the difference from a > b?

@meniga-marcin
Copy link

@meniga-marcin I have a plan to implement this feature, but it requires free time.

Right, we might support you on this one and contribute with a solution - just wanted to gather your opinion on how to approach this. We aren't familiar with the internals of the library and will need to dig into it to make the change.

Can you please describe the need of value in LHS?

In our case we need to do a comparison of a

  • value with function result
  • two function results

Just thought that adding value in LHS might be easier than adding a function in LHS but after a brief look at the model I suppose it would be the same effort. Hence adding function as a LHS should suffice.

@ukrbublik
Copy link
Owner

Just thought that adding value in LHS might be easier than adding a function in LHS but after a brief look at the model I suppose it would be the same effort. Hence adding function as a LHS should suffice.

I have an idea to not add "three dots" in LHS like in this coment. But instead allow user to start a rule with a field always (as now), and add button "convert field to a function" (maybe just neat icon "f") that opens a list of functions appliable to selected field (eg. for text field functions can be "length", "uppercase" etc.). And after selection of function LHS will be converted to a function with previously selected field as an argument.

Another way would be as suggested in this coment but it has one disadvantage in my optinion - we'll have to list ALL functions for all possible types (date functions, text functions etc.) Thay could be grouped of course, but still..
WDYT?

Right, we might support you on this one and contribute with a solution

Nice to hear

We aren't familiar with the internals of the library and will need to dig into it to make the change.

Maybe it would be reasonably create discord/slack channel for development questions?

@kjroshan
Copy link

@meniga-marcin I have a plan to implement this feature, but it requires free time.

Can you please describe the need of value in LHS? I don't see reason to compare value with value. So in my opinion LHS can be field/function, RHS can be field/value/function.

Let's say, you want 5 < a. What's the difference from a > b?

The problem is already existing logic, if we want to provide a facility to see the existing logic in query builder then we may have to provide the facility to have value as well in LHS. Otherwise your point was valid.

@dbg4200
Copy link

dbg4200 commented Jan 21, 2022

"three dots" in a first LHS is required, if user doesn't want he will not select the dots. And on clicking of dots give option like field or function. if a function is selected give list of functions and then allow him to select the fields.

@MattEagle95
Copy link

awesome work on this query builder! I would love to see that feauture, too. But I know doing this in the free time is hard

@dbg4200
Copy link

dbg4200 commented Jul 13, 2022

@ukrbublik LHS seems very important feature missing here, please take on this priority.

@rhallerman
Copy link
Contributor

rhallerman commented Jan 23, 2023

@ukrbublik I'm going to start preliminary development work on this, but I want to make sure that something isn't already started. My plan is to make the LHS pretty much exactly the same as the RHS, meaning that you'll be able to put fields and functions on the LHS using the ∨ selector (values are more complicated because the widget would need to be specified as well, so I'm leaving those out for now). I plan to keep "fields only" as the default.

@ukrbublik
Copy link
Owner

@rhallerman1 I'm glad you wrote this ☺️ As I was going to start development of this (probably most requested) feature this week. My plan was same.
You can start development, I can help with your work.
Meanwhile I can work on another issues/features.
Btw I saw some forks with development drafts of this feature some time ago. If this could be helpful to you, I can search them.

@ejavatem
Copy link

@ukrbublik I'm trying to use dropdown (Value, Field) on the left hand side before or after Slider dropdown.
image
Can you please suggest me something.
Currently I'm using 4.8.0 version

@ukrbublik
Copy link
Owner

@tejamannava Not possible for now. Planning to add this feature in 6.x version

@ejavatem
Copy link

Just for my information, when can we expect 6.x version.

Can I add a new text box after selecting the field on RHS
image

@ejavatem
Copy link

ejavatem commented Feb 10, 2023

@ukrbublik Can we pass a specific funcs to each added record?
Ex: When adding 1 row and selecting a specific value from a dropdown, I'm updating func. But, when I add next row and select another value from dropdown which will update a new func.
Now, When the second func is updated the 1st one also get affected. So, can we pass func specific to each row?

@rhallerman
Copy link
Contributor

@ukrbublik Sorry for the long delay -- my team reprioritized things so I was working on unrelated stuff for quite a while. I'm back to this now, though. Would it be possible to somehow talk and discuss the general requirements/file locations for this? I already have some changes made, but going through those and my many other questions would be very helpful.

@ukrbublik
Copy link
Owner

You can ping me on discord, tomorrow I should have time
https://discord.gg/xdBwZnJYhM
Or ukrbublik@gmail.com

@rhallerman
Copy link
Contributor

Current progress for those interested:
image

@dbg4200
Copy link

dbg4200 commented Mar 21, 2023

Current progress for those interested: image

hi @rhallerman1 Can you please share repo details and changes ?

@rhallerman2
Copy link

I'm still working on bugs and other cases, but will hopefully be able to make a PR soon.

@rhallerman2
Copy link

@ukrbublik Any idea/plan/hope for when this will be added and released? I don't know how much work is still left before you'll be comfortable releasing it, since I realize that I only really implemented the basic feature.

@ukrbublik
Copy link
Owner

@rhallerman I was busy with big PR #866 , now it's merged so my top priority now is to merge your PR, after fixing tests

@ukrbublik ukrbublik linked a pull request Jul 6, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.