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