X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/44e147b16322f9bdd4606cda7deec631b951ab06..f4bc389289188870b866130402008a02e55e9a5d:/apps/workbench/app/views/application/_paging.html.erb diff --git a/apps/workbench/app/views/application/_paging.html.erb b/apps/workbench/app/views/application/_paging.html.erb index f5677f77ce..df9d08d778 100644 --- a/apps/workbench/app/views/application/_paging.html.erb +++ b/apps/workbench/app/views/application/_paging.html.erb @@ -5,9 +5,31 @@ padding-left: 1em; padding-right: 1em; background-color: whitesmoke; } +.paging-number { +display: inline-block; +min-width: 1.2em; +} <% end %> -<% if results.result_offset != nil and results.result_limit != nil and results.items_available != nil %> +<% if results.respond_to? :result_offset and + results.respond_to? :result_limit and + results.respond_to? :items_available and + results.result_offset != nil and + results.result_limit != nil and + results.items_available != nil +%> +
+ Displaying <%= results.result_offset+1 %> – + <%= if results.result_offset + results.result_limit > results.items_available + results.items_available + else + results.result_offset + results.result_limit + end %> + out of <%= results.items_available %> +
+ +<% if not (results.result_offset == 0 and results.items_available <= results.result_limit) %> +
<% if results.result_offset > 0 %> @@ -21,7 +43,6 @@ background-color: whitesmoke; <% end %> <% this_offset = results.result_offset %> -<% this_page = results.result_offset / results.result_limit %> <% if (results.result_offset + results.result_limit) < results.items_available %> <% next_offset = results.result_offset + results.result_limit %> @@ -43,27 +64,42 @@ background-color: whitesmoke; <% end %> -<% n = this_page - 10 %> -<% if n >= 0 %> - <% last = this_page + 10 %> - … -<% else %> - <% n = 0 %> - <% last = 20 %> +<% first = this_offset - (10 * results.result_limit) %> +<% last = this_offset + (11 * results.result_limit) %> + +<% lastpage_offset = (results.items_available / results.result_limit) * results.result_limit %> + +<% if last > results.items_available %> + <% first -= (last - lastpage_offset) %> + <% last -= (last - results.items_available) %> +<% end %> + +<% if first < 0 %> + <% d = -first %> + <% first += d %> + <% last += d %> <% end %> -<% i = n * results.result_limit %> -<% while i < results.items_available and n < last %> -<% if n != this_page %> - <%= link_to "#{n+1}", {:id => @object, :offset => i, :limit => results.result_limit} %> +<% last = results.items_available if last > results.items_available %> + +<% i = first %> +<% n = first / results.result_limit %> + +<% if first > 0 %> +… +<% end %> + +<% while i < last %> +<% if i != this_offset %> + <%= link_to "#{n+1}", {:id => @object, :offset => i, :limit => results.result_limit}, class: 'paging-number' %> <% else %> - <%= n+1 %> + <%= n+1 %> <% end %> <% i += results.result_limit %> <% n += 1 %> <% end %> -<% if i < results.items_available %> +<% if last < results.items_available %> … <% end %> @@ -84,4 +120,7 @@ background-color: whitesmoke;
+ +<% end %> + <% end %>