0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Move lock/unlock to publish bar

This commit is contained in:
Dan Braghis 2020-06-05 10:05:21 +01:00 committed by Matt Westcott
parent 01926f62d6
commit 2153721426
4 changed files with 26 additions and 43 deletions

View File

@ -544,11 +544,14 @@ footer .preview {
}
.lock-status {
margin: 0 0.5em 0.5em 0;
display: inline-block;
margin: 0 .5em;
text-transform: uppercase;
width: 4em;
}
.lock-status.status-tag {
color: $color-teal;
.lock-indicator .button-toggle--on .icon {
fill: $color-red;
}

View File

@ -26,6 +26,7 @@
<script src="{% versioned_static 'wagtailadmin/js/vendor/urlify.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/workflow-action.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/workflow-status.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/lock-unlock-action.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/vendor/bootstrap-tooltip.js' %}"></script>
{% hook_output 'insert_editor_js' %}

View File

@ -10,44 +10,22 @@
{% url 'wagtailadmin_pages:lock' page.id as form_action %}
{% endif %}
<form action="{{ form_action }}" method="POST" class="lock-indicator {{ page.locked|yesno:'locked,unlocked' }}">
<span class="lock-status">
{% if page.locked %}
{% trans "This page is locked" %}
{% else %}
{% trans "This page is unlocked" %}
{% endif %}</span>
{% csrf_token %}
{% if page.locked %}
{% if page_perms.can_unlock %}
<input type="hidden" name="next" value="{% url 'wagtailadmin_pages:edit' page.id %}" />
<button
type="submit"
class="status-tag primary lock-status"
aria-label="{% trans 'Remove editor lock' %}">
{% trans "Unlock" %}
<div class="lock-indicator {{ page.locked|yesno:'locked,unlocked' }}">
{% if page.locked %}
{% if page_perms.can_unlock %}
<button class="button button-nobg button-strokeonhover" data-locking-action="{{ form_action }}" aria-label="{% trans 'Remove editor lock' %}">
{% trans "Unlock" as unlock_text %}
{% icon name="lock" title=unlock_text class_name="default" %}
{% trans "Locked" %}
</button>
{% else %}
<div class="lock-status">
({% trans "You don't have permission to unlock" %})
</div>
{% endif %}
{% else %}
{% if page_perms.can_lock %}
<input type="hidden" name="next" value="{% url 'wagtailadmin_pages:edit' page.id %}" />
<button
type="submit"
class="status-tag primary lock-status"
aria-label="{% trans 'Apply editor lock' %}">
{% trans "Lock" %}
</button>
{% else %}
<div class="lock-status">
({% trans "You don't have permission to lock" %})
</div>
{% endif %}
{% endif %}
</form>
{% else %}
{% if page_perms.can_lock %}
<button class="button button-nobg button-strokeonhover" data-locking-action="{{ form_action }}" aria-label="{% trans 'Apply editor lock' %}">
{% trans "Lock" as lock_text %}
{% icon name="lock-open" title=lock_text class_name="default" %}
{% trans "Unlocked" %}
</button>
{% endif %}
{% endif %}
</div>

View File

@ -80,6 +80,7 @@
{% endif %}
<li class="meta">
{% include "wagtailadmin/pages/_lock_switch.html" %}
</li>
{% block extra_footer_actions %}
{% endblock %}
@ -128,7 +129,6 @@
);
});
/* Tooltips used by the workflow status component */
$(function() {
$('[data-wagtail-tooltip]').tooltip({
@ -143,6 +143,7 @@
$(function() {
document.addEventListener('DOMContentLoaded', ActivateWorkflowActions('{{ csrf_token|escapejs }}'));
document.addEventListener('DOMContentLoaded', LockUnlockAction('{{ csrf_token|escapejs }}', '{% url 'wagtailadmin_pages:edit' page.id %}'));
})
</script>
{% endblock %}