Shifted NavigationManager caching to use node instances rather than node pks. Improve...
[philo.git] / templates / admin / philo / edit_inline / tabular_container.html
1 {% load i18n adminmedia %}
2 {{ inline_admin_formset.formset.management_form }}
3 {% if inline_admin_formset.formset.forms %}
4 <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
5   <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
6 <fieldset class="module{% if inline_admin_formset.classes %} {{ inline_admin_formset.classes|join:' ' }}{% endif %}">
7    <h2>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h2>
8    {{ inline_admin_formset.formset.non_form_errors }}
9    <table>
10          <thead><tr>
11          {% for field in inline_admin_formset.fields %}
12            {% if not field.widget.is_hidden %}
13                  <th{% if field.required %} class="required"{% endif %}>{{ field.label|capfirst }}</th>
14            {% endif %}
15          {% endfor %}
16          {% if inline_admin_formset.formset.can_delete %}<th>{% trans "Delete?" %}</th>{% endif %}
17          </tr></thead>
18
19          <tbody>
20          {% for inline_admin_form in inline_admin_formset %}
21                 {% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
22                 {{ inline_admin_form.fk_field.field }}
23                 {% spaceless %}
24                 {% for fieldset in inline_admin_form %}
25                 {% for line in fieldset %}
26                   {% for field in line %}
27                         {% if field.is_hidden %} {{ field.field }} {% endif %}
28                   {% endfor %}
29                 {% endfor %}
30                 {% endfor %}
31                 {{ inline_admin_form.form.name.as_hidden }}
32                 {% endspaceless %}
33                 {% if inline_admin_form.form.non_field_errors %}
34                 <tr><td colspan="{{ inline_admin_form.field_count }}">{{ inline_admin_form.form.non_field_errors }}</td></tr>
35                 {% endif %}
36                 <tr class="{% cycle "row1" "row2" %} {% if forloop.last %} empty-form{% endif %}"
37                          id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
38                         <th>{{ inline_admin_form.form.verbose_name|capfirst }}:</th>
39                 {% for fieldset in inline_admin_form %}
40                   {% for line in fieldset %}
41                         {% for field in line %}
42                           {% if field.field.name != 'name' %}
43                           <td class="{{ field.field.name }}">
44                           {% if field.is_readonly %}
45                                   <p>{{ field.contents }}</p>
46                           {% else %}
47                                   {{ field.field.errors.as_ul }}
48                                   {{ field.field }}
49                           {% endif %}
50                           </td>
51                           {% endif %}
52                         {% endfor %}
53                   {% endfor %}
54                 {% endfor %}
55                 {% if inline_admin_formset.formset.can_delete %}
56                   <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
57                 {% endif %}
58                 </tr>
59          {% endfor %}
60          </tbody>
61    </table>
62 </fieldset>
63   </div>
64 </div>
65
66 <script type="text/javascript">
67 (function($) {
68         $(document).ready(function($) {
69                 var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
70                 var alternatingRows = function(row) {
71                         $(rows).not(".add-row").removeClass("row1 row2")
72                                 .filter(":even").addClass("row1").end()
73                                 .filter(rows + ":odd").addClass("row2");
74                 }
75                 var reinitDateTimeShortCuts = function() {
76                         // Reinitialize the calendar and clock widgets by force
77                         if (typeof DateTimeShortcuts != "undefined") {
78                                 $(".datetimeshortcuts").remove();
79                                 DateTimeShortcuts.init();
80                         }
81                 }
82                 var updateSelectFilter = function() {
83                         // If any SelectFilter widgets are a part of the new form,
84                         // instantiate a new SelectFilter instance for it.
85                         if (typeof SelectFilter != "undefined"){
86                                 $(".selectfilter").each(function(index, value){
87                                   var namearr = value.name.split('-');
88                                   SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
89                                 })
90                                 $(".selectfilterstacked").each(function(index, value){
91                                   var namearr = value.name.split('-');
92                                   SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
93                                 })
94                         }
95                 }
96                 var initPrepopulatedFields = function(row) {
97                         row.find('.prepopulated_field').each(function() {
98                                 var field = $(this);
99                                 var input = field.find('input, select, textarea');
100                                 var dependency_list = input.data('dependency_list') || [];
101                                 var dependencies = row.find(dependency_list.join(',')).find('input, select, textarea');
102                                 if (dependencies.length) {
103                                         input.prepopulate(dependencies, input.attr('maxlength'));
104                                 }
105                         });
106                 }
107                 $(rows).formset({
108                         prefix: "{{ inline_admin_formset.formset.prefix }}",
109                         addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
110                         formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
111                         deleteCssClass: "inline-deletelink",
112                         deleteText: "{% trans "Remove" %}",
113                         emptyCssClass: "empty-form",
114                         removed: alternatingRows,
115                         added: (function(row) {
116                                 initPrepopulatedFields(row);
117                                 reinitDateTimeShortCuts();
118                                 updateSelectFilter();
119                                 alternatingRows(row);
120                         })
121                 });
122         });
123 })(django.jQuery);
124 </script>
125 {% endif %}