##// END OF EJS Templates
Converted issue filters to non-AJAX GET requests (#1965)....
Jean-Philippe Lang -
r5156:a80b909cc8f7
parent child
Show More
@@ -1,3 +1,20
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 class CalendarsController < ApplicationController
18 class CalendarsController < ApplicationController
2 menu_item :calendar
19 menu_item :calendar
3 before_filter :find_optional_project
20 before_filter :find_optional_project
@@ -36,9 +53,4 class CalendarsController < ApplicationController
36
53
37 render :action => 'show', :layout => false if request.xhr?
54 render :action => 'show', :layout => false if request.xhr?
38 end
55 end
39
40 def update
41 show
42 end
43
44 end
56 end
@@ -1,3 +1,20
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
1 class GanttsController < ApplicationController
18 class GanttsController < ApplicationController
2 menu_item :gantt
19 menu_item :gantt
3 before_filter :find_optional_project
20 before_filter :find_optional_project
@@ -28,9 +45,4 class GanttsController < ApplicationController
28 format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
45 format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
29 end
46 end
30 end
47 end
31
32 def update
33 show
34 end
35
36 end
48 end
@@ -335,8 +335,6 module ApplicationHelper
335 page_param = options.delete(:page_param) || :page
335 page_param = options.delete(:page_param) || :page
336 per_page_links = options.delete(:per_page_links)
336 per_page_links = options.delete(:per_page_links)
337 url_param = params.dup
337 url_param = params.dup
338 # don't reuse query params if filters are present
339 url_param.merge!(:fields => nil, :values => nil, :operators => nil) if url_param.delete(:set_filter)
340
338
341 html = ''
339 html = ''
342 if paginator.current.previous
340 if paginator.current.previous
@@ -32,9 +32,7 module CalendarsHelper
32 end
32 end
33
33
34 def link_to_month(link_name, year, month, options={})
34 def link_to_month(link_name, year, month, options={})
35 project_id = options[:project].present? ? options[:project].to_param : nil
35 link_target = url_for(params.merge(:year => year, :month => month))
36
37 link_target = calendar_path(:year => year, :month => month, :project_id => project_id)
38
36
39 link_to_remote(link_name,
37 link_to_remote(link_name,
40 {:update => "content", :url => link_target, :method => :put},
38 {:update => "content", :url => link_target, :method => :put},
@@ -1,5 +1,5
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
@@ -22,8 +22,8 module GanttHelper
22 when :in
22 when :in
23 if gantt.zoom < 4
23 if gantt.zoom < 4
24 link_to_remote(l(:text_zoom_in),
24 link_to_remote(l(:text_zoom_in),
25 {:url => gantt.params.merge(:zoom => (gantt.zoom+1)), :method => :get, :update => 'content'},
25 {:url => params.merge(gantt.params.merge(:zoom => (gantt.zoom+1))), :method => :get, :update => 'content'},
26 {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom+1))),
26 {:href => url_for(params.merge(gantt.params.merge(:zoom => (gantt.zoom+1)))),
27 :class => 'icon icon-zoom-in'})
27 :class => 'icon icon-zoom-in'})
28 else
28 else
29 content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in')
29 content_tag('span', l(:text_zoom_in), :class => 'icon icon-zoom-in')
@@ -32,8 +32,8 module GanttHelper
32 when :out
32 when :out
33 if gantt.zoom > 1
33 if gantt.zoom > 1
34 link_to_remote(l(:text_zoom_out),
34 link_to_remote(l(:text_zoom_out),
35 {:url => gantt.params.merge(:zoom => (gantt.zoom-1)), :method => :get, :update => 'content'},
35 {:url => params.merge(gantt.params.merge(:zoom => (gantt.zoom-1))), :method => :get, :update => 'content'},
36 {:href => url_for(gantt.params.merge(:zoom => (gantt.zoom-1))),
36 {:href => url_for(params.merge(gantt.params.merge(:zoom => (gantt.zoom-1)))),
37 :class => 'icon icon-zoom-out'})
37 :class => 'icon icon-zoom-out'})
38 else
38 else
39 content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out')
39 content_tag('span', l(:text_zoom_out), :class => 'icon icon-zoom-out')
@@ -1,7 +1,7
1 <h2><%= @query.new_record? ? l(:label_calendar) : h(@query.name) %></h2>
1 <h2><%= @query.new_record? ? l(:label_calendar) : h(@query.name) %></h2>
2
2
3 <% form_tag(calendar_path, :method => :put, :id => 'query_form') do %>
3 <% form_tag({:controller => 'calendars', :action => 'show', :project_id => @project}, :method => :get, :id => 'query_form') do %>
4 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
4 <%= hidden_field_tag 'set_filter', '1' %>
5 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
5 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
6 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
7 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
7 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
@@ -10,7 +10,7
10 </fieldset>
10 </fieldset>
11
11
12 <p style="float:right;">
12 <p style="float:right;">
13 <%= link_to_previous_month(@year, @month, :project => @project) %> | <%= link_to_next_month(@year, @month, :project => @project) %>
13 <%= link_to_previous_month(@year, @month) %> | <%= link_to_next_month(@year, @month) %>
14 </p>
14 </p>
15
15
16 <p class="buttons">
16 <p class="buttons">
@@ -19,17 +19,8
19 <%= label_tag('year', l(:label_year)) %>
19 <%= label_tag('year', l(:label_year)) %>
20 <%= select_year(@year, :prefix => "year", :discard_type => true) %>
20 <%= select_year(@year, :prefix => "year", :discard_type => true) %>
21
21
22 <%= link_to_remote l(:button_apply),
22 <%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
23 { :url => { :set_filter => 1 },
23 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
24 :update => "content",
25 :with => "Form.serialize('query_form')"
26 }, :class => 'icon icon-checked' %>
27
28 <%= link_to_remote l(:button_clear),
29 { :url => { :project_id => @project, :set_filter => 1 },
30 :method => :put,
31 :update => "content",
32 }, :class => 'icon icon-reload' %>
33 </p>
24 </p>
34 <% end %>
25 <% end %>
35
26
@@ -1,8 +1,8
1 <% @gantt.view = self %>
1 <% @gantt.view = self %>
2 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
2 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
3
3
4 <% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
4 <% form_tag({:controller => 'gantts', :action => 'show', :project_id => @project, :month => params[:month], :year => params[:year], :months => params[:months]}, :method => :get, :id => 'query_form') do %>
5 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
5 <%= hidden_field_tag 'set_filter', '1' %>
6 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
6 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
7 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
7 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
8 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
8 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
@@ -22,17 +22,8
22 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
22 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
23 <%= hidden_field_tag 'zoom', @gantt.zoom %>
23 <%= hidden_field_tag 'zoom', @gantt.zoom %>
24
24
25 <%= link_to_remote l(:button_apply),
25 <%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
26 { :url => { :set_filter => 1 },
26 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
27 :update => "content",
28 :with => "Form.serialize('query_form')"
29 }, :class => 'icon icon-checked' %>
30
31 <%= link_to_remote l(:button_clear),
32 { :url => { :project_id => @project, :set_filter => 1 },
33 :method => :put,
34 :update => "content",
35 }, :class => 'icon icon-reload' %>
36 </p>
27 </p>
37 <% end %>
28 <% end %>
38
29
@@ -178,14 +169,14 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
178
169
179 <table width="100%">
170 <table width="100%">
180 <tr>
171 <tr>
181 <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>
172 <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>
182 <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>
173 <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>
183 </tr>
174 </tr>
184 </table>
175 </table>
185
176
186 <% other_formats_links do |f| %>
177 <% other_formats_links do |f| %>
187 <%= f.link_to 'PDF', :url => @gantt.params %>
178 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
188 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
179 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
189 <% end %>
180 <% end %>
190 <% end # query.valid? %>
181 <% end # query.valid? %>
191
182
@@ -8,8 +8,8
8 <h2><%= @query.new_record? ? l(:label_issue_plural) : h(@query.name) %></h2>
8 <h2><%= @query.new_record? ? l(:label_issue_plural) : h(@query.name) %></h2>
9 <% html_title(@query.new_record? ? l(:label_issue_plural) : @query.name) %>
9 <% html_title(@query.new_record? ? l(:label_issue_plural) : @query.name) %>
10
10
11 <% form_tag({ :controller => 'queries', :action => 'new' }, :id => 'query_form') do %>
11 <% form_tag({ :controller => 'issues', :action => 'index', :project_id => @project }, :method => :get, :id => 'query_form') do %>
12 <%= hidden_field_tag('project_id', @project.to_param) if @project %>
12 <%= hidden_field_tag 'set_filter', '1' %>
13 <div id="query_form_content" class="hide-when-print">
13 <div id="query_form_content" class="hide-when-print">
14 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
14 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
15 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
15 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
@@ -35,22 +35,10
35 </div>
35 </div>
36 <p class="buttons hide-when-print">
36 <p class="buttons hide-when-print">
37
37
38 <%= link_to_remote l(:button_apply),
38 <%= link_to_function l(:button_apply), 'submit_query_form("query_form")', :class => 'icon icon-checked' %>
39 { :url => { :set_filter => 1 },
39 <%= link_to l(:button_clear), { :set_filter => 1, :project_id => @project }, :class => 'icon icon-reload' %>
40 :before => 'selectAllOptions("selected_columns");',
41 :update => "content",
42 :complete => "apply_filters_observer()",
43 :with => "Form.serialize('query_form')"
44 }, :class => 'icon icon-checked' %>
45
46 <%= link_to_remote l(:button_clear),
47 { :url => { :set_filter => 1, :project_id => @project },
48 :method => :get,
49 :update => "content",
50 }, :class => 'icon icon-reload' %>
51
52 <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
40 <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
53 <%= link_to l(:button_save), {}, :onclick => "selectAllOptions('selected_columns'); $('query_form').submit(); return false;", :class => 'icon icon-save' %>
41 <%= 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' %>
54 <% end %>
42 <% end %>
55 </p>
43 </p>
56 <% end %>
44 <% end %>
@@ -65,9 +53,9
65 <% end %>
53 <% end %>
66
54
67 <% other_formats_links do |f| %>
55 <% other_formats_links do |f| %>
68 <%= f.link_to 'Atom', :url => { :project_id => @project, :query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key } %>
56 <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %>
69 <%= f.link_to 'CSV', :url => { :project_id => @project } %>
57 <%= f.link_to 'CSV', :url => params %>
70 <%= f.link_to 'PDF', :url => { :project_id => @project } %>
58 <%= f.link_to 'PDF', :url => params %>
71 <% end %>
59 <% end %>
72
60
73 <% end %>
61 <% end %>
@@ -54,13 +54,15 function toggle_multi_select(field) {
54 }
54 }
55 }
55 }
56
56
57 function submit_query_form(id) {
58 selectAllOptions("selected_columns");
59 $(id).submit();
60 }
61
57 function apply_filters_observer() {
62 function apply_filters_observer() {
58 $$("#query_form input[type=text]").invoke("observe", "keypress", function(e){
63 $$("#query_form input[type=text]").invoke("observe", "keypress", function(e){
59 if(e.keyCode == Event.KEY_RETURN) {
64 if(e.keyCode == Event.KEY_RETURN) {
60 <%= remote_function(:url => { :set_filter => 1},
65 submit_query_form("query_form");
61 :update => "content",
62 :with => "Form.serialize('query_form')",
63 :complete => "e.stop(); apply_filters_observer()") %>
64 }
66 }
65 });
67 });
66 }
68 }
@@ -80,10 +80,15 ActionController::Routing::Routes.draw do |map|
80 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
80 map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post }
81 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
81 map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy
82
82
83 map.resource :gantt, :path_prefix => '/issues', :controller => 'gantts', :only => [:show, :update]
83 map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
84 map.resource :gantt, :path_prefix => '/projects/:project_id/issues', :controller => 'gantts', :only => [:show, :update]
84 gantts_routes.connect '/projects/:project_id/issues/gantt'
85 map.resource :calendar, :path_prefix => '/issues', :controller => 'calendars', :only => [:show, :update]
85 gantts_routes.connect '/issues/gantt'
86 map.resource :calendar, :path_prefix => '/projects/:project_id/issues', :controller => 'calendars', :only => [:show, :update]
86 end
87
88 map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
89 calendars_routes.connect '/projects/:project_id/issues/calendar'
90 calendars_routes.connect '/issues/calendar'
91 end
87
92
88 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
93 map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
89 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
94 reports.connect 'projects/:id/issues/report', :action => 'issue_report'
@@ -215,6 +220,7 ActionController::Routing::Routes.draw do |map|
215 map.resources :groups
220 map.resources :groups
216
221
217 #left old routes at the bottom for backwards compat
222 #left old routes at the bottom for backwards compat
223 map.connect 'projects/:project_id/queries/:action', :controller => 'queries'
218 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
224 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
219 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
225 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
220 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
226 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
@@ -91,14 +91,10 class RoutingTest < ActionController::IntegrationTest
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
91 should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1'
92
92
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
93 should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show'
94 should_route :put, "/issues/calendar", :controller => 'calendars', :action => 'update'
95 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
94 should_route :get, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'show', :project_id => 'project-name'
96 should_route :put, "/projects/project-name/issues/calendar", :controller => 'calendars', :action => 'update', :project_id => 'project-name'
97
95
98 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
96 should_route :get, "/issues/gantt", :controller => 'gantts', :action => 'show'
99 should_route :put, "/issues/gantt", :controller => 'gantts', :action => 'update'
100 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
97 should_route :get, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'show', :project_id => 'project-name'
101 should_route :put, "/projects/project-name/issues/gantt", :controller => 'gantts', :action => 'update', :project_id => 'project-name'
102
98
103 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
99 should_route :get, "/issues/auto_complete", :controller => 'auto_completes', :action => 'issues'
104
100
@@ -197,6 +193,14 class RoutingTest < ActionController::IntegrationTest
197 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
193 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
198 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
194 should_route :delete, "/projects/64/enumerations", :controller => 'project_enumerations', :action => 'destroy', :project_id => '64'
199 end
195 end
196
197 context "queries" do
198 should_route :get, "/queries/new", :controller => 'queries', :action => 'new'
199 should_route :get, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
200
201 should_route :post, "/queries/new", :controller => 'queries', :action => 'new'
202 should_route :post, "/projects/redmine/queries/new", :controller => 'queries', :action => 'new', :project_id => 'redmine'
203 end
200
204
201 context "repositories" do
205 context "repositories" do
202 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
206 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
General Comments 0
You need to be logged in to leave comments. Login now