list.html 7.3 KB

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