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