forked from joewalnes/filtrex
-
Notifications
You must be signed in to change notification settings - Fork 17
Add option to use dot attribute access #44
Copy link
Copy link
Closed
Labels
designAn issue regarding the user experienceAn issue regarding the user experienceenhancementNew feature or requestNew feature or requestimplementedThis feature is implemented in `develop` and ready for testingThis feature is implemented in `develop` and ready for testing
Milestone
Metadata
Metadata
Assignees
Labels
designAn issue regarding the user experienceAn issue regarding the user experienceenhancementNew feature or requestNew feature or requestimplementedThis feature is implemented in `develop` and ready for testingThis feature is implemented in `develop` and ready for testing
Hi! I just want to say that I love this package and it's super useful for things like offloading dashboard search and filtering logic to config files so thank you!
My only hangup is that you have to do
y of x of configinstead ofconfig.x.ywhich to me feels a bit confusing and counter-intuitive. And it makes it harder to teach others about how to use the expressions because it goes against how you access data in most other languages.I wonder if it'd be possible to add a filter compile option that allows you to enable dot attribute access? That way we could keep the default functionality, but allow for a more familiar
config.x.yto access attributes (instead of key literals) if a user prefers.A headstart on a solution?
I'm not very familiar with language grammar definitions so I'm sure this isn't all right, but I'm hoping it's in the right direction.
Add
['\\.', 'return ".";'],after this line?https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L39
Replace this regex with:
'[a-zA-Z$_][a-zA-Z0-9$_]*'https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L44
Add
['left', '.'],afterhttps://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L80
Add
['e . SYMBOL', code(['prop(', 1, ',', 3, ')'])],(I think?)https://github.com/m93a/filtrex/blob/20a016d5c13527047520de4573eaeda98a49e69f/src/generateParser.js#L111