@@ -0,0 +1,9 | |||||
|
1 | class AddQueriesOptions < ActiveRecord::Migration | |||
|
2 | def up | |||
|
3 | add_column :queries, :options, :text | |||
|
4 | end | |||
|
5 | ||||
|
6 | def down | |||
|
7 | remove_column :queries, :options | |||
|
8 | end | |||
|
9 | end |
@@ -59,7 +59,7 class QueriesController < ApplicationController | |||||
59 |
|
59 | |||
60 | if @query.save |
|
60 | if @query.save | |
61 | flash[:notice] = l(:notice_successful_create) |
|
61 | flash[:notice] = l(:notice_successful_create) | |
62 |
redirect_to |
|
62 | redirect_to_issues(:query_id => @query) | |
63 | else |
|
63 | else | |
64 | render :action => 'new', :layout => !request.xhr? |
|
64 | render :action => 'new', :layout => !request.xhr? | |
65 | end |
|
65 | end | |
@@ -77,7 +77,7 class QueriesController < ApplicationController | |||||
77 |
|
77 | |||
78 | if @query.save |
|
78 | if @query.save | |
79 | flash[:notice] = l(:notice_successful_update) |
|
79 | flash[:notice] = l(:notice_successful_update) | |
80 |
redirect_to |
|
80 | redirect_to_issues(:query_id => @query) | |
81 | else |
|
81 | else | |
82 | render :action => 'edit' |
|
82 | render :action => 'edit' | |
83 | end |
|
83 | end | |
@@ -85,7 +85,7 class QueriesController < ApplicationController | |||||
85 |
|
85 | |||
86 | def destroy |
|
86 | def destroy | |
87 | @query.destroy |
|
87 | @query.destroy | |
88 |
redirect_to |
|
88 | redirect_to_issues(:set_filter => 1) | |
89 | end |
|
89 | end | |
90 |
|
90 | |||
91 | private |
|
91 | private | |
@@ -103,4 +103,16 private | |||||
103 | rescue ActiveRecord::RecordNotFound |
|
103 | rescue ActiveRecord::RecordNotFound | |
104 | render_404 |
|
104 | render_404 | |
105 | end |
|
105 | end | |
|
106 | ||||
|
107 | def redirect_to_issues(options) | |||
|
108 | if params[:gantt] | |||
|
109 | if @project | |||
|
110 | redirect_to project_gantt_path(@project, options) | |||
|
111 | else | |||
|
112 | redirect_to issues_gantt_path(options) | |||
|
113 | end | |||
|
114 | else | |||
|
115 | redirect_to _project_issues_path(@project, options) | |||
|
116 | end | |||
|
117 | end | |||
106 | end |
|
118 | end |
@@ -97,6 +97,31 class IssueQuery < Query | |||||
97 | !is_private? |
|
97 | !is_private? | |
98 | end |
|
98 | end | |
99 |
|
99 | |||
|
100 | def draw_relations | |||
|
101 | r = options[:draw_relations] | |||
|
102 | r.nil? || r == '1' | |||
|
103 | end | |||
|
104 | ||||
|
105 | def draw_relations=(arg) | |||
|
106 | options[:draw_relations] = (arg == '0' ? '0' : nil) | |||
|
107 | end | |||
|
108 | ||||
|
109 | def draw_progress_line | |||
|
110 | r = options[:draw_progress_line] | |||
|
111 | r == '1' | |||
|
112 | end | |||
|
113 | ||||
|
114 | def draw_progress_line=(arg) | |||
|
115 | options[:draw_progress_line] = (arg == '1' ? '1' : nil) | |||
|
116 | end | |||
|
117 | ||||
|
118 | def build_from_params(params) | |||
|
119 | super | |||
|
120 | self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations]) | |||
|
121 | self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line]) | |||
|
122 | self | |||
|
123 | end | |||
|
124 | ||||
100 | def initialize_available_filters |
|
125 | def initialize_available_filters | |
101 | principals = [] |
|
126 | principals = [] | |
102 | subprojects = [] |
|
127 | subprojects = [] |
@@ -130,6 +130,7 class Query < ActiveRecord::Base | |||||
130 | serialize :filters |
|
130 | serialize :filters | |
131 | serialize :column_names |
|
131 | serialize :column_names | |
132 | serialize :sort_criteria, Array |
|
132 | serialize :sort_criteria, Array | |
|
133 | serialize :options, Hash | |||
133 |
|
134 | |||
134 | attr_protected :project_id, :user_id |
|
135 | attr_protected :project_id, :user_id | |
135 |
|
136 |
@@ -1,4 +1,11 | |||||
1 | <% @gantt.view = self %> |
|
1 | <% @gantt.view = self %> | |
|
2 | <div class="contextual"> | |||
|
3 | <% if !@query.new_record? && @query.editable_by?(User.current) %> | |||
|
4 | <%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %> | |||
|
5 | <%= delete_link query_path(@query, :gantt => 1) %> | |||
|
6 | <% end %> | |||
|
7 | </div> | |||
|
8 | ||||
2 | <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2> |
|
9 | <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2> | |
3 |
|
10 | |||
4 | <%= form_tag({:controller => 'gantts', :action => 'show', |
|
11 | <%= form_tag({:controller => 'gantts', :action => 'show', | |
@@ -6,6 +13,7 | |||||
6 | :year => params[:year], :months => params[:months]}, |
|
13 | :year => params[:year], :months => params[:months]}, | |
7 | :method => :get, :id => 'query_form') do %> |
|
14 | :method => :get, :id => 'query_form') do %> | |
8 | <%= hidden_field_tag 'set_filter', '1' %> |
|
15 | <%= hidden_field_tag 'set_filter', '1' %> | |
|
16 | <%= hidden_field_tag 'gantt', '1' %> | |||
9 | <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>"> |
|
17 | <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>"> | |
10 | <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> |
|
18 | <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> | |
11 | <div style="<%= @query.new_record? ? "" : "display: none;" %>"> |
|
19 | <div style="<%= @query.new_record? ? "" : "display: none;" %>"> | |
@@ -20,8 +28,8 | |||||
20 | <td> |
|
28 | <td> | |
21 | <fieldset> |
|
29 | <fieldset> | |
22 | <legend><%= l(:label_related_issues) %></legend> |
|
30 | <legend><%= l(:label_related_issues) %></legend> | |
23 | <label> |
|
31 | <label for="draw_relations"> | |
24 | <%= check_box_tag "draw_rels", params["draw_rels"], params[:set_filter].blank? || params[:draw_rels] %> |
|
32 | <%= check_box 'query', 'draw_relations', :id => 'draw_relations' %> | |
25 | <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %> |
|
33 | <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %> | |
26 | <% rels.each do |rel| %> |
|
34 | <% rels.each do |rel| %> | |
27 | <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %> |
|
35 | <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %> | |
@@ -35,8 +43,8 | |||||
35 | <td> |
|
43 | <td> | |
36 | <fieldset> |
|
44 | <fieldset> | |
37 | <legend><%= l(:label_gantt_progress_line) %></legend> |
|
45 | <legend><%= l(:label_gantt_progress_line) %></legend> | |
38 | <label> |
|
46 | <label for="draw_progress_line"> | |
39 |
<%= check_box |
|
47 | <%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %> | |
40 | <%= l(:label_display) %> |
|
48 | <%= l(:label_display) %> | |
41 | </label> |
|
49 | </label> | |
42 | </fieldset> |
|
50 | </fieldset> | |
@@ -62,6 +70,11 | |||||
62 | :class => 'icon icon-checked' %> |
|
70 | :class => 'icon icon-checked' %> | |
63 | <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, |
|
71 | <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, | |
64 | :class => 'icon icon-reload' %> |
|
72 | :class => 'icon icon-reload' %> | |
|
73 | <% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %> | |||
|
74 | <%= link_to_function l(:button_save), | |||
|
75 | "$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();", | |||
|
76 | :class => 'icon icon-save' %> | |||
|
77 | <% end %> | |||
65 | </p> |
|
78 | </p> | |
66 | <% end %> |
|
79 | <% end %> | |
67 |
|
80 | |||
@@ -313,7 +326,7 | |||||
313 | $(document).ready(drawGanttHandler); |
|
326 | $(document).ready(drawGanttHandler); | |
314 | $(window).resize(drawGanttHandler); |
|
327 | $(window).resize(drawGanttHandler); | |
315 | $(function() { |
|
328 | $(function() { | |
316 | $("#draw_rels").change(drawGanttHandler); |
|
329 | $("#draw_relations").change(drawGanttHandler); | |
317 | $("#draw_progress_line").change(drawGanttHandler); |
|
330 | $("#draw_progress_line").change(drawGanttHandler); | |
318 | }); |
|
331 | }); | |
319 | <% end %> |
|
332 | <% end %> |
@@ -2,6 +2,8 | |||||
2 |
|
2 | |||
3 | <div class="box"> |
|
3 | <div class="box"> | |
4 | <div class="tabular"> |
|
4 | <div class="tabular"> | |
|
5 | <%= hidden_field_tag 'gantt', '1' if params[:gantt] %> | |||
|
6 | ||||
5 | <p><label for="query_name"><%=l(:field_name)%></label> |
|
7 | <p><label for="query_name"><%=l(:field_name)%></label> | |
6 | <%= text_field 'query', 'name', :size => 80 %></p> |
|
8 | <%= text_field 'query', 'name', :size => 80 %></p> | |
7 |
|
9 | |||
@@ -31,6 +33,13 | |||||
31 |
|
33 | |||
32 | <p><label><%= l(:button_show) %></label> |
|
34 | <p><label><%= l(:button_show) %></label> | |
33 | <%= available_block_columns_tags(@query) %></p> |
|
35 | <%= available_block_columns_tags(@query) %></p> | |
|
36 | ||||
|
37 | <% if params[:gantt] %> | |||
|
38 | <p><label><%= l(:label_gantt) %></label> | |||
|
39 | <label class="inline"><%= check_box_tag "query[draw_relations]", "1", @query.draw_relations %> <%= l(:label_related_issues) %></label> | |||
|
40 | <label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label> | |||
|
41 | </p> | |||
|
42 | <% end %> | |||
34 | </fieldset> |
|
43 | </fieldset> | |
35 | </div> |
|
44 | </div> | |
36 |
|
45 |
@@ -167,6 +167,6 function drawGanttHandler() { | |||||
167 | setDrawArea(); |
|
167 | setDrawArea(); | |
168 | if ($("#draw_progress_line").attr('checked')) |
|
168 | if ($("#draw_progress_line").attr('checked')) | |
169 | drawGanttProgressLines(); |
|
169 | drawGanttProgressLines(); | |
170 | if ($("#draw_rels").attr('checked')) |
|
170 | if ($("#draw_relations").attr('checked')) | |
171 | drawRelations(); |
|
171 | drawRelations(); | |
172 | } |
|
172 | } |
@@ -155,6 +155,43 class QueriesControllerTest < ActionController::TestCase | |||||
155 | assert_select 'input[name=?]', 'query[name]' |
|
155 | assert_select 'input[name=?]', 'query[name]' | |
156 | end |
|
156 | end | |
157 |
|
157 | |||
|
158 | def test_create_global_query_from_gantt | |||
|
159 | @request.session[:user_id] = 1 | |||
|
160 | assert_difference 'IssueQuery.count' do | |||
|
161 | post :create, | |||
|
162 | :gantt => 1, | |||
|
163 | :operators => {"status_id" => "o"}, | |||
|
164 | :values => {"status_id" => ["1"]}, | |||
|
165 | :query => {:name => "test_create_from_gantt", | |||
|
166 | :draw_relations => '1', | |||
|
167 | :draw_progress_line => '1'} | |||
|
168 | assert_response 302 | |||
|
169 | end | |||
|
170 | query = IssueQuery.order('id DESC').first | |||
|
171 | assert_redirected_to "/issues/gantt?query_id=#{query.id}" | |||
|
172 | assert_equal true, query.draw_relations | |||
|
173 | assert_equal true, query.draw_progress_line | |||
|
174 | end | |||
|
175 | ||||
|
176 | def test_create_project_query_from_gantt | |||
|
177 | @request.session[:user_id] = 1 | |||
|
178 | assert_difference 'IssueQuery.count' do | |||
|
179 | post :create, | |||
|
180 | :project_id => 'ecookbook', | |||
|
181 | :gantt => 1, | |||
|
182 | :operators => {"status_id" => "o"}, | |||
|
183 | :values => {"status_id" => ["1"]}, | |||
|
184 | :query => {:name => "test_create_from_gantt", | |||
|
185 | :draw_relations => '0', | |||
|
186 | :draw_progress_line => '0'} | |||
|
187 | assert_response 302 | |||
|
188 | end | |||
|
189 | query = IssueQuery.order('id DESC').first | |||
|
190 | assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}" | |||
|
191 | assert_equal false, query.draw_relations | |||
|
192 | assert_equal false, query.draw_progress_line | |||
|
193 | end | |||
|
194 | ||||
158 | def test_edit_global_public_query |
|
195 | def test_edit_global_public_query | |
159 | @request.session[:user_id] = 1 |
|
196 | @request.session[:user_id] = 1 | |
160 | get :edit, :id => 4 |
|
197 | get :edit, :id => 4 |
General Comments 0
You need to be logged in to leave comments.
Login now