diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-01 14:34:44 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-01 14:34:44 +0000 |
commit | a80b909cc8f7f0ca47744093ff0decaaa45f2264 (patch) | |
tree | b9708ef62d92b36f8ed0346f2099b5c589d8e2dc | |
parent | cf8d19592995b4ca55b0a113a0645edd5f917345 (diff) | |
download | redmine-a80b909cc8f7f0ca47744093ff0decaaa45f2264.tar.gz redmine-a80b909cc8f7f0ca47744093ff0decaaa45f2264.zip |
Converted issue filters to non-AJAX GET requests (#1965).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5276 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/calendars_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/gantts_controller.rb | 22 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/calendars_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/gantt_helper.rb | 12 | ||||
-rw-r--r-- | app/views/calendars/show.html.erb | 19 | ||||
-rw-r--r-- | app/views/gantts/show.html.erb | 25 | ||||
-rw-r--r-- | app/views/issues/index.rhtml | 28 | ||||
-rw-r--r-- | app/views/queries/_filters.rhtml | 10 | ||||
-rw-r--r-- | config/routes.rb | 14 | ||||
-rw-r--r-- | test/integration/routing_test.rb | 12 |
11 files changed, 86 insertions, 84 deletions
diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 4544b3399..a65f39b0f 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -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 diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index 50fd8c13d..b4eb5e666 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f7400bc9c..df3104b5d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index 08e665dcd..20f1e8297 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_helper.rb @@ -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}, diff --git a/app/helpers/gantt_helper.rb b/app/helpers/gantt_helper.rb index aa7438562..03a48c4f3 100644 --- a/app/helpers/gantt_helper.rb +++ b/app/helpers/gantt_helper.rb @@ -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') diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb index b2d1c5cd2..0b9d67727 100644 --- a/app/views/calendars/show.html.erb +++ b/app/views/calendars/show.html.erb @@ -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"> @@ -19,17 +19,8 @@ <%= 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 %> diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb index 1e38647ee..c43c6639e 100644 --- a/app/views/gantts/show.html.erb +++ b/app/views/gantts/show.html.erb @@ -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;" %>"> @@ -22,17 +22,8 @@ <%= 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 ('« ' + 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) + ' »'), {: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 ('« ' + 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) + ' »'), {: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? %> diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index ddd5d9080..67c5b63f0 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -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> @@ -35,22 +35,10 @@ </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 %> diff --git a/app/views/queries/_filters.rhtml b/app/views/queries/_filters.rhtml index 29f916eb7..7fdd29d09 100644 --- a/app/views/queries/_filters.rhtml +++ b/app/views/queries/_filters.rhtml @@ -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"); } }); } diff --git a/config/routes.rb b/config/routes.rb index 383d9cf89..f1fc59331 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 1198081fc..cb01a891a 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -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' |