comparison app/views/gantts/show.html.erb @ 22:40f7cfd4df19

* Update to SVN trunk rev 4173
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 24 Sep 2010 14:06:04 +0100
parents 513646585e45
children 94944d00e43c
comparison
equal deleted inserted replaced
14:1d32c0a0efbf 22:40f7cfd4df19
1 <% @gantt.view = self %>
1 <h2><%= l(:label_gantt) %></h2> 2 <h2><%= l(:label_gantt) %></h2>
2 3
3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %> 4 <% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
5 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
4 <fieldset id="filters" class="collapsible"> 6 <fieldset id="filters" class="collapsible">
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> 7 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <div> 8 <div>
7 <%= render :partial => 'queries/filters', :locals => {:query => @query} %> 9 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
8 </div> 10 </div>
52 show_days = true 54 show_days = true
53 headers_height = 3*header_heigth 55 headers_height = 3*header_heigth
54 end 56 end
55 end 57 end
56 58
59 # Width of the entire chart
57 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom 60 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
58 g_height = [(20 * @gantt.events.length + 6)+150, 206].max 61 # Collect the number of issues on Versions
62 g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max
59 t_height = g_height + headers_height 63 t_height = g_height + headers_height
60 %> 64 %>
61
62 <table width="100%" style="border:0; border-collapse: collapse;"> 65 <table width="100%" style="border:0; border-collapse: collapse;">
63 <tr> 66 <tr>
64 <td style="width:<%= subject_width %>px; padding:0px;"> 67 <td style="width:<%= subject_width %>px; padding:0px;">
65 68
66 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> 69 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
67 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div> 70 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
68 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div> 71 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
69 <% 72 <% top = headers_height + 8 %>
70 # 73
71 # Tasks subjects 74 <%= @gantt.subjects(:headers_height => headers_height, :top => top, :g_width => g_width) %>
72 # 75
73 top = headers_height + 8
74 @gantt.events.each do |i|
75 left = 4 + (i.is_a?(Issue) ? i.level * 16 : 0)
76 %>
77 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:<%= left %>px;overflow:hidden;"><small>
78 <% if i.is_a? Issue %>
79 <%= h("#{i.project} -") unless @project && @project == i.project %>
80 <%= link_to_issue i %>
81 <% else %>
82 <span class="icon icon-package">
83 <%= link_to_version i %>
84 </span>
85 <% end %>
86 </small></div>
87 <% top = top + 20
88 end %>
89 </div> 76 </div>
90 </td> 77 </td>
91 <td> 78 <td>
92 79
93 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> 80 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
161 wday = wday + 1 148 wday = wday + 1
162 wday = 1 if wday > 7 149 wday = 1 if wday > 7
163 end 150 end
164 end %> 151 end %>
165 152
166 <% 153 <% top = headers_height + 10 %>
167 # 154
168 # Tasks 155 <%= @gantt.lines(:top => top, :zoom => zoom, :g_width => g_width ) %>
169 #
170 top = headers_height + 10
171 @gantt.events.each do |i|
172 if i.is_a? Issue
173 i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
174 i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
175
176 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
177 i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
178 i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
179
180 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
181
182 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
183 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
184 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
185 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
186 css = "task " + (i.leaf? ? 'leaf' : 'parent')
187 %>
188 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="<%= css %> task_todo"><div class="left"></div>&nbsp;<div class="right"></div></div>
189 <% if l_width > 0 %>
190 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="<%= css %> task_late">&nbsp;</div>
191 <% end %>
192 <% if d_width > 0 %>
193 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="<%= css %> task_done">&nbsp;</div>
194 <% end %>
195 <div style="top:<%= top %>px;left:<%= i_left + i_width + 8 %>px;background:#fff;" class="<%= css %>">
196 <%= i.status.name %>
197 <%= (i.done_ratio).to_i %>%
198 </div>
199 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
200 <span class="tip">
201 <%= render_issue_tooltip i %>
202 </span></div>
203 <% else
204 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
205 %>
206 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
207 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
208 <strong><%= format_version_name i %></strong>
209 </div>
210 <% end %>
211 <% top = top + 20
212 end %>
213 156
214 <% 157 <%
215 # 158 #
216 # Today red line (excluded from cache) 159 # Today red line (excluded from cache)
217 # 160 #
224 </tr> 167 </tr>
225 </table> 168 </table>
226 169
227 <table width="100%"> 170 <table width="100%">
228 <tr> 171 <tr>
229 <td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td> 172 <td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td>
230 <td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td> 173 <td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td>
231 </tr> 174 </tr>
232 </table> 175 </table>
233 176
234 <% other_formats_links do |f| %> 177 <% other_formats_links do |f| %>
235 <%= f.link_to 'PDF', :url => @gantt.params %> 178 <%= f.link_to 'PDF', :url => @gantt.params %>