]> source.dussan.org Git - redmine.git/commitdiff
ajaxified paginators
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Oct 2006 10:38:53 +0000 (10:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Oct 2006 10:38:53 +0000 (10:38 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@33 e93f8b46-1217-0410-a6f0-8f06a7374b81

12 files changed:
redmine/app/controllers/admin_controller.rb
redmine/app/controllers/auth_sources_controller.rb
redmine/app/controllers/custom_fields_controller.rb
redmine/app/controllers/issue_statuses_controller.rb
redmine/app/controllers/projects_controller.rb
redmine/app/controllers/roles_controller.rb
redmine/app/controllers/trackers_controller.rb
redmine/app/controllers/users_controller.rb
redmine/app/helpers/application_helper.rb
redmine/app/helpers/sort_helper.rb
redmine/app/views/auth_sources/list.rhtml
redmine/app/views/projects/list_issues.rhtml

index 4b144e8d560bb7bdbebebbd01f64ba215347a2a7..2c9f67586e7c4932dd5eb6754cc321cbdb219e27 100644 (file)
@@ -34,7 +34,9 @@ class AdminController < ApplicationController
                                                                @params['page']                                                         \r
     @projects = Project.find :all, :order => sort_clause,\r
                                                :limit  =>  @project_pages.items_per_page,\r
-                                               :offset =>  @project_pages.current.offset               \r
+                                               :offset =>  @project_pages.current.offset\r
+\r
+    render :action => "projects", :layout => false if request.xhr?\r
   end\r
 \r
   def mail_options\r
index fe8536f990f54335e60987e8d1c30b9f8587b98a..86b58d3655d2f897791ea14097adef89ef29a662 100644 (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
index d0ffddf7f6a2f44a8e0cd16d9396bdedbe365505..bfa152fd1885a25787529927eb60b2d33fcc6f90 100644 (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\r
+    render :action => "list", :layout => false if request.xhr?
   end
   \r
   def new\r
index be577ef19f95d02357f8e1ca3898417812814e6c..18ca9c76d8bc916a17d43d1c62e2201a8a04d666 100644 (file)
@@ -21,11 +21,12 @@ class IssueStatusesController < ApplicationController
        \r
   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\r
+    render :action => "list", :layout => false if request.xhr?
   end
 
   def new
index 8343c7a5fb81059c742c781da6601aa893f677bc..a3dac1e04da06604ab98dda92a0d16cd7441871f 100644 (file)
@@ -29,7 +29,7 @@ class ProjectsController < ApplicationController
 \r
   def index
     list
-    render :action => 'list'
+    render :action => 'list' unless request.xhr?
   end
 \r
   # Lists public projects
@@ -43,7 +43,9 @@ class ProjectsController < ApplicationController
     @projects = Project.find :all, :order => sort_clause,\r
                                                :conditions => ["is_public=?", true],\r
                                                :limit  =>  @project_pages.items_per_page,\r
-                                               :offset =>  @project_pages.current.offset               
+                                               :offset =>  @project_pages.current.offset\r
+\r
+    render :action => "list", :layout => false if request.xhr? 
   end\r
           \r
   # Add a new project
@@ -204,7 +206,7 @@ class ProjectsController < ApplicationController
     sort_update\r
 \r
     search_filter_init_list_issues\r
-    search_filter_update if params[:set_filter] or request.post?\r
+    search_filter_update if params[:set_filter]\r
 \r
     @issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)           \r
     @issue_pages = Paginator.new self, @issue_count, 15, @params['page']                                                               \r
@@ -212,7 +214,9 @@ class ProjectsController < ApplicationController
                                                :include => [ :author, :status, :tracker, :project ],\r
                                                :conditions => search_filter_clause,\r
                                                :limit  =>  @issue_pages.items_per_page,\r
-                                               :offset =>  @issue_pages.current.offset\r
+                                               :offset =>  @issue_pages.current.offset                                         \r
+    \r
+    render :action => "list_issues", :layout => false if request.xhr?\r
   end\r
 \r
   # Export filtered/sorted issues list to CSV\r
@@ -279,6 +283,7 @@ class ProjectsController < ApplicationController
   # Show news list of @project\r
   def list_news\r
     @news_pages, @news = paginate :news, :per_page => 10, :conditions => ["project_id=?", @project.id], :include => :author, :order => "news.created_on DESC"\r
+    render :action => "list_news", :layout => false if request.xhr?\r
   end\r
 \r
   def add_file  \r
index 6d524cf142f5aaadd130c2a857c8ab5a0d05df5e..e16127b615bee484857a6a0b14415c4ae7fa13b1 100644 (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\r
+    render :action => "list", :layout => false if request.xhr?
   end
 
   def new
index bc76ea55600ab18e40a42e5a75083b8e78d5db3c..bbfb4f48b1f65ae47220cae5335635ecc3e3343d 100644 (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\r
+    render :action => "list", :layout => false if request.xhr?
   end
 
   def new
index 51c10ca8a72f9ae92ed3fea05f0b99b47cc1ba60..dee9e9d6be13c779d3f0802a14c6723f0860d4dd 100644 (file)
@@ -26,7 +26,7 @@ class UsersController < ApplicationController
 
   def index
     list
-    render :action => 'list'
+    render :action => 'list' unless request.xhr?
   end
 
   def list\r
@@ -38,7 +38,9 @@ class UsersController < ApplicationController
                                                                @params['page']                                                         \r
     @users =  User.find :all,:order => sort_clause,\r
                                                :limit  =>  @user_pages.items_per_page,\r
-                                               :offset =>  @user_pages.current.offset          
+                                               :offset =>  @user_pages.current.offset\r
+\r
+    render :action => "list", :layout => false if request.xhr? 
   end
 
   def add
index d3fc00cd5ee0b7afa2c27da7e0342fdb45a1d871..4dc4acc272bb63383da882ad62c2110c4e85095d 100644 (file)
@@ -59,10 +59,20 @@ module ApplicationHelper
   end\r
   \r
   def pagination_links_full(paginator, options={}, html_options={})\r
-    html =''\r
-    html << link_to(('&#171; ' + l(:label_previous) ), { :page => paginator.current.previous }) + ' ' if paginator.current.previous
-    html << (pagination_links(paginator, options, html_options) || '')\r
-    html << ' ' + link_to((l(:label_next) + ' &#187;'), { :page => paginator.current.next }) if paginator.current.next\r
+    html = ''    \r
+    html << link_to_remote(('&#171; ' + l(:label_previous)), \r
+                            {:update => "content", :url => { :page => paginator.current.previous }},\r
+                            {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.previous}))}) + ' ' if paginator.current.previous\r
+                            \r
+    html << (pagination_links_each(paginator, options) do |n|\r
+      link_to_remote(n.to_s, \r
+                      {:url => {:action => 'list', :params => @params.merge({:page => n})}, :update => 'content'},\r
+                      {:href => url_for(:action => 'list', :params => @params.merge({:page => n}))})\r
+    end || '')\r
+    \r
+    html << ' ' + link_to_remote((l(:label_next) + ' &#187;'), \r
+                                 {:update => "content", :url => { :page => paginator.current.next }},\r
+                                 {:href => url_for(:action => 'list', :params => @params.merge({:page => paginator.current.next}))}) if paginator.current.next\r
     html  \r
   end\r
   \r
index bec2117ec1bf4667e5d628c9e62115b143ad441d..04a84c8e4c303a9461991b01cdddc957b30f8d58 100644 (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
index 1c27ddaf717d7cd081341213f51d4ee79c1e8c0a..47cbeeaffbf1bf754760bea7754c6444f8ab6694 100644 (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 %>
index 7a924b134a2b96eaa41905478d37c63fe52a5059..6cd5f80705df0528dc3eafec94cee10f05ec4a1f 100644 (file)
     <td><small><%=l(:field_fixed_version)%>:</small><br /><%= search_filter_tag 'fixed_version_id', :class => 'select-small' %></td>\r
     <td><small><%=l(:field_assigned_to)%>:</small><br /><%= search_filter_tag 'assigned_to_id', :class => 'select-small' %></td>\r
     <td><small><%=l(:label_subproject_plural)%>:</small><br /><%= search_filter_tag 'subproject_id', :class => 'select-small' %></td>\r
-\r
     <td valign="bottom">\r
+      <%= hidden_field_tag 'set_filter', 1 %>\r
       <%= submit_tag l(:button_apply), :class => 'button-small' %>\r
-      <%= end_form_tag %>\r
-      \r
-      <%= start_form_tag %>\r
-      <%= submit_tag l(:button_clear), :class => 'button-small' %>\r
-      <%= end_form_tag %>\r
     </td>\r
-  </tr>\r
+    <td valign="bottom">  \r
+      <%= link_to l(:button_clear), :action => 'list_issues', :id => @project, :set_filter => 1 %>\r
+    </td>\r
+  </tr>  \r
 </table>\r
+<%= end_form_tag %>\r
+\r
  &nbsp;\r
 \r
 <%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %>\r