]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2795 Add pagination over 20, with "First" and "Last" links.
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 14 Dec 2011 18:15:36 +0000 (19:15 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Wed, 14 Dec 2011 18:16:29 +0000 (19:16 +0100)
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/views/filters/_list.html.erb

index 43594da482a744256ff51c5485f63f6fa9cad3b1..ab73c7f6e6bb9a3aecdc4ad892a92d555e67e2f5 100644 (file)
@@ -184,6 +184,8 @@ no_lines_match_your_filter_criteria=No lines match your filter criteria.
 no_results=No results
 over_x_days=over {0} days
 page_size=Page size
+paging_first=First
+paging_last=Last
 paging_next=Next
 paging_previous=Previous
 project_name=Project name
index 9adf1d8c247e7310e108e53953b1e8e39a68483f..bdd465d4e9578bb950003c3df36d7b54a3719ab7 100644 (file)
         <% 
           if @filter_context.page_count>1
             max_pages = @filter_context.page_count
-            max_pages = 20 if @filter_context.page_count > 20 
+            current_page = @filter_context.page_id
+            start_page = 1
+            end_page = max_pages
+            if max_pages > 20
+              if current_page < 12
+                start_page = 1
+                end_page = 20
+              elsif current_page > max_pages-10
+                start_page = max_pages-20
+                end_page = max_pages
+              else
+                start_page = current_page-10
+                end_page = current_page+9              
+              end
+            end
         %>
           |
-          <%= link_to_if @filter_context.page_id>1, message('paging_previous'), {:overwrite_params => {:page_id => @filter_context.page_id-1}} %>
-          <% for index in 1..max_pages %>
-            <%= link_to_unless index==@filter_context.page_id, index.to_s, {:overwrite_params => {:page_id => index}} %>
+          <% if max_pages > 20 && start_page > 1 %>
+            <%= link_to message('paging_first'), {:overwrite_params => {:page_id => 1}} -%>
+          <% end %>
+          <%= link_to_if current_page>start_page, message('paging_previous'), {:overwrite_params => {:page_id => current_page-1}} %>
+          <% for index in start_page..end_page %>
+            <%= link_to_unless index==current_page, index.to_s, {:overwrite_params => {:page_id => index}} %>
+          <% end %>
+          <%= link_to_if current_page<end_page, message('paging_next'), {:overwrite_params => {:page_id => 1+current_page}} %>
+          <% if max_pages > 20 && end_page < max_pages %>
+            <%= link_to message('paging_last'), {:overwrite_params => {:page_id => max_pages}} -%>
           <% end %>
-          <%= '... ' if @filter_context.page_count>20 -%>
-          <%= link_to_if @filter_context.page_id<20, message('paging_next'), {:overwrite_params => {:page_id => 1+@filter_context.page_id}} %>
         <% end %>
 
         <% if @filter.projects_homepage? %>