Project

General



Profile

« Previous | Next » 

Revision 1026

New setting added to specify how many objects should be displayed on most paginated lists.
Default is: 25, 50, 100 (users can choose one of these values).
If one value only is entered in this setting (eg. 25), the 'per page' links are not displayed (prior behaviour).

View differences:

trunk/app/controllers/admin_controller.rb
35 35
    
36 36
    @project_count = Project.count(:conditions => conditions)
37 37
    @project_pages = Paginator.new self, @project_count,
38
								25,
38
								per_page_option,
39 39
								params['page']								
40 40
    @projects = Project.find :all, :order => sort_clause,
41 41
                        :conditions => conditions,
trunk/app/controllers/application.rb
158 158
    attachments
159 159
  end
160 160

  
161
  # Returns the number of objects that should be displayed
162
  # on the paginated list
163
  def per_page_option
164
    per_page = nil
165
    if params[:per_page] && Setting.per_page_options_array.include?(params[:per_page].to_s.to_i)
166
      per_page = params[:per_page].to_s.to_i
167
      session[:per_page] = per_page
168
    elsif session[:per_page]
169
      per_page = session[:per_page]
170
    else
171
      per_page = Setting.per_page_options_array.first || 25
172
    end
173
    per_page
174
  end
175

  
161 176
  # qvalues http header parser
162 177
  # code taken from webrick
163 178
  def parse_qvalues(value)
trunk/app/controllers/boards_controller.rb
40 40
    sort_update	
41 41
      
42 42
    @topic_count = @board.topics.count
43
    @topic_pages = Paginator.new self, @topic_count, 25, params['page']
43
    @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
44 44
    @topics =  @board.topics.find :all, :order => "#{Message.table_name}.sticky DESC, #{sort_clause}",
45 45
                                  :include => [:author, {:last_reply => :author}],
46 46
                                  :limit  =>  @topic_pages.items_per_page,
trunk/app/controllers/issues_controller.rb
45 45
    sort_update
46 46
    retrieve_query
47 47
    if @query.valid?
48
      limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : 25
48
      limit = %w(pdf csv).include?(params[:format]) ? Setting.issues_export_limit.to_i : per_page_option
49 49
      @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement)
50 50
      @issue_pages = Paginator.new self, @issue_count, limit, params['page']
51 51
      @issues = Issue.find :all, :order => sort_clause,
trunk/app/controllers/repositories_controller.rb
75 75
  def revisions
76 76
    @changeset_count = @repository.changesets.count
77 77
    @changeset_pages = Paginator.new self, @changeset_count,
78
								      25,
78
								      per_page_option,
79 79
								      params['page']								
80 80
    @changesets = @repository.changesets.find(:all,
81 81
						:limit  =>  @changeset_pages.items_per_page,
trunk/app/controllers/users_controller.rb
39 39
    
40 40
    @user_count = User.count(:conditions => conditions)
41 41
    @user_pages = Paginator.new self, @user_count,
42
								15,
42
								per_page_option,
43 43
								params['page']								
44 44
    @users =  User.find :all,:order => sort_clause,
45 45
                        :conditions => conditions,
trunk/app/controllers/wiki_controller.rb
97 97
    @page = @wiki.find_page(params[:page])
98 98
    
99 99
    @version_count = @page.content.versions.count
100
    @version_pages = Paginator.new self, @version_count, 25, params['p']
100
    @version_pages = Paginator.new self, @version_count, per_page_option, params['p']
101 101
    # don't load text    
102 102
    @versions = @page.content.versions.find :all, 
103 103
                                            :select => "id, author_id, comments, updated_on, version",
trunk/app/helpers/application_helper.rb
103 103
    l(:actionview_datehelper_select_month_names).split(',')[month-1]
104 104
  end
105 105

  
106
  def pagination_links_full(paginator, options={}, html_options={})
106
  def pagination_links_full(paginator, count=nil, options={})
107 107
    page_param = options.delete(:page_param) || :page
108
  
108
    url_param = params.dup
109
    
109 110
    html = ''    
110 111
    html << link_to_remote(('&#171; ' + l(:label_previous)), 
111
                            {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
112
                            {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
112
                            {:update => "content", :url => url_param.merge(page_param => paginator.current.previous)},
113
                            {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
113 114
                            
114 115
    html << (pagination_links_each(paginator, options) do |n|
115 116
      link_to_remote(n.to_s, 
116
                      {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
117
                      {:href => url_for(:params => options.merge(page_param => n))})
117
                      {:url => {:params => url_param.merge(page_param => n)}, :update => 'content'},
118
                      {:href => url_for(:params => url_param.merge(page_param => n))})
118 119
    end || '')
119 120
    
120 121
    html << ' ' + link_to_remote((l(:label_next) + ' &#187;'), 
121
                                 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
122
                                 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
122
                                 {:update => "content", :url => url_param.merge(page_param => paginator.current.next)},
123
                                 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
124
    
125
    unless count.nil?
126
      html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
127
    end
128
    
123 129
    html  
124 130
  end
125 131
  
132
  def per_page_links(selected=nil)
133
    links = Setting.per_page_options_array.collect do |n|
134
      n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, 
135
                                            {:href => url_for(params.dup.merge(:per_page => n))})
136
    end
137
    links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
138
  end
139
  
126 140
  def set_html_title(text)
127 141
    @html_header_title = text
128 142
  end
trunk/app/models/setting.rb
95 95
    class_eval src, __FILE__, __LINE__
96 96
  end
97 97
  
98
  # Helper that returns an array based on per_page_options setting
99
  def self.per_page_options_array
100
    per_page_options.split(%r{[\s,]}).collect(&:to_i).select {|n| n > 0}.sort
101
  end
102
  
98 103
  # Checks if settings have changed since the values were read
99 104
  # and clears the cache hash if it's the case
100 105
  # Called once per request
trunk/app/views/admin/projects.rhtml
45 45
  </tbody>
46 46
</table>
47 47

  
48
<p><%= pagination_links_full @project_pages, :status => @status %>
49
[ <%= @project_pages.current.first_item %> - <%= @project_pages.current.last_item %> / <%= @project_count %> ]</p>
48
<p class="pagination"><%= pagination_links_full @project_pages, @project_count %></p>
50 49

  
51 50
<% set_html_title l(:label_project_plural) -%>
trunk/app/views/auth_sources/list.rhtml
25 25
  </tbody>
26 26
</table>
27 27

  
28
<%= pagination_links_full @auth_source_pages %>
28
<p class="pagination"><%= pagination_links_full @auth_source_pages %></p>
trunk/app/views/boards/show.rhtml
43 43
  <% end %>
44 44
  </tbody>
45 45
</table>
46
<p><%= pagination_links_full @topic_pages %>
47
[ <%= @topic_pages.current.first_item %> - <%= @topic_pages.current.last_item %> / <%= @topic_count %> ]</p>
46
<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p>
48 47
<% else %>
49 48
<p class="nodata"><%= l(:label_no_data) %></p>
50 49
<% end %>
trunk/app/views/issue_statuses/list.rhtml
32 32
  </tbody>
33 33
</table>
34 34

  
35
<%= pagination_links_full @issue_status_pages %>
35
<p class="pagination"><%= pagination_links_full @issue_status_pages %></p>
36 36

  
37 37
<% set_html_title(l(:label_issue_status_plural)) -%>
trunk/app/views/issues/index.rhtml
48 48
<%= link_to 'CSV', {:format => 'csv'}, :class => 'icon icon-csv' %>,
49 49
<%= link_to 'PDF', {:format => 'pdf'}, :class => 'icon icon-pdf' %>
50 50
</div>
51
<p><%= pagination_links_full @issue_pages %>
52
[ <%= @issue_pages.current.first_item %> - <%= @issue_pages.current.last_item %> / <%= @issue_count %> ]</p>
51
<p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p>
53 52
<% end %>
54 53
<% end %>
55 54
<% end %>
trunk/app/views/news/index.rhtml
27 27
    <%= textilizable(news.description) %>
28 28
<% end %>
29 29
<% end %>
30
<%= pagination_links_full @news_pages %>
30
<p class="pagination"><%= pagination_links_full @news_pages %></p>
31 31

  
32 32
<% content_for :header_tags do %>
33 33
  <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
trunk/app/views/repositories/revision.rhtml
56 56
<% end %>
57 57
</tbody>
58 58
</table>
59
<p><%= pagination_links_full @changes_pages, :rev => @changeset.revision %>
60
[ <%= @changes_pages.current.first_item %> - <%= @changes_pages.current.last_item %> / <%= @changes_count %> ]</p>
59
<p class="pagination"><%= pagination_links_full @changes_pages %></p>
61 60

  
62 61
<% content_for :header_tags do %>
63 62
<%= stylesheet_link_tag "scm" %>
trunk/app/views/repositories/revisions.rhtml
9 9

  
10 10
<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>
11 11

  
12
<p><%= pagination_links_full @changeset_pages %>
13
[ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]</p>
12
<p class="pagination"><%= pagination_links_full @changeset_pages,@changeset_count %></p>
14 13

  
15 14
<% content_for :header_tags do %>
16 15
<%= stylesheet_link_tag "scm" %>
trunk/app/views/roles/list.rhtml
29 29
  </tbody>
30 30
</table>
31 31

  
32
<p><%= pagination_links_full @role_pages %></p>
32
<p class="pagination"><%= pagination_links_full @role_pages %></p>
33 33

  
34 34
<p><%= link_to l(:label_permissions_report), :action => 'report' %></p>
35 35

  
trunk/app/views/settings/edit.rhtml
27 27
<p><label><%= l(:setting_attachment_max_size) %></label>
28 28
<%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p>
29 29

  
30
<p><label><%= l(:setting_per_page_options) %></label>
31
<%= text_field_tag 'settings[per_page_options]', Setting.per_page_options_array.join(', '), :size => 20 %><br /><em><%= l(:text_comma_separated) %></em></p>
32

  
30 33
<p><label><%= l(:setting_issues_export_limit) %></label>
31 34
<%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
32 35

  
trunk/app/views/trackers/list.rhtml
30 30
  </tbody>
31 31
</table>
32 32

  
33
<%= pagination_links_full @tracker_pages %>
33
<p class="pagination"><%= pagination_links_full @tracker_pages %></p>
34 34

  
35 35
<% set_html_title(l(:label_tracker_plural)) -%>
trunk/app/views/users/list.rhtml
55 55
  </tbody>
56 56
</table>
57 57

  
58
<p><%= pagination_links_full @user_pages, :status => @status %>
59
[ <%= @user_pages.current.first_item %> - <%= @user_pages.current.last_item %> / <%= @user_count %> ]
60
</p>
58
<p class="pagination"><%= pagination_links_full @user_pages, @user_count %></p>
61 59

  
62 60
<% set_html_title(l(:label_user_plural)) -%>
trunk/app/views/wiki/history.rhtml
31 31
</tbody>
32 32
</table>
33 33
<%= submit_tag l(:label_view_diff), :class => 'small' %>
34
<%= pagination_links_full @version_pages, :page_param => :p %>
35
[ <%= @version_pages.current.first_item %> - <%= @version_pages.current.last_item %> / <%= @version_count %> ]
34
<span class="pagination"><%= pagination_links_full @version_pages, @version_count, :page_param => :p %></span>
36 35
<% end %>
trunk/config/settings.yml
37 37
issues_export_limit:
38 38
  format: int
39 39
  default: 500
40
per_page_options:
41
  default: '25,50,100'
40 42
mail_from:
41 43
  default: redmine@somenet.foo
42 44
bcc_recipients:
trunk/lang/bg.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/cs.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/de.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/en.yml
198 198
setting_repositories_encodings: Repositories encodings
199 199
setting_emails_footer: Emails footer
200 200
setting_protocol: Protocol
201
setting_per_page_options: Objects per page options
201 202

  
202 203
label_user: User
203 204
label_user_plural: Users
......
456 457
label_registration_activation_by_email: account activation by email
457 458
label_registration_manual_activation: manual account activation
458 459
label_registration_automatic_activation: automatic account activation
460
label_display_per_page: 'Per page: %s'
459 461

  
460 462
button_login: Login
461 463
button_submit: Submit
trunk/lang/es.yml
553 553
button_annotate: Annotate
554 554
label_issues_by: Issues by %s
555 555
field_searchable: Searchable
556
label_display_per_page: 'Per page: %s'
557
setting_per_page_options: Objects per page options
trunk/lang/fr.yml
198 198
setting_repositories_encodings: Encodages des dépôts
199 199
setting_emails_footer: Pied-de-page des emails
200 200
setting_protocol: Protocole
201
setting_per_page_options: Options d'objets affichés par page
201 202

  
202 203
label_user: Utilisateur
203 204
label_user_plural: Utilisateurs
......
456 457
label_registration_activation_by_email: activation du compte par email
457 458
label_registration_manual_activation: activation manuelle du compte
458 459
label_registration_automatic_activation: activation automatique du compte
460
label_display_per_page: 'Par page: %s'
459 461

  
460 462
button_login: Connexion
461 463
button_submit: Soumettre
trunk/lang/he.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/it.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/ja.yml
551 551
button_annotate: 注釈
552 552
label_issues_by: %s別の問題
553 553
field_searchable: Searchable
554
label_display_per_page: 'Per page: %s'
555
setting_per_page_options: Objects per page options
trunk/lang/ko.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/nl.yml
551 551
button_annotate: Annotate
552 552
label_issues_by: Issues by %s
553 553
field_searchable: Searchable
554
label_display_per_page: 'Per page: %s'
555
setting_per_page_options: Objects per page options
trunk/lang/pl.yml
550 550
button_annotate: Adnotuj
551 551
label_issues_by: Zagadnienia wprowadzone przez %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/pt-br.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/pt.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/ro.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/ru.yml
550 550
button_annotate: Annotate
551 551
label_issues_by: Issues by %s
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/sr.yml
551 551
button_annotate: Annotate
552 552
label_issues_by: Issues by %s
553 553
field_searchable: Searchable
554
label_display_per_page: 'Per page: %s'
555
setting_per_page_options: Objects per page options
trunk/lang/sv.yml
551 551
button_annotate: Annotate
552 552
label_issues_by: Issues by %s
553 553
field_searchable: Searchable
554
label_display_per_page: 'Per page: %s'
555
setting_per_page_options: Objects per page options
trunk/lang/zh-tw.yml
550 550
enumeration_doc_categories: 文件分類
551 551
enumeration_activities: 活動 (time tracking)
552 552
field_searchable: Searchable
553
label_display_per_page: 'Per page: %s'
554
setting_per_page_options: Objects per page options
trunk/lang/zh.yml
553 553
button_annotate: Annotate
554 554
label_issues_by: Issues by %s
555 555
field_searchable: Searchable
556
label_display_per_page: 'Per page: %s'
557
setting_per_page_options: Objects per page options
trunk/public/stylesheets/application.css
126 126
.autoscroll {overflow-x: auto; padding:1px; width:100%; margin-bottom: 1.2em;}
127 127
#user_firstname, #user_lastname, #user_mail, #my_account_form select { width: 90%; }
128 128

  
129
.pagination {font-size: 90%}
130
p.pagination {margin-top:8px;}
131

  
129 132
/***** Tabular forms ******/
130 133
.tabular p{
131 134
margin: 0;

Also available in: Unified diff