Reordering with unsaved inlines is faulty and counter intuitive.

In this commit I added a javascript alert that prompts the user to save their changes before reordering if unsaved inlines are detected.
Please review and let me know if this in compliance with your guidelines.
master
Moritz Pfeiffer 2013-12-03 10:45:17 +01:00
parent 629bfb058d
commit 818a231a1a
5 changed files with 48 additions and 7 deletions

View File

@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Adminsortable 1.6.2\n" "Project-Id-Version: Adminsortable 1.6.2\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-29 10:36+0100\n" "POT-Creation-Date: 2013-12-03 10:36+0100\n"
"PO-Revision-Date: 2013-11-29 10:50+0100\n" "PO-Revision-Date: 2013-12-03 10:37+0100\n"
"Last-Translator: Moritz Pfeiffer <moritz.pfeiffer@alp-phone.ch>\n" "Last-Translator: Moritz Pfeiffer <moritz.pfeiffer@alp-phone.ch>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -17,11 +17,27 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.7\n" "X-Generator: Poedit 1.5.7\n"
#: templates/adminsortable/change_form.html:32
msgid ""
"There are unsaved changes on this page. Please save your changes before "
"reordering."
msgstr ""
"Bitte speichern Sie zuerst die Änderungen auf dieser Seite bevor Sie die "
"Reihenfolge ändern."
#: templates/adminsortable/change_list.html:19 #: templates/adminsortable/change_list.html:19
#, python-format #, python-format
msgid "Drag and drop %(model)s to change display order" msgid "Drag and drop %(model)s to change display order"
msgstr "Drag and drop %(model)s um die Reihenfolge zu ändern" msgstr "Drag and drop %(model)s um die Reihenfolge zu ändern"
#: templates/adminsortable/change_list.html:19
msgid "Django site admin"
msgstr ""
#: templates/adminsortable/change_list.html:24
msgid "Home"
msgstr ""
#: templates/adminsortable/change_list.html:31 #: templates/adminsortable/change_list.html:31
msgid "Reorder" msgid "Reorder"
msgstr "Reihenfolge ändern" msgstr "Reihenfolge ändern"
@ -54,27 +70,36 @@ msgstr "Zurück zu %(model)s"
msgid "Change Order" msgid "Change Order"
msgstr "Reihenfolge ändern" msgstr "Reihenfolge ändern"
#: templates/adminsortable/edit_inline/stacked-1.5.x.html:4
#: templates/adminsortable/edit_inline/stacked.html:3 #: templates/adminsortable/edit_inline/stacked.html:3
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:7
#: templates/adminsortable/edit_inline/tabular.html:6 #: templates/adminsortable/edit_inline/tabular.html:6
msgid "drag and drop to change order" msgid "drag and drop to change order"
msgstr "drag and drop um die Reihenfolge zu ändern" msgstr "drag and drop um die Reihenfolge zu ändern"
#: templates/adminsortable/edit_inline/stacked-1.5.x.html:10
#: templates/adminsortable/edit_inline/stacked.html:9 #: templates/adminsortable/edit_inline/stacked.html:9
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:30
#: templates/adminsortable/edit_inline/tabular.html:30 #: templates/adminsortable/edit_inline/tabular.html:30
msgid "View on site" msgid "View on site"
msgstr "" msgstr ""
#: templates/adminsortable/edit_inline/stacked.html:29 #: templates/adminsortable/edit_inline/stacked-1.5.x.html:71
#: templates/adminsortable/edit_inline/tabular.html:79
msgid "Remove"
msgstr "Entfernen"
#: templates/adminsortable/edit_inline/stacked.html:30 #: templates/adminsortable/edit_inline/stacked.html:30
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:118
#: templates/adminsortable/edit_inline/tabular.html:78 #: templates/adminsortable/edit_inline/tabular.html:78
#, python-format #, python-format
msgid "Add another %(verbose_name)s" msgid "Add another %(verbose_name)s"
msgstr "" msgstr ""
#: templates/adminsortable/edit_inline/stacked-1.5.x.html:74
#: templates/adminsortable/edit_inline/stacked.html:29
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:121
#: templates/adminsortable/edit_inline/tabular.html:79
msgid "Remove"
msgstr "Entfernen"
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:16
#: templates/adminsortable/edit_inline/tabular.html:17 #: templates/adminsortable/edit_inline/tabular.html:17
msgid "Delete?" msgid "Delete?"
msgstr "Löschen?" msgstr "Löschen?"

View File

@ -16,6 +16,12 @@
items : '.inline-related', items : '.inline-related',
stop : function(event, ui) stop : function(event, ui)
{ {
if ($('.inline-deletelink').length > 0) {
$(ui.sender).sortable('cancel');
alert($('#localized_save_before_reorder_message').val());
return false;
}
var indexes = []; var indexes = [];
ui.item.parent().children('.inline-related').each(function(i) ui.item.parent().children('.inline-related').each(function(i)
{ {

View File

@ -16,6 +16,12 @@
items : 'tr:not(.add-row)', items : 'tr:not(.add-row)',
stop : function(event, ui) stop : function(event, ui)
{ {
if ($('.inline-deletelink').length > 0) {
$(ui.sender).sortable('cancel');
alert($('#localized_save_before_reorder_message').val());
return false;
}
var indexes = []; var indexes = [];
ui.item.parent().children('tr').each(function(i) ui.item.parent().children('tr').each(function(i)
{ {

View File

@ -27,3 +27,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'adminsortable/css/admin.sortable.inline.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'adminsortable/css/admin.sortable.inline.css' %}" />
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block after_related_objects %}{{ block.super }}
<input type="hidden" id="localized_save_before_reorder_message" value="{% trans 'There are unsaved changes on this page. Please save your changes before reordering.' %}"/>
{% endblock %}