annotate app/views/gantts/show.html.erb @ 1115:433d4f72a19b redmine-2.2

Update to Redmine SVN revision 11137 on 2.2-stable branch
author Chris Cannam
date Mon, 07 Jan 2013 12:01:42 +0000
parents cbb26bc654de
children 622f24f53b42 261b3d9a4903
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@0 15
chris@37 16 <p class="contextual">
Chris@0 17 <%= gantt_zoom_link(@gantt, :in) %>
Chris@0 18 <%= gantt_zoom_link(@gantt, :out) %>
Chris@0 19 </p>
Chris@0 20
Chris@0 21 <p class="buttons">
Chris@0 22 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
Chris@0 23 <%= l(:label_months_from) %>
Chris@0 24 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
Chris@0 25 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
Chris@0 26 <%= hidden_field_tag 'zoom', @gantt.zoom %>
Chris@0 27
Chris@1115 28 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
Chris@1115 29 :class => 'icon icon-checked' %>
Chris@1115 30 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
Chris@1115 31 :class => 'icon icon-reload' %>
Chris@0 32 </p>
Chris@0 33 <% end %>
Chris@0 34
Chris@0 35 <%= error_messages_for 'query' %>
Chris@0 36 <% if @query.valid? %>
Chris@1115 37 <%
Chris@1115 38 zoom = 1
Chris@1115 39 @gantt.zoom.times { zoom = zoom * 2 }
Chris@0 40
Chris@1115 41 subject_width = 330
Chris@1115 42 header_heigth = 18
Chris@0 43
Chris@1115 44 headers_height = header_heigth
Chris@1115 45 show_weeks = false
Chris@1115 46 show_days = false
Chris@0 47
Chris@1115 48 if @gantt.zoom > 1
Chris@0 49 show_weeks = true
Chris@1115 50 headers_height = 2 * header_heigth
Chris@0 51 if @gantt.zoom > 2
Chris@0 52 show_days = true
Chris@1115 53 headers_height = 3 * header_heigth
Chris@0 54 end
Chris@1115 55 end
Chris@0 56
Chris@1115 57 # Width of the entire chart
Chris@1115 58 g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
Chris@1115 59 @gantt.render(:top => headers_height + 8,
Chris@1115 60 :zoom => zoom,
Chris@1115 61 :g_width => g_width,
Chris@1115 62 :subject_width => subject_width)
Chris@1115 63 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
Chris@1115 64 t_height = g_height + headers_height
Chris@0 65 %>
Chris@119 66
Chris@119 67 <% if @gantt.truncated %>
Chris@909 68 <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
Chris@119 69 <% end %>
Chris@119 70
Chris@1115 71 <table style="width:100%; border:0; border-collapse: collapse;">
Chris@0 72 <tr>
Chris@0 73 <td style="width:<%= subject_width %>px; padding:0px;">
Chris@1115 74 <%
Chris@1115 75 style = ""
Chris@1115 76 style += "position:relative;"
Chris@1115 77 style += "height: #{t_height + 24}px;"
Chris@1115 78 style += "width: #{subject_width + 1}px;"
Chris@1115 79 %>
Chris@1115 80 <%= content_tag(:div, :style => style) do %>
Chris@1115 81 <%
Chris@1115 82 style = ""
Chris@1115 83 style += "right:-2px;"
Chris@1115 84 style += "width: #{subject_width}px;"
Chris@1115 85 style += "height: #{headers_height}px;"
Chris@1115 86 style += 'background: #eee;'
Chris@1115 87 %>
Chris@1115 88 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
Chris@1115 89 <%
Chris@1115 90 style = ""
Chris@1115 91 style += "right:-2px;"
Chris@1115 92 style += "width: #{subject_width}px;"
Chris@1115 93 style += "height: #{t_height}px;"
Chris@1115 94 style += 'border-left: 1px solid #c0c0c0;'
Chris@1115 95 style += 'overflow: hidden;'
Chris@1115 96 %>
Chris@1115 97 <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
Chris@1115 98 <%= content_tag(:div, :class => "gantt_subjects") do %>
Chris@1115 99 <%= @gantt.subjects.html_safe %>
Chris@1115 100 <% end %>
Chris@1115 101 <% end %>
Chris@1115 102 </td>
Chris@0 103
Chris@1115 104 <td>
Chris@1115 105 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
Chris@1115 106 <%
Chris@1115 107 style = ""
Chris@1115 108 style += "width: #{g_width - 1}px;"
Chris@1115 109 style += "height: #{headers_height}px;"
Chris@1115 110 style += 'background: #eee;'
Chris@1115 111 %>
Chris@1115 112 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
chris@22 113
Chris@1115 114 <% ###### Months headers ###### %>
Chris@1115 115 <%
Chris@1115 116 month_f = @gantt.date_from
Chris@1115 117 left = 0
Chris@1115 118 height = (show_weeks ? header_heigth : header_heigth + g_height)
Chris@1115 119 %>
Chris@1115 120 <% @gantt.months.times do %>
Chris@1115 121 <%
Chris@1115 122 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
Chris@1115 123 style = ""
Chris@1115 124 style += "left: #{left}px;"
Chris@1115 125 style += "width: #{width}px;"
Chris@1115 126 style += "height: #{height}px;"
Chris@1115 127 %>
Chris@1115 128 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
Chris@1115 129 <%= link_to h("#{month_f.year}-#{month_f.month}"),
Chris@1115 130 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
Chris@1115 131 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
Chris@1115 132 <% end %>
Chris@1115 133 <%
Chris@1115 134 left = left + width + 1
Chris@1115 135 month_f = month_f >> 1
Chris@1115 136 %>
Chris@1115 137 <% end %>
chris@22 138
Chris@1115 139 <% ###### Weeks headers ###### %>
Chris@1115 140 <% if show_weeks %>
Chris@1115 141 <%
Chris@1115 142 left = 0
Chris@1115 143 height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height)
Chris@1115 144 %>
Chris@1115 145 <% if @gantt.date_from.cwday == 1 %>
Chris@1115 146 <%
Chris@1115 147 # @date_from is monday
Chris@1115 148 week_f = @gantt.date_from
Chris@1115 149 %>
Chris@1115 150 <% else %>
Chris@1115 151 <%
Chris@1115 152 # find next monday after @date_from
Chris@1115 153 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
Chris@1115 154 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
Chris@1115 155 style = ""
Chris@1115 156 style += "left: #{left}px;"
Chris@1115 157 style += "top: 19px;"
Chris@1115 158 style += "width: #{width}px;"
Chris@1115 159 style += "height: #{height}px;"
Chris@1115 160 %>
Chris@1115 161 <%= content_tag(:div, '&nbsp;'.html_safe,
Chris@1115 162 :style => style, :class => "gantt_hdr") %>
Chris@1115 163 <% left = left + width + 1 %>
Chris@1115 164 <% end %>
Chris@1115 165 <% while week_f <= @gantt.date_to %>
Chris@1115 166 <%
Chris@1115 167 width = ((week_f + 6 <= @gantt.date_to) ?
Chris@1115 168 7 * zoom - 1 :
Chris@1115 169 (@gantt.date_to - week_f + 1) * zoom - 1).to_i
Chris@1115 170 style = ""
Chris@1115 171 style += "left: #{left}px;"
Chris@1115 172 style += "top: 19px;"
Chris@1115 173 style += "width: #{width}px;"
Chris@1115 174 style += "height: #{height}px;"
Chris@1115 175 %>
Chris@1115 176 <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
Chris@1115 177 <%= content_tag(:small) do %>
Chris@1115 178 <%= week_f.cweek if width >= 16 %>
Chris@1115 179 <% end %>
Chris@1115 180 <% end %>
Chris@1115 181 <%
Chris@1115 182 left = left + width + 1
Chris@1115 183 week_f = week_f + 7
Chris@1115 184 %>
Chris@1115 185 <% end %>
Chris@1115 186 <% end %>
Chris@0 187
Chris@1115 188 <% ###### Days headers ####### %>
Chris@1115 189 <% if show_days %>
Chris@1115 190 <%
Chris@1115 191 left = 0
Chris@1115 192 height = g_height + header_heigth - 1
Chris@1115 193 wday = @gantt.date_from.cwday
Chris@909 194 %>
Chris@1115 195 <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
Chris@1115 196 <%
Chris@1115 197 width = zoom - 1
Chris@1115 198 style = ""
Chris@1115 199 style += "left: #{left}px;"
Chris@1115 200 style += "top:37px;"
Chris@1115 201 style += "width: #{width}px;"
Chris@1115 202 style += "height: #{height}px;"
Chris@1115 203 style += "font-size:0.7em;"
Chris@1115 204 clss = "gantt_hdr"
Chris@1115 205 clss << " nwday" if @gantt.non_working_week_days.include?(wday)
Chris@909 206 %>
Chris@1115 207 <%= content_tag(:div, :style => style, :class => clss) do %>
Chris@1115 208 <%= day_letter(wday) %>
Chris@1115 209 <% end %>
Chris@909 210 <%
Chris@1115 211 left = left + width + 1
Chris@1115 212 wday = wday + 1
Chris@1115 213 wday = 1 if wday > 7
Chris@909 214 %>
Chris@1115 215 <% end %>
Chris@1115 216 <% end %>
Chris@0 217
Chris@909 218 <%= @gantt.lines.html_safe %>
Chris@0 219
Chris@1115 220 <% ###### Today red line (excluded from cache) ###### %>
Chris@1115 221 <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
Chris@1115 222 <%
Chris@1115 223 today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
Chris@1115 224 style = ""
Chris@1115 225 style += "position: absolute;"
Chris@1115 226 style += "height: #{g_height}px;"
Chris@1115 227 style += "top: #{headers_height + 1}px;"
Chris@1115 228 style += "left: #{today_left}px;"
Chris@1115 229 style += "width:10px;"
Chris@1115 230 style += "border-left: 1px dashed red;"
Chris@1115 231 %>
Chris@1115 232 <%= content_tag(:div, '&nbsp;'.html_safe, :style => style) %>
Chris@0 233 <% end %>
Chris@0 234
Chris@0 235 </div>
Chris@0 236 </td>
Chris@0 237 </tr>
Chris@0 238 </table>
Chris@0 239
Chris@1115 240 <table style="width:100%">
Chris@0 241 <tr>
Chris@1115 242 <td align="left">
Chris@1115 243 <%= link_to_content_update("\xc2\xab " + l(:label_previous),
Chris@1115 244 params.merge(@gantt.params_previous)) %>
Chris@1115 245 </td>
Chris@1115 246 <td align="right">
Chris@1115 247 <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
Chris@1115 248 params.merge(@gantt.params_next)) %>
Chris@1115 249 </td>
Chris@0 250 </tr>
Chris@0 251 </table>
Chris@0 252
Chris@0 253 <% other_formats_links do |f| %>
Chris@909 254 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
Chris@909 255 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
Chris@0 256 <% end %>
Chris@0 257 <% end # query.valid? %>
Chris@0 258
Chris@0 259 <% content_for :sidebar do %>
Chris@1115 260 <%= render :partial => 'issues/sidebar' %>
Chris@0 261 <% end %>
Chris@0 262
Chris@0 263 <% html_title(l(:label_gantt)) -%>