From 9e36fa74b6d50be0580c23a0f97c5ef3c99c5018 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Thu, 15 Aug 2024 11:21:40 +0100 Subject: [PATCH] Move all interim support of non-breadcrumbs listing views to the index.html template We want to remove all breadcrumbs_items check in the templates eventually (as we want all listing views to use breadcrumbs). Instead of having both BaseListingView's listing.html and IndexView's index.html templates support the non-breadcrumbs case, do this only for the index.html template. The reasoning is because the BaseListingView was extracted more recently as part of the Universal Listings work. When the filtering support was moved from the IndexView to BaseListingView in 130c7ff, we still had to support the non-breadcrumbs case due to the report views still using the old filters implementation. Now that we have migrated the report views to use the new AJAX-based filtering, it's much less likely there's a BaseListingView subclass out there that uses the non-breadcrumbs version. For such views, it's likely they would work with IndexView too (as we haven't really documented BaseListingView since its creation). So, put the interim support in the IndexView template for now. We could also completely drop the non-breadcrumbs case for both views, but this would mean any custom listing view that uses filters now _must_ implement a results-only view _and_ enable breadcrumbs, or include the filtering template themselves... --- .../templates/wagtailadmin/generic/index.html | 17 +++++++++++ .../wagtailadmin/generic/listing.html | 28 ++++++++----------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/wagtail/admin/templates/wagtailadmin/generic/index.html b/wagtail/admin/templates/wagtailadmin/generic/index.html index 58e86c1451..18a48d7b4e 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/index.html +++ b/wagtail/admin/templates/wagtailadmin/generic/index.html @@ -13,3 +13,20 @@ {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle action_url=header_action_url action_text=header_action_label action_icon=header_action_icon extra_actions=extra_actions icon=header_icon search_url=search_url search_form=search_form search_results_url=index_results_url only %} {% endif %} {% endblock %} + +{% block listing %} + {% comment %} + DEPRECATED: This block override is for supporting views that have filters + but not using breadcrumbs (thus have no slim_header to put the filters in). + There is no longer such a view in Wagtail core, but we keep this block + until we can enforce the use of breadcrumbs in all listing views. + {% endcomment %} + {% if filters and not breadcrumbs_items %} +
+ {{ block.super }} + {% include "wagtailadmin/shared/filters.html" %} +
+ {% else %} + {{ block.super }} + {% endif %} +{% endblock %} diff --git a/wagtail/admin/templates/wagtailadmin/generic/listing.html b/wagtail/admin/templates/wagtailadmin/generic/listing.html index 450b8dfd8a..53d92e1921 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/listing.html +++ b/wagtail/admin/templates/wagtailadmin/generic/listing.html @@ -1,29 +1,23 @@ {% extends "wagtailadmin/generic/base.html" %} {% load i18n %} -{% block main_header %} - {% if not breadcrumbs_items %} - {% include "wagtailadmin/shared/header.html" with title=page_title subtitle=page_subtitle action_url=header_action_url action_text=header_action_label icon=header_icon only %} - {% endif %} -{% endblock %} - {% block content %} + {% comment %} + Override the content block instead of main_content so we get the full-width layout without the nice-padding. + However, this means we need to include the header block again (and only do {{ block.super }} inside it). + {% endcomment %} + {% block header %} {{ block.super }} {% endblock %} {% block listing %} -