Merge pull request #68 from Alp-Phone/master
Javascript alert to prompt before reordering unsaved inlines.master
commit
29eeeaf1e6
Binary file not shown.
|
|
@ -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?"
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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 %}
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
{% load i18n admin_modify adminsortable_tags %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||||
|
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }} {% if inline_admin_formset.formset.initial_form_count > 1 %} - {% trans "drag and drop to change order" %}{% endif %}</h2>
|
||||||
|
{{ inline_admin_formset.formset.management_form }}
|
||||||
|
{{ inline_admin_formset.formset.non_form_errors }}
|
||||||
|
|
||||||
|
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if inline_admin_form.original %} has_original{% endif %}{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
|
||||||
|
<h3><b>{{ inline_admin_formset.opts.verbose_name|title }}:</b> <span class="inline_label">{% if inline_admin_form.original %}{{ inline_admin_form.original }}{% else %}#{{ forloop.counter }}{% endif %}</span>
|
||||||
|
{% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %}
|
||||||
|
{% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}<span class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</span>{% endif %}
|
||||||
|
</h3>
|
||||||
|
{% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
|
||||||
|
{% for fieldset in inline_admin_form %}
|
||||||
|
{% include "admin/includes/fieldset.html" %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
|
||||||
|
{{ inline_admin_form.fk_field.field }}
|
||||||
|
{% if inline_admin_form.original %}
|
||||||
|
<input type="hidden" name="admin_sorting_url" value="{% url 'admin:admin_do_sorting' inline_admin_form.original.model_type_id %}" />
|
||||||
|
{% endif %}
|
||||||
|
</div>{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function($) {
|
||||||
|
$(document).ready(function() {
|
||||||
|
var rows = "#{{ inline_admin_formset.formset.prefix }}-group .inline-related";
|
||||||
|
var updateInlineLabel = function(row) {
|
||||||
|
$(rows).find(".inline_label").each(function(i) {
|
||||||
|
var count = i + 1;
|
||||||
|
$(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var reinitDateTimeShortCuts = function() {
|
||||||
|
// Reinitialize the calendar and clock widgets by force, yuck.
|
||||||
|
if (typeof DateTimeShortcuts != "undefined") {
|
||||||
|
$(".datetimeshortcuts").remove();
|
||||||
|
DateTimeShortcuts.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var updateSelectFilter = function() {
|
||||||
|
// If any SelectFilter widgets were added, instantiate a new instance.
|
||||||
|
if (typeof SelectFilter != "undefined"){
|
||||||
|
$(".selectfilter").each(function(index, value){
|
||||||
|
var namearr = value.name.split('-');
|
||||||
|
SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% static 'admin/' %}");
|
||||||
|
});
|
||||||
|
$(".selectfilterstacked").each(function(index, value){
|
||||||
|
var namearr = value.name.split('-');
|
||||||
|
SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% static 'admin/' %}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var initPrepopulatedFields = function(row) {
|
||||||
|
row.find('.prepopulated_field').each(function() {
|
||||||
|
var field = $(this);
|
||||||
|
var input = field.find('input, select, textarea');
|
||||||
|
var dependency_list = input.data('dependency_list') || [];
|
||||||
|
var dependencies = [];
|
||||||
|
$.each(dependency_list, function(i, field_name) {
|
||||||
|
dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
|
||||||
|
});
|
||||||
|
if (dependencies.length) {
|
||||||
|
input.prepopulate(dependencies, input.attr('maxlength'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(rows).formset({
|
||||||
|
prefix: "{{ inline_admin_formset.formset.prefix }}",
|
||||||
|
addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
|
||||||
|
formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
|
||||||
|
deleteCssClass: "inline-deletelink",
|
||||||
|
deleteText: "{% trans "Remove" %}",
|
||||||
|
emptyCssClass: "empty-form",
|
||||||
|
removed: updateInlineLabel,
|
||||||
|
added: (function(row) {
|
||||||
|
initPrepopulatedFields(row);
|
||||||
|
reinitDateTimeShortCuts();
|
||||||
|
updateSelectFilter();
|
||||||
|
updateInlineLabel(row);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})(django.jQuery);
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
{% load i18n admin_modify adminsortable_tags %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
|
||||||
|
<div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
|
||||||
|
{{ inline_admin_formset.formset.management_form }}
|
||||||
|
<fieldset class="module">
|
||||||
|
<h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }} {% if inline_admin_formset.formset.initial_form_count > 1 %} - {% trans "drag and drop to change order" %}{% endif %}</h2>
|
||||||
|
{{ inline_admin_formset.formset.non_form_errors }}
|
||||||
|
<table>
|
||||||
|
<thead><tr>
|
||||||
|
{% for field in inline_admin_formset.fields %}
|
||||||
|
{% if not field.widget.is_hidden %}
|
||||||
|
<th{% if forloop.first %} colspan="2"{% endif %}{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
|
||||||
|
</tr></thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{% for inline_admin_form in inline_admin_formset %}
|
||||||
|
{% if inline_admin_form.form.non_field_errors %}
|
||||||
|
<tr><td colspan="{{ inline_admin_form|cell_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
|
||||||
|
{% endif %}
|
||||||
|
<tr class="{% cycle "row1" "row2" %} {% if inline_admin_form.original or inline_admin_form.show_url %}has_original{% endif %}{% if forloop.last %} empty-form{% endif %}"
|
||||||
|
id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
|
||||||
|
<td class="original">
|
||||||
|
|
||||||
|
{% if inline_admin_form.original or inline_admin_form.show_url %}<p>
|
||||||
|
{% if inline_admin_form.original %} {{ inline_admin_form.original }}{% endif %}
|
||||||
|
{% if inline_admin_form.show_url %}<a href="../../../r/{{ inline_admin_form.original_content_type_id }}/{{ inline_admin_form.original.id }}/">{% trans "View on site" %}</a>{% endif %}
|
||||||
|
</p>{% endif %}
|
||||||
|
{% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
|
||||||
|
{{ inline_admin_form.fk_field.field }}
|
||||||
|
{% spaceless %}
|
||||||
|
{% for fieldset in inline_admin_form %}
|
||||||
|
{% for line in fieldset %}
|
||||||
|
{% for field in line %}
|
||||||
|
{% if field.is_hidden %} {{ field.field }} {% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endspaceless %}
|
||||||
|
{% if inline_admin_form.original %}
|
||||||
|
<input type="hidden" name="admin_sorting_url" value="{% url 'admin:admin_do_sorting' inline_admin_form.original.model_type_id %}" />
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% for fieldset in inline_admin_form %}
|
||||||
|
{% for line in fieldset %}
|
||||||
|
{% for field in line %}
|
||||||
|
<td class="{{ field.field.name }}">
|
||||||
|
{% if field.is_readonly %}
|
||||||
|
<p>{{ field.contents }}</p>
|
||||||
|
{% else %}
|
||||||
|
{{ field.field.errors.as_ul }}
|
||||||
|
{{ field.field }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if inline_admin_formset.formset.can_delete %}
|
||||||
|
<td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function($) {
|
||||||
|
$(document).ready(function($) {
|
||||||
|
var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
|
||||||
|
var alternatingRows = function(row) {
|
||||||
|
$(rows).not(".add-row").removeClass("row1 row2")
|
||||||
|
.filter(":even").addClass("row1").end()
|
||||||
|
.filter(rows + ":odd").addClass("row2");
|
||||||
|
}
|
||||||
|
var reinitDateTimeShortCuts = function() {
|
||||||
|
// Reinitialize the calendar and clock widgets by force
|
||||||
|
if (typeof DateTimeShortcuts != "undefined") {
|
||||||
|
$(".datetimeshortcuts").remove();
|
||||||
|
DateTimeShortcuts.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var updateSelectFilter = function() {
|
||||||
|
// If any SelectFilter widgets are a part of the new form,
|
||||||
|
// instantiate a new SelectFilter instance for it.
|
||||||
|
if (typeof SelectFilter != "undefined"){
|
||||||
|
$(".selectfilter").each(function(index, value){
|
||||||
|
var namearr = value.name.split('-');
|
||||||
|
SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% static 'admin/' %}");
|
||||||
|
});
|
||||||
|
$(".selectfilterstacked").each(function(index, value){
|
||||||
|
var namearr = value.name.split('-');
|
||||||
|
SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% static 'admin/' %}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var initPrepopulatedFields = function(row) {
|
||||||
|
row.find('.prepopulated_field').each(function() {
|
||||||
|
var field = $(this);
|
||||||
|
var input = field.find('input, select, textarea');
|
||||||
|
var dependency_list = input.data('dependency_list') || [];
|
||||||
|
var dependencies = [];
|
||||||
|
$.each(dependency_list, function(i, field_name) {
|
||||||
|
dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
|
||||||
|
});
|
||||||
|
if (dependencies.length) {
|
||||||
|
input.prepopulate(dependencies, input.attr('maxlength'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(rows).formset({
|
||||||
|
prefix: "{{ inline_admin_formset.formset.prefix }}",
|
||||||
|
addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
|
||||||
|
formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
|
||||||
|
deleteCssClass: "inline-deletelink",
|
||||||
|
deleteText: "{% trans "Remove" %}",
|
||||||
|
emptyCssClass: "empty-form",
|
||||||
|
removed: alternatingRows,
|
||||||
|
added: (function(row) {
|
||||||
|
initPrepopulatedFields(row);
|
||||||
|
reinitDateTimeShortCuts();
|
||||||
|
updateSelectFilter();
|
||||||
|
alternatingRows(row);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})(django.jQuery);
|
||||||
|
</script>
|
||||||
|
|
@ -40,7 +40,7 @@ SITE_ID = 1
|
||||||
|
|
||||||
# If you set this to False, Django will make some optimizations so as not
|
# If you set this to False, Django will make some optimizations so as not
|
||||||
# to load the internationalization machinery.
|
# to load the internationalization machinery.
|
||||||
USE_I18N = False
|
USE_I18N = True
|
||||||
|
|
||||||
# If you set this to False, Django will not format dates, numbers and
|
# If you set this to False, Django will not format dates, numbers and
|
||||||
# calendars according to the current locale.
|
# calendars according to the current locale.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue