aboutsummaryrefslogtreecommitdiffstats
path: root/lib/srtgui/templates/detail_search_header.html
blob: 7a9865908df64a67e6894b91fae4de1ffe940c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{% comment %}
  Show a detail table Search field and Rows per page.
  Input:
    objects, our boilerplated paginated with search fields set.
    object_count, count of full, unfiltered, objects list
    search_what, fills in "Search ___"
  Only show the search form if we have more than 10 results,
  or if return from a previous search.
{% endcomment %}


<script>
$(document).ready(function() {
  /* Clear the current search selection and reload the results */
  $(".search-clear").click(function(){
    $("#search").val("");
    $(this).parents("form").submit();
  });
});
</script>

{% if objects.paginator.count > 10 or request.GET.search %}
  {% if objects.paginator.count == 0 %}
  <div class="alert alert-warning">
    <h4>No {{search_what}} found</h4>
    <form id="searchform" class="form-inline">
      {% else %}
      <form id="searchform" class="navbar-form navbar-left detail-page-controls">
        {% endif %}

        <div class="form-group">
          <div class="btn-group">
            <input id="search" class="form-control" type="text" placeholder="Search {{search_what}}" name="search" value="{% if request.GET.search %}{{request.GET.search}}{% endif %}">
            <input type="hidden" value="name:+" name="orderby">
            <input type="hidden" value="l" name="page">
            {% if request.GET.search %}
            <span class="remove-search-btn-detail-search search-clear glyphicon glyphicon-remove-circle"></span>
            {% endif %}
          </div>
        </div>
        <button type="submit" class="btn btn-default">Search</button>
        {% if objects.paginator.count == 0 %}
        <button type="submit" class="btn btn-link search-clear">
          Show all {{search_what}}
        </button>
        {% endif %}
      </form>
      {% endif %}

      {% if objects.paginator.count == 0 %}
  </div> {# end alert #}
  {% else %}
  {% if object_count > 10 %}
  <form class="navbar-form navbar-right">
    <div class="form-group">
      <label>Show rows:</label>
      <select class="pagesize form-control">
        {% with "10 25 50 100 150" as list%}
        {% for i in list.split %}
        {% if request.session.limit == i %}
        <option value="{{i}}" selected>{{i}}</option>
        {% else %}
        <option value="{{i}}">{{i}}</option>
        {% endif %}
        {% endfor %}
        {% endwith %}
      </select>
    </div>
  </form>
  {% endif %}
{% endif %}