##// END OF EJS Templates
Preserve gantt options when changing filters (#12122)....
Jean-Philippe Lang -
r11341:9c2561b59dfc
parent child
Show More
@@ -1,319 +1,319
1 1 <% @gantt.view = self %>
2 2 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
3 3
4 4 <%= form_tag({:controller => 'gantts', :action => 'show',
5 5 :project_id => @project, :month => params[:month],
6 6 :year => params[:year], :months => params[:months]},
7 7 :method => :get, :id => 'query_form') do %>
8 8 <%= hidden_field_tag 'set_filter', '1' %>
9 9 <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
10 10 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
11 11 <div style="<%= @query.new_record? ? "" : "display: none;" %>">
12 12 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
13 13 </div>
14 14 </fieldset>
15 15 <fieldset class="collapsible collapsed">
16 16 <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
17 17 <div style="display: none;">
18 18 <table>
19 19 <tr>
20 20 <td>
21 21 <fieldset>
22 22 <legend><%= l(:label_related_issues) %></legend>
23 23 <label>
24 <%= check_box_tag "draw_rels", params["draw_rels"], true %>
24 <%= check_box_tag "draw_rels", params["draw_rels"], params[:set_filter].blank? || params[:draw_rels] %>
25 25 <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
26 26 <% rels.each do |rel| %>
27 27 <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
28 28 <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
29 29 :style => "background-color: #{color}") %>
30 30 <%= l(IssueRelation::TYPES[rel][:name]) %>
31 31 <% end %>
32 32 </label>
33 33 </fieldset>
34 34 </td>
35 35 <td>
36 36 <fieldset>
37 37 <legend><%= l(:label_gantt_progress_line) %></legend>
38 38 <label>
39 <%= check_box_tag "draw_progress_line", params[:draw_progress_line], false %>
39 <%= check_box_tag "draw_progress_line", params[:draw_progress_line], params[:draw_progress_line] %>
40 40 <%= l(:label_display) %>
41 41 </label>
42 42 </fieldset>
43 43 </td>
44 44 </tr>
45 45 </table>
46 46 </div>
47 47 </fieldset>
48 48
49 49 <p class="contextual">
50 50 <%= gantt_zoom_link(@gantt, :in) %>
51 51 <%= gantt_zoom_link(@gantt, :out) %>
52 52 </p>
53 53
54 54 <p class="buttons">
55 55 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
56 56 <%= l(:label_months_from) %>
57 57 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
58 58 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
59 59 <%= hidden_field_tag 'zoom', @gantt.zoom %>
60 60
61 61 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
62 62 :class => 'icon icon-checked' %>
63 63 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
64 64 :class => 'icon icon-reload' %>
65 65 </p>
66 66 <% end %>
67 67
68 68 <%= error_messages_for 'query' %>
69 69 <% if @query.valid? %>
70 70 <%
71 71 zoom = 1
72 72 @gantt.zoom.times { zoom = zoom * 2 }
73 73
74 74 subject_width = 330
75 75 header_height = 18
76 76
77 77 headers_height = header_height
78 78 show_weeks = false
79 79 show_days = false
80 80
81 81 if @gantt.zoom > 1
82 82 show_weeks = true
83 83 headers_height = 2 * header_height
84 84 if @gantt.zoom > 2
85 85 show_days = true
86 86 headers_height = 3 * header_height
87 87 end
88 88 end
89 89
90 90 # Width of the entire chart
91 91 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
92 92 @gantt.render(:top => headers_height + 8,
93 93 :zoom => zoom,
94 94 :g_width => g_width,
95 95 :subject_width => subject_width)
96 96 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
97 97 t_height = g_height + headers_height
98 98 %>
99 99
100 100 <% if @gantt.truncated %>
101 101 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
102 102 <% end %>
103 103
104 104 <table style="width:100%; border:0; border-collapse: collapse;">
105 105 <tr>
106 106 <td style="width:<%= subject_width %>px; padding:0px;">
107 107 <%
108 108 style = ""
109 109 style += "position:relative;"
110 110 style += "height: #{t_height + 24}px;"
111 111 style += "width: #{subject_width + 1}px;"
112 112 %>
113 113 <%= content_tag(:div, :style => style) do %>
114 114 <%
115 115 style = ""
116 116 style += "right:-2px;"
117 117 style += "width: #{subject_width}px;"
118 118 style += "height: #{headers_height}px;"
119 119 style += 'background: #eee;'
120 120 %>
121 121 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
122 122 <%
123 123 style = ""
124 124 style += "right:-2px;"
125 125 style += "width: #{subject_width}px;"
126 126 style += "height: #{t_height}px;"
127 127 style += 'border-left: 1px solid #c0c0c0;'
128 128 style += 'overflow: hidden;'
129 129 %>
130 130 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
131 131 <%= content_tag(:div, :class => "gantt_subjects") do %>
132 132 <%= @gantt.subjects.html_safe %>
133 133 <% end %>
134 134 <% end %>
135 135 </td>
136 136
137 137 <td>
138 138 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
139 139 <%
140 140 style = ""
141 141 style += "width: #{g_width - 1}px;"
142 142 style += "height: #{headers_height}px;"
143 143 style += 'background: #eee;'
144 144 %>
145 145 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
146 146
147 147 <% ###### Months headers ###### %>
148 148 <%
149 149 month_f = @gantt.date_from
150 150 left = 0
151 151 height = (show_weeks ? header_height : header_height + g_height)
152 152 %>
153 153 <% @gantt.months.times do %>
154 154 <%
155 155 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
156 156 style = ""
157 157 style += "left: #{left}px;"
158 158 style += "width: #{width}px;"
159 159 style += "height: #{height}px;"
160 160 %>
161 161 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
162 162 <%= link_to h("#{month_f.year}-#{month_f.month}"),
163 163 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
164 164 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
165 165 <% end %>
166 166 <%
167 167 left = left + width + 1
168 168 month_f = month_f >> 1
169 169 %>
170 170 <% end %>
171 171
172 172 <% ###### Weeks headers ###### %>
173 173 <% if show_weeks %>
174 174 <%
175 175 left = 0
176 176 height = (show_days ? header_height - 1 : header_height - 1 + g_height)
177 177 %>
178 178 <% if @gantt.date_from.cwday == 1 %>
179 179 <%
180 180 # @date_from is monday
181 181 week_f = @gantt.date_from
182 182 %>
183 183 <% else %>
184 184 <%
185 185 # find next monday after @date_from
186 186 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
187 187 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
188 188 style = ""
189 189 style += "left: #{left}px;"
190 190 style += "top: 19px;"
191 191 style += "width: #{width}px;"
192 192 style += "height: #{height}px;"
193 193 %>
194 194 <%= content_tag(:div, '&nbsp;'.html_safe,
195 195 :style => style, :class => "gantt_hdr") %>
196 196 <% left = left + width + 1 %>
197 197 <% end %>
198 198 <% while week_f <= @gantt.date_to %>
199 199 <%
200 200 width = ((week_f + 6 <= @gantt.date_to) ?
201 201 7 * zoom - 1 :
202 202 (@gantt.date_to - week_f + 1) * zoom - 1).to_i
203 203 style = ""
204 204 style += "left: #{left}px;"
205 205 style += "top: 19px;"
206 206 style += "width: #{width}px;"
207 207 style += "height: #{height}px;"
208 208 %>
209 209 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
210 210 <%= content_tag(:small) do %>
211 211 <%= week_f.cweek if width >= 16 %>
212 212 <% end %>
213 213 <% end %>
214 214 <%
215 215 left = left + width + 1
216 216 week_f = week_f + 7
217 217 %>
218 218 <% end %>
219 219 <% end %>
220 220
221 221 <% ###### Days headers ####### %>
222 222 <% if show_days %>
223 223 <%
224 224 left = 0
225 225 height = g_height + header_height - 1
226 226 wday = @gantt.date_from.cwday
227 227 %>
228 228 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
229 229 <%
230 230 width = zoom - 1
231 231 style = ""
232 232 style += "left: #{left}px;"
233 233 style += "top:37px;"
234 234 style += "width: #{width}px;"
235 235 style += "height: #{height}px;"
236 236 style += "font-size:0.7em;"
237 237 clss = "gantt_hdr"
238 238 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
239 239 %>
240 240 <%= content_tag(:div, :style => style, :class => clss) do %>
241 241 <%= day_letter(wday) %>
242 242 <% end %>
243 243 <%
244 244 left = left + width + 1
245 245 wday = wday + 1
246 246 wday = 1 if wday > 7
247 247 %>
248 248 <% end %>
249 249 <% end %>
250 250
251 251 <%= @gantt.lines.html_safe %>
252 252
253 253 <% ###### Today red line (excluded from cache) ###### %>
254 254 <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
255 255 <%
256 256 today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
257 257 style = ""
258 258 style += "position: absolute;"
259 259 style += "height: #{g_height}px;"
260 260 style += "top: #{headers_height + 1}px;"
261 261 style += "left: #{today_left}px;"
262 262 style += "width:10px;"
263 263 style += "border-left: 1px dashed red;"
264 264 %>
265 265 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
266 266 <% end %>
267 267 <%
268 268 style = ""
269 269 style += "position: absolute;"
270 270 style += "height: #{g_height}px;"
271 271 style += "top: #{headers_height + 1}px;"
272 272 style += "left: 0px;"
273 273 style += "width: #{g_width - 1}px;"
274 274 %>
275 275 <%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
276 276 </div>
277 277 </td>
278 278 </tr>
279 279 </table>
280 280
281 281 <table style="width:100%">
282 282 <tr>
283 283 <td align="left">
284 284 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
285 285 params.merge(@gantt.params_previous)) %>
286 286 </td>
287 287 <td align="right">
288 288 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
289 289 params.merge(@gantt.params_next)) %>
290 290 </td>
291 291 </tr>
292 292 </table>
293 293
294 294 <% other_formats_links do |f| %>
295 295 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
296 296 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
297 297 <% end %>
298 298 <% end # query.valid? %>
299 299
300 300 <% content_for :sidebar do %>
301 301 <%= render :partial => 'issues/sidebar' %>
302 302 <% end %>
303 303
304 304 <% html_title(l(:label_gantt)) -%>
305 305
306 306 <% content_for :header_tags do %>
307 307 <%= javascript_include_tag 'raphael' %>
308 308 <%= javascript_include_tag 'gantt' %>
309 309 <% end %>
310 310
311 311 <%= javascript_tag do %>
312 312 var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
313 313 $(document).ready(drawGanttHandler);
314 314 $(window).resize(drawGanttHandler);
315 315 $(function() {
316 316 $("#draw_rels").change(drawGanttHandler);
317 317 $("#draw_progress_line").change(drawGanttHandler);
318 318 });
319 319 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now