-
-
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
Show matching filters in search results #7005
Conversation
970840a
to
0e0b818
Compare
4e9728d
to
7104342
Compare
label-primary instead of default in order to have some colors ? |
7104342
to
7f6438c
Compare
7f6438c
to
294e700
Compare
@core23, @VincentLanglet; could you please bring a new review? |
{# | ||
When case sensitivity issues (like the one present when using MySQL database) were resolved, remove | ||
the previous condition and uncommment the following one. | ||
See https://github.com/sonata-project/SonataDoctrineORMAdminBundle/pull/1395. | ||
#} | ||
{#{% if match and (((filter.options.case_sensitive or filter.options.case_sensitive is null) and filter.value.value in match) | ||
or filter.options.case_sensitive is same as(false) and filter.value.value|lower in match|lower) | ||
%}#} |
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.
It's not clear to me when we can update the code.
The PR: sonata-project/SonataDoctrineORMAdminBundle#1395 is already merged.
And the Admin bundle should be aware about the issues from persistence bundles.
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.
Plus if we rename the option in the persistence bundle, this won't work.
The AdminBundle shouldn't rely on the persistence bundle code
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.
The AdminBundle shouldn't rely on the persistence bundle code
This option is set in the SearchHandler
:
$filter->setOption('case_sensitive', $this->caseSensitive); |
And the Admin bundle should be aware about the issues from persistence bundles.
We already know that isn't properly respected with some DB platforms.
If I use the commented code instead, this template will respect the "case_sensitive" option, which can lead to not matching some results returned by the persistence bundle (since the persistence bundle is not properly respecting the option).
What do you suggest?
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 left the right behavior (respecting the "case_sensitive" option), adding this comment in the template:
Some model managers are not respecting the "sonata_admin.global_search.case_sensitive" configuration option.
If you see no matching filters for a search result, it is probably the reason. In that case, you SHOULD consider usingfalse
as value for this option.
Is it fine for you?
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.
Seems ok like this
453a137
to
37e5e97
Compare
If you see no matching filters for a search result, it is probably the reason. In that case, | ||
you SHOULD consider using `false` as value for this option. | ||
#} | ||
{% if match and (((filter.options.case_sensitive or filter.options.case_sensitive is null) and filter.value.value in match) |
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.
{% if match and (((filter.options.case_sensitive or filter.options.case_sensitive is null) and filter.value.value in match) | |
{% if match and ((filter.options.case_sensitive is not same as(false) and filter.value.value in match) |
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.
Done.
37e5e97
to
fff7d02
Compare
If you see no matching filters for a search result, it is probably the reason. In that case, | ||
you SHOULD consider using `false` as value for this option. | ||
#} | ||
{% if match and ((filter.options.case_sensitive is not same as(false) and filter.value.value in match) |
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.
These filters are implementing FilterInterface
if I'm not mistaken, but there is no getValue
method in the interface.
And getValue
from Filter
is deprecated.
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.
Nice catch!
I've replaced these usages with a new variable holding the search term.
Thank you.
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.
getValue is not in the interface in master :/
fff7d02
to
6626ee0
Compare
6626ee0
to
6d77bdc
Compare
This highlight does not work if you use cascaded fields, e.g.: protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('addresses.city')
;
} This will result in a
|
This feature was partially removed from Sonata 4. Do you know if it'll be still present ? |
What do you mean with still present? Tested it just today with the |
If the bug you describe will be still present in the master branch since the code were modified |
Subject
Show matching filters in search results.
I am targeting this branch, because these changes respect BC.
The search results are using the
Admin::toString()
method to show a representation of the model matching the search criteria, but in cases where the value of the field matching a filter is not present on that string, is hard to understand why that result is presented as a match.These changes add the name of the filters that produced the model match in each search result.
Here is an example:
Changelog
To do
sub.model.property
).If someone with good CSS skills wants to get rid of the required work to provide a better UI, please be free to suggest any change.