comparison app/views/gantts/show.html.erb @ 1464:261b3d9a4903 redmine-2.4

Update to Redmine 2.4 branch rev 12663
author Chris Cannam
date Tue, 14 Jan 2014 14:37:42 +0000
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1296:038ba2d95de8 1464:261b3d9a4903
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',
5 :project_id => @project, :month => params[:month], 12 :project_id => @project, :month => params[:month],
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;" %>">
12 <%= render :partial => 'queries/filters', :locals => {:query => @query} %> 20 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
13 </div> 21 </div>
14 </fieldset> 22 </fieldset>
23 <fieldset class="collapsible collapsed">
24 <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
25 <div style="display: none;">
26 <table>
27 <tr>
28 <td>
29 <fieldset>
30 <legend><%= l(:label_related_issues) %></legend>
31 <label for="draw_relations">
32 <%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
33 <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
34 <% rels.each do |rel| %>
35 <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
36 <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
37 :style => "background-color: #{color}") %>
38 <%= l(IssueRelation::TYPES[rel][:name]) %>
39 <% end %>
40 </label>
41 </fieldset>
42 </td>
43 <td>
44 <fieldset>
45 <legend><%= l(:label_gantt_progress_line) %></legend>
46 <label for="draw_progress_line">
47 <%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
48 <%= l(:label_display) %>
49 </label>
50 </fieldset>
51 </td>
52 </tr>
53 </table>
54 </div>
55 </fieldset>
15 56
16 <p class="contextual"> 57 <p class="contextual">
17 <%= gantt_zoom_link(@gantt, :in) %> 58 <%= gantt_zoom_link(@gantt, :in) %>
18 <%= gantt_zoom_link(@gantt, :out) %> 59 <%= gantt_zoom_link(@gantt, :out) %>
19 </p> 60 </p>
27 68
28 <%= link_to_function l(:button_apply), '$("#query_form").submit()', 69 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
29 :class => 'icon icon-checked' %> 70 :class => 'icon icon-checked' %>
30 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, 71 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
31 :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 %>
32 </p> 78 </p>
33 <% end %> 79 <% end %>
34 80
35 <%= error_messages_for 'query' %> 81 <%= error_messages_for 'query' %>
36 <% if @query.valid? %> 82 <% if @query.valid? %>
37 <% 83 <%
38 zoom = 1 84 zoom = 1
39 @gantt.zoom.times { zoom = zoom * 2 } 85 @gantt.zoom.times { zoom = zoom * 2 }
40 86
41 subject_width = 330 87 subject_width = 330
42 header_heigth = 18 88 header_height = 18
43 89
44 headers_height = header_heigth 90 headers_height = header_height
45 show_weeks = false 91 show_weeks = false
46 show_days = false 92 show_days = false
47 93
48 if @gantt.zoom > 1 94 if @gantt.zoom > 1
49 show_weeks = true 95 show_weeks = true
50 headers_height = 2 * header_heigth 96 headers_height = 2 * header_height
51 if @gantt.zoom > 2 97 if @gantt.zoom > 2
52 show_days = true 98 show_days = true
53 headers_height = 3 * header_heigth 99 headers_height = 3 * header_height
54 end 100 end
55 end 101 end
56 102
57 # Width of the entire chart 103 # Width of the entire chart
58 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i 104 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
100 <% end %> 146 <% end %>
101 <% end %> 147 <% end %>
102 </td> 148 </td>
103 149
104 <td> 150 <td>
105 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> 151 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
106 <% 152 <%
107 style = "" 153 style = ""
108 style += "width: #{g_width - 1}px;" 154 style += "width: #{g_width - 1}px;"
109 style += "height: #{headers_height}px;" 155 style += "height: #{headers_height}px;"
110 style += 'background: #eee;' 156 style += 'background: #eee;'
113 159
114 <% ###### Months headers ###### %> 160 <% ###### Months headers ###### %>
115 <% 161 <%
116 month_f = @gantt.date_from 162 month_f = @gantt.date_from
117 left = 0 163 left = 0
118 height = (show_weeks ? header_heigth : header_heigth + g_height) 164 height = (show_weeks ? header_height : header_height + g_height)
119 %> 165 %>
120 <% @gantt.months.times do %> 166 <% @gantt.months.times do %>
121 <% 167 <%
122 width = (((month_f >> 1) - month_f) * zoom - 1).to_i 168 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
123 style = "" 169 style = ""
138 184
139 <% ###### Weeks headers ###### %> 185 <% ###### Weeks headers ###### %>
140 <% if show_weeks %> 186 <% if show_weeks %>
141 <% 187 <%
142 left = 0 188 left = 0
143 height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height) 189 height = (show_days ? header_height - 1 : header_height - 1 + g_height)
144 %> 190 %>
145 <% if @gantt.date_from.cwday == 1 %> 191 <% if @gantt.date_from.cwday == 1 %>
146 <% 192 <%
147 # @date_from is monday 193 # @date_from is monday
148 week_f = @gantt.date_from 194 week_f = @gantt.date_from
187 233
188 <% ###### Days headers ####### %> 234 <% ###### Days headers ####### %>
189 <% if show_days %> 235 <% if show_days %>
190 <% 236 <%
191 left = 0 237 left = 0
192 height = g_height + header_heigth - 1 238 height = g_height + header_height - 1
193 wday = @gantt.date_from.cwday 239 wday = @gantt.date_from.cwday
194 %> 240 %>
195 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %> 241 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
196 <% 242 <%
197 width = zoom - 1 243 width = zoom - 1
227 style += "top: #{headers_height + 1}px;" 273 style += "top: #{headers_height + 1}px;"
228 style += "left: #{today_left}px;" 274 style += "left: #{today_left}px;"
229 style += "width:10px;" 275 style += "width:10px;"
230 style += "border-left: 1px dashed red;" 276 style += "border-left: 1px dashed red;"
231 %> 277 %>
232 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style) %> 278 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
233 <% end %> 279 <% end %>
234 280 <%
281 style = ""
282 style += "position: absolute;"
283 style += "height: #{g_height}px;"
284 style += "top: #{headers_height + 1}px;"
285 style += "left: 0px;"
286 style += "width: #{g_width - 1}px;"
287 %>
288 <%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
235 </div> 289 </div>
236 </td> 290 </td>
237 </tr> 291 </tr>
238 </table> 292 </table>
239 293
240 <table style="width:100%"> 294 <table style="width:100%">
241 <tr> 295 <tr>
242 <td align="left"> 296 <td style="text-align:left;">
243 <%= link_to_content_update("\xc2\xab " + l(:label_previous), 297 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
244 params.merge(@gantt.params_previous)) %> 298 params.merge(@gantt.params_previous)) %>
245 </td> 299 </td>
246 <td align="right"> 300 <td style="text-align:right;">
247 <%= link_to_content_update(l(:label_next) + " \xc2\xbb", 301 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
248 params.merge(@gantt.params_next)) %> 302 params.merge(@gantt.params_next)) %>
249 </td> 303 </td>
250 </tr> 304 </tr>
251 </table> 305 </table>
259 <% content_for :sidebar do %> 313 <% content_for :sidebar do %>
260 <%= render :partial => 'issues/sidebar' %> 314 <%= render :partial => 'issues/sidebar' %>
261 <% end %> 315 <% end %>
262 316
263 <% html_title(l(:label_gantt)) -%> 317 <% html_title(l(:label_gantt)) -%>
318
319 <% content_for :header_tags do %>
320 <%= javascript_include_tag 'raphael' %>
321 <%= javascript_include_tag 'gantt' %>
322 <% end %>
323
324 <%= javascript_tag do %>
325 var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
326 $(document).ready(drawGanttHandler);
327 $(window).resize(drawGanttHandler);
328 $(function() {
329 $("#draw_relations").change(drawGanttHandler);
330 $("#draw_progress_line").change(drawGanttHandler);
331 });
332 <% end %>