X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/44e147b16322f9bdd4606cda7deec631b951ab06..72e22b49ec2721d3a1369da768d3d74fa9c079c3:/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..9c64c2b304 100644 --- a/apps/workbench/app/views/application/_paging.html.erb +++ b/apps/workbench/app/views/application/_paging.html.erb @@ -5,9 +5,33 @@ 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 %> +<% results.fetch_multiple_pages(false) %> + +<% 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 +45,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 %> @@ -33,7 +56,7 @@ background-color: whitesmoke; <% if results.result_offset > 0 %> <%= link_to raw(""), {:id => object, :offset => 0, :limit => results.result_limit} %> <% else %> - + <% end %> <% if prev_offset %> @@ -43,27 +66,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 %> -<% 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} %> +<% if first < 0 %> + <% d = -first %> + <% first += d %> + <% last += d %> +<% end %> + +<% 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 %> @@ -75,13 +113,16 @@ background-color: whitesmoke; <% end %> <% if (results.items_available - results.result_offset) >= results.result_limit %> - <%= link_to raw(""), {:id => @object, :offset => results.items_available - (results.items_available % results.result_limit), + <%= link_to raw(""), {:id => @object, :offset => results.items_available - (results.items_available % results.result_limit), :limit => results.result_limit} %> <% else %> - + <% end %>
+ +<% end %> + <% end %>