mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 01:22:07 +01:00
Add status side panel to generic CreateView and simplify snippets CreateView
This commit is contained in:
parent
47d6a8e01f
commit
dae20c2038
@ -20,6 +20,11 @@
|
|||||||
&__emphasise-span-tags span {
|
&__emphasise-span-tags span {
|
||||||
color: theme('colors.warning.100');
|
color: theme('colors.warning.100');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't apply horizontal margins if nice-padding is applied in the parent
|
||||||
|
.nice-padding & {
|
||||||
|
margin-inline: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer__container {
|
.footer__container {
|
||||||
|
@ -43,10 +43,10 @@
|
|||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{{ form.media.js }}
|
{{ media.js }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{{ form.media.css }}
|
{{ media.css }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -588,10 +588,25 @@ class CreateView(
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
self.form = context.get("form")
|
||||||
|
side_panels = self.get_side_panels()
|
||||||
context["action_url"] = self.get_add_url()
|
context["action_url"] = self.get_add_url()
|
||||||
context["submit_button_label"] = self.submit_button_label
|
context["submit_button_label"] = self.submit_button_label
|
||||||
|
context["side_panels"] = side_panels
|
||||||
|
context["media"] += side_panels.media
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
def get_side_panels(self):
|
||||||
|
side_panels = [
|
||||||
|
StatusSidePanel(
|
||||||
|
self.form.instance,
|
||||||
|
self.request,
|
||||||
|
locale=self.locale,
|
||||||
|
translations=self.translations,
|
||||||
|
)
|
||||||
|
]
|
||||||
|
return MediaContainer(side_panels)
|
||||||
|
|
||||||
def get_translations(self):
|
def get_translations(self):
|
||||||
add_url = self.get_add_url()
|
add_url = self.get_add_url()
|
||||||
return [
|
return [
|
||||||
@ -833,11 +848,10 @@ class EditView(
|
|||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
self.form = context.get("form")
|
self.form = context.get("form")
|
||||||
side_panels = self.get_side_panels()
|
side_panels = self.get_side_panels()
|
||||||
media = context.get("media") + side_panels.media
|
|
||||||
context["action_url"] = self.get_edit_url()
|
context["action_url"] = self.get_edit_url()
|
||||||
context["history_url"] = self.get_history_url()
|
context["history_url"] = self.get_history_url()
|
||||||
context["side_panels"] = side_panels
|
context["side_panels"] = side_panels
|
||||||
context["media"] = media
|
context["media"] += side_panels.media
|
||||||
context["submit_button_label"] = self.submit_button_label
|
context["submit_button_label"] = self.submit_button_label
|
||||||
context["can_delete"] = (
|
context["can_delete"] = (
|
||||||
self.permission_policy is None
|
self.permission_policy is None
|
||||||
|
@ -1,37 +1,26 @@
|
|||||||
{% extends "wagtailadmin/base.html" %}
|
{% extends "wagtailadmin/generic/create.html" %}
|
||||||
{% load i18n wagtailadmin_tags %}
|
{% load i18n wagtailadmin_tags %}
|
||||||
{% block titletag %}{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}New {{ snippet_type_name }}{% endblocktrans %}{% endblock %}
|
|
||||||
{% block bodyclass %}editor-view{% endblock %}
|
{% block slim_header %}
|
||||||
{% block content %}
|
{% comment %}
|
||||||
|
We can't use the `only` keyword yet, because the SnippetStatusSidePanel still rely on some
|
||||||
|
context variables from the view. As a result, we can't reuse the include from the generic
|
||||||
|
template and have to copy it here without the `only` keyword.
|
||||||
|
{% endcomment %}
|
||||||
{% include 'wagtailadmin/shared/headers/slim_header.html' with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url %}
|
{% include 'wagtailadmin/shared/headers/slim_header.html' with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url %}
|
||||||
|
|
||||||
{% trans "New" as new_str %}
|
|
||||||
{% include "wagtailadmin/shared/header.html" with title=new_str subtitle=model_opts.verbose_name icon=header_icon merged=1 only %}
|
|
||||||
|
|
||||||
<form action="{{ action_url }}" method="POST" novalidate{% if form.is_multipart %} enctype="multipart/form-data"{% endif %} data-edit-form>
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<div class="nice-padding">
|
|
||||||
{{ panel.render_form_content }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="footer">
|
|
||||||
<nav class="actions actions--primary footer__container w-grid" aria-label="{% trans 'Actions' %}">
|
|
||||||
{{ action_menu.render_html }}
|
|
||||||
</nav>
|
|
||||||
</footer>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block actions %}
|
||||||
{{ block.super }}
|
<footer class="footer">
|
||||||
{{ media.css }}
|
<nav class="actions actions--primary footer__container w-grid" aria-label="{% trans 'Actions' %}">
|
||||||
|
{{ action_menu.render_html }}
|
||||||
|
</nav>
|
||||||
|
</footer>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% include "wagtailadmin/pages/_editor_js.html" %}
|
{% include "wagtailadmin/pages/_editor_js.html" %}
|
||||||
{{ media.js }}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Set wagtailConfig.ACTIVE_CONTENT_LOCALE if this is a translated page
|
// Set wagtailConfig.ACTIVE_CONTENT_LOCALE if this is a translated page
|
||||||
|
@ -87,7 +87,7 @@ class TestCustomIcon(BaseSnippetViewSetTests):
|
|||||||
# TODO: Some of these views have been migrated to use the slim_header
|
# TODO: Some of these views have been migrated to use the slim_header
|
||||||
# only, so there is no header_icon anymore.
|
# only, so there is no header_icon anymore.
|
||||||
# ("list", []),
|
# ("list", []),
|
||||||
("add", []),
|
# ("add", []),
|
||||||
("edit", [pk]),
|
("edit", [pk]),
|
||||||
("delete", [pk]),
|
("delete", [pk]),
|
||||||
# ("usage", [pk]),
|
# ("usage", [pk]),
|
||||||
|
@ -271,21 +271,9 @@ class CreateView(generic.CreateEditViewOptionalFeaturesMixin, generic.CreateView
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
self.form = context.get("form")
|
|
||||||
action_menu = self._get_action_menu()
|
action_menu = self._get_action_menu()
|
||||||
side_panels = self.get_side_panels()
|
context["media"] += action_menu.media
|
||||||
media = context.get("media") + MediaContainer([action_menu, side_panels]).media
|
context["action_menu"] = action_menu
|
||||||
|
|
||||||
context.update(
|
|
||||||
{
|
|
||||||
"model_opts": self.model._meta,
|
|
||||||
"action_menu": action_menu,
|
|
||||||
"side_panels": side_panels,
|
|
||||||
"media": media,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user