From ee08249875a844de0000f811b7455bc0dafdeb43 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 12 Dec 2012 10:36:33 +0100 Subject: [PATCH] Add documentation to ruby method "table_pagination" and deprecated the template utils/tfoot_pagination --- .../WEB-INF/app/helpers/application_helper.rb | 10 ++-- .../WEB-INF/app/views/roles/projects.html.erb | 2 +- .../views/rules_configuration/index.html.erb | 2 +- .../views/utils/_tfoot_pagination.html.erb | 47 ++----------------- 4 files changed, 12 insertions(+), 49 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 6b5798a4620..e44d640636a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -688,10 +688,12 @@ module ApplicationHelper "#{h label}" end + # Add a section to a table with pagination details and links. # Options : - # :id - # :colspan - # :include_loading_icon - only if :id is set as well + # :id HTML id of the node + # :colspan number of columns in the table + # :include_loading_icon adds a hidden loading icon, only if value is true and if the option :id is set as well. The HTML id of the icon + # is '_loading' def table_pagination(pagination, options={}, &block) html = ' - <%= render :partial => 'utils/tfoot_pagination', :locals => {:pagination => @pagination, :colspan => 4} %> + <%= table_pagination(@pagination, :colspan => 4) { |label, page_id| link_to(label, params.merge({:page => page_id}))} -%> <% if @projects.empty? %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb index 3b74916f80a..4b82c3d0509 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/rules_configuration/index.html.erb @@ -105,7 +105,7 @@ -<%= render :partial => 'utils/tfoot_pagination', :locals => {:pagination => @pagination, :colspan => 2} %> + <%= table_pagination(@pagination, :colspan => 2) { |label, page_id| link_to(label, params.merge({:page => page_id}))} -%> <% if @current_rules.empty? %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/utils/_tfoot_pagination.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/utils/_tfoot_pagination.html.erb index f50dafc2aa1..a6a6c3ec537 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/utils/_tfoot_pagination.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/utils/_tfoot_pagination.html.erb @@ -1,43 +1,4 @@ - - - - <% if pagination.count > 0 %> - <%= message('x_results', :params => [pagination.count]) -%> - <% end %> - <% - if pagination.pages > 1 - max_pages = pagination.pages - current_page = pagination.page - 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 - %> - | - <% if max_pages > 20 && start_page > 1 %> - <%= link_to_if current_page != 1, message('paging_first'), params.merge(:page => 1) %> - <% end %> - <%= link_to_if pagination.previous?, message('paging_previous'), params.merge(:page => current_page-1) %> - <% for index in start_page..end_page %> - <%= link_to_if index != current_page, index.to_s, params.merge(:page => index) %> - <% end %> - <%= link_to_if pagination.next?, message('paging_next'), params.merge(:page => current_page+1) %> - <% if max_pages > 20 && end_page < max_pages %> - <%= link_to_if current_page != max_pages, message('paging_last'), params.merge(:page => max_pages) %> - <% end %> - <% - end - %> - - - \ No newline at end of file +<% + # this template is deprecated. Please use the method table_pagination. +%> +<%= table_pagination(pagination, :colspan => (colspan||1)) { |label, page_id| link_to(label, params.merge({:page => page_id}))} -%> \ No newline at end of file -- 2.39.5