Skip to content

Commit

Permalink
Conditionally split the edit_translation html template based on version
Browse files Browse the repository at this point in the history
  • Loading branch information
zerolab committed Nov 6, 2023
1 parent 74c9aad commit a2d26d9
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,13 @@
<svg aria-hidden="true" class="icon icon-arrow-right w-w-4 w-h-4">
<use href="#icon-arrow-right"></use>
</svg>
{{ target_locale.get_display_name }}
{% if translations %}
{% if has_dropdown_tag %}
{{ target_locale.get_display_name }}
{% dropdown toggle_icon="dots-horizontal" toggle_aria_label=_("Translations") %}
{% for label, url in translations %}
<a href="{{ url }}">{{ label }}</a>
{% endfor %}
{% enddropdown %}
{% else %}
<div
class="c-dropdown t-inverted"
data-dropdown=""
style="display: inline-block"
>
<a
href="javascript:void(0)"
class="c-dropdown__button u-btn-current button button-small button-nobg text-notransform"
>
{{ target_locale.get_display_name }}
<div
data-dropdown-toggle=""
class="o-icon c-dropdown__toggle c-dropdown__togle--icon [ icon icon-arrow-down ]"
style="padding-left: 5px;"
>
<Icon name="arrow-down" />
<Icon name="arrow-up" />
</div>
</a>
<div class="t-dark">
<ul class="c-dropdown__menu u-toggle u-arrow u-arrow--tl u-background">
{% for label, url in translations %}
<li className="c-dropdown__item ">
<a href="{{ url }}" aria-label="" class="u-link is-live">
{{ label }}
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% else %}
{{ target_locale.get_display_name }}
{% dropdown toggle_icon="dots-horizontal" toggle_aria_label=_("Translations") %}
{% for label, url in translations %}
<a href="{{ url }}">{{ label }}</a>
{% endfor %}
{% enddropdown %}
{% endif %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{% extends "wagtailadmin/generic/edit.html" %}
{% load i18n wagtailadmin_tags %}

{% block bodyclass %}page-editor{% endblock %}

{% block titletag %}{% blocktrans with instance=translation.source.as_instance locale=translation.target_locale %}Translation of {{ instance }} into {{ locale }}{% endblocktrans %}{% endblock %}

{% block content %}
{% if is_page %}
<div class="w-sticky w-top-0 w-z-header">
{% include 'wagtailadmin/shared/headers/page_edit_header.html' with page=instance page_for_status=instance page_perms=page_perms content_type=instance.content_type %}
{% include "wagtailadmin/shared/side_panels.html" with page=instance page_for_status=instance page_perms=page_perms content_type=instance.content_type in_explorer=True %}
</div>
{% else %}
<div class="w-sticky w-top-0 w-z-header">
{% include 'wagtail_localize/admin/includes/generic_header.html' %}
</div>
{% include "wagtailadmin/shared/header.html" with title=instance icon="snippet" merged=1 only %}
{% endif %}

<header class="w-flex w-flex-col sm:w-flex-row w-items-center w-justify-between w-bg-grey-50 w-px-0 w-py-0 w-mb-0 w-relative w-top-0 w-min-h-slim-header">
<div class="w-pl-slim-header sm:w-pl-5 w-min-h-slim-header sm:w-pr-2 w-w-full w-flex-1 w-overflow-x-auto w-box-border">
<div class="w-flex w-flex-1 w-items-center w-overflow-hidden w-p-4 header-meta--locales">
{% if source_translation.editUrl %}
<a href="{{ source_translation.editUrl }}">{{ source_translation.locale.displayName }}</a>
{% else %}
{{ source_translation.locale.displayName }}
{% endif %}
<svg aria-hidden="true" class="icon icon-arrow-right w-w-4 w-h-4">
<use href="#icon-arrow-right"></use>
</svg>
{% if translations %}
<div class="c-dropdown t-inverted" data-dropdown="" style="display: inline-block">
<a
href="javascript:void(0)"
class="c-dropdown__button u-btn-current button button-small button-nobg text-notransform"
>
{{ target_locale.get_display_name }}
<div
data-dropdown-toggle=""
class="o-icon c-dropdown__toggle c-dropdown__togle--icon [ icon icon-arrow-down ]"
style="padding-left: 5px;"
>
{% icon name="arrow-down" %}
{% icon name="arrow-up" %}
</div>
</a>
<div class="t-dark">
<ul class="c-dropdown__menu u-toggle u-arrow u-arrow--tl u-background">
{% for label, url in translations %}
<li class="c-dropdown__item ">
<a href="{{ url }}" aria-label="" class="u-link is-live">
{{ label }}
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% else %}
{{ target_locale.get_display_name }}
{% endif %}
</div>
</div>
</header>
<div class="js-translation-editor" data-props="{{ props }}">
{# Generates the CSRF token hidden input. This is read by the JavaScript. #}
{% csrf_token %}
</div>
{% endblock %}

{% block extra_js %}
{% include "wagtailadmin/pages/_editor_js.html" %}

<script src="{% url 'wagtail_localize:javascript_catalog' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/page-chooser-modal.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/page-chooser.js' %}"></script>
<script src="{% versioned_static 'wagtailimages/js/image-chooser-modal.js' %}"></script>
<script src="{% versioned_static 'wagtailimages/js/image-chooser.js' %}"></script>
<script src="{% versioned_static 'wagtaildocs/js/document-chooser-modal.js' %}"></script>
<script src="{% versioned_static 'wagtaildocs/js/document-chooser.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/chooser-modal.js' %}"></script>
<script src="{% versioned_static 'wagtailsnippets/js/snippet-chooser.js' %}"></script>
<script src="{% versioned_static 'wagtail_localize/js/wagtail-localize.js' %}"></script>
{% endblock %}
Loading

0 comments on commit a2d26d9

Please sign in to comment.