Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / views / application / _paging.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <% content_for :css do %>
6 .index-paging {
7 text-align: center;
8 padding-left: 1em;
9 padding-right: 1em;
10 background-color: whitesmoke;
11 }
12 .paging-number {
13 display: inline-block;
14 min-width: 1.2em;
15 }
16 <% end %>
17
18 <% results.fetch_multiple_pages(false) %>
19
20 <% if results.respond_to? :result_offset and
21        results.respond_to? :result_limit and
22        results.respond_to? :items_available and
23        results.result_offset != nil and
24        results.result_limit != nil and
25        results.items_available != nil
26 %>
27 <div class="index-paging">
28   Displaying <%= results.result_offset+1 %> &ndash;
29   <%= if results.result_offset + results.result_limit > results.items_available
30         results.items_available
31       else
32         results.result_offset + results.result_limit
33       end %>
34  out of <%= results.items_available %>
35 </div>
36
37 <% if not (results.result_offset == 0 and results.items_available <= results.result_limit) %>
38
39 <div class="index-paging">
40
41 <% if results.result_offset > 0 %>
42   <% if results.result_offset > results.result_limit %>
43     <% prev_offset = results.result_offset - results.result_limit %>
44   <% else %>
45     <% prev_offset = 0 %>
46   <% end %>
47 <% else %>
48   <% prev_offset = nil %>
49 <% end %>
50
51 <% this_offset = results.result_offset %>
52
53 <% if (results.result_offset + results.result_limit) < results.items_available %>
54   <% next_offset = results.result_offset + results.result_limit %>
55 <% else %>
56   <% next_offset = nil %>
57 <% end %>
58
59 <span class="pull-left">
60 <% if results.result_offset > 0 %>
61   <%= link_to raw("<span class='glyphicon glyphicon-fast-backward'></span>"), {:id => object, :offset => 0, :limit => results.result_limit}  %>
62 <% else %>
63   <span class='glyphicon glyphicon-fast-backward text-muted'></span>
64 <% end %>
65
66 <% if prev_offset %>
67   <%= link_to raw("<span class='glyphicon glyphicon-step-backward'></span>"), {:id => object, :offset => prev_offset, :limit => results.result_limit}  %>
68 <% else %>
69 <span class='glyphicon glyphicon-step-backward text-muted'></span>
70 <% end %>
71 </span>
72
73 <% first = this_offset - (10 * results.result_limit) %>
74 <% last = this_offset + (11 * results.result_limit) %>
75
76 <% lastpage_offset = (results.items_available / results.result_limit) * results.result_limit %>
77
78 <% if last > results.items_available %>
79   <% first -= (last - lastpage_offset) %>
80   <% last -= (last - results.items_available) %>
81 <% end %>
82
83 <% if first < 0 %>
84   <% d = -first %>
85   <% first += d %>
86   <% last += d %>
87 <% end %>
88
89 <% last = results.items_available if last > results.items_available %>
90
91 <% i = first %>
92 <% n = first / results.result_limit %>
93
94 <% if first > 0 %>
95 &hellip;
96 <% end %>
97
98 <% while i < last %>
99 <% if i != this_offset %>
100   <%= link_to "#{n+1}", {:id => @object, :offset => i, :limit => results.result_limit}, class: 'paging-number' %>
101 <% else %>
102   <span class="paging-number" style="font-weight: bold;"><%= n+1 %></span>
103 <% end %>
104 <% i += results.result_limit %>
105 <% n += 1 %>
106 <% end %>
107
108 <% if last < results.items_available %>
109 &hellip;
110 <% end %>
111
112 <span class="pull-right">
113 <% if next_offset %>
114   <%= link_to raw("<span class='glyphicon glyphicon-step-forward'></span>"), {:id => @object, :offset => next_offset, :limit => results.result_limit}  %>
115 <% else %>
116 <span class='glyphicon glyphicon-forward text-muted'></span>
117 <% end %>
118
119 <% if (results.items_available - results.result_offset) >= results.result_limit %>
120   <%= link_to raw("<span class='glyphicon glyphicon-fast-forward'></span>"), {:id => @object, :offset => results.items_available - (results.items_available % results.result_limit),
121         :limit => results.result_limit}  %>
122 <% else %>
123   <span class='glyphicon glyphicon-fast-forward text-muted'></span>
124 <% end %>
125
126 </span>
127
128 </div>
129
130 <% end %>
131
132 <% end %>