diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/application.rb | 15 | ||||
-rw-r--r-- | app/controllers/boards_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/issues_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/repositories_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/wiki_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 30 | ||||
-rw-r--r-- | app/models/setting.rb | 5 | ||||
-rw-r--r-- | app/views/admin/projects.rhtml | 3 | ||||
-rw-r--r-- | app/views/auth_sources/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/boards/show.rhtml | 3 | ||||
-rw-r--r-- | app/views/issue_statuses/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/issues/index.rhtml | 3 | ||||
-rw-r--r-- | app/views/news/index.rhtml | 2 | ||||
-rw-r--r-- | app/views/repositories/revision.rhtml | 3 | ||||
-rw-r--r-- | app/views/repositories/revisions.rhtml | 3 | ||||
-rw-r--r-- | app/views/roles/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/settings/edit.rhtml | 3 | ||||
-rw-r--r-- | app/views/trackers/list.rhtml | 2 | ||||
-rw-r--r-- | app/views/users/list.rhtml | 4 | ||||
-rw-r--r-- | app/views/wiki/history.rhtml | 3 |
22 files changed, 63 insertions, 34 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 5ad3d696b..0f8eb32a5 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -35,7 +35,7 @@ class AdminController < ApplicationController @project_count = Project.count(:conditions => conditions) @project_pages = Paginator.new self, @project_count, - 25, + per_page_option, params['page'] @projects = Project.find :all, :order => sort_clause, :conditions => conditions, diff --git a/app/controllers/application.rb b/app/controllers/application.rb index ad86b6b33..607ac091b 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -158,6 +158,21 @@ class ApplicationController < ActionController::Base attachments end + # Returns the number of objects that should be displayed + # on the paginated list + def per_page_option + per_page = nil + if params[:per_page] && Setting.per_page_options_array.include?(params[:per_page].to_s.to_i) + per_page = params[:per_page].to_s.to_i + session[:per_page] = per_page + elsif session[:per_page] + per_page = session[:per_page] + else + per_page = Setting.per_page_options_array.first || 25 + end + per_page + end + # qvalues http header parser # code taken from webrick def parse_qvalues(value) diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 200792370..5bf4499bd 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -40,7 +40,7 @@ class BoardsController < ApplicationController sort_update @topic_count = @board.topics.count - @topic_pages = Paginator.new self, @topic_count, 25, params['page'] + @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] @topics = @board.topics.find :all, :order => "#{Message.table_name}.sticky DESC, #{sort_clause}", :include => [:author, {:last_reply => :author}], :limit => @topic_pages.items_per_page, diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f202e9bba..be854f98e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -45,7 +45,7 @@ class IssuesController < ApplicationController sort_update retrieve_query if @query.valid? - limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : 25 + limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : per_page_option @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) @issue_pages = Paginator.new self, @issue_count, limit, params['page'] @issues = Issue.find :all, :order => sort_clause, diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ef332eb37..f8b1eae81 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -75,7 +75,7 @@ class RepositoriesController < ApplicationController def revisions @changeset_count = @repository.changesets.count @changeset_pages = Paginator.new self, @changeset_count, - 25, + per_page_option, params['page'] @changesets = @repository.changesets.find(:all, :limit => @changeset_pages.items_per_page, diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3f3adb57d..f67d1ae53 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -39,7 +39,7 @@ class UsersController < ApplicationController @user_count = User.count(:conditions => conditions) @user_pages = Paginator.new self, @user_count, - 15, + per_page_option, params['page'] @users = User.find :all,:order => sort_clause, :conditions => conditions, diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index bc4b7b451..53c5ec53b 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -97,7 +97,7 @@ class WikiController < ApplicationController @page = @wiki.find_page(params[:page]) @version_count = @page.content.versions.count - @version_pages = Paginator.new self, @version_count, 25, params['p'] + @version_pages = Paginator.new self, @version_count, per_page_option, params['p'] # don't load text @versions = @page.content.versions.find :all, :select => "id, author_id, comments, updated_on, version", diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a3509b99a..e510f881f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -103,26 +103,40 @@ module ApplicationHelper l(:actionview_datehelper_select_month_names).split(',')[month-1] end - def pagination_links_full(paginator, options={}, html_options={}) + def pagination_links_full(paginator, count=nil, options={}) page_param = options.delete(:page_param) || :page - + url_param = params.dup + html = '' html << link_to_remote(('« ' + l(:label_previous)), - {:update => "content", :url => options.merge(page_param => paginator.current.previous)}, - {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous + {:update => "content", :url => url_param.merge(page_param => paginator.current.previous)}, + {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous html << (pagination_links_each(paginator, options) do |n| link_to_remote(n.to_s, - {:url => {:params => options.merge(page_param => n)}, :update => 'content'}, - {:href => url_for(:params => options.merge(page_param => n))}) + {:url => {:params => url_param.merge(page_param => n)}, :update => 'content'}, + {:href => url_for(:params => url_param.merge(page_param => n))}) end || '') html << ' ' + link_to_remote((l(:label_next) + ' »'), - {:update => "content", :url => options.merge(page_param => paginator.current.next)}, - {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next + {:update => "content", :url => url_param.merge(page_param => paginator.current.next)}, + {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next + + unless count.nil? + html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ') + end + html end + def per_page_links(selected=nil) + links = Setting.per_page_options_array.collect do |n| + n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, + {:href => url_for(params.dup.merge(:per_page => n))}) + end + links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil + end + def set_html_title(text) @html_header_title = text end diff --git a/app/models/setting.rb b/app/models/setting.rb index 4d4cf0045..46b6d76ce 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -95,6 +95,11 @@ class Setting < ActiveRecord::Base class_eval src, __FILE__, __LINE__ end + # Helper that returns an array based on per_page_options setting + def self.per_page_options_array + per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort + end + # Checks if settings have changed since the values were read # and clears the cache hash if it's the case # Called once per request diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml index e9d5e8537..295cfd101 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.rhtml @@ -45,7 +45,6 @@ </tbody> </table> -<p><%= pagination_links_full @project_pages, :status => @status %> -[ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]</p> +<p class="pagination"><%= pagination_links_full @project_pages, @project_count %></p> <% set_html_title l(:label_project_plural) -%> diff --git a/app/views/auth_sources/list.rhtml b/app/views/auth_sources/list.rhtml index f486f45b7..6836e6c67 100644 --- a/app/views/auth_sources/list.rhtml +++ b/app/views/auth_sources/list.rhtml @@ -25,4 +25,4 @@ </tbody> </table> -<%= pagination_links_full @auth_source_pages %> +<p class="pagination"><%= pagination_links_full @auth_source_pages %></p> diff --git a/app/views/boards/show.rhtml b/app/views/boards/show.rhtml index 8bcf960b2..01db0854c 100644 --- a/app/views/boards/show.rhtml +++ b/app/views/boards/show.rhtml @@ -43,8 +43,7 @@ <% end %> </tbody> </table> -<p><%= pagination_links_full @topic_pages %> -[ <%= @topic_pages.current.first_item %> - <%= @topic_pages.current.last_item %> / <%= @topic_count %> ]</p> +<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p> <% else %> <p class="nodata"><%= l(:label_no_data) %></p> <% end %> diff --git a/app/views/issue_statuses/list.rhtml b/app/views/issue_statuses/list.rhtml index 05506f3c7..a45f5d4d0 100644 --- a/app/views/issue_statuses/list.rhtml +++ b/app/views/issue_statuses/list.rhtml @@ -32,6 +32,6 @@ </tbody> </table> -<%= pagination_links_full @issue_status_pages %> +<p class="pagination"><%= pagination_links_full @issue_status_pages %></p> <% set_html_title(l(:label_issue_status_plural)) -%> diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index de0fd4add..c298b9bcc 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -48,8 +48,7 @@ <%= link_to 'CSV', {:format => 'csv'}, :class => 'icon icon-csv' %>, <%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %> </div> -<p><%= pagination_links_full @issue_pages %> -[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]</p> +<p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p> <% end %> <% end %> <% end %> diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml index 0b677d241..354467229 100644 --- a/app/views/news/index.rhtml +++ b/app/views/news/index.rhtml @@ -27,7 +27,7 @@ <%= textilizable(news.description) %> <% end %> <% end %> -<%= pagination_links_full @news_pages %> +<p class="pagination"><%= pagination_links_full @news_pages %></p> <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index d87dfa955..265070e37 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -56,8 +56,7 @@ <% end %> </tbody> </table> -<p><%= pagination_links_full @changes_pages, :rev => @changeset.revision %> -[ <%= @changes_pages.current.first_item %> - <%= @changes_pages.current.last_item %> / <%= @changes_count %> ]</p> +<p class="pagination"><%= pagination_links_full @changes_pages %></p> <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/repositories/revisions.rhtml b/app/views/repositories/revisions.rhtml index 4483a482c..99c3f7afd 100644 --- a/app/views/repositories/revisions.rhtml +++ b/app/views/repositories/revisions.rhtml @@ -9,8 +9,7 @@ <%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%> -<p><%= pagination_links_full @changeset_pages %> -[ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]</p> +<p class="pagination"><%= pagination_links_full @changeset_pages,@changeset_count %></p> <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/roles/list.rhtml b/app/views/roles/list.rhtml index 02bb20f5e..fabc5edcd 100644 --- a/app/views/roles/list.rhtml +++ b/app/views/roles/list.rhtml @@ -29,7 +29,7 @@ </tbody> </table> -<p><%= pagination_links_full @role_pages %></p> +<p class="pagination"><%= pagination_links_full @role_pages %></p> <p><%= link_to l(:label_permissions_report), :action => 'report' %></p> diff --git a/app/views/settings/edit.rhtml b/app/views/settings/edit.rhtml index 758045f05..b1db0e7ad 100644 --- a/app/views/settings/edit.rhtml +++ b/app/views/settings/edit.rhtml @@ -27,6 +27,9 @@ <p><label><%= l(:setting_attachment_max_size) %></label> <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p> +<p><label><%= l(:setting_per_page_options) %></label> +<%= text_field_tag 'settings[per_page_options]', Setting.per_page_options_array.join(', '), :size => 20 %><br /><em><%= l(:text_comma_separated) %></em></p> + <p><label><%= l(:setting_issues_export_limit) %></label> <%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p> diff --git a/app/views/trackers/list.rhtml b/app/views/trackers/list.rhtml index d339bdba0..447507210 100644 --- a/app/views/trackers/list.rhtml +++ b/app/views/trackers/list.rhtml @@ -30,6 +30,6 @@ </tbody> </table> -<%= pagination_links_full @tracker_pages %> +<p class="pagination"><%= pagination_links_full @tracker_pages %></p> <% set_html_title(l(:label_tracker_plural)) -%> diff --git a/app/views/users/list.rhtml b/app/views/users/list.rhtml index 3f879d7a6..fbac1e8e9 100644 --- a/app/views/users/list.rhtml +++ b/app/views/users/list.rhtml @@ -55,8 +55,6 @@ </tbody> </table> -<p><%= pagination_links_full @user_pages, :status => @status %> -[ <%= @user_pages.current.first_item %> - <%= @user_pages.current.last_item %> / <%= @user_count %> ] -</p> +<p class="pagination"><%= pagination_links_full @user_pages, @user_count %></p> <% set_html_title(l(:label_user_plural)) -%> diff --git a/app/views/wiki/history.rhtml b/app/views/wiki/history.rhtml index fc77e7fb5..6462e9fdd 100644 --- a/app/views/wiki/history.rhtml +++ b/app/views/wiki/history.rhtml @@ -31,6 +31,5 @@ </tbody> </table> <%= submit_tag l(:label_view_diff), :class => 'small' %> -<%= pagination_links_full @version_pages, :page_param => :p %> -[ <%= @version_pages.current.first_item %> - <%= @version_pages.current.last_item %> / <%= @version_count %> ] +<span class="pagination"><%= pagination_links_full @version_pages, @version_count, :page_param => :p %></span> <% end %> |