-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Unchanged filters params #6700
Unchanged filters params #6700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also provide a screenshot Before/After ? :)
Im suggest only idea now. Its works how expects in ISSUE. |
Yes, but I never worked with the js of Sonata, so I can't say if it works or not. A screenshot was a great way to prove it works as expected, and comments could help futur developers. |
src/Resources/public/Admin.js
Outdated
window.location = this.action + (diffValues.length ? ('?' + diffValues.join('&')) : ''); | ||
|
||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not updated with Javascript, but last time I checked (many years ago), return false;
was not a best practice. IMO we should keep the "normal" flow of the form and do not use window.location
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im dont view something bad in it.
You can find other usages in your project(also Admin.js) with window.location.href
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false
only works for jQuery and does not express clearly what it does, it is not explicit. IMO we should use Vanilla JS as much as we can.
By not using window.location
I meant that some other listener else could listen to the form submit.
https://github.com/sonata-project/SonataAdminBundle/search?q=window.location this are the usages in mythis project, I see just one and I guess it is used when selecting how many results per page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Only read access. Ok. What is your suggeston to refactor it?
Im will see:
- Disable no need to submit values.
- Create fake form with this url and submit it.
I don't think we should add another method to If it is just for the "view", maybe just in twig. |
How did you get the What about advanced filters ? It seems like you're only working on values for simple filters.
Where When I used an advance filter I get
When I use a multiple filter I get
I'm not sure you're currently supporting these situation. Also, since #6402, filters should be submitted as soon as they have not-empty value or a not-empty type. Here you're filtering every empty values. |
It main purpose for this PR |
But like I said, if a |
It problem don`t solves in this PR. |
My code just compute difference between two 1d arrays. Comparing worked on |
Its no so. Im keep non empty AND non default. Becouse not present filter in defaults has empty value after submit. Im prevent it. |
Just tried, and it seems to cover every case but one. When there is some persistent parameters (
|
Its problem on 3.x too |
No, in 3.x the url with the persistent parameters and the filters is
with the persistent parameter
And I lose all my filters because of the two
|
Im agree in one point. If action already has query parameter. But its impossible. |
How can you say it's impossible since I just said to you that I tried it on my project. Action is
Which is
and
So YES, it's possible. And if you look at the code, there is others way to have query params in the You have to support both case where there is already query params and case where there is no query params. And since this code has a lot of logic, some comments could help. |
just asking: does this have anything to do with null filter values? they should be valid too |
Im think no. Null filter value (in 3.x branch too) equal inactive filter |
IMO we should not add a method in |
What would be the alternative ? Only the admin can determine the default filters values. |
I have no idea, but I had supposed that datagrid would have some info or at least sounds like a better place |
Could you please rebase your PR and fix merge conflicts? |
Co-authored-by: Javier Spagnoletti <[email protected]>
I was just pointing out that we should be able to filter by empty value NULL in db. Haven't had time to check how this works.. Use case: I have post entity and it has comments. I would like to find posts without comments. |
Please use Callback filter with full control query builder |
Probably relation was not the best example. I meant basic text field |
You should just try this branch in your composer.json and then check if your filter still work. But for what I read, this has nothing to do with the form data, just the url. |
@phansys you are approve this PR or not? wait new conflicts on merge?) |
First of all, I want to thank you very much for your contribution and for sharing your thoughts and concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these changes and its goal are fine. My only concern is that we are delegating such a core feature to the frontend, where we have no tests.
Is it ok for you @franmomu ? :) |
I have still problems with this feature. Tested with sonata-admin verion 3.89. Have to step back to <3.86 to get old filter behavior. My Scenario Having a default filter of choice type with activated advanced filters
When I open the list and change the type to "equal" and press "Filter" the page reloads and the list is empty. The filter value is missing in the get param list. Thats the list:
But it has to be:
|
@kappaj Can you open an issue ? It will be better to discuss/solve it |
Added issue: #6865 |
Subject
I am targeting this branch, because created new feature for SonataAdminBundle: Only changed filters will be submitted. Made admin`s urls shorter as possible.
Closes #6642.
Changelog