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 %}
</header>
<form id="page-reorder-form">
{% csrf_token %}
{% 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>
{% endblock %}
@ -30,9 +30,10 @@
var orderform = $('#page-reorder-form');
$('.listing tbody').sortable({
cursor: "move",
containment: "parent",
handle: ".handle",
cursor: "move",
tolerance: "pointer",
containment: "parent",
handle: ".handle",
items: "> tr",
axis: "y",
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
if position_page:
# Move page into this position
page_to_move.move(position_page, pos='left')
# If the page has been moved to the right, insert it to the
# 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:
# Move page to end
page_to_move.move(parent_page, pos='last-child')