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

Suggestion -- Add a simple query language to be able to filter specific column values from List view #39

Open
icsy7867 opened this issue Jan 3, 2023 · 2 comments

Comments

@icsy7867
Copy link

icsy7867 commented Jan 3, 2023

I took a stab at this, and it works quite well I think. I am not sure if I did the pull correctly though. I havent done many, sorry about that!

#38

I added a search input on the List.vue page which changes the page to the same URL with a GET variable. I also added some additional methods under the loadData javascript function to add some queries. It also is smart enough where if you dont use the query syntax ( I.E manufacturer:string or location:string, and just type in string, it defaults to searching the name property)
https://github.com/icsy7867/StoreDown/blob/itemTreeSearch/src/views/List.vue
This could also be implemented with your "search" functionality as well.

It seems pretty useful. You can search specifically for a string in each column. So if you want to search for specific Tags, Names, Locations, Price Paid, Manufacturer, acquiredFrom, etc... You can easily do this. However only one at a time! Would be neat to be able to do something like location:house manufacturer:dewalt. But that would add WAY more complexity.

One caveat, though, is this is done in the DATA variable via javascript in the browser. It would be more efficient to let couchDB handle this, but you would need to add variables as indexes, and update all of your database functions to include some sort of search. However, even with 5000 items, I think this would still be decently quick.

--Examples --
I can use:
acquiredfrom:Home Depot
image

Which is helpful, as you entered data as "The Home Depot" and "Home Depot".

Or:
tags:appliance
image

Or:
location:house 1
image

@icsy7867
Copy link
Author

icsy7867 commented Jan 3, 2023

Also, I saw in your code that you had a todo for regex stuff. You could use the .match method instead of the .include in my suggested code. However regex is a bit of a learned thing, so it might make sense to have a separate regex search prefix:

I.E
nameRegEx:regex-for-searching-name-property

I stayed away from editing the fuse.js search, but I think this would be handled in almost an identical way by updating the loadData method on the view. So it might make more sense to apply to the search, and not add another search/filter.

Also, after reading up on a bit of js, it looks like the match method will work the same for a basic string, and accept regex as well. So I might try it with a .match instead of a .include, which would automagically enable searching the same way, as well as more advanced regex.

@icsy7867
Copy link
Author

icsy7867 commented Jan 6, 2023

I tested out using .match instead of .includes and it does work with regex!

For example:

name:Documents$|^JIG
This would find entries that end in "Documents" OR begin with "Jig".
image

or another example:
location:^house 2|mobile
image

*Update *

I took a stab at adding this to the search page and I believe it's all working! Sent a pull request

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

1 participant