kopia lustrzana https://github.com/wagtail/wagtail
Fix page reordering in Wagtail Admin
rodzic
c3b4bb29c1
commit
065a912b37
|
@ -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",
|
||||
|
|
|
@ -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')
|
||||
|
|
Ładowanie…
Reference in New Issue