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

Multiple default filters interfere with each other #1151

Open
AIC-BV opened this issue Jun 24, 2024 · 6 comments
Open

Multiple default filters interfere with each other #1151

AIC-BV opened this issue Jun 24, 2024 · 6 comments
Labels
needs test case Issues/PRs that need a test case to be implemented

Comments

@AIC-BV
Copy link
Contributor

AIC-BV commented Jun 24, 2024

Winter CMS Build

dev-develop

PHP Version

8.1

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

When you have multiple defined default filters in config_filter.yaml and do the following action:

  1. CLEAR the first
  2. CLEAR the second
  3. Both are CLEARED visually, but in fact, the first has been reset to its default value! It is impossible to clear both filters!
approved_status:
        label: Approved status
        type: group
        conditions: approved_status in (:filtered)
        options:
           'x': X
           'y': Y
           'z': Z
        default:
            'x': X

    shipped_status:
        label: Shipped status
        type: group
        conditions: shipped_status in (:filtered)
        options:
            1: Shipped
            0: Not shipped
        default:
            0: Shipped
  1. image
  2. image
  3. image

Steps to replicate

See description

Workaround

No response

@AIC-BV AIC-BV added needs review Issues/PRs that require a review from a maintainer Type: Unconfirmed Bug labels Jun 24, 2024
@AIC-BV
Copy link
Contributor Author

AIC-BV commented Jun 28, 2024

Also, when you have default filters (doesn't matter wether its single or multiple), clear them, and go to the next page, the filters get reapplied and you can never go to the second page

I believe the same happens when you clear and search for something.

@mjauvin
Copy link
Member

mjauvin commented Jun 30, 2024

@AIC-BV could you test if this commit has anything to do with this?

4847f8b

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Jul 1, 2024

@AIC-BV could you test if this commit has anything to do with this?

4847f8b

I changed my files and ran php artisan winter:util compile js but I don't notice any changes. Still not working. Must be broken for years now and an unused functionality 😅

@bennothommo
Copy link
Member

bennothommo commented Jul 8, 2024

The problem would be that when a filter is empty, it would instead apply the default value. There's no way for a filter to send a POST value to indicate it is empty and not populate the default value.

I had the same issue with an ecommerce site (being able to filter between order status as well as completed or incomplete orders), and I had to change the "completed" filter to a checkbox that, when ticked, only included "completed" orders. You could possibly do the same with your "shipped" filter.

EDIT: These were the scopes I used

scopes:
    paid:
        label: Completed orders only
        type: checkbox
        default: 1
        conditions: placed_at IS NOT NULL

    status:
        label: Status
        type: group
        scope: isStatus
        modelClass: \BennoThommo\Snowcart\Models\Status
        options: getList

    placed_at:
        label: Placed at
        type: daterange
        yearRange: 10
        conditions: DATE(placed_at) >= ':afterDate' AND DATE(placed_at) <= ':beforeDate'

@AIC-BV
Copy link
Contributor Author

AIC-BV commented Jul 9, 2024

scopes:
    paid:
        label: Completed orders only
        type: checkbox
        default: 1
        conditions: placed_at IS NOT NULL

I'm not entirely following:

  1. Here you have paid -> default: 1.
  2. When you uncheck this, and 'search' on the top right, or go to the next page, it will secretly be checked again.
  3. Meaning you can never see records with paid value 0 on the 2nd page or by search.

Or does the checkbox avoid this problem..?

@bennothommo
Copy link
Member

Sorry for the delay @AIC-BV. As I recall, my setup above didn't exhibit any problems when switching pages. If you're willing, would you mind providing us an example in the Test plugin?

@bennothommo bennothommo added needs response Issues/PRs where a maintainer is awaiting a response from the submitter and removed Type: Unconfirmed Bug needs review Issues/PRs that require a review from a maintainer labels Oct 3, 2024
@bennothommo bennothommo added needs test case Issues/PRs that need a test case to be implemented and removed needs response Issues/PRs where a maintainer is awaiting a response from the submitter labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs test case Issues/PRs that need a test case to be implemented
Projects
None yet
Development

No branches or pull requests

3 participants