diff --git a/wagtail/snippets/templates/wagtailsnippets/snippets/tables/title_cell.html b/wagtail/snippets/templates/wagtailsnippets/snippets/tables/title_cell.html new file mode 100644 index 0000000000..e7d5a08fa7 --- /dev/null +++ b/wagtail/snippets/templates/wagtailsnippets/snippets/tables/title_cell.html @@ -0,0 +1,14 @@ +{% load wagtailsnippets_admin_tags %} + + +
+ {% if link_url %} + {{ value }} + {% else %} + {{ value }} + {% endif %} +
+ + diff --git a/wagtail/snippets/templatetags/wagtailsnippets_admin_tags.py b/wagtail/snippets/templatetags/wagtailsnippets_admin_tags.py index 03250e87c3..54ebc2b35a 100644 --- a/wagtail/snippets/templatetags/wagtailsnippets_admin_tags.py +++ b/wagtail/snippets/templatetags/wagtailsnippets_admin_tags.py @@ -9,16 +9,16 @@ register = template.Library() "wagtailsnippets/snippets/listing_buttons.html", takes_context=True ) def snippet_listing_buttons(context, snippet): - next_url = context.request.path + next_url = context["request"].path button_hooks = hooks.get_hooks("register_snippet_listing_buttons") buttons = [] for hook in button_hooks: - buttons.extend(hook(snippet, context.request.user, next_url)) + buttons.extend(hook(snippet, context["request"].user, next_url)) buttons.sort() for hook in hooks.get_hooks("construct_snippet_listing_buttons"): - hook(buttons, snippet, context.request.user, context) + hook(buttons, snippet, context["request"].user, context) return {"snippet": snippet, "buttons": buttons} diff --git a/wagtail/snippets/views/snippets.py b/wagtail/snippets/views/snippets.py index 70db4b28fe..6ad5092db5 100644 --- a/wagtail/snippets/views/snippets.py +++ b/wagtail/snippets/views/snippets.py @@ -23,6 +23,7 @@ from wagtail.admin.ui.tables import ( Column, DateColumn, InlineActionsTable, + TitleColumn, UserColumn, ) from wagtail.admin.views.generic import CreateView, DeleteView, EditView, IndexView @@ -103,6 +104,10 @@ class Index(TemplateView): return super().get_context_data(snippet_types=snippet_types, **kwargs) +class SnippetTitleColumn(TitleColumn): + cell_template_name = "wagtailsnippets/snippets/tables/title_cell.html" + + class List(IndexView): view_name = "list" index_results_url_name = None @@ -113,6 +118,9 @@ class List(IndexView): # If true, returns just the 'results' include, for use in AJAX responses from search results_only = False + def _get_title_column(self, column_class=SnippetTitleColumn): + return super()._get_title_column(column_class) + def get_columns(self): return [ BulkActionsCheckboxColumn("checkbox", accessor=lambda obj: obj),