Skip to content

feat: implement filtersTools for managing query filters in hooks #214

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
merged 2 commits into from
May 23, 2025

Conversation

NoOne7135
Copy link
Contributor

No description provided.

@NoOne7135 NoOne7135 requested a review from ivictbor May 22, 2025 08:47
@ivictbor ivictbor requested a review from Copilot May 22, 2025 09:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the new filtersTools functionality to manage query filters via hooks. It introduces a new hook in apartments.ts, integrates filtersTools in the REST API module, adds the filtersTools module, and updates documentation accordingly.

  • Added AdminForthResource import and a new beforeDatasourceRequest hook in apartments.ts.
  • Integrated filtersTools into resource and dropdown hooks in restApi.ts.
  • Introduced the filtersTools module with utility methods for query filters.
  • Updated documentation (04-hooks.md) to demonstrate the usage of filtersTools.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
dev-demo/resources/apartments.ts Adds a new beforeDatasourceRequest hook and a realtor_id column configuration using filtersTools.
adminforth/modules/restApi.ts Integrates filtersTools into hook calls for datasource requests.
adminforth/modules/filtersTools.ts Introduces a new module providing utilities for filter operations.
adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md Updates the code example for applying a realtor_id filter to use filtersTools.
Comments suppressed due to low confidence (1)

adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md:140

  • The code example is missing a closing parenthesis and uses 'filterTools' instead of 'filtersTools' as defined in the implementation. Please update the example to: query.filtersTools.replaceOrAddTopFilter(Filters.EQ('realtor_id', adminUser.dbUser.id)).
query.filterTools.replaceOrAddTopFilter(Filters.EQ('realtor_id', adminUser.dbUser.id).

},

removeTopFilterIfExists(field: string) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

@NoOne7135 lets get rid of try except

@ivictbor ivictbor merged commit 4de0654 into next May 23, 2025
1 check passed
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