Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | {% comment %} |
| 2 | Show pagination controls as per search/pagination table detail spec. |
| 3 | Input: objects, setup for pagination using the standard method in views. |
| 4 | object_count, count for complete list of objects, (all pages, no pattern) |
| 5 | {% endcomment %} |
| 6 | |
| 7 | {# only paginate if 10 or more rows unfiltered, all pages #} |
| 8 | {% if object_count >= 10 %} |
| 9 | <div class="pagination"> |
| 10 | <ul> |
| 11 | {%if objects.has_previous %} |
| 12 | <li><a href="javascript:reload_params({'page':{{objects.previous_page_number}}})">«</a></li> |
| 13 | {%else%} |
| 14 | <li class="disabled"><a href="#">«</a></li> |
| 15 | {%endif%} |
| 16 | {% for i in objects.page_range %} |
| 17 | <li{%if i == objects.number %} class="active" {%endif%}><a href="javascript:reload_params({'page':{{i}}})">{{i}}</a></li> |
| 18 | {% endfor %} |
| 19 | {%if objects.has_next%} |
| 20 | <li><a href="javascript:reload_params({'page':{{objects.next_page_number}}})">»</a></li> |
| 21 | {%else%} |
| 22 | <li class="disabled"><a href="#">»</a></li> |
| 23 | {%endif%} |
| 24 | </ul> |
| 25 | |
| 26 | <div class="pull-right"> |
| 27 | <span class="help-inline" style="padding-bottom:10px;">Show rows:</span> |
| 28 | <select class="pagesize"> |
| 29 | {% with "10 25 50 100 150" as list%} |
| 30 | {% for i in list.split %} |
| 31 | <option value="{{i}}">{{i}}</option> |
| 32 | {% endfor %} |
| 33 | {% endwith %} |
| 34 | </select> |
| 35 | </div> |
| 36 | </div> |
| 37 | |
| 38 | <!-- Update page display settings --> |
| 39 | <script> |
| 40 | $(document).ready(function() { |
| 41 | // load data for number of entries to be displayed on page |
| 42 | if ({{request.GET.count}} != "") { |
| 43 | pagesize = {{request.GET.count}}; |
| 44 | } |
| 45 | $('.pagesize option').prop('selected', false) |
| 46 | .filter('[value="' + pagesize + '"]') |
| 47 | .attr('selected', true); |
| 48 | |
| 49 | $(".pagesize").change(function () { |
| 50 | reload_params({"count":$(this).val()}); |
| 51 | }); |
| 52 | }); |
| 53 | </script> |
| 54 | {% endif %} |
| 55 | |