Fix page reordering in Wagtail Admin

pull/665/head
Tom Talbot 2014-10-02 11:26:33 +01:00
rodzic c3b4bb29c1
commit 065a912b37
2 zmienionych plików z 13 dodań i 7 usunięć

Wyświetl plik

@ -9,12 +9,12 @@
{% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page %} {% include "wagtailadmin/shared/breadcrumb.html" with page=parent_page %}
</header> </header>
<form id="page-reorder-form"> <form id="page-reorder-form">
{% csrf_token %} {% csrf_token %}
{% page_permissions parent_page as parent_page_perms %} {% page_permissions parent_page as parent_page_perms %}
{% include "wagtailadmin/pages/list.html" with sortable=1 allow_navigation=1 full_width=1 parent_page=parent_page orderable=parent_page_perms.can_reorder_children %} {% include "wagtailadmin/pages/list.html" with sortable=1 allow_navigation=1 full_width=1 parent_page=parent_page orderable=parent_page_perms.can_reorder_children %}
</form> </form>
{% endblock %} {% endblock %}
@ -30,9 +30,10 @@
var orderform = $('#page-reorder-form'); var orderform = $('#page-reorder-form');
$('.listing tbody').sortable({ $('.listing tbody').sortable({
cursor: "move", cursor: "move",
containment: "parent", tolerance: "pointer",
handle: ".handle", containment: "parent",
handle: ".handle",
items: "> tr", items: "> tr",
axis: "y", axis: "y",
placeholder: "dropzone", placeholder: "dropzone",

Wyświetl plik

@ -634,8 +634,13 @@ def set_page_position(request, page_to_move_id):
# so don't bother to catch InvalidMoveToDescendant # so don't bother to catch InvalidMoveToDescendant
if position_page: if position_page:
# Move page into this position # If the page has been moved to the right, insert it to the
page_to_move.move(position_page, pos='left') # right. If left, then left.
old_position = list(parent_page.get_children()).index(page_to_move)
if int(position) < old_position:
page_to_move.move(position_page, pos='left')
elif int(position) > old_position:
page_to_move.move(position_page, pos='right')
else: else:
# Move page to end # Move page to end
page_to_move.move(parent_page, pos='last-child') page_to_move.move(parent_page, pos='last-child')