kopia lustrzana https://github.com/wagtail/wagtail
Pass aria-description to table
rodzic
61168d62fa
commit
910490ae2f
|
@ -1,6 +1,6 @@
|
||||||
{% load wagtailadmin_tags %}
|
{% load wagtailadmin_tags %}
|
||||||
|
|
||||||
<table {% if table.classname %}class="{{ table.classname }}"{% endif %}>
|
<table{% include "wagtailadmin/tables/attrs.html" with attrs=table.attrs %}>
|
||||||
{% if table.has_column_widths %}
|
{% if table.has_column_widths %}
|
||||||
{% for column in table.columns.values %}
|
{% for column in table.columns.values %}
|
||||||
<col {% if column.width %}width="{{ column.width }}"{% endif %} />
|
<col {% if column.width %}width="{{ column.width }}"{% endif %} />
|
||||||
|
|
|
@ -356,6 +356,7 @@ class Table(Component):
|
||||||
base_url=None,
|
base_url=None,
|
||||||
ordering=None,
|
ordering=None,
|
||||||
classname=None,
|
classname=None,
|
||||||
|
attrs=None,
|
||||||
):
|
):
|
||||||
self.columns = OrderedDict([(column.name, column) for column in columns])
|
self.columns = OrderedDict([(column.name, column) for column in columns])
|
||||||
self.data = data
|
self.data = data
|
||||||
|
@ -365,6 +366,7 @@ class Table(Component):
|
||||||
self.ordering = ordering
|
self.ordering = ordering
|
||||||
if classname is not None:
|
if classname is not None:
|
||||||
self.classname = classname
|
self.classname = classname
|
||||||
|
self.base_attrs = attrs or {}
|
||||||
|
|
||||||
def get_context_data(self, parent_context):
|
def get_context_data(self, parent_context):
|
||||||
context = super().get_context_data(parent_context)
|
context = super().get_context_data(parent_context)
|
||||||
|
@ -388,6 +390,12 @@ class Table(Component):
|
||||||
def row_count(self):
|
def row_count(self):
|
||||||
return len(self.data)
|
return len(self.data)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def attrs(self):
|
||||||
|
attrs = self.base_attrs.copy()
|
||||||
|
attrs["class"] = self.classname
|
||||||
|
return attrs
|
||||||
|
|
||||||
def get_row_classname(self, instance):
|
def get_row_classname(self, instance):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ from django.conf import settings
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from wagtail import hooks
|
from wagtail import hooks
|
||||||
|
@ -168,6 +169,12 @@ class IndexView(PermissionCheckedMixin, BaseListingView):
|
||||||
kwargs = super().get_table_kwargs()
|
kwargs = super().get_table_kwargs()
|
||||||
kwargs["use_row_ordering_attributes"] = self.show_ordering_column
|
kwargs["use_row_ordering_attributes"] = self.show_ordering_column
|
||||||
kwargs["parent_page"] = self.parent_page
|
kwargs["parent_page"] = self.parent_page
|
||||||
|
if self.show_ordering_column:
|
||||||
|
kwargs["attrs"] = {
|
||||||
|
"aria-description": gettext(
|
||||||
|
"Press enter to select an item, use up and down arrows to move the item, press enter to complete the move or escape to cancel the current move."
|
||||||
|
)
|
||||||
|
}
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
Ładowanie…
Reference in New Issue