mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-30 01:46:24 +01:00
Bring back snippet listing buttons
This commit is contained in:
parent
80d15637d8
commit
89fb9df3b7
@ -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>
|
@ -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}
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user