]> source.dussan.org Git - redmine.git/commitdiff
Converted issue filters to non-AJAX GET requests (#1965).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 1 Apr 2011 14:34:44 +0000 (14:34 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 1 Apr 2011 14:34:44 +0000 (14:34 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5276 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/calendars_controller.rb
app/controllers/gantts_controller.rb
app/helpers/application_helper.rb
app/helpers/calendars_helper.rb
app/helpers/gantt_helper.rb
app/views/calendars/show.html.erb
app/views/gantts/show.html.erb
app/views/issues/index.rhtml
app/views/queries/_filters.rhtml
config/routes.rb
test/integration/routing_test.rb

index 4544b3399705da1e443d80b050773d057935ad29..a65f39b0fe3295875e2eaeaf4e40bcf6c2dd4e60 100644 (file)
@@ -1,3 +1,20 @@
+# Redmine - project management software
+# Copyright (C) 2006-2011  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
 class CalendarsController < ApplicationController
   menu_item :calendar
   before_filter :find_optional_project
@@ -36,9 +53,4 @@ class CalendarsController < ApplicationController
     
     render :action => 'show', :layout => false if request.xhr?
   end
-  
-  def update
-    show
-  end
-
 end
index 50fd8c13dc603271568491a74113ae785be9bea4..b4eb5e666583b5096bfba742a2df059a28b79472 100644 (file)
@@ -1,3 +1,20 @@
+# Redmine - project management software
+# Copyright (C) 2006-2011  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
 class GanttsController < ApplicationController
   menu_item :gantt
   before_filter :find_optional_project
@@ -28,9 +45,4 @@ class GanttsController < ApplicationController
       format.pdf  { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
     end
   end
-
-  def update
-    show
-  end
-
 end
index f7400bc9c96f130d4c39358221deecc107b15df2..df3104b5d287be22f00838ef64e40755088b71ee 100644 (file)
@@ -335,8 +335,6 @@ module ApplicationHelper
     page_param = options.delete(:page_param) || :page
     per_page_links = options.delete(:per_page_links)
     url_param = params.dup
-    # don't reuse query params if filters are present
-    url_param.merge!(:fields => nil, :values => nil, :operators => nil) if url_param.delete(:set_filter)
 
     html = ''
     if paginator.current.previous
index 08e665dcd4eeb95a44603cb0958255d1e38708b7..20f1e82976e91a57eec60423d738552e4f80d37d 100644 (file)
@@ -32,9 +32,7 @@ module CalendarsHelper
   end
 
   def link_to_month(link_name, year, month, options={})
-    project_id = options[:project].present? ? options[:project].to_param : nil
-
-    link_target = calendar_path(:year => year, :month => month, :project_id => project_id)
+    link_target = url_for(params.merge(:year => year, :month => month))
 
     link_to_remote(link_name,
                    {:update => "content", :url => link_target, :method => :put},
index aa7438562dbd4c180ae1eccc31ac386a85eab2a3..03a48c4f3c4527e8a4c82cc4a1504f074030c10d 100644 (file)
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006  Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2011  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -22,8 +22,8 @@ module GanttHelper
     when :in
       if gantt.zoom < 4
         link_to_remote(l(:text_zoom_in),
-                       {:url => gantt.params.merge(:zoom => (gantt.zoom+1)), :method => :get, :update => 'content'},
-                       {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom+1))),
+                       {:url => params.merge(gantt.params.merge(:zoom => (gantt.zoom+1))), :method => :get, :update => 'content'},
+                       {:href => url_for(params.merge(gantt.params.merge(:zoom => (gantt.zoom+1)))),
                         :class => 'icon icon-zoom-in'})
       else
         content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in')
@@ -32,8 +32,8 @@ module GanttHelper
     when :out
       if gantt.zoom > 1
         link_to_remote(l(:text_zoom_out),
-                       {:url => gantt.params.merge(:zoom => (gantt.zoom-1)), :method => :get, :update => 'content'},
-                       {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom-1))),
+                       {:url => params.merge(gantt.params.merge(:zoom => (gantt.zoom-1))), :method => :get, :update => 'content'},
+                       {:href => url_for(params.merge(gantt.params.merge(:zoom => (gantt.zoom-1)))),
                         :class => 'icon icon-zoom-out'})
       else
         content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out')
index b2d1c5cd288245622add1bf77e9fe7833fab7484..0b9d6772737730e09a11ff81cd342bf77d7b5e88 100644 (file)
@@ -1,7 +1,7 @@
 <h2><%= @query.new_record? ? l(:label_calendar) : h(@query.name) %></h2>
 
-<% form_tag(calendar_path, :method => :put, :id => 'query_form') do %>
-  <%= hidden_field_tag('project_id', @project.to_param) if @project%>
+<% form_tag({:controller => 'calendars', :action => 'show', :project_id => @project}, :method => :get, :id => 'query_form') do %>
+<%= hidden_field_tag 'set_filter', '1' %>
 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
   <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
   <div style="<%= @query.new_record? ? "" : "display: none;" %>">
@@ -10,7 +10,7 @@
 </fieldset>
 
 <p style="float:right;">
-  <%= link_to_previous_month(@year, @month, :project => @project) %> | <%= link_to_next_month(@year, @month, :project => @project) %>
+  <%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %>
 </p>
 
 <p class="buttons">
 <%= label_tag('year', l(:label_year)) %>
 <%= select_year(@year, :prefix => "year", :discard_type => true) %>
 
-<%= link_to_remote l(:button_apply), 
-                   { :url => { :set_filter => 1 },
-                     :update => "content",
-                     :with => "Form.serialize('query_form')"
-                   }, :class => 'icon icon-checked' %>
-                   
-<%= link_to_remote l(:button_clear),
-                   { :url => { :project_id => @project, :set_filter => 1 }, 
-                     :method => :put,
-                     :update => "content",
-                   }, :class => 'icon icon-reload' %>
+<%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
+<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
 </p>
 <% end %>
 
index 1e38647ee8bf11c4775bada170624ec7e9c1942a..c43c6639ebf5f8d5afc4f06c1b6f99e216099097 100644 (file)
@@ -1,8 +1,8 @@
 <% @gantt.view = self %>
 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
 
-<% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
-  <%= hidden_field_tag('project_id', @project.to_param) if @project%>
+<% form_tag({:controller => 'gantts', :action => 'show', :project_id => @project, :month => params[:month], :year => params[:year], :months => params[:months]}, :method => :get, :id => 'query_form') do %>
+<%= hidden_field_tag 'set_filter', '1' %>
 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
   <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
        <div style="<%= @query.new_record? ? "" : "display: none;" %>">
 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
 <%= hidden_field_tag 'zoom', @gantt.zoom %>
 
-<%= link_to_remote l(:button_apply), 
-                   { :url => { :set_filter => 1 },
-                     :update => "content",
-                     :with => "Form.serialize('query_form')"
-                   }, :class => 'icon icon-checked' %>
-                   
-<%= link_to_remote l(:button_clear),
-                   { :url => { :project_id => @project, :set_filter => 1 }, 
-                        :method => :put,
-                     :update => "content",
-                   }, :class => 'icon icon-reload' %>
+<%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
+<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
 </p>
 <% end %>
 
@@ -178,14 +169,14 @@ if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
 
 <table width="100%">
 <tr>
-<td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td>
-<td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td>
+<td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => params.merge(@gantt.params_previous), :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(params.merge(@gantt.params_previous))} %></td>
+<td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => params.merge(@gantt.params_next), :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(params.merge(@gantt.params_next))} %></td>
 </tr>
 </table>
 
 <% other_formats_links do |f| %>
-       <%= f.link_to 'PDF', :url => @gantt.params %>
-       <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
+       <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
+       <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
 <% end %>
 <% end # query.valid? %>
 
index ddd5d90800011f976cbcff7caf7a8f80b33f8d57..67c5b63f068d7b5ad60aa9e03b1985667a507477 100644 (file)
@@ -8,8 +8,8 @@
 <h2><%= @query.new_record? ? l(:label_issue_plural) : h(@query.name) %></h2>
 <% html_title(@query.new_record? ? l(:label_issue_plural) : @query.name) %>
 
-<% form_tag({ :controller => 'queries', :action => 'new' }, :id => 'query_form') do %>
-    <%= hidden_field_tag('project_id', @project.to_param) if @project %>
+<% form_tag({ :controller => 'issues', :action => 'index', :project_id => @project }, :method => :get, :id => 'query_form') do %>
+    <%= hidden_field_tag 'set_filter', '1' %>
                <div id="query_form_content" class="hide-when-print">
     <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
        <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
                </div>
     <p class="buttons hide-when-print">
 
-    <%= link_to_remote l(:button_apply), 
-                       { :url => { :set_filter => 1 },
-                         :before => 'selectAllOptions("selected_columns");',
-                         :update => "content",
-                         :complete => "apply_filters_observer()",
-                         :with => "Form.serialize('query_form')"
-                       }, :class => 'icon icon-checked' %>
-                       
-    <%= link_to_remote l(:button_clear),
-                       { :url => { :set_filter => 1, :project_id => @project },
-                         :method => :get,
-                         :update => "content",
-                       }, :class => 'icon icon-reload'  %>
-                       
+    <%= link_to_function l(:button_apply), 'submit_query_form("query_form")', :class => 'icon icon-checked' %>
+    <%= link_to l(:button_clear), { :set_filter => 1, :project_id => @project }, :class => 'icon icon-reload'  %>
     <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
-    <%= link_to l(:button_save), {}, :onclick => "selectAllOptions('selected_columns'); $('query_form').submit(); return false;", :class => 'icon icon-save' %>
+    <%= link_to_function l(:button_save), "$('query_form').action='#{ url_for :controller => 'queries', :action => 'new', :project_id => @project }'; submit_query_form('query_form')", :class => 'icon icon-save' %>
     <% end %>
     </p>
 <% end %>
@@ -65,9 +53,9 @@
 <% end %>
 
 <% other_formats_links do |f| %>
-       <%= f.link_to 'Atom', :url => { :project_id => @project, :query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key } %>
-       <%= f.link_to 'CSV', :url => { :project_id => @project } %>
-       <%= f.link_to 'PDF', :url => { :project_id => @project } %>
+       <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %>
+       <%= f.link_to 'CSV', :url => params %>
+       <%= f.link_to 'PDF', :url => params %>
 <% end %>
 
 <% end %>
index 29f916eb794ad1fea4e2d608ec304e76854035f5..7fdd29d09b5b5a7e2452ca36df91ad5bd6174704 100644 (file)
@@ -54,13 +54,15 @@ function toggle_multi_select(field) {
     }
 }
 
+function submit_query_form(id) {
+  selectAllOptions("selected_columns");
+  $(id).submit();
+}
+
 function apply_filters_observer() {
   $$("#query_form input[type=text]").invoke("observe", "keypress", function(e){
     if(e.keyCode == Event.KEY_RETURN) {
-      <%= remote_function(:url => { :set_filter => 1},
-                          :update => "content",
-                          :with => "Form.serialize('query_form')",
-                          :complete => "e.stop(); apply_filters_observer()") %>
+      submit_query_form("query_form");
     }
   });
 }
index 383d9cf89e3dc5b21d555d41242a28c589da4962..f1fc593316cdce7816ec733f113539052a386159 100644 (file)
@@ -80,10 +80,15 @@ ActionController::Routing::Routes.draw do |map|
   map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
   map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
 
-  map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
-  map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
-  map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
-  map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
+  map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
+    gantts_routes.connect '/projects/:project_id/issues/gantt'
+    gantts_routes.connect '/issues/gantt'
+  end
+  
+  map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
+    calendars_routes.connect '/projects/:project_id/issues/calendar'
+    calendars_routes.connect '/issues/calendar'
+  end
 
   map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
     reports.connect 'projects/:id/issues/report', :action => 'issue_report'
@@ -215,6 +220,7 @@ ActionController::Routing::Routes.draw do |map|
   map.resources :groups
   
   #left old routes at the bottom for backwards compat
+  map.connect 'projects/:project_id/queries/:action', :controller => 'queries'
   map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
   map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
   map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
index 1198081fcd3c4df90f58e8a45cb2ee717a0e3170..cb01a891a52789f30e46d42e3af921e45082bc29 100644 (file)
@@ -91,14 +91,10 @@ class RoutingTest < ActionController::IntegrationTest
     should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
 
     should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
-    should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
     should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
-    should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
 
     should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
-    should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
     should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
-    should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
 
     should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
 
@@ -197,6 +193,14 @@ class RoutingTest < ActionController::IntegrationTest
     should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
     should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
   end
+  
+  context "queries" do
+    should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
+    should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
+    
+    should_route :post, "/queries/new", :controller => 'queries', :action => 'new'
+    should_route :post, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
+  end
 
   context "repositories" do
     should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'