annotate app/views/gantts/show.html.erb @ 1298:4f746d8966dd redmine_2.3_integration

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