##// END OF EJS Templates
Makes use of format_version_name....
Jean-Philippe Lang -
r3293:00d7bc376641
parent child
Show More
@@ -1,250 +1,249
1 <h2><%= l(:label_gantt) %></h2>
1 <h2><%= l(:label_gantt) %></h2>
2
2
3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
3 <% form_tag(params.merge(:month => nil, :year => nil, :months => nil), :id => 'query_form') do %>
4 <fieldset id="filters" class="collapsible">
4 <fieldset id="filters" class="collapsible">
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
5 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
6 <div>
6 <div>
7 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
7 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
8 </div>
8 </div>
9 </fieldset>
9 </fieldset>
10
10
11 <p style="float:right;">
11 <p style="float:right;">
12 <%= if @gantt.zoom < 4
12 <%= if @gantt.zoom < 4
13 link_to_remote image_tag('zoom_in.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom+1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom+1)))}
13 link_to_remote image_tag('zoom_in.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom+1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom+1)))}
14 else
14 else
15 image_tag 'zoom_in_g.png'
15 image_tag 'zoom_in_g.png'
16 end %>
16 end %>
17 <%= if @gantt.zoom > 1
17 <%= if @gantt.zoom > 1
18 link_to_remote image_tag('zoom_out.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom-1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom-1)))}
18 link_to_remote image_tag('zoom_out.png'), {:url => @gantt.params.merge(:zoom => (@gantt.zoom-1)), :update => 'content'}, {:href => url_for(@gantt.params.merge(:zoom => (@gantt.zoom-1)))}
19 else
19 else
20 image_tag 'zoom_out_g.png'
20 image_tag 'zoom_out_g.png'
21 end %>
21 end %>
22 </p>
22 </p>
23
23
24 <p class="buttons">
24 <p class="buttons">
25 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
25 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
26 <%= l(:label_months_from) %>
26 <%= l(:label_months_from) %>
27 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
27 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
28 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
28 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
29 <%= hidden_field_tag 'zoom', @gantt.zoom %>
29 <%= hidden_field_tag 'zoom', @gantt.zoom %>
30
30
31 <%= link_to_remote l(:button_apply),
31 <%= link_to_remote l(:button_apply),
32 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
32 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
33 :update => "content",
33 :update => "content",
34 :with => "Form.serialize('query_form')"
34 :with => "Form.serialize('query_form')"
35 }, :class => 'icon icon-checked' %>
35 }, :class => 'icon icon-checked' %>
36
36
37 <%= link_to_remote l(:button_clear),
37 <%= link_to_remote l(:button_clear),
38 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
38 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
39 :update => "content",
39 :update => "content",
40 }, :class => 'icon icon-reload' if @query.new_record? %>
40 }, :class => 'icon icon-reload' if @query.new_record? %>
41 </p>
41 </p>
42 <% end %>
42 <% end %>
43
43
44 <%= error_messages_for 'query' %>
44 <%= error_messages_for 'query' %>
45 <% if @query.valid? %>
45 <% if @query.valid? %>
46 <% zoom = 1
46 <% zoom = 1
47 @gantt.zoom.times { zoom = zoom * 2 }
47 @gantt.zoom.times { zoom = zoom * 2 }
48
48
49 subject_width = 330
49 subject_width = 330
50 header_heigth = 18
50 header_heigth = 18
51
51
52 headers_height = header_heigth
52 headers_height = header_heigth
53 show_weeks = false
53 show_weeks = false
54 show_days = false
54 show_days = false
55
55
56 if @gantt.zoom >1
56 if @gantt.zoom >1
57 show_weeks = true
57 show_weeks = true
58 headers_height = 2*header_heigth
58 headers_height = 2*header_heigth
59 if @gantt.zoom > 2
59 if @gantt.zoom > 2
60 show_days = true
60 show_days = true
61 headers_height = 3*header_heigth
61 headers_height = 3*header_heigth
62 end
62 end
63 end
63 end
64
64
65 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
65 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
66 g_height = [(20 * @gantt.events.length + 6)+150, 206].max
66 g_height = [(20 * @gantt.events.length + 6)+150, 206].max
67 t_height = g_height + headers_height
67 t_height = g_height + headers_height
68 %>
68 %>
69
69
70 <table width="100%" style="border:0; border-collapse: collapse;">
70 <table width="100%" style="border:0; border-collapse: collapse;">
71 <tr>
71 <tr>
72 <td style="width:<%= subject_width %>px; padding:0px;">
72 <td style="width:<%= subject_width %>px; padding:0px;">
73
73
74 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
74 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
75 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
75 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
76 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
76 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
77 <%
77 <%
78 #
78 #
79 # Tasks subjects
79 # Tasks subjects
80 #
80 #
81 top = headers_height + 8
81 top = headers_height + 8
82 @gantt.events.each do |i| %>
82 @gantt.events.each do |i| %>
83 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
83 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
84 <% if i.is_a? Issue %>
84 <% if i.is_a? Issue %>
85 <%= h("#{i.project} -") unless @project && @project == i.project %>
85 <%= h("#{i.project} -") unless @project && @project == i.project %>
86 <%= link_to_issue i %>
86 <%= link_to_issue i %>
87 <% else %>
87 <% else %>
88 <span class="icon icon-package">
88 <span class="icon icon-package">
89 <%= link_to_version i %>
89 <%= link_to_version i %>
90 </span>
90 </span>
91 <% end %>
91 <% end %>
92 </small></div>
92 </small></div>
93 <% top = top + 20
93 <% top = top + 20
94 end %>
94 end %>
95 </div>
95 </div>
96 </td>
96 </td>
97 <td>
97 <td>
98
98
99 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
99 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
100 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
100 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
101 <%
101 <%
102 #
102 #
103 # Months headers
103 # Months headers
104 #
104 #
105 month_f = @gantt.date_from
105 month_f = @gantt.date_from
106 left = 0
106 left = 0
107 height = (show_weeks ? header_heigth : header_heigth + g_height)
107 height = (show_weeks ? header_heigth : header_heigth + g_height)
108 @gantt.months.times do
108 @gantt.months.times do
109 width = ((month_f >> 1) - month_f) * zoom - 1
109 width = ((month_f >> 1) - month_f) * zoom - 1
110 %>
110 %>
111 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
111 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
112 <%= link_to "#{month_f.year}-#{month_f.month}", @gantt.params.merge(:year => month_f.year, :month => month_f.month), :title => "#{month_name(month_f.month)} #{month_f.year}"%>
112 <%= link_to "#{month_f.year}-#{month_f.month}", @gantt.params.merge(:year => month_f.year, :month => month_f.month), :title => "#{month_name(month_f.month)} #{month_f.year}"%>
113 </div>
113 </div>
114 <%
114 <%
115 left = left + width + 1
115 left = left + width + 1
116 month_f = month_f >> 1
116 month_f = month_f >> 1
117 end %>
117 end %>
118
118
119 <%
119 <%
120 #
120 #
121 # Weeks headers
121 # Weeks headers
122 #
122 #
123 if show_weeks
123 if show_weeks
124 left = 0
124 left = 0
125 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
125 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
126 if @gantt.date_from.cwday == 1
126 if @gantt.date_from.cwday == 1
127 # @date_from is monday
127 # @date_from is monday
128 week_f = @gantt.date_from
128 week_f = @gantt.date_from
129 else
129 else
130 # find next monday after @date_from
130 # find next monday after @date_from
131 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
131 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
132 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
132 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
133 %>
133 %>
134 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
134 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
135 <%
135 <%
136 left = left + width+1
136 left = left + width+1
137 end %>
137 end %>
138 <%
138 <%
139 while week_f <= @gantt.date_to
139 while week_f <= @gantt.date_to
140 width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1
140 width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1
141 %>
141 %>
142 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
142 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
143 <small><%= week_f.cweek if width >= 16 %></small>
143 <small><%= week_f.cweek if width >= 16 %></small>
144 </div>
144 </div>
145 <%
145 <%
146 left = left + width+1
146 left = left + width+1
147 week_f = week_f+7
147 week_f = week_f+7
148 end
148 end
149 end %>
149 end %>
150
150
151 <%
151 <%
152 #
152 #
153 # Days headers
153 # Days headers
154 #
154 #
155 if show_days
155 if show_days
156 left = 0
156 left = 0
157 height = g_height + header_heigth - 1
157 height = g_height + header_heigth - 1
158 wday = @gantt.date_from.cwday
158 wday = @gantt.date_from.cwday
159 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
159 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
160 width = zoom - 1
160 width = zoom - 1
161 %>
161 %>
162 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
162 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" class="gantt_hdr">
163 <%= day_name(wday).first %>
163 <%= day_name(wday).first %>
164 </div>
164 </div>
165 <%
165 <%
166 left = left + width+1
166 left = left + width+1
167 wday = wday + 1
167 wday = wday + 1
168 wday = 1 if wday > 7
168 wday = 1 if wday > 7
169 end
169 end
170 end %>
170 end %>
171
171
172 <%
172 <%
173 #
173 #
174 # Tasks
174 # Tasks
175 #
175 #
176 top = headers_height + 10
176 top = headers_height + 10
177 @gantt.events.each do |i|
177 @gantt.events.each do |i|
178 if i.is_a? Issue
178 if i.is_a? Issue
179 i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
179 i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
180 i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
180 i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
181
181
182 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
182 i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
183 i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
183 i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
184 i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
184 i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
185
185
186 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
186 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
187
187
188 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
188 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
189 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
189 i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
190 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
190 d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
191 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
191 l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
192 %>
192 %>
193 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
193 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div>
194 <% if l_width > 0 %>
194 <% if l_width > 0 %>
195 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
195 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div>
196 <% end %>
196 <% end %>
197 <% if d_width > 0 %>
197 <% if d_width > 0 %>
198 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
198 <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div>
199 <% end %>
199 <% end %>
200 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
200 <div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task">
201 <%= i.status.name %>
201 <%= i.status.name %>
202 <%= (i.done_ratio).to_i %>%
202 <%= (i.done_ratio).to_i %>%
203 </div>
203 </div>
204 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
204 <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
205 <span class="tip">
205 <span class="tip">
206 <%= render_issue_tooltip i %>
206 <%= render_issue_tooltip i %>
207 </span></div>
207 </span></div>
208 <% else
208 <% else
209 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
209 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
210 %>
210 %>
211 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
211 <div style="top:<%= top %>px;left:<%= i_left %>px;width:15px;" class="task milestone">&nbsp;</div>
212 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
212 <div style="top:<%= top %>px;left:<%= i_left + 12 %>px;background:#fff;" class="task">
213 <%= h("#{i.project} -") unless @project && @project == i.project %>
213 <strong><%= format_version_name i %></strong>
214 <strong><%=h i %></strong>
215 </div>
214 </div>
216 <% end %>
215 <% end %>
217 <% top = top + 20
216 <% top = top + 20
218 end %>
217 end %>
219
218
220 <%
219 <%
221 #
220 #
222 # Today red line (excluded from cache)
221 # Today red line (excluded from cache)
223 #
222 #
224 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
223 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
225 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@gantt.date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
224 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@gantt.date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
226 <% end %>
225 <% end %>
227
226
228 </div>
227 </div>
229 </td>
228 </td>
230 </tr>
229 </tr>
231 </table>
230 </table>
232
231
233 <table width="100%">
232 <table width="100%">
234 <tr>
233 <tr>
235 <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>
234 <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>
236 <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>
235 <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>
237 </tr>
236 </tr>
238 </table>
237 </table>
239
238
240 <% other_formats_links do |f| %>
239 <% other_formats_links do |f| %>
241 <%= f.link_to 'PDF', :url => @gantt.params %>
240 <%= f.link_to 'PDF', :url => @gantt.params %>
242 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
241 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
243 <% end %>
242 <% end %>
244 <% end # query.valid? %>
243 <% end # query.valid? %>
245
244
246 <% content_for :sidebar do %>
245 <% content_for :sidebar do %>
247 <%= render :partial => 'issues/sidebar' %>
246 <%= render :partial => 'issues/sidebar' %>
248 <% end %>
247 <% end %>
249
248
250 <% html_title(l(:label_gantt)) -%>
249 <% html_title(l(:label_gantt)) -%>
General Comments 0
You need to be logged in to leave comments. Login now