|
1 |
| -{% load i18n admin_modify adminsortable_tags %} |
2 |
| -{% load static from staticfiles %} |
3 |
| -<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group"> |
4 |
| - <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> |
5 |
| -{{ inline_admin_formset.formset.management_form }} |
6 |
| -{{ inline_admin_formset.formset.non_form_errors }} |
7 |
| - |
8 |
| -{% 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 %}"> |
9 |
| - <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> |
10 |
| - {% 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 %} |
11 |
| - {% 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 %} |
12 |
| - </h3> |
13 |
| - {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} |
14 |
| - {% for fieldset in inline_admin_form %} |
15 |
| - {% include "admin/includes/fieldset.html" %} |
16 |
| - {% endfor %} |
17 |
| - {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %} |
18 |
| - {{ inline_admin_form.fk_field.field }} |
19 |
| - {% if inline_admin_form.original %} |
20 |
| - <input type="hidden" name="admin_sorting_url" value="{% url 'admin:admin_do_sorting' inline_admin_form.original.model_type_id %}" /> |
21 |
| - {% endif %} |
22 |
| -</div>{% endfor %} |
23 |
| -</div> |
24 |
| - |
25 |
| -<script type="text/javascript"> |
26 |
| -(function($) { |
27 |
| - $(document).ready(function() { |
28 |
| - var rows = "#{{ inline_admin_formset.formset.prefix }}-group .inline-related"; |
29 |
| - var updateInlineLabel = function(row) { |
30 |
| - $(rows).find(".inline_label").each(function(i) { |
31 |
| - var count = i + 1; |
32 |
| - $(this).html($(this).html().replace(/(#\d+)/g, "#" + count)); |
33 |
| - }); |
34 |
| - } |
35 |
| - var reinitDateTimeShortCuts = function() { |
36 |
| - // Reinitialize the calendar and clock widgets by force, yuck. |
37 |
| - if (typeof DateTimeShortcuts != "undefined") { |
38 |
| - $(".datetimeshortcuts").remove(); |
39 |
| - DateTimeShortcuts.init(); |
40 |
| - } |
41 |
| - } |
42 |
| - var updateSelectFilter = function() { |
43 |
| - // If any SelectFilter widgets were added, instantiate a new instance. |
44 |
| - if (typeof SelectFilter != "undefined"){ |
45 |
| - $(".selectfilter").each(function(index, value){ |
46 |
| - var namearr = value.name.split('-'); |
47 |
| - SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% static 'admin/' %}"); |
48 |
| - }); |
49 |
| - $(".selectfilterstacked").each(function(index, value){ |
50 |
| - var namearr = value.name.split('-'); |
51 |
| - SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% static 'admin/' %}"); |
52 |
| - }); |
53 |
| - } |
54 |
| - } |
55 |
| - var initPrepopulatedFields = function(row) { |
56 |
| - row.find('.prepopulated_field').each(function() { |
57 |
| - var field = $(this); |
58 |
| - var input = field.find('input, select, textarea'); |
59 |
| - var dependency_list = input.data('dependency_list') || []; |
60 |
| - var dependencies = []; |
61 |
| - $.each(dependency_list, function(i, field_name) { |
62 |
| - dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id')); |
63 |
| - }); |
64 |
| - if (dependencies.length) { |
65 |
| - input.prepopulate(dependencies, input.attr('maxlength')); |
66 |
| - } |
67 |
| - }); |
68 |
| - } |
69 |
| - $(rows).formset({ |
70 |
| - prefix: "{{ inline_admin_formset.formset.prefix }}", |
71 |
| - addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}", |
72 |
| - formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}", |
73 |
| - deleteCssClass: "inline-deletelink", |
74 |
| - deleteText: "{% trans "Remove" %}", |
75 |
| - emptyCssClass: "empty-form", |
76 |
| - removed: updateInlineLabel, |
77 |
| - added: (function(row) { |
78 |
| - initPrepopulatedFields(row); |
79 |
| - reinitDateTimeShortCuts(); |
80 |
| - updateSelectFilter(); |
81 |
| - updateInlineLabel(row); |
82 |
| - }) |
83 |
| - }); |
84 |
| - }); |
85 |
| -})(django.jQuery); |
86 |
| -</script> |
| 1 | +{% load i18n admin_static %} |
| 2 | +<div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group"> |
| 3 | + <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> |
| 4 | +{{ inline_admin_formset.formset.management_form }} |
| 5 | +{{ inline_admin_formset.formset.non_form_errors }} |
| 6 | + |
| 7 | +{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}"> |
| 8 | + <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> |
| 9 | + {% if inline_admin_form.show_url %}<a href="{% url 'admin:view_on_site' inline_admin_form.original_content_type_id inline_admin_form.original.pk %}">{% trans "View on site" %}</a>{% endif %} |
| 10 | + {% 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 %} |
| 11 | + </h3> |
| 12 | + {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} |
| 13 | + {% for fieldset in inline_admin_form %} |
| 14 | + {% include "admin/includes/fieldset.html" %} |
| 15 | + {% endfor %} |
| 16 | + {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %} |
| 17 | + {{ inline_admin_form.fk_field.field }} |
| 18 | + {% if inline_admin_form.original %} |
| 19 | + <input type="hidden" name="admin_sorting_url" value="{% url 'admin:admin_do_sorting' inline_admin_form.original.model_type_id %}" /> |
| 20 | + {% endif %} |
| 21 | +</div>{% endfor %} |
| 22 | +</div> |
| 23 | + |
| 24 | +<script type="text/javascript"> |
| 25 | +(function($) { |
| 26 | + $("#{{ inline_admin_formset.formset.prefix }}-group .inline-related").stackedFormset({ |
| 27 | + prefix: '{{ inline_admin_formset.formset.prefix }}', |
| 28 | + adminStaticPrefix: '{% static "admin/" %}', |
| 29 | + deleteText: "{% trans "Remove" %}", |
| 30 | + addText: "{% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|title %}Add another {{ verbose_name }}{% endblocktrans %}" |
| 31 | + }); |
| 32 | +})(django.jQuery); |
| 33 | +</script> |
0 commit comments