stacked.html 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% load i18n admin_urls admin_static jet_tags %}
  2. <div class="module" id="inline_module_{{ index }}">
  3. <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
  4. {{ inline_admin_formset.formset.management_form }}
  5. {% if errors %}
  6. <p class="errornote">
  7. {% trans "Please correct the errors below." %}
  8. </p>
  9. {% endif %}
  10. {{ inline_admin_formset.formset.non_form_errors }}
  11. <div class="stacked-inline{% if not inline_admin_formset.formset|if_onetoone %} side{% endif %} cf">
  12. {% if not inline_admin_formset.formset|if_onetoone %}
  13. <div class="stacked-inline-side">
  14. <div class="stacked-inline-side-top"></div>
  15. <ul class="stacked-inline-list">
  16. {% for inline_admin_form in inline_admin_formset %}
  17. <li class="stacked-inline-list-item{% if inline_admin_form.original %} has_original{% endif %}{% if forloop.first and not forloop.last %} selected{% endif %}{% if forloop.last %} empty{% endif %}{% if inline_admin_form.form.errors %} errors{% endif %}">
  18. <a href="#" class="stacked-inline-list-item-link" data-inline-related-id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}">
  19. {% if not inline_admin_form.original %}
  20. <span class="stacked-inline-list-item-link-remove">{% trans "Remove" %}</span>
  21. <span class="icon-new"></span>
  22. {% endif %}
  23. <b>{{ inline_admin_formset.opts.verbose_name|capfirst }}:</b>&nbsp;
  24. <span class="inline_label">
  25. {% if inline_admin_form.original %}
  26. {{ inline_admin_form.original }}
  27. {% else %}
  28. #{{ forloop.counter }}
  29. {% endif %}
  30. </span>
  31. </a>
  32. </li>
  33. {% endfor %}
  34. </ul>
  35. <div class="stacked-inline-side-bottom"></div>
  36. </div>
  37. {% endif %}
  38. <div class="stacked-inline-content">
  39. {% for inline_admin_form in inline_admin_formset %}
  40. <div class="stacked {% if forloop.first and not forloop.last %}selected {% endif %}inline-related {% if inline_admin_form.original or inline_admin_form.show_url %} 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 %}">
  41. <div class="actions">
  42. {% if inline_admin_form.original and inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}
  43. <a href="{% url inline_admin_form.model_admin.opts|admin_urlname:'change' inline_admin_form.original.pk|admin_urlquote %}" class="inlinechangelink" title="{% trans "Change" %} {{ inline_admin_form.original }}">
  44. <span class="icon-edit"></span>
  45. </a>
  46. {% endif %}
  47. {% if inline_admin_form.show_url %}
  48. <a href="{{ inline_admin_form.absolute_url }}" title="{% trans "View on site" %}">
  49. <span class="icon-open-external"></span>
  50. </a>
  51. {% endif %}
  52. </div>
  53. {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}
  54. <div class="delete">{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}</div>
  55. {% endif %}
  56. {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %}
  57. {% for fieldset in inline_admin_form %}
  58. {% include "admin/includes/fieldset.html" with errors=False %}
  59. {% endfor %}
  60. {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
  61. {{ inline_admin_form.fk_field.field }}
  62. </div>
  63. {% endfor %}
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <script type="text/javascript">
  69. (function($) {
  70. $("#{{ inline_admin_formset.formset.prefix }}-group .inline-related").stackedFormset({
  71. prefix: '{{ inline_admin_formset.formset.prefix }}',
  72. adminStaticPrefix: '{% static "admin/" %}',
  73. deleteText: "{% trans "Remove" %}",
  74. addText: "<span class=\"icon-add\"></span> {% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|capfirst %}Add another {{ verbose_name }}{% endblocktrans %}"
  75. });
  76. })(django.jQuery);
  77. </script>