@@ -1,262 +1,270 | |||
|
1 | 1 | <% @gantt.view = self %> |
|
2 | 2 | <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2> |
|
3 | 3 | |
|
4 | 4 | <%= form_tag({:controller => 'gantts', :action => 'show', |
|
5 | 5 | :project_id => @project, :month => params[:month], |
|
6 | 6 | :year => params[:year], :months => params[:months]}, |
|
7 | 7 | :method => :get, :id => 'query_form') do %> |
|
8 | 8 | <%= hidden_field_tag 'set_filter', '1' %> |
|
9 | 9 | <fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>"> |
|
10 | 10 | <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> |
|
11 | 11 | <div style="<%= @query.new_record? ? "" : "display: none;" %>"> |
|
12 | 12 | <%= render :partial => 'queries/filters', :locals => {:query => @query} %> |
|
13 | 13 | </div> |
|
14 | 14 | </fieldset> |
|
15 | 15 | |
|
16 | 16 | <p class="contextual"> |
|
17 | 17 | <%= gantt_zoom_link(@gantt, :in) %> |
|
18 | 18 | <%= gantt_zoom_link(@gantt, :out) %> |
|
19 | 19 | </p> |
|
20 | 20 | |
|
21 | 21 | <p class="buttons"> |
|
22 | 22 | <%= text_field_tag 'months', @gantt.months, :size => 2 %> |
|
23 | 23 | <%= l(:label_months_from) %> |
|
24 | 24 | <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %> |
|
25 | 25 | <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %> |
|
26 | 26 | <%= hidden_field_tag 'zoom', @gantt.zoom %> |
|
27 | 27 | |
|
28 | 28 | <%= link_to_function l(:button_apply), '$("#query_form").submit()', |
|
29 | 29 | :class => 'icon icon-checked' %> |
|
30 | 30 | <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, |
|
31 | 31 | :class => 'icon icon-reload' %> |
|
32 | 32 | </p> |
|
33 | 33 | <% end %> |
|
34 | 34 | |
|
35 | 35 | <%= error_messages_for 'query' %> |
|
36 | 36 | <% if @query.valid? %> |
|
37 | 37 | <% |
|
38 | 38 | zoom = 1 |
|
39 | 39 | @gantt.zoom.times { zoom = zoom * 2 } |
|
40 | 40 | |
|
41 | 41 | subject_width = 330 |
|
42 | 42 | header_heigth = 18 |
|
43 | 43 | |
|
44 | 44 | headers_height = header_heigth |
|
45 | 45 | show_weeks = false |
|
46 | 46 | show_days = false |
|
47 | 47 | |
|
48 | 48 | if @gantt.zoom > 1 |
|
49 | 49 | show_weeks = true |
|
50 | 50 | headers_height = 2 * header_heigth |
|
51 | 51 | if @gantt.zoom > 2 |
|
52 | 52 | show_days = true |
|
53 | 53 | headers_height = 3 * header_heigth |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | # Width of the entire chart |
|
58 | 58 | g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i |
|
59 | 59 | @gantt.render(:top => headers_height + 8, |
|
60 | 60 | :zoom => zoom, |
|
61 | 61 | :g_width => g_width, |
|
62 | 62 | :subject_width => subject_width) |
|
63 | 63 | g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max |
|
64 | 64 | t_height = g_height + headers_height |
|
65 | 65 | %> |
|
66 | 66 | |
|
67 | 67 | <% if @gantt.truncated %> |
|
68 | 68 | <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p> |
|
69 | 69 | <% end %> |
|
70 | 70 | |
|
71 | 71 | <table style="width:100%; border:0; border-collapse: collapse;"> |
|
72 | 72 | <tr> |
|
73 | 73 | <td style="width:<%= subject_width %>px; padding:0px;"> |
|
74 | 74 | <% |
|
75 | 75 | style = "" |
|
76 | 76 | style += "position:relative;" |
|
77 | 77 | style += "height: #{t_height + 24}px;" |
|
78 | 78 | style += "width: #{subject_width + 1}px;" |
|
79 | 79 | %> |
|
80 | 80 | <%= content_tag(:div, :style => style) do %> |
|
81 | 81 | <% |
|
82 | 82 | style = "" |
|
83 | 83 | style += "right:-2px;" |
|
84 | 84 | style += "width: #{subject_width}px;" |
|
85 | 85 | style += "height: #{headers_height}px;" |
|
86 | 86 | style += 'background: #eee;' |
|
87 | 87 | %> |
|
88 | 88 | <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %> |
|
89 | 89 | <% |
|
90 | 90 | style = "" |
|
91 | 91 | style += "right:-2px;" |
|
92 | 92 | style += "width: #{subject_width}px;" |
|
93 | 93 | style += "height: #{t_height}px;" |
|
94 | 94 | style += 'border-left: 1px solid #c0c0c0;' |
|
95 | 95 | style += 'overflow: hidden;' |
|
96 | 96 | %> |
|
97 | 97 | <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %> |
|
98 | 98 | <%= content_tag(:div, :class => "gantt_subjects") do %> |
|
99 | 99 | <%= @gantt.subjects.html_safe %> |
|
100 | 100 | <% end %> |
|
101 | 101 | <% end %> |
|
102 | 102 | </td> |
|
103 | 103 | |
|
104 | 104 | <td> |
|
105 | 105 | <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> |
|
106 | 106 | <% |
|
107 | 107 | style = "" |
|
108 | 108 | style += "width: #{g_width - 1}px;" |
|
109 | 109 | style += "height: #{headers_height}px;" |
|
110 | 110 | style += 'background: #eee;' |
|
111 | 111 | %> |
|
112 | 112 | <%= content_tag(:div, ' '.html_safe, :style => style, :class => "gantt_hdr") %> |
|
113 | 113 | |
|
114 | 114 | <% ###### Months headers ###### %> |
|
115 | 115 | <% |
|
116 | 116 | month_f = @gantt.date_from |
|
117 | 117 | left = 0 |
|
118 | 118 | height = (show_weeks ? header_heigth : header_heigth + g_height) |
|
119 | 119 | %> |
|
120 | 120 | <% @gantt.months.times do %> |
|
121 | 121 | <% |
|
122 | 122 | width = (((month_f >> 1) - month_f) * zoom - 1).to_i |
|
123 | 123 | style = "" |
|
124 | 124 | style += "left: #{left}px;" |
|
125 | 125 | style += "width: #{width}px;" |
|
126 | 126 | style += "height: #{height}px;" |
|
127 | 127 | %> |
|
128 | 128 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> |
|
129 | 129 | <%= link_to h("#{month_f.year}-#{month_f.month}"), |
|
130 | 130 | @gantt.params.merge(:year => month_f.year, :month => month_f.month), |
|
131 | 131 | :title => "#{month_name(month_f.month)} #{month_f.year}" %> |
|
132 | 132 | <% end %> |
|
133 | 133 | <% |
|
134 | 134 | left = left + width + 1 |
|
135 | 135 | month_f = month_f >> 1 |
|
136 | 136 | %> |
|
137 | 137 | <% end %> |
|
138 | 138 | |
|
139 | 139 | <% |
|
140 | 140 | # |
|
141 | 141 | # Weeks headers |
|
142 | 142 | # |
|
143 | 143 | %> |
|
144 | 144 | <% if show_weeks %> |
|
145 | 145 | <% |
|
146 | 146 | left = 0 |
|
147 | 147 | height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height) |
|
148 | 148 | %> |
|
149 | 149 | <% if @gantt.date_from.cwday == 1 %> |
|
150 | 150 | <% |
|
151 | 151 | # @date_from is monday |
|
152 | 152 | week_f = @gantt.date_from |
|
153 | 153 | %> |
|
154 | 154 | <% else %> |
|
155 | 155 | <% |
|
156 | 156 | # find next monday after @date_from |
|
157 | 157 | week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1) |
|
158 | 158 | width = (7 - @gantt.date_from.cwday + 1) * zoom - 1 |
|
159 | 159 | style = "" |
|
160 | 160 | style += "left: #{left}px;" |
|
161 | 161 | style += "top: 19px;" |
|
162 | 162 | style += "width: #{width}px;" |
|
163 | 163 | style += "height: #{height}px;" |
|
164 | 164 | %> |
|
165 | 165 | <%= content_tag(:div, ' '.html_safe, |
|
166 | 166 | :style => style, :class => "gantt_hdr") %> |
|
167 | 167 | <% left = left + width + 1 %> |
|
168 | 168 | <% end %> |
|
169 | 169 | <% while week_f <= @gantt.date_to %> |
|
170 | 170 | <% |
|
171 | 171 | width = ((week_f + 6 <= @gantt.date_to) ? |
|
172 | 172 | 7 * zoom - 1 : |
|
173 | 173 | (@gantt.date_to - week_f + 1) * zoom - 1).to_i |
|
174 | 174 | style = "" |
|
175 | 175 | style += "left: #{left}px;" |
|
176 | 176 | style += "top: 19px;" |
|
177 | 177 | style += "width: #{width}px;" |
|
178 | 178 | style += "height: #{height}px;" |
|
179 | 179 | %> |
|
180 | 180 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> |
|
181 | 181 | <%= content_tag(:small) do %> |
|
182 | 182 | <%= week_f.cweek if width >= 16 %> |
|
183 | 183 | <% end %> |
|
184 | 184 | <% end %> |
|
185 | 185 | <% |
|
186 | 186 | left = left + width + 1 |
|
187 | 187 | week_f = week_f + 7 |
|
188 | 188 | %> |
|
189 | 189 | <% end %> |
|
190 | 190 | <% end %> |
|
191 | 191 | |
|
192 | 192 | <% |
|
193 | 193 | # |
|
194 | 194 | # Days headers |
|
195 | 195 | # |
|
196 | 196 | %> |
|
197 | 197 | <% if show_days %> |
|
198 | 198 | <% |
|
199 | 199 | left = 0 |
|
200 | 200 | height = g_height + header_heigth - 1 |
|
201 | 201 | wday = @gantt.date_from.cwday |
|
202 | 202 | %> |
|
203 | 203 | <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %> |
|
204 | <% width = zoom - 1 %> | |
|
205 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" | |
|
206 | class="gantt_hdr"> | |
|
207 | <%= day_letter(wday) %> | |
|
208 | </div> | |
|
204 | <% | |
|
205 | width = zoom - 1 | |
|
206 | style = "" | |
|
207 | style += "left: #{left}px;" | |
|
208 | style += "top:37px;" | |
|
209 | style += "width: #{width}px;" | |
|
210 | style += "height: #{height}px;" | |
|
211 | style += "font-size:0.7em;" | |
|
212 | style += 'background:#f1f1f1;' if wday > 5 | |
|
213 | %> | |
|
214 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> | |
|
215 | <%= day_letter(wday) %> | |
|
216 | <% end %> | |
|
209 | 217 | <% |
|
210 | 218 | left = left + width + 1 |
|
211 | 219 | wday = wday + 1 |
|
212 | 220 | wday = 1 if wday > 7 |
|
213 | 221 | %> |
|
214 | 222 | <% end %> |
|
215 | 223 | <% end %> |
|
216 | 224 | |
|
217 | 225 | <%= @gantt.lines.html_safe %> |
|
218 | 226 | |
|
219 | 227 | <% ###### Today red line (excluded from cache) ###### %> |
|
220 | 228 | <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %> |
|
221 | 229 | <% |
|
222 | 230 | today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i |
|
223 | 231 | style = "" |
|
224 | 232 | style += "position: absolute;" |
|
225 | 233 | style += "height: #{g_height}px;" |
|
226 | 234 | style += "top: #{headers_height + 1}px;" |
|
227 | 235 | style += "left: #{today_left}px;" |
|
228 | 236 | style += "width:10px;" |
|
229 | 237 | style += "border-left: 1px dashed red;" |
|
230 | 238 | %> |
|
231 | 239 | <%= content_tag(:div, ' '.html_safe, :style => style) %> |
|
232 | 240 | <% end %> |
|
233 | 241 | |
|
234 | 242 | </div> |
|
235 | 243 | </td> |
|
236 | 244 | </tr> |
|
237 | 245 | </table> |
|
238 | 246 | |
|
239 | 247 | <table style="width:100%"> |
|
240 | 248 | <tr> |
|
241 | 249 | <td align="left"> |
|
242 | 250 | <%= link_to_content_update("\xc2\xab " + l(:label_previous), |
|
243 | 251 | params.merge(@gantt.params_previous)) %> |
|
244 | 252 | </td> |
|
245 | 253 | <td align="right"> |
|
246 | 254 | <%= link_to_content_update(l(:label_next) + " \xc2\xbb", |
|
247 | 255 | params.merge(@gantt.params_next)) %> |
|
248 | 256 | </td> |
|
249 | 257 | </tr> |
|
250 | 258 | </table> |
|
251 | 259 | |
|
252 | 260 | <% other_formats_links do |f| %> |
|
253 | 261 | <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %> |
|
254 | 262 | <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %> |
|
255 | 263 | <% end %> |
|
256 | 264 | <% end # query.valid? %> |
|
257 | 265 | |
|
258 | 266 | <% content_for :sidebar do %> |
|
259 | 267 | <%= render :partial => 'issues/sidebar' %> |
|
260 | 268 | <% end %> |
|
261 | 269 | |
|
262 | 270 | <% html_title(l(:label_gantt)) -%> |
General Comments 0
You need to be logged in to leave comments.
Login now