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