mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
FIXED #5899 -- Allowed having the collapsible fieldset and inlines expended on page load.
This commit is contained in:
parent
0596263c31
commit
deaaa441c5
8 changed files with 44 additions and 5 deletions
1
AUTHORS
1
AUTHORS
|
@ -1002,6 +1002,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Terry Huang <terryh.tp@gmail.com>
|
||||
thebjorn <bp@datakortet.no>
|
||||
Thejaswi Puthraya <thejaswi.puthraya@gmail.com>
|
||||
Theo Poncelet <theo.poncelet99@gmail.com>
|
||||
Thijs van Dien <thijs@vandien.net>
|
||||
Thom Wiggers
|
||||
Thomas Chaumeny <t.chaumeny@gmail.com>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
data-inline-type="stacked"
|
||||
data-inline-formset="{{ inline_admin_formset.inline_formset_data }}">
|
||||
<fieldset class="module {{ inline_admin_formset.classes }}" aria-labelledby="{{ inline_admin_formset.formset.prefix }}-heading">
|
||||
{% if inline_admin_formset.is_collapsible %}<details><summary>{% endif %}
|
||||
{% if inline_admin_formset.is_collapsible %}<details {% if 'collapse-open' in inline_admin_formset.classes %}open{% endif %}><summary>{% endif %}
|
||||
<h2 id="{{ inline_admin_formset.formset.prefix }}-heading" class="inline-heading">
|
||||
{% if inline_admin_formset.formset.max_num == 1 %}
|
||||
{{ inline_admin_formset.opts.verbose_name|capfirst }}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
|
||||
{{ inline_admin_formset.formset.management_form }}
|
||||
<fieldset class="module {{ inline_admin_formset.classes }}" aria-labelledby="{{ inline_admin_formset.formset.prefix }}-heading">
|
||||
{% if inline_admin_formset.is_collapsible %}<details><summary>{% endif %}
|
||||
{% if inline_admin_formset.is_collapsible %}<details {% if 'collapse-open' in inline_admin_formset.classes %}open{% endif %}><summary>{% endif %}
|
||||
<h2 id="{{ inline_admin_formset.formset.prefix }}-heading" class="inline-heading">
|
||||
{% if inline_admin_formset.formset.max_num == 1 %}
|
||||
{{ inline_admin_formset.opts.verbose_name|capfirst }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<fieldset class="module aligned {{ fieldset.classes }}"{% if fieldset.name %} aria-labelledby="{{ prefix }}-{{ id_prefix}}-{{ id_suffix }}-heading"{% endif %}>
|
||||
{% if fieldset.name %}
|
||||
{% if fieldset.is_collapsible %}<details><summary>{% endif %}
|
||||
{% if fieldset.is_collapsible %}<details {% if 'collapse-open' in fieldset.classes %}open{% endif %}><summary>{% endif %}
|
||||
<h{{ heading_level|default:2 }} id="{{ prefix }}-{{ id_prefix}}-{{ id_suffix }}-heading" class="fieldset-heading">{{ fieldset.name }}</h{{ heading_level|default:2 }}>
|
||||
{% if fieldset.is_collapsible %}</summary>{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -430,7 +430,8 @@ subclass::
|
|||
space in the admin interface.
|
||||
Fieldsets with a name and the ``collapse`` style will be initially
|
||||
collapsed, using an expandable widget with a toggle for switching
|
||||
their visibility.
|
||||
their visibility. Add the ``collapse-open`` class to have the fieldset
|
||||
initially expanded.
|
||||
|
||||
* ``description``
|
||||
A string of optional extra text to be displayed at the top of each
|
||||
|
@ -2325,7 +2326,8 @@ The ``InlineModelAdmin`` class adds or customizes:
|
|||
A list or tuple containing extra CSS classes to apply to the fieldset that
|
||||
is rendered for the inlines. Defaults to ``None``. As with classes
|
||||
configured in :attr:`~ModelAdmin.fieldsets`, inlines with a ``collapse``
|
||||
class will be initially collapsed using an expandable widget.
|
||||
class will be initially collapsed using an expandable widget. Add the
|
||||
``collapse-open`` class to have the inline initially expanded.
|
||||
|
||||
.. attribute:: InlineModelAdmin.extra
|
||||
|
||||
|
|
|
@ -238,6 +238,13 @@ class ArticleAdmin(ArticleAdminWithExtraUrl):
|
|||
{"classes": ("wide",), "fields": ("date", "section", "sub_section")},
|
||||
),
|
||||
("이름", {"fields": ("another_section",)}),
|
||||
(
|
||||
"Collapsible open fields",
|
||||
{
|
||||
"classes": ("collapse", "collapse-open"),
|
||||
"fields": ("collapsible_open_field",),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
# These orderings aren't particularly useful but show that expressions can
|
||||
|
|
|
@ -46,6 +46,7 @@ class Article(models.Model):
|
|||
sub_section = models.ForeignKey(
|
||||
Section, models.SET_NULL, null=True, blank=True, related_name="+"
|
||||
)
|
||||
collapsible_open_field = models.TextField(blank=True, default="")
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
|
|
@ -6127,6 +6127,34 @@ class SeleniumTests(AdminSeleniumTestCase):
|
|||
self.assertTrue(self.selenium.find_element(By.ID, "id_title").is_displayed())
|
||||
self.take_screenshot("expanded")
|
||||
|
||||
@screenshot_cases(["desktop_size", "mobile_size", "dark", "high_contrast"])
|
||||
def test_collapsible_open_fieldset(self):
|
||||
"""
|
||||
The 'collapse-open' class in fieldsets definition allows showing
|
||||
on load the appropriate field section.
|
||||
"""
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
self.admin_login(
|
||||
username="super", password="secret", login_url=reverse("admin:index")
|
||||
)
|
||||
self.selenium.get(
|
||||
self.live_server_url + reverse("admin:admin_views_article_add")
|
||||
)
|
||||
self.assertTrue(
|
||||
self.selenium.find_element(
|
||||
By.ID, "id_collapsible_open_field"
|
||||
).is_displayed()
|
||||
)
|
||||
self.take_screenshot("collapsible-open-expanded")
|
||||
self.selenium.find_elements(By.TAG_NAME, "summary")[1].click()
|
||||
self.assertFalse(
|
||||
self.selenium.find_element(
|
||||
By.ID, "id_collapsible_open_field"
|
||||
).is_displayed()
|
||||
)
|
||||
self.take_screenshot("collapsible-open-collapsed")
|
||||
|
||||
@screenshot_cases(["desktop_size", "mobile_size", "rtl", "dark", "high_contrast"])
|
||||
def test_selectbox_height_collapsible_fieldset(self):
|
||||
from selenium.webdriver.common.by import By
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue