0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Bring back snippet listing buttons

This commit is contained in:
Sage Abdullah 2022-06-06 12:43:01 +07:00 committed by Karl Hobley
parent 80d15637d8
commit 89fb9df3b7
3 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,14 @@
{% load wagtailsnippets_admin_tags %}
<td class="{% if column.classname %}{{ column.classname }} {% endif %}title">
<div class="title-wrapper">
{% if link_url %}
<a {% include "wagtailadmin/tables/attrs.html" with attrs=link_attrs %}>{{ value }}</a>
{% else %}
{{ value }}
{% endif %}
</div>
<ul class="actions">
{% snippet_listing_buttons instance %}
</ul>
</td>

View File

@ -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}

View File

@ -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),