diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-12 10:36:33 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-12-12 10:36:33 +0100 |
commit | ee08249875a844de0000f811b7455bc0dafdeb43 (patch) | |
tree | 84fc5ca73e849d726f23f0b482f4e3886e89665f /sonar-server | |
parent | 35ed9868ed703c04cf40b48eff239eef34fdae13 (diff) | |
download | sonarqube-ee08249875a844de0000f811b7455bc0dafdeb43.tar.gz sonarqube-ee08249875a844de0000f811b7455bc0dafdeb43.zip |
Add documentation to ruby method "table_pagination" and deprecated the template utils/tfoot_pagination
Diffstat (limited to 'sonar-server')
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 "<a href='#{url}' modal-width='#{width}' class='open-modal #{clazz}' #{id}>#{h label}</a>" end + # Add a <tfoot> 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 <tfoot> 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 '<id>_loading' def table_pagination(pagination, options={}, &block) html = '<tfoot' html += " id='#{options[:id]}'" if options[:id] @@ -741,7 +743,7 @@ module ApplicationHelper html += ' ' end end - html+= '</div></td></tr></tfoot>' + html += '</div></td></tr></tfoot>' html end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb index 3c5f09a00c5..cd31a381d22 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb @@ -83,7 +83,7 @@ </tr> </thead> - <%= 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}))} -%> <tbody> <% 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 @@ </tr> </thead> -<%= 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}))} -%> <tbody> <% 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 @@ -<tfoot> -<tr> - <td colspan="<%= colspan || 1 -%>"> - <% 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 - %> - </td> -</tr> -</tfoot>
\ 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 |