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