From 6a0022d7a146d7827fc7acccde07cd3c159e2cfb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 21 Oct 2006 10:38:53 +0000 Subject: [PATCH] ajaxified paginators git-svn-id: http://redmine.rubyforge.org/svn/trunk@33 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- redmine/app/controllers/admin_controller.rb | 4 +++- .../app/controllers/auth_sources_controller.rb | 3 ++- .../controllers/custom_fields_controller.rb | 5 +++-- .../controllers/issue_statuses_controller.rb | 5 +++-- redmine/app/controllers/projects_controller.rb | 13 +++++++++---- redmine/app/controllers/roles_controller.rb | 5 +++-- redmine/app/controllers/trackers_controller.rb | 5 +++-- redmine/app/controllers/users_controller.rb | 6 ++++-- redmine/app/helpers/application_helper.rb | 18 ++++++++++++++---- redmine/app/helpers/sort_helper.rb | 5 ++++- redmine/app/views/auth_sources/list.rhtml | 10 +++++----- redmine/app/views/projects/list_issues.rhtml | 14 +++++++------- 12 files changed, 60 insertions(+), 33 deletions(-) diff --git a/redmine/app/controllers/admin_controller.rb b/redmine/app/controllers/admin_controller.rb index 4b144e8d5..2c9f67586 100644 --- a/redmine/app/controllers/admin_controller.rb +++ b/redmine/app/controllers/admin_controller.rb @@ -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 diff --git a/redmine/app/controllers/auth_sources_controller.rb b/redmine/app/controllers/auth_sources_controller.rb index fe8536f99..86b58d365 100644 --- a/redmine/app/controllers/auth_sources_controller.rb +++ b/redmine/app/controllers/auth_sources_controller.rb @@ -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 diff --git a/redmine/app/controllers/custom_fields_controller.rb b/redmine/app/controllers/custom_fields_controller.rb index d0ffddf7f..bfa152fd1 100644 --- a/redmine/app/controllers/custom_fields_controller.rb +++ b/redmine/app/controllers/custom_fields_controller.rb @@ -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 diff --git a/redmine/app/controllers/issue_statuses_controller.rb b/redmine/app/controllers/issue_statuses_controller.rb index be577ef19..18ca9c76d 100644 --- a/redmine/app/controllers/issue_statuses_controller.rb +++ b/redmine/app/controllers/issue_statuses_controller.rb @@ -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 diff --git a/redmine/app/controllers/projects_controller.rb b/redmine/app/controllers/projects_controller.rb index 8343c7a5f..a3dac1e04 100644 --- a/redmine/app/controllers/projects_controller.rb +++ b/redmine/app/controllers/projects_controller.rb @@ -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 diff --git a/redmine/app/controllers/roles_controller.rb b/redmine/app/controllers/roles_controller.rb index 6d524cf14..e16127b61 100644 --- a/redmine/app/controllers/roles_controller.rb +++ b/redmine/app/controllers/roles_controller.rb @@ -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 diff --git a/redmine/app/controllers/trackers_controller.rb b/redmine/app/controllers/trackers_controller.rb index bc76ea556..bbfb4f48b 100644 --- a/redmine/app/controllers/trackers_controller.rb +++ b/redmine/app/controllers/trackers_controller.rb @@ -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 diff --git a/redmine/app/controllers/users_controller.rb b/redmine/app/controllers/users_controller.rb index 51c10ca8a..dee9e9d6b 100644 --- a/redmine/app/controllers/users_controller.rb +++ b/redmine/app/controllers/users_controller.rb @@ -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 diff --git a/redmine/app/helpers/application_helper.rb b/redmine/app/helpers/application_helper.rb index d3fc00cd5..4dc4acc27 100644 --- a/redmine/app/helpers/application_helper.rb +++ b/redmine/app/helpers/application_helper.rb @@ -59,10 +59,20 @@ module ApplicationHelper end def pagination_links_full(paginator, options={}, html_options={}) - html ='' - html << link_to(('« ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous - html << (pagination_links(paginator, options, html_options) || '') - html << ' ' + link_to((l(:label_next) + ' »'), { :page => paginator.current.next }) if paginator.current.next + html = '' + html << link_to_remote(('« ' + 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) + ' »'), + {: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 diff --git a/redmine/app/helpers/sort_helper.rb b/redmine/app/helpers/sort_helper.rb index bec2117ec..04a84c8e4 100644 --- a/redmine/app/helpers/sort_helper.rb +++ b/redmine/app/helpers/sort_helper.rb @@ -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 tag with a sort link for the named column diff --git a/redmine/app/views/auth_sources/list.rhtml b/redmine/app/views/auth_sources/list.rhtml index 1c27ddaf7..47cbeeaff 100644 --- a/redmine/app/views/auth_sources/list.rhtml +++ b/redmine/app/views/auth_sources/list.rhtml @@ -2,11 +2,11 @@ - - - - - + + + + + <% for source in @auth_sources %> diff --git a/redmine/app/views/projects/list_issues.rhtml b/redmine/app/views/projects/list_issues.rhtml index 7a924b134..6cd5f8070 100644 --- a/redmine/app/views/projects/list_issues.rhtml +++ b/redmine/app/views/projects/list_issues.rhtml @@ -10,17 +10,17 @@ - - + +
<%=l(:field_name)%><%=l(:field_type)%><%=l(:field_host)%><%=l(:field_name)%><%=l(:field_type)%><%=l(:field_host)%>
<%=l(:field_fixed_version)%>:
<%= search_filter_tag 'fixed_version_id', :class => 'select-small' %>
<%=l(:field_assigned_to)%>:
<%= search_filter_tag 'assigned_to_id', :class => 'select-small' %>
<%=l(:label_subproject_plural)%>:
<%= search_filter_tag 'subproject_id', :class => 'select-small' %>
+ <%= 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 %>
+ <%= link_to l(:button_clear), :action => 'list_issues', :id => @project, :set_filter => 1 %> +
+<%= end_form_tag %> +   <%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %> -- 2.39.5