Skip to content

Commit

Permalink
Templates need to be conditional based on the Wagtail version
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmoreton committed Dec 24, 2024
1 parent ab128aa commit ffb3fb3
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 16 deletions.
5 changes: 4 additions & 1 deletion wagtailmenus/menuadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class MainMenuAdmin(SnippetViewSet):
index_view_class = MainMenuIndexView

edit_view_class = MainMenuEditView
edit_template_name = "wagtailmenus/mainmenu_edit.html"
if WAGTAIL_VERSION < (6, 3):
edit_template_name = "wagtailmenus/mainmenu_edit.html"
else:
edit_template_name = "wagtailmenus/wagtail_63/mainmenu_edit.html"
error_message = _("The menu could not be saved due to errors.")

copy_view_enabled = False
Expand Down
14 changes: 14 additions & 0 deletions wagtailmenus/templates/wagtailmenus/includes/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<header class="w-header">
<div class="row nice-padding">
<div class="left">
<div class="col header-title">
<h1 class="w-header__title" id="header-title">
<svg class="icon icon-list-ol w-header__glyph" aria-hidden="true"><use href="#icon-list-ol"></use></svg>
{{ title }}{% if subtitle %} <span>{{ subtitle }}</span>{% endif %}</h1>
</div>
</div>
<div class="right">
{% block right_content %}{% endblock %}
</div>
</div>
</header>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% if site_switcher %}
<div class="w-field__wrapper " data-field-wrapper="">
<form method="get" id="settings-site-switch">
<label class="w-field__label" for="{{ site_switcher.site.id_for_label }}" id="{{ site_switcher.site.id_for_label }}-label">
Site: <span class="w-required-mark">*</span>
</label>
<div class="w-field__input" data-field-input="">
{{ site_switcher.site }}
</div>
</form>
</div>
{% endif %}
{% extends 'wagtailmenus/includes/header.html' %}

{% block right_content %}
{% if site_switcher %}
<form method="get" id="settings-site-switch">
<label for="{{ site_switcher.site.id_for_label }}">
Site:
</label>
{{ site_switcher.site }}
</form>
{% endif %}
{% endblock %}
29 changes: 26 additions & 3 deletions wagtailmenus/templates/wagtailmenus/mainmenu_edit.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
{% extends "wagtailadmin/generic/edit.html" %}
{% extends "wagtailadmin/base.html" %}
{% load wagtailadmin_tags i18n %}
{% block titletag %}{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}Editing {{ snippet_type_name }} - {{ object }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}{% if locked_for_user %}content-locked{% endif %}{% endblock %}
{% block content %}
{% include 'wagtailadmin/shared/headers/slim_header.html' %}

{% block main_content %}
{% include "wagtailmenus/includes/header_with_site_switcher.html" with title=object icon=header_icon merged=1 %}
{{ block.super }}

<div class="row row-flush">

<div class="{% if uc_enabled %}col10 divider-after{% else %}col12{% endif %}">
<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 aria-label="{% trans 'Actions' %}">
<ul>
<li class="actions actions--primary footer__container">
<div class="dropdown dropup dropdown-button match-width {% if view.view_name == 'revisions_revert' %}warning{% endif %}">
{{ action_menu.render_html }}
</div>
</li>
</ul>
</nav>
</footer>
</form>
</div>
</div>
{% endblock %}

{% block extra_css %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% if site_switcher %}
<div class="w-field__wrapper " data-field-wrapper="">
<form method="get" id="settings-site-switch">
<label class="w-field__label" for="{{ site_switcher.site.id_for_label }}" id="{{ site_switcher.site.id_for_label }}-label">
Site: <span class="w-required-mark">*</span>
</label>
<div class="w-field__input" data-field-input="">
{{ site_switcher.site }}
</div>
</form>
</div>
{% endif %}
34 changes: 34 additions & 0 deletions wagtailmenus/templates/wagtailmenus/wagtail_63/mainmenu_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "wagtailadmin/generic/edit.html" %}
{% load wagtailadmin_tags i18n %}
{% block titletag %}{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}Editing {{ snippet_type_name }} - {{ object }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}{% if locked_for_user %}content-locked{% endif %}{% endblock %}

{% block main_content %}
{% include "wagtailmenus/wagtail_63/includes/header_with_site_switcher.html" with title=object icon=header_icon merged=1 %}
{{ block.super }}
{% endblock %}

{% block extra_css %}
{{ block.super }}
{{ media.css }}
{{ view.media.css }}
{% endblock %}
{% block extra_js %}
{{ block.super }}
{% include "wagtailadmin/pages/_editor_js.html" %}
{{ media.js }}
{{ view.media.js }}

<script>
// Set wagtailConfig.ACTIVE_CONTENT_LOCALE if this is a translated page
// This value may be used by JS widgets on the form
{% if locale %}
window.wagtailConfig = window.wagtailConfig || {};
window.wagtailConfig.ACTIVE_CONTENT_LOCALE = '{{ locale.language_code|escapejs }}';
{% endif %}
</script>

{% if workflow_enabled %}
{% include "wagtailadmin/shared/_workflow_init.html" %}
{% endif %}
{% endblock %}

0 comments on commit ffb3fb3

Please sign in to comment.