edit.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. {% extends "wagtailadmin/base.html" %}
  2. {% load wagtailadmin_tags %}
  3. {% load i18n %}
  4. {% load l10n %}
  5. {% block titletag %}{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
  6. {% block bodyclass %}page-editor {% if page.live %}page-is-live{% endif %} model-{{ content_type.model }} {% if page_locked %}page-locked{% endif %}{% endblock %}
  7. {% block content %}
  8. {% page_permissions page as page_perms %}
  9. <div id="comments">
  10. </div>
  11. <header class="merged tab-merged">
  12. {% explorer_breadcrumb page %}
  13. <div class="row">
  14. <h1 class="left col9 header-title" title="{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}{% endblocktrans %}">
  15. {{ page.get_admin_display_title }}
  16. </h1>
  17. <div class="right col3">
  18. {% include "wagtailadmin/pages/_page_view_live_tag.html" with page=page_for_status %}
  19. </div>
  20. </div>
  21. <ul class="row header-meta">
  22. {% include "wagtailadmin/shared/workflow_status.html" with page=page_for_status %}
  23. {% if page.get_latest_revision %}
  24. <li>
  25. <a href="{% url 'wagtailadmin_pages:history' page.id %}" class="button button-small button-nobg text-notransform">
  26. {% icon "history" class_name="default" %}
  27. {% trans "History" %}
  28. </a>
  29. </li>
  30. {% endif %}
  31. <li class="header-meta--type">
  32. {% icon name="doc-empty-inverse" class_name="default" %}
  33. {{ content_type.model_class.get_verbose_name }}
  34. </li>
  35. {% if locale %}
  36. <li class="header-meta--locale">
  37. {% include "wagtailadmin/shared/locale_selector.html" %}
  38. </li>
  39. {% endif %}
  40. </ul>
  41. </header>
  42. {% block form %}
  43. <form id="page-edit-form" action="{% url 'wagtailadmin_pages:edit' page.id %}" method="POST" novalidate{% if form.is_multipart %} enctype="multipart/form-data"{% endif %}>
  44. {% csrf_token %}
  45. <input type="hidden" name="next" value="{{ next }}">
  46. {{ edit_handler.render_form_content }}
  47. {% if is_revision %}
  48. <input type="hidden" name="revision" value="{{ revision.id|unlocalize }}" />
  49. {% endif %}
  50. <footer>
  51. <nav aria-label="{% trans 'Actions' %}">
  52. <ul>
  53. <li class="actions actions--primary">
  54. <div class="dropdown dropup dropdown-button match-width {% if is_revision %}warning{% endif %}">
  55. {{ action_menu.render_html }}
  56. </div>
  57. </li>
  58. {% if preview_modes %}
  59. <li class="preview">
  60. {% trans 'Preview' as preview_label %}
  61. {% if preview_modes|length > 1 %}
  62. <div class="dropdown dropup dropdown-button match-width">
  63. {% include "wagtailadmin/pages/_preview_button_on_edit.html" with label=preview_label icon=1 %}
  64. <div class="dropdown-toggle">{% icon name="arrow-up" %}</div>
  65. <ul>
  66. {% for mode_name, mode_display_name in preview_modes %}
  67. <li>
  68. {% include "wagtailadmin/pages/_preview_button_on_edit.html" with mode=mode_name label=mode_display_name %}
  69. </li>
  70. {% endfor %}
  71. </ul>
  72. </div>
  73. {% else %}
  74. {% include "wagtailadmin/pages/_preview_button_on_edit.html" with label=preview_label icon=1 %}
  75. {% endif %}
  76. </li>
  77. {% endif %}
  78. {% block extra_footer_actions %}
  79. {% endblock %}
  80. </ul>
  81. </nav>
  82. </footer>
  83. </form>
  84. {% endblock %}
  85. {% endblock %}
  86. {% block extra_css %}
  87. {{ block.super }}
  88. {% include "wagtailadmin/pages/_editor_css.html" %}
  89. {{ edit_handler.form.media.css }}
  90. {{ action_menu.media.css }}
  91. {% endblock %}
  92. {% block extra_js %}
  93. {{ block.super }}
  94. {% include "wagtailadmin/pages/_editor_js.html" %}
  95. {% comment %}
  96. Additional js from widgets media. Allows for custom widgets in admin panel.
  97. {% endcomment %}
  98. {{ edit_handler.form.media.js }}
  99. {{ action_menu.media.js }}
  100. {% comment %}
  101. Additional HTML code that edit handlers define through 'html_declarations'. (Technically this isn't JavaScript, but it will generally be data that exists for JavaScript to work with...)
  102. {% endcomment %}
  103. {{ edit_handler.html_declarations }}
  104. {{ comments_author|json_script:"comments-author" }}
  105. <button type="button" id="comment-icon" data-annotation class="button button-secondary button-small u-hidden">{% icon name='comment' class_name='initial' %}</button>
  106. <script>
  107. $(function() {
  108. {% if publishing_will_cancel_workflow %}
  109. /* Make user confirm before publishing the page if it will cancel an ongoing workflow */
  110. let cancellationConfirmed = false;
  111. $('[name=action-publish]').click((e) => {
  112. if (!cancellationConfirmed) {
  113. e.stopImmediatePropagation();
  114. e.preventDefault();
  115. ModalWorkflow({
  116. 'url': "{% url 'wagtailadmin_pages:confirm_workflow_cancellation' page.id %}",
  117. 'onload': {
  118. 'confirm': function(modal, jsonData) {
  119. $('[data-confirm-cancellation]', modal.body).click((event) => {
  120. cancellationConfirmed = true;
  121. modal.close();
  122. e.currentTarget.click();
  123. })
  124. $('[data-cancel-dialog]', modal.body).click((event) => {
  125. modal.close();
  126. })
  127. },
  128. 'no_confirmation_needed': function(modal, jsonData) {
  129. modal.close();
  130. cancellationConfirmed = true;
  131. e.currentTarget.click();
  132. }
  133. },
  134. });
  135. }
  136. });
  137. {% endif %}
  138. /* Make user confirm before leaving the editor if there are unsaved changes */
  139. {% trans "This page has unsaved changes." as confirmation_message %}
  140. enableDirtyFormCheck(
  141. '#page-edit-form',
  142. {
  143. confirmationMessage: '{{ confirmation_message|escapejs }}',
  144. {% if has_unsaved_changes %}
  145. alwaysDirty: true,
  146. {% endif %}
  147. }
  148. );
  149. /* Tooltips used by the workflow status component */
  150. $('[data-wagtail-tooltip]').tooltip({
  151. animation: false,
  152. title: function() {
  153. return $(this).attr('data-wagtail-tooltip');
  154. },
  155. trigger: 'hover',
  156. placement: 'bottom',
  157. });
  158. ActivateWorkflowActionsForEditView('#page-edit-form');
  159. LockUnlockAction('{{ csrf_token|escapejs }}', '{% url 'wagtailadmin_pages:edit' page.id %}');
  160. });
  161. </script>
  162. <script>
  163. window.comments.initComments([]);
  164. </script>
  165. {% endblock %}