ajaxified paginators

git-svn-id: http://redmine.rubyforge.org/svn/trunk@33 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2006-10-21 10:38:53 +00:00
parent e4d4a12c6a
commit 6a0022d7a1
12 changed files with 60 additions and 33 deletions

View File

@ -35,6 +35,8 @@ class AdminController < ApplicationController
@projects = Project.find :all, :order => sort_clause, @projects = Project.find :all, :order => sort_clause,
:limit => @project_pages.items_per_page, :limit => @project_pages.items_per_page,
:offset => @project_pages.current.offset :offset => @project_pages.current.offset
render :action => "projects", :layout => false if request.xhr?
end end
def mail_options def mail_options

View File

@ -21,7 +21,7 @@ class AuthSourcesController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
@ -30,6 +30,7 @@ class AuthSourcesController < ApplicationController
def list def list
@auth_source_pages, @auth_sources = paginate :auth_sources, :per_page => 10 @auth_source_pages, @auth_sources = paginate :auth_sources, :per_page => 10
render :action => "list", :layout => false if request.xhr?
end end
def new def new

View File

@ -21,11 +21,12 @@ class CustomFieldsController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
def list def list
@custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15 @custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15
render :action => "list", :layout => false if request.xhr?
end end
def new def new

View File

@ -21,11 +21,12 @@ class IssueStatusesController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
def list def list
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
render :action => "list", :layout => false if request.xhr?
end end
def new def new

View File

@ -29,7 +29,7 @@ class ProjectsController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
# Lists public projects # Lists public projects
@ -44,6 +44,8 @@ class ProjectsController < ApplicationController
:conditions => ["is_public=?", true], :conditions => ["is_public=?", true],
:limit => @project_pages.items_per_page, :limit => @project_pages.items_per_page,
:offset => @project_pages.current.offset :offset => @project_pages.current.offset
render :action => "list", :layout => false if request.xhr?
end end
# Add a new project # Add a new project
@ -204,7 +206,7 @@ class ProjectsController < ApplicationController
sort_update sort_update
search_filter_init_list_issues search_filter_init_list_issues
search_filter_update if params[:set_filter] or request.post? search_filter_update if params[:set_filter]
@issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause) @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
@issue_pages = Paginator.new self, @issue_count, 15, @params['page'] @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
@ -213,6 +215,8 @@ class ProjectsController < ApplicationController
:conditions => search_filter_clause, :conditions => search_filter_clause,
:limit => @issue_pages.items_per_page, :limit => @issue_pages.items_per_page,
:offset => @issue_pages.current.offset :offset => @issue_pages.current.offset
render :action => "list_issues", :layout => false if request.xhr?
end end
# Export filtered/sorted issues list to CSV # Export filtered/sorted issues list to CSV
@ -279,6 +283,7 @@ class ProjectsController < ApplicationController
# Show news list of @project # Show news list of @project
def list_news def list_news
@news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC" @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"
render :action => "list_news", :layout => false if request.xhr?
end end
def add_file def add_file

View File

@ -21,11 +21,12 @@ class RolesController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
def list def list
@role_pages, @roles = paginate :roles, :per_page => 10 @role_pages, @roles = paginate :roles, :per_page => 10
render :action => "list", :layout => false if request.xhr?
end end
def new def new

View File

@ -21,7 +21,7 @@ class TrackersController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
@ -29,6 +29,7 @@ class TrackersController < ApplicationController
def list def list
@tracker_pages, @trackers = paginate :trackers, :per_page => 10 @tracker_pages, @trackers = paginate :trackers, :per_page => 10
render :action => "list", :layout => false if request.xhr?
end end
def new def new

View File

@ -26,7 +26,7 @@ class UsersController < ApplicationController
def index def index
list list
render :action => 'list' render :action => 'list' unless request.xhr?
end end
def list def list
@ -39,6 +39,8 @@ class UsersController < ApplicationController
@users = User.find :all,:order => sort_clause, @users = User.find :all,:order => sort_clause,
:limit => @user_pages.items_per_page, :limit => @user_pages.items_per_page,
:offset => @user_pages.current.offset :offset => @user_pages.current.offset
render :action => "list", :layout => false if request.xhr?
end end
def add def add

View File

@ -59,10 +59,20 @@ module ApplicationHelper
end end
def pagination_links_full(paginator, options={}, html_options={}) def pagination_links_full(paginator, options={}, html_options={})
html ='' html = ''
html << link_to(('&#171; ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous html << link_to_remote(('&#171; ' + l(:label_previous)),
html << (pagination_links(paginator, options, html_options) || '') {:update => "content", :url => { :page => paginator.current.previous }},
html << ' ' + link_to((l(:label_next) + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous
html << (pagination_links_each(paginator, options) do |n|
link_to_remote(n.to_s,
{:url => {:action => 'list', :params => @params.merge({:page => n})}, :update => 'content'},
{:href => url_for(:action => 'list', :params => @params.merge({:page => n}))})
end || '')
html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
{:update => "content", :url => { :page => paginator.current.next }},
{:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.next}))}) if paginator.current.next
html html
end end

View File

@ -108,7 +108,10 @@ module SortHelper
end end
caption = titleize(Inflector::humanize(column)) unless caption caption = titleize(Inflector::humanize(column)) unless caption
params = {:params => {:sort_key => column, :sort_order => order}} params = {:params => {:sort_key => column, :sort_order => order}}
link_to(caption, params) + (icon ? nbsp(2) + image_tag(icon) : '') link_to_remote(caption,
{:update => "content", :url => { :sort_key => column, :sort_order => order}},
{:href => url_for(:params => { :sort_key => column, :sort_order => order})}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end end
# Returns a table header <th> tag with a sort link for the named column # Returns a table header <th> tag with a sort link for the named column

View File

@ -2,11 +2,11 @@
<table class="listTableContent"> <table class="listTableContent">
<tr class="ListHead"> <tr class="ListHead">
<td><%=l(:field_name)%></td> <th><%=l(:field_name)%></th>
<td><%=l(:field_type)%></td> <th><%=l(:field_type)%></th>
<td><%=l(:field_host)%></td> <th><%=l(:field_host)%></th>
<td></td> <th></th>
<td></td> <th></th>
</tr> </tr>
<% for source in @auth_sources %> <% for source in @auth_sources %>

View File

@ -10,17 +10,17 @@
<td><small><%=l(:field_fixed_version)%>:</small><br /><%= search_filter_tag 'fixed_version_id', :class => 'select-small' %></td> <td><small><%=l(:field_fixed_version)%>:</small><br /><%= search_filter_tag 'fixed_version_id', :class => 'select-small' %></td>
<td><small><%=l(:field_assigned_to)%>:</small><br /><%= search_filter_tag 'assigned_to_id', :class => 'select-small' %></td> <td><small><%=l(:field_assigned_to)%>:</small><br /><%= search_filter_tag 'assigned_to_id', :class => 'select-small' %></td>
<td><small><%=l(:label_subproject_plural)%>:</small><br /><%= search_filter_tag 'subproject_id', :class => 'select-small' %></td> <td><small><%=l(:label_subproject_plural)%>:</small><br /><%= search_filter_tag 'subproject_id', :class => 'select-small' %></td>
<td valign="bottom"> <td valign="bottom">
<%= hidden_field_tag 'set_filter', 1 %>
<%= submit_tag l(:button_apply), :class => 'button-small' %> <%= submit_tag l(:button_apply), :class => 'button-small' %>
<%= end_form_tag %> </td>
<td valign="bottom">
<%= start_form_tag %> <%= link_to l(:button_clear), :action => 'list_issues', :id => @project, :set_filter => 1 %>
<%= submit_tag l(:button_clear), :class => 'button-small' %>
<%= end_form_tag %>
</td> </td>
</tr> </tr>
</table> </table>
<%= end_form_tag %>
&nbsp; &nbsp;
<%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %> <%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %>