- Fully remove initTooltips util and replace with Controller usage
- Move plugins to their used Controller files
- Export hideTooltipOnEsc as it's used by other code
- Add unit tests for plugin behaviour in the controller tests
- Fixes #10668
- Built on #10869
This makes get_queryset more-or-less generic. It's a bit of a hack to put it here, but it's reasonable to say that this should happen immediately before the search logic (so that the queryset passed to the hook is as close as possible to the final result, while still actually being a queryset and not a SearchResults object).
Introduce an is_explicitly_ordered method to check whether an ordering URL parameter is present; if it is, search will use it, and if not, search will be ordered by relevance.
Change the override from get_filters to __init__. The get_filters method
is a classmethod and gets called at import time due to how django-filter
sets up its FilterSets. This prevents override_settings from taking
effect in tests. Moving the override to __init__ defers the locale
filter instantiation to runtime as part of the view's lifecycle.
This means that for index views that don't use the breadcrumbs,
locale selection is now done using the filters on the right side.
Remove the locale filtering from get_queryset(), as it's been
handled by filter_queryset() using django-filter.
Also remove the get_translations() method as it was only used to
generate links for the legacy locale selector.
This is an example of how a view that uses the legacy header and locale
selector can be migrated to use the slim header (which means the locale
selector is now a filter).
Ensure the locale filter is always included by overriding
WagtailFilterSet.get_filters(), so if developers use a custom
filterset_class, the locale filter will automatically be added.
Adding an initial default value for a filter is not recommended as it
prevents users from skipping the filter:
https://django-filter.readthedocs.io/en/stable/guide/tips.html#using-initial-values-as-defaults
For this reason, add the option to filter by "All" locales instead,
which is applied when the locale filter is empty.
This means that the default state of the IndexView (before a locale is
specifically selected) is now to show objects from all locales instead
of only those of the default locale.
All this is only done if breadcrumbs are used, which means that the slim
header (along with its search+filter components) is used.
If breadcrumbs are not used i.e. the legacy header is still in use,
keep the old logic with the legacy locale selector for now.