Skip to content

feat(client): Allow the client to be used more flexibly #274

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

Merged

Conversation

max-scopp
Copy link
Contributor

@max-scopp max-scopp commented May 26, 2025

Description

We use Gridify in a base table component, which adds it's own current state (such as pageSize, page, filter, sorting) within a group.
The query builder instance is not automatically built, so parent component users can add more filters.

Because of this, there may be situations - such as the grid having no specific filtering state that empty groups can occour. In that case, we would want to simply "skip" this group.

Another case would be, the base table adds its filters and we want to concatinate it with an and() or or(), but if the table did not create a filter group, both operations are only informational if it would have other conditions.

This PR addresses both problems as well as a bit of housekeeping in the tsconfig.
This PR also changes the query and filterExpressions to be protected, making it easier to extend the class and manage edge cases whose may not belong to the core library itself manually.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Copy link

what-the-diff bot commented May 26, 2025

PR Summary

  • Access Modifiers Updated: The changes allow greater accessibility within the framework. Certain key aspects, such as query and filteringExpressions in GridifyQueryBuilder, have moved from being privately accessible to protected. It allows subclasses to access these features directly.
  • New Constructor: A new constructor was added to GridifyQueryBuilder. This constructor simplifies object creation by initializing key properties (query and filteringExpressions) with given options right at the start.
  • Logical Operator Features Improvement: The logical operator methods and() and or() were improved to become more versatile. Now, they can take an optional parameter and include it in the filtering expressions, providing flexibility while forming complex logical groupings.
  • Conditional Returns Added: To make the logical grouping more robust and adaptable, early return checks based on the optional property are added. These checks validate the expressions, and if the optional property is true, they allow the use of optional operators.
  • New Interface Introduced: A new GridifyQueryBuilderOptions interface helps standardize the options available for the GridifyQueryBuilder. from and allowEmptyGroups properties are part of this interface, clarifying expectations for developers.
  • TypeScript Configuration Updated: The lib option in the TypeScript configuration (tsconfig.json) was updated to include ES2017, expanding the language features available for development.

Copy link
Owner

@alirezanet alirezanet left a comment

Choose a reason for hiding this comment

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

Looks good to me 💐,
But in order to make sure it works as expected, it would be nice if you cover your new features with some tests, also we need to update the documentation.

@alirezanet alirezanet added the gridify-client Issues related to the TypeScript client label May 26, 2025
@max-scopp
Copy link
Contributor Author

max-scopp commented Jun 1, 2025

Oops, I forgot to comment after I pushed—silly me!

This initial version is a cleaned-up take on the hotfix we released earlier. I noticed that empty groups weren’t being properly removed. I'm not totally happy with how I handled it using a regex. It works, but it feels a bit clunky. I couldn't think of a better solution without making bigger changes.

Maybe the third eye has a better idea. I might've already been in weekend mode. :)

Let me know if the new tests are plently for your liking.

@alirezanet alirezanet merged commit c4bd16c into alirezanet:master Jun 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gridify-client Issues related to the TypeScript client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants