kopia lustrzana https://github.com/wagtail/wagtail
Add missing extra CSS and JS defined by filters in snippets listing view
- Fixes #10254pull/10257/head
rodzic
5f154a5a51
commit
9f33ef3137
|
@ -50,6 +50,7 @@ Changelog
|
|||
* Fix: Fix select elements expanding beyond their container when using a long option label (Sage Abdullah)
|
||||
* Fix: Fix timezone handling of `TemplateResponse`s for users with a custom timezone (Stefan Hammer, Sage Abdullah)
|
||||
* Fix: Ensure TableBlock initialisation correctly runs after load and its width is aligned with the parent panel (Dan Braghis)
|
||||
* Fix: Ensure that the JavaScript media files are loaded by default in Snippet index listings for date fields (Sage Abdullah)
|
||||
* Docs: Add code block to make it easier to understand contribution docs (Suyash Singh)
|
||||
* Docs: Add new "Icons" page for icons customisation and reuse across the admin interface (Coen van der Kamp)
|
||||
* Docs: Fix broken formatting for MultiFieldPanel / FieldRowPanel permission kwarg docs (Matt Westcott)
|
||||
|
|
|
@ -67,6 +67,7 @@ Support for adding custom validation logic to StreamField blocks has been formal
|
|||
* Fix select elements expanding beyond their container when using a long option label (Sage Abdullah)
|
||||
* Fix timezone handling of `TemplateResponse`s for users with a custom timezone (Stefan Hammer, Sage Abdullah)
|
||||
* Ensure TableBlock initialisation correctly runs after load and its width is aligned with the parent panel (Dan Braghis)
|
||||
* Ensure that the JavaScript media files are loaded by default in Snippet index listings for date fields (Sage Abdullah)
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
|
@ -332,6 +332,7 @@ class IndexView(
|
|||
|
||||
index_url = self.get_index_url()
|
||||
table = self.get_table(context["object_list"], base_url=index_url)
|
||||
context["media"] = table.media
|
||||
|
||||
context["can_add"] = (
|
||||
self.permission_policy is None
|
||||
|
@ -346,9 +347,9 @@ class IndexView(
|
|||
context["is_filtering"] = any(
|
||||
self.request.GET.get(f) for f in set(self.filters.get_fields())
|
||||
)
|
||||
context["media"] += self.filters.form.media
|
||||
|
||||
context["table"] = table
|
||||
context["media"] = table.media
|
||||
context["index_url"] = index_url
|
||||
context["is_paginated"] = bool(self.paginate_by)
|
||||
context["is_searchable"] = self.is_searchable
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% extends "wagtailadmin/generic/index.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% blocktrans trimmed with snippet_type_name_plural=model_opts.verbose_name_plural|capfirst %}Snippets {{ snippet_type_name_plural }}{% endblocktrans %}{% endblock %}
|
||||
{% block bodyclass %}model-{{ model_opts.model_name }}{% endblock %}
|
||||
|
@ -13,6 +13,7 @@
|
|||
window.wagtailConfig.BULK_ACTION_ITEM_TYPE = 'SNIPPET';
|
||||
</script>
|
||||
<script defer src="{% versioned_static 'wagtailadmin/js/bulk-actions.js' %}"></script>
|
||||
{{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -24,6 +24,7 @@ from wagtail import hooks
|
|||
from wagtail.admin.admin_url_finder import AdminURLFinder
|
||||
from wagtail.admin.forms import WagtailAdminModelForm
|
||||
from wagtail.admin.panels import FieldPanel, ObjectList, get_edit_handler
|
||||
from wagtail.admin.staticfiles import versioned_static
|
||||
from wagtail.blocks.field_block import FieldBlockAdapter
|
||||
from wagtail.models import Locale, ModelLogEntry, Revision
|
||||
from wagtail.signals import published, unpublished
|
||||
|
@ -531,6 +532,14 @@ class TestSnippetListViewWithFilterSet(WagtailTestUtils, TestCase):
|
|||
FilterableSnippet.objects.create(text="From Indonesia", country_code="ID")
|
||||
FilterableSnippet.objects.create(text="From the UK", country_code="UK")
|
||||
|
||||
def test_get_include_filters_form_media(self):
|
||||
response = self.get()
|
||||
html = response.content.decode()
|
||||
datetime_js = versioned_static("wagtailadmin/js/date-time-chooser.js")
|
||||
|
||||
# The script file for the date time chooser should be included
|
||||
self.assertTagInHTML(f'<script src="{datetime_js}"></script>', html)
|
||||
|
||||
def test_unfiltered_no_results(self):
|
||||
response = self.get()
|
||||
add_url = reverse("wagtailsnippets_snippetstests_filterablesnippet:add")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.2b1 on 2023-03-21 14:17
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("snippetstests", "0008_filterablesnippet"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="filterablesnippet",
|
||||
name="some_date",
|
||||
field=models.DateField(auto_now=True),
|
||||
),
|
||||
]
|
|
@ -72,6 +72,7 @@ class FilterableSnippet(index.Indexed, models.Model):
|
|||
|
||||
text = models.CharField(max_length=255)
|
||||
country_code = models.CharField(max_length=2, choices=CountryCode.choices)
|
||||
some_date = models.DateField(auto_now=True)
|
||||
|
||||
search_fields = [
|
||||
index.SearchField("text"),
|
||||
|
@ -91,7 +92,7 @@ class FilterableSnippet(index.Indexed, models.Model):
|
|||
class FilterableSnippetFilterSet(WagtailFilterSet):
|
||||
class Meta:
|
||||
model = FilterableSnippet
|
||||
fields = ["country_code"]
|
||||
fields = ["country_code", "some_date"]
|
||||
|
||||
|
||||
@register_snippet
|
||||
|
|
Ładowanie…
Reference in New Issue