list.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {% extends "admin/admin/layout.html" %}
  2. {% load i18n %}
  3. {% load l10n %}
  4. {% load url from future %}
  5. {% import "_forms.html" as form_theme with context %}
  6. {% block action_body %}
  7. {%- if search_form %}
  8. <div class="row">
  9. <div class="span9">{% endif -%}
  10. {% if items|length > 0 -%}
  11. <table class="table table-striped">
  12. <thead>
  13. <tr>{% block table_head scoped %}{% for column in action.columns %}
  14. <th{{ th_class(column, sorting, sorting_method) }}>
  15. {%- if column[0] in sorting %}<a href="
  16. {%- if column[0] == sorting_method[0]-%}
  17. {% if sorting_method[1] %}{{ url ~ query(sort=column[0],dir=0) }}{% else %}{{ url ~ query(sort=column[0],dir=1) }}{% endif %}
  18. {%- else -%}
  19. {{ url ~ query(sort=column[0],dir=sorting[column[0]]) }}
  20. {%- endif %}">{{ column[1] }}</a>{% else %}{{ column[1] }}{% endif %}</th>{% endfor %}{% endblock %}
  21. {% if not action.hide_actions%}<th>{% trans %}Actions{% endtrans %}</th>{% endif -%}
  22. {% if list_form %}<th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>{% endif -%}
  23. </tr>
  24. </thead>
  25. <tbody>{% for item in items %}
  26. <tr>{% block table_row scoped %}{% for column in action.columns %}
  27. <td{% if loop.first %} class="lead-cell{% if column[3] is defined %} span{{ widthratio(column[3], 100, 12) }}{% endif %}"{% elif column[3] is defined %} class="span{{ widthratio(column[3], 100, 12) }}"{% endif %}>{{ item[column[0]] }}</td>{% endfor %}{% endblock %}
  28. {%- if not action.hide_actions%}
  29. <td class="span2">
  30. {%- set item_actions = action.get_item_actions(item) -%}
  31. {% if item_actions -%}
  32. <ul class="list-actions">
  33. {% for action in item_actions %}
  34. <li>{% if action.post -%}
  35. <form action="{{ action.url }}" method="post"{% if action.prompt %} class="confirm" data-jsconfirm="{{ action.prompt }}"{% endif %}>
  36. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  37. <button type="submit" class="tooltip-top" title="{{ action.name }}"><i class="icon-{{ action.icon }}"></i></button>
  38. </form>
  39. {%- else -%}
  40. <a href="{{ action.url }}" class="tooltip-top{% if action.prompt %} confirm{% endif %}"{% if action.prompt %} data-jsconfirm="{{ action.prompt }}"{% endif %} title="{{ action.name }}"><i class="icon-{{ action.icon }}"></i></a>
  41. {%- endif %}</li>
  42. {% endfor %}
  43. </ul>
  44. {%- else -%}
  45. <em>{% trans %}Not available{% endtrans %}</em>
  46. {%- endif %}
  47. </td>{% endif %}
  48. {% if list_form %}<td class="check-cell"><label class="checkbox"><input form="list_form" name="{{ list_form.fields['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ item.pk }}"{% if list_form.fields['list_items']['has_value'] and item.pk in list_form.fields['list_items']['value'] %} checked="checked"{% endif %}></label></td>{% endif %}
  49. </tr>{% endfor %}
  50. </tbody>
  51. </table>
  52. <div class="form-actions table-footer">
  53. {% if table_form %}
  54. <form id="table_form" class="form-inline table-actions-right pull-left" action="{{ url }}" method="POST">
  55. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  56. <input type="hidden" name="origin" value="table">
  57. <button type="submit" class="btn btn-primary">{{ action.table_form_button }}</button>
  58. </form>
  59. {% endif %}
  60. {% if pagination and (pagination['prev'] > 0 or pagination['next'] > 0) %}
  61. <ul class="pager pull-left">
  62. {%- if pagination['prev'] > 0 %}<li><a href="{{ action.get_pagination_url(pagination['prev']) }}" class="tooltip-top" title="{% trans %}Previous Page{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  63. {%- if pagination['next'] > 0 %}<li><a href="{{ action.get_pagination_url(pagination['next']) }}" class="tooltip-top" title="{% trans %}Next Page{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  64. </ul>
  65. <div class="table-count pull-left">{%- trans current_page=pagination['page'], pages=pagination['total'] -%}
  66. Page {{ current_page }} of {{ pages }}
  67. {%- endtrans -%}</div>{% else %}
  68. <div class="table-count pull-left">{% trans count=items_total, total=items_total|intcomma, shown=items_shown|intcomma -%}Showing one item
  69. {%- pluralize -%}
  70. Showing {{ shown }} of {{ total }} items
  71. {%- endtrans %}</div>{% endif %}
  72. {% if list_form -%}
  73. <form id="list_form" class="form-inline pull-right" action="{{ url }}" method="POST">
  74. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  75. <input type="hidden" name="origin" value="list">
  76. {{ form_theme.input_select(list_form.fields['list_action'],width=3) }}
  77. <button type="submit" class="btn btn-primary">{% trans %}Go{% endtrans %}</button>
  78. </form>
  79. {%- endif %}
  80. </div>
  81. {%- else -%}
  82. <div class="alert alert-{% if action.is_filtering %}error{% else %}info{% endif %} alert-form">
  83. <div class="alert-icon"><span><i class="icon-{% if action.is_filtering %}remove{% else %}info-sign{% endif %} icon-white"></i></span></div>
  84. <p>{% if action.is_filtering %}{{ action.empty_search_message }}{% else %}{{ action.empty_message }}{% endif %}</p>
  85. </div>
  86. {% endif -%}
  87. {%- if search_form %}
  88. </div>
  89. <div class="span3 side-search">
  90. <h4>{% if search_form.fieldsets[0].legend %}{{ search_form.fieldsets[0].legend }}{% else %}{% trans %}Search Items{% endtrans %}{% endif %}</h4>
  91. <form id="search_form" action="{{ url }}" method="post">
  92. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  93. <input type="hidden" name="origin" value="search">
  94. {% for field in search_form.fieldsets[0].fields %}
  95. {{ form_theme.row_widget(field, width=3) }}
  96. {% endfor %}
  97. </form>
  98. <div class="form-actions">
  99. <div class="row">
  100. <button type="submit" form="search_form" class="btn btn-primary span1"><i class="icon-search icon-white"></i></button>{% if action.is_filtering %}
  101. <button type="submit" form="search_clear" class="btn btn-inverse span1 offset1"><i class="icon-remove icon-white"></i></button>{% endif %}
  102. </div>
  103. </div>
  104. </div>
  105. </div>{% if action.is_filtering %}
  106. <form id="search_clear" class="form-inline" action="{{ url }}" method="post">
  107. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  108. <input type="hidden" name="origin" value="clear">
  109. </form>{% endif %}{% endif -%}
  110. {% endblock %}
  111. {% block javascripts -%}
  112. {{ super() }}
  113. {%- if action.prompt_select %}
  114. <script type="text/javascript">
  115. $(function () {
  116. $('#list_form').submit(function() {
  117. if ($('.check-cell[]:checked').length == 0) {
  118. alert("{{ action.nothing_checked_message }}");
  119. return false;
  120. }
  121. {%- for item in action.actions %}{% if item.2 %}
  122. if ($('#id_list_action').val() == '{{ item.0 }}') {
  123. var decision = confirm("{{ item.2 }}");
  124. return decision;
  125. }
  126. {%- endif %}{% endfor %}
  127. return true;
  128. });
  129. });
  130. </script>{% endif %}
  131. {%- endblock %}
  132. {#- COLUMN CLASS -#}
  133. {%- macro th_class(column, sorting, sorting_method) -%}
  134. {%- if column[2] or column[0] in sorting %} class="
  135. {#- COLUMN WIDTH (ex. "span4") -#}
  136. {%- if column[2] %}span{{ widthratio(column[2], 100, 12) }}{% endif -%}
  137. {#- SEPARATOR -#}
  138. {%- if column[2] and column[0] in sorting %} {% endif -%}
  139. {#- COLUMN SORTING -#}
  140. {%- if column[0] in sorting -%}table-sort sort-
  141. {%- if column[0] == sorting_method[0] -%}
  142. active-{% if sorting_method[1] %}asc{% else %}desc{% endif -%}
  143. {%- else -%}
  144. {%- if sorting[column[0]] -%}asc{% else %}desc{% endif -%}
  145. {%- endif -%}
  146. {%- endif -%}
  147. "{%- endif -%}
  148. {%- endmacro -%}