##// END OF EJS Templates
Fixed: Duplicated project name for subproject version on gantt chart (#4775)....
Jean-Philippe Lang -
r3292:0b17e735eadf
parent child
Show More
@@ -1,251 +1,250
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 <%= h("#{i.project} -") unless @project && @project == i.project %>
90 <%= link_to_version i %>
89 <%= link_to_version i %>
91 </span>
90 </span>
92 <% end %>
91 <% end %>
93 </small></div>
92 </small></div>
94 <% top = top + 20
93 <% top = top + 20
95 end %>
94 end %>
96 </div>
95 </div>
97 </td>
96 </td>
98 <td>
97 <td>
99
98
100 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
99 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
101 <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>
102 <%
101 <%
103 #
102 #
104 # Months headers
103 # Months headers
105 #
104 #
106 month_f = @gantt.date_from
105 month_f = @gantt.date_from
107 left = 0
106 left = 0
108 height = (show_weeks ? header_heigth : header_heigth + g_height)
107 height = (show_weeks ? header_heigth : header_heigth + g_height)
109 @gantt.months.times do
108 @gantt.months.times do
110 width = ((month_f >> 1) - month_f) * zoom - 1
109 width = ((month_f >> 1) - month_f) * zoom - 1
111 %>
110 %>
112 <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">
113 <%= 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}"%>
114 </div>
113 </div>
115 <%
114 <%
116 left = left + width + 1
115 left = left + width + 1
117 month_f = month_f >> 1
116 month_f = month_f >> 1
118 end %>
117 end %>
119
118
120 <%
119 <%
121 #
120 #
122 # Weeks headers
121 # Weeks headers
123 #
122 #
124 if show_weeks
123 if show_weeks
125 left = 0
124 left = 0
126 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
125 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
127 if @gantt.date_from.cwday == 1
126 if @gantt.date_from.cwday == 1
128 # @date_from is monday
127 # @date_from is monday
129 week_f = @gantt.date_from
128 week_f = @gantt.date_from
130 else
129 else
131 # find next monday after @date_from
130 # find next monday after @date_from
132 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
131 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
133 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
132 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
134 %>
133 %>
135 <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>
136 <%
135 <%
137 left = left + width+1
136 left = left + width+1
138 end %>
137 end %>
139 <%
138 <%
140 while week_f <= @gantt.date_to
139 while week_f <= @gantt.date_to
141 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
142 %>
141 %>
143 <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">
144 <small><%= week_f.cweek if width >= 16 %></small>
143 <small><%= week_f.cweek if width >= 16 %></small>
145 </div>
144 </div>
146 <%
145 <%
147 left = left + width+1
146 left = left + width+1
148 week_f = week_f+7
147 week_f = week_f+7
149 end
148 end
150 end %>
149 end %>
151
150
152 <%
151 <%
153 #
152 #
154 # Days headers
153 # Days headers
155 #
154 #
156 if show_days
155 if show_days
157 left = 0
156 left = 0
158 height = g_height + header_heigth - 1
157 height = g_height + header_heigth - 1
159 wday = @gantt.date_from.cwday
158 wday = @gantt.date_from.cwday
160 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
159 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
161 width = zoom - 1
160 width = zoom - 1
162 %>
161 %>
163 <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">
164 <%= day_name(wday).first %>
163 <%= day_name(wday).first %>
165 </div>
164 </div>
166 <%
165 <%
167 left = left + width+1
166 left = left + width+1
168 wday = wday + 1
167 wday = wday + 1
169 wday = 1 if wday > 7
168 wday = 1 if wday > 7
170 end
169 end
171 end %>
170 end %>
172
171
173 <%
172 <%
174 #
173 #
175 # Tasks
174 # Tasks
176 #
175 #
177 top = headers_height + 10
176 top = headers_height + 10
178 @gantt.events.each do |i|
177 @gantt.events.each do |i|
179 if i.is_a? Issue
178 if i.is_a? Issue
180 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 )
181 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 )
182
181
183 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
184 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 )
185 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 )
186
185
187 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
188
187
189 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
188 i_left = ((i_start_date - @gantt.date_from)*zoom).floor
190 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)
191 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
192 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
193 %>
192 %>
194 <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>
195 <% if l_width > 0 %>
194 <% if l_width > 0 %>
196 <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>
197 <% end %>
196 <% end %>
198 <% if d_width > 0 %>
197 <% if d_width > 0 %>
199 <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>
200 <% end %>
199 <% end %>
201 <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">
202 <%= i.status.name %>
201 <%= i.status.name %>
203 <%= (i.done_ratio).to_i %>%
202 <%= (i.done_ratio).to_i %>%
204 </div>
203 </div>
205 <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;">
206 <span class="tip">
205 <span class="tip">
207 <%= render_issue_tooltip i %>
206 <%= render_issue_tooltip i %>
208 </span></div>
207 </span></div>
209 <% else
208 <% else
210 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
209 i_left = ((i.start_date - @gantt.date_from)*zoom).floor
211 %>
210 %>
212 <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>
213 <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">
214 <%= h("#{i.project} -") unless @project && @project == i.project %>
213 <%= h("#{i.project} -") unless @project && @project == i.project %>
215 <strong><%=h i %></strong>
214 <strong><%=h i %></strong>
216 </div>
215 </div>
217 <% end %>
216 <% end %>
218 <% top = top + 20
217 <% top = top + 20
219 end %>
218 end %>
220
219
221 <%
220 <%
222 #
221 #
223 # Today red line (excluded from cache)
222 # Today red line (excluded from cache)
224 #
223 #
225 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
224 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
226 <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>
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>
227 <% end %>
226 <% end %>
228
227
229 </div>
228 </div>
230 </td>
229 </td>
231 </tr>
230 </tr>
232 </table>
231 </table>
233
232
234 <table width="100%">
233 <table width="100%">
235 <tr>
234 <tr>
236 <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>
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>
237 <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>
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>
238 </tr>
237 </tr>
239 </table>
238 </table>
240
239
241 <% other_formats_links do |f| %>
240 <% other_formats_links do |f| %>
242 <%= f.link_to 'PDF', :url => @gantt.params %>
241 <%= f.link_to 'PDF', :url => @gantt.params %>
243 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
242 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
244 <% end %>
243 <% end %>
245 <% end # query.valid? %>
244 <% end # query.valid? %>
246
245
247 <% content_for :sidebar do %>
246 <% content_for :sidebar do %>
248 <%= render :partial => 'issues/sidebar' %>
247 <%= render :partial => 'issues/sidebar' %>
249 <% end %>
248 <% end %>
250
249
251 <% html_title(l(:label_gantt)) -%>
250 <% html_title(l(:label_gantt)) -%>
General Comments 0
You need to be logged in to leave comments. Login now