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 ""
"Project-Id-Version: Adminsortable 1.6.2\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-29 10:36+0100\n"
"PO-Revision-Date: 2013-11-29 10:50+0100\n"
"POT-Creation-Date: 2013-12-03 10:36+0100\n"
"PO-Revision-Date: 2013-12-03 10:37+0100\n"
"Last-Translator: Moritz Pfeiffer <moritz.pfeiffer@alp-phone.ch>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
@ -17,11 +17,27 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\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
#, python-format
msgid "Drag and drop %(model)s to change display order"
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
msgid "Reorder"
msgstr "Reihenfolge ändern"
@ -54,27 +70,36 @@ msgstr "Zurück zu %(model)s"
msgid "Change Order"
msgstr "Reihenfolge ändern"
#: templates/adminsortable/edit_inline/stacked-1.5.x.html:4
#: templates/adminsortable/edit_inline/stacked.html:3
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:7
#: templates/adminsortable/edit_inline/tabular.html:6
msgid "drag and drop to change order"
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/tabular-1.5.x.html:30
#: templates/adminsortable/edit_inline/tabular.html:30
msgid "View on site"
msgstr ""
#: templates/adminsortable/edit_inline/stacked.html:29
#: templates/adminsortable/edit_inline/tabular.html:79
msgid "Remove"
msgstr "Entfernen"
#: templates/adminsortable/edit_inline/stacked-1.5.x.html:71
#: templates/adminsortable/edit_inline/stacked.html:30
#: templates/adminsortable/edit_inline/tabular-1.5.x.html:118
#: templates/adminsortable/edit_inline/tabular.html:78
#, python-format
msgid "Add another %(verbose_name)s"
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
msgid "Delete?"
msgstr "Löschen?"

View File

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

View File

@ -16,6 +16,12 @@
items : 'tr:not(.add-row)',
stop : function(event, ui)
{
if ($('.inline-deletelink').length > 0) {
$(ui.sender).sortable('cancel');
alert($('#localized_save_before_reorder_message').val());
return false;
}
var indexes = [];
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' %}" />
{% endif %}
{% 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 %}