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

@ -34,7 +34,9 @@ class AdminController < ApplicationController
@params['page']
@projects = Project.find :all, :order => sort_clause,
: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
def mail_options

View File

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

View File

@ -21,11 +21,12 @@ class CustomFieldsController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
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
def new

View File

@ -21,11 +21,12 @@ class IssueStatusesController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
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
def new

View File

@ -29,7 +29,7 @@ class ProjectsController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
# Lists public projects
@ -43,7 +43,9 @@ class ProjectsController < ApplicationController
@projects = Project.find :all, :order => sort_clause,
:conditions => ["is_public=?", true],
: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
# Add a new project
@ -204,7 +206,7 @@ class ProjectsController < ApplicationController
sort_update
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_pages = Paginator.new self, @issue_count, 15, @params['page']
@ -212,7 +214,9 @@ class ProjectsController < ApplicationController
:include => [ :author, :status, :tracker, :project ],
:conditions => search_filter_clause,
: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
# Export filtered/sorted issues list to CSV
@ -279,6 +283,7 @@ class ProjectsController < ApplicationController
# Show news list of @project
def list_news
@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
def add_file

View File

@ -21,11 +21,12 @@ class RolesController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
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
def new

View File

@ -21,14 +21,15 @@ class TrackersController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :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
def new

View File

@ -26,7 +26,7 @@ class UsersController < ApplicationController
def index
list
render :action => 'list'
render :action => 'list' unless request.xhr?
end
def list
@ -38,7 +38,9 @@ class UsersController < ApplicationController
@params['page']
@users = User.find :all,:order => sort_clause,
: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
def add

View File

@ -59,10 +59,20 @@ module ApplicationHelper
end
def pagination_links_full(paginator, options={}, html_options={})
html =''
html << link_to(('&#171; ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
html << (pagination_links(paginator, options, html_options) || '')
html << ' ' + link_to((l(:label_next) + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next
html = ''
html << link_to_remote(('&#171; ' + l(:label_previous)),
{:update => "content", :url => { :page => paginator.current.previous }},
{: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
end

View File

@ -108,7 +108,10 @@ module SortHelper
end
caption = titleize(Inflector::humanize(column)) unless caption
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
# Returns a table header <th> tag with a sort link for the named column

View File

@ -2,11 +2,11 @@
<table class="listTableContent">
<tr class="ListHead">
<td><%=l(:field_name)%></td>
<td><%=l(:field_type)%></td>
<td><%=l(:field_host)%></td>
<td></td>
<td></td>
<th><%=l(:field_name)%></th>
<th><%=l(:field_type)%></th>
<th><%=l(:field_host)%></th>
<th></th>
<th></th>
</tr>
<% 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_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 valign="bottom">
<%= hidden_field_tag 'set_filter', 1 %>
<%= submit_tag l(:button_apply), :class => 'button-small' %>
<%= end_form_tag %>
<%= start_form_tag %>
<%= submit_tag l(:button_clear), :class => 'button-small' %>
<%= end_form_tag %>
</td>
</tr>
<td valign="bottom">
<%= link_to l(:button_clear), :action => 'list_issues', :id => @project, :set_filter => 1 %>
</td>
</tr>
</table>
<%= end_form_tag %>
&nbsp;
<%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %>