netcreateorg / netcreate-itest

Developing the 2.0 version of NetCreate
https://github.com/netcreateorg/netcreate-2018
Other
0 stars 0 forks source link

Feature: Add filters using `&&` or `||` in strings. #105

Closed benloh closed 7 months ago

benloh commented 7 months ago

See #83

Adds ability to define string filters that use && or || in strings.

For example:

label [ contains ] "Ben || Joshua"     // matches "ben" or "joshua"
label [ contains ] "scuba && diving"   // matches "likes scuba diving in the Maldives"
label [ contains ] "scuba || swim"     // matches "likes scuba" and "likes swimming"
label [ contains ] "scuba || swim && diving"     // matches "likes scuba diving" but not "likes swimming" because it's missing "diving"

A few notes:

jdanish commented 7 months ago

Contains works great. Does not Contain is a bit weird.

This || statement works right on "contains" but on "does not contain" misses the second node.

Screenshot 2023-11-27 at 5 42 07 PM Screenshot 2023-11-27 at 5 42 19 PM

And on the && ... it seems the reverse - gets one too many on the does not contain. Almost like AND and OR are flipped with does not contain?

Screenshot 2023-11-27 at 5 43 56 PM Screenshot 2023-11-27 at 5 44 06 PM

Also, the field has the same issue the search used to. If you type Books && Burning, then place the cursor to change && to ||, press delete and it now reads Books & Burning and the cursor is at the end.

benloh commented 7 months ago

does not contain logic

Ah, the logic was flawed. I was applying the "does containt/does not contain" logic to subclause. Please try again and see if this fixes it. c1ec735dd223bf6617c37564ceea9270408977e5

the field has the same issue the search used to. If you type Books && Burning, then place the cursor to change && to ||, press delete and it now reads Books & Burning and the cursor is at the end.

This has been fixed with 5342dec

jdanish commented 7 months ago

That works, thanks! Helped me notice another (maybe new?) issue though. If you type a filter for a string, and then switch contains to --, the filter text should be removed, right? It does not. Then if you switch -- back to contains it is not recognizing the text immediately. Though if you add to it by a letter, it then functions as expected.

jdanish commented 7 months ago

I also just noticed that markdown fields do not appear in the filters, but would assume they appear / use the same functionality as strings. Sorry I didn't catch that before.

benloh commented 7 months ago

If you type a filter for a string, and then switch contains to --, the filter text should be removed, right? It does not. Then if you switch -- back to contains it is not recognizing the text immediately. Though if you add to it by a letter, it then functions as expected.

Sorry about that. We actually had that fixed previously, but then another bug was introduced where the cursor position was being lost with state updates (Kalani's issue from a few weeks ago). This should be fixed now.

I also just noticed that markdown fields do not appear in the filters, but would assume they appear / use the same functionality as strings. Sorry I didn't catch that before.

Oops. Good catch. Markdown fields just use strings to work. But I had to explicitly add support for filters. Should be fixed with cb3e3d03472cea0212dc34f3f2d6ff850316b32b

In addition:

benloh commented 7 months ago

@jdanish Did you want to add help text in the "More...> Help" panel for using && and || in filter searches? Should I leave that to you?

jdanish commented 7 months ago

Debating, so leave it to me. Thanks!

jdanish commented 7 months ago

@benloh looks good - go ahead and merge when you are ready!