0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Wrap JS in missing callbacks for DOMContentLoaded

Until now, those calls have been executed synchronously with the call of addEventListener.
Fixes #9528
Fixes issue where home page lock/unlock would not work at all (data-url should be used)
This commit is contained in:
Stefan Hammer 2022-10-28 09:36:28 +02:00 committed by LB (Ben Johnston)
parent 1fe9581548
commit 5584b44ca7
3 changed files with 7 additions and 3 deletions

View File

@ -31,7 +31,7 @@
</div>
<ul class="actions">
{% if can_remove_locks %}
<li><button data-action-lock-unlock="{% url 'wagtailadmin_pages:unlock' page.id %}" class="button button-small button-secondary">{% trans "Unlock" %}</button></li>
<li><button data-action-lock-unlock data-url="{% url 'wagtailadmin_pages:unlock' page.id %}" class="button button-small button-secondary">{% trans "Unlock" %}</button></li>
{% endif %}
<li><a href="{% url 'wagtailadmin_pages:edit' page.id %}" class="button button-small button-secondary">{% trans "Edit" %}</a></li>
{% if page.has_unpublished_changes and page.is_previewable %}
@ -55,6 +55,6 @@
{% endpanel %}
<script src="{% versioned_static 'wagtailadmin/js/lock-unlock-action.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', LockUnlockAction('{{ csrf_token|escapejs }}', '{% url 'wagtailadmin_home' %}'));
document.addEventListener('DOMContentLoaded', () => LockUnlockAction('{{ csrf_token|escapejs }}', '{% url 'wagtailadmin_home' %}'));
</script>
{% endif %}

View File

@ -84,7 +84,7 @@
<script src="{% versioned_static 'wagtailadmin/js/workflow-action.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/vendor/bootstrap-tooltip.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', ActivateWorkflowActionsForDashboard('{{ csrf_token|escapejs }}'));
document.addEventListener('DOMContentLoaded', () => ActivateWorkflowActionsForDashboard('{{ csrf_token|escapejs }}'));
/* Tooltips used by the workflow status component */
$(function() {
$('[data-wagtail-tooltip]').tooltip({

View File

@ -25,6 +25,10 @@
{% block extra_js %}
{{ block.super }}
<script src="{% versioned_static 'wagtailadmin/js/lock-unlock-action.js' %}"></script>
<script>
document.addEventListener('DOMContentLoaded', () => LockUnlockAction('{{ csrf_token|escapejs }}', '{% url 'wagtailadmin_home' %}'));
</script>
{% comment %} modal-workflow is required by the view restrictions interface {% endcomment %}
<script src="{% versioned_static 'wagtailadmin/js/modal-workflow.js' %}"></script>