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

feat(filter): add support for more operators than contains #1750

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

roggervalf
Copy link

@roggervalf roggervalf commented Mar 5, 2025

When filtering data, by default, default-type component generates urls where records are going to be filtered by attribute using contains operations. This pr provides a way to choose different operators and reflect that in the url. Operators are: startsWith, endsWith, equals, notEquals and contains (default) operators. Or operator is supported too.
Screenshot 2025-03-17 at 1 15 41 a m
Updates were added to these adapters as well:

@roggervalf
Copy link
Author

pls @dziraf when you get some time to take a look

package.json Outdated
@@ -86,6 +86,7 @@
"homepage": "https://github.com/SoftwareBrothers/adminjs#readme",
"dependencies": {
"@adminjs/design-system": "^4.1.0",
"@adminjs/themes": "^1.0.1",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added as when using example repo https://github.com/SoftwareBrothers/adminjs-example-app fails when this package is linked and this package failed because this dependency does not exist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in a circular dependency issue because adminjs is a peer dependency of @adminjs/themes. adminjs-example-app is also an outdated repository.

Local linking issue can be solved by linking @adminjs/themes in your local app and in local adminjs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know, I'll remove this package though


const Filter: React.FC<FilterPropertyProps> = (props) => {
const { property, onChange, filter } = props

const possibleKeys = [
property.path,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping contains key as it was before to prevent other adapters to not be able to recognize it

@dziraf
Copy link
Contributor

dziraf commented Mar 13, 2025

This is a good start but ideally the entire filter system should be rebuilt to allow AND, OR and NOT plus we should use symbols for operators. This would also require us to update all adapters to make sure the app works the same regardless of your ORM/ODM/database

@roggervalf
Copy link
Author

This is a good start but ideally the entire filter system should be rebuilt to allow AND, OR and NOT plus we should use symbols for operators. This would also require us to update all adapters to make sure the app works the same regardless of your ORM/ODM/database

hey @dziraf, I added this functionality into adapaters and covered the other operators that you mentioned. Pls when you get some time

@roggervalf roggervalf requested a review from dziraf March 20, 2025 03:25
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 this pull request may close these issues.

2 participants