@@ -1,237 +1,242 | |||||
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 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> |
|
75 | <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> | |
76 | <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:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div> | |
77 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" |
|
77 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" | |
78 | class="gantt_hdr"></div> |
|
78 | class="gantt_hdr"></div> | |
79 |
|
79 | |||
80 | <div class="gantt_subjects"> |
|
80 | <div class="gantt_subjects"> | |
81 | <%= @gantt.subjects.html_safe %> |
|
81 | <%= @gantt.subjects.html_safe %> | |
82 | </div> |
|
82 | </div> | |
83 |
|
83 | |||
84 | </div> |
|
84 | </div> | |
85 | </td> |
|
85 | </td> | |
86 | <td> |
|
86 | <td> | |
87 |
|
87 | |||
88 | <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> |
|
88 | <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> | |
89 | <div style="width:<%= g_width - 1 %>px;height:<%= headers_height %>px;background: #eee;" |
|
89 | <div style="width:<%= g_width - 1 %>px;height:<%= headers_height %>px;background: #eee;" | |
90 | class="gantt_hdr"> </div> |
|
90 | class="gantt_hdr"> </div> | |
91 | <% |
|
91 | <% | |
92 | # |
|
92 | # | |
93 | # Months headers |
|
93 | # Months headers | |
94 | # |
|
94 | # | |
95 | %> |
|
95 | %> | |
96 | <% |
|
96 | <% | |
97 | month_f = @gantt.date_from |
|
97 | month_f = @gantt.date_from | |
98 | left = 0 |
|
98 | left = 0 | |
99 | height = (show_weeks ? header_heigth : header_heigth + g_height) |
|
99 | height = (show_weeks ? header_heigth : header_heigth + g_height) | |
100 | %> |
|
100 | %> | |
101 | <% @gantt.months.times do %> |
|
101 | <% @gantt.months.times do %> | |
102 | <% |
|
102 | <% | |
103 | width = (((month_f >> 1) - month_f) * zoom - 1).to_i |
|
103 | width = (((month_f >> 1) - month_f) * zoom - 1).to_i | |
104 | style = "" |
|
104 | style = "" | |
105 | style += "left: #{left}px;" |
|
105 | style += "left: #{left}px;" | |
106 | style += "width: #{width}px;" |
|
106 | style += "width: #{width}px;" | |
107 | style += "height: #{height}px;" |
|
107 | style += "height: #{height}px;" | |
108 | %> |
|
108 | %> | |
109 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> |
|
109 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> | |
110 | <%= link_to h("#{month_f.year}-#{month_f.month}"), |
|
110 | <%= link_to h("#{month_f.year}-#{month_f.month}"), | |
111 | @gantt.params.merge(:year => month_f.year, :month => month_f.month), |
|
111 | @gantt.params.merge(:year => month_f.year, :month => month_f.month), | |
112 | :title => "#{month_name(month_f.month)} #{month_f.year}" %> |
|
112 | :title => "#{month_name(month_f.month)} #{month_f.year}" %> | |
113 | <% end %> |
|
113 | <% end %> | |
114 | <% |
|
114 | <% | |
115 | left = left + width + 1 |
|
115 | left = left + width + 1 | |
116 | month_f = month_f >> 1 |
|
116 | month_f = month_f >> 1 | |
117 | %> |
|
117 | %> | |
118 | <% end %> |
|
118 | <% end %> | |
119 |
|
119 | |||
120 | <% |
|
120 | <% | |
121 | # |
|
121 | # | |
122 | # Weeks headers |
|
122 | # Weeks headers | |
123 | # |
|
123 | # | |
124 | %> |
|
124 | %> | |
125 | <% if show_weeks %> |
|
125 | <% if show_weeks %> | |
126 | <% |
|
126 | <% | |
127 | left = 0 |
|
127 | left = 0 | |
128 | height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height) |
|
128 | height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height) | |
129 | %> |
|
129 | %> | |
130 | <% if @gantt.date_from.cwday == 1 %> |
|
130 | <% if @gantt.date_from.cwday == 1 %> | |
131 | <% |
|
131 | <% | |
132 | # @date_from is monday |
|
132 | # @date_from is monday | |
133 | week_f = @gantt.date_from |
|
133 | week_f = @gantt.date_from | |
134 | %> |
|
134 | %> | |
135 | <% else %> |
|
135 | <% else %> | |
136 | <% |
|
136 | <% | |
137 | # find next monday after @date_from |
|
137 | # find next monday after @date_from | |
138 | week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1) |
|
138 | week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1) | |
139 | width = (7 - @gantt.date_from.cwday + 1) * zoom - 1 |
|
139 | width = (7 - @gantt.date_from.cwday + 1) * zoom - 1 | |
140 | style = "" |
|
140 | style = "" | |
141 | style += "left: #{left}px;" |
|
141 | style += "left: #{left}px;" | |
142 | style += "top: 19px;" |
|
142 | style += "top: 19px;" | |
143 | style += "width: #{width}px;" |
|
143 | style += "width: #{width}px;" | |
144 | style += "height: #{height}px;" |
|
144 | style += "height: #{height}px;" | |
145 | %> |
|
145 | %> | |
146 | <%= content_tag(:div, ' '.html_safe, |
|
146 | <%= content_tag(:div, ' '.html_safe, | |
147 | :style => style, :class => "gantt_hdr") %> |
|
147 | :style => style, :class => "gantt_hdr") %> | |
148 | <% left = left + width + 1 %> |
|
148 | <% left = left + width + 1 %> | |
149 | <% end %> |
|
149 | <% end %> | |
150 | <% while week_f <= @gantt.date_to %> |
|
150 | <% while week_f <= @gantt.date_to %> | |
151 | <% |
|
151 | <% | |
152 | width = ((week_f + 6 <= @gantt.date_to) ? |
|
152 | width = ((week_f + 6 <= @gantt.date_to) ? | |
153 | 7 * zoom - 1 : |
|
153 | 7 * zoom - 1 : | |
154 | (@gantt.date_to - week_f + 1) * zoom - 1).to_i |
|
154 | (@gantt.date_to - week_f + 1) * zoom - 1).to_i | |
155 | style = "" |
|
155 | style = "" | |
156 | style += "left: #{left}px;" |
|
156 | style += "left: #{left}px;" | |
157 | style += "top: 19px;" |
|
157 | style += "top: 19px;" | |
158 | style += "width: #{width}px;" |
|
158 | style += "width: #{width}px;" | |
159 | style += "height: #{height}px;" |
|
159 | style += "height: #{height}px;" | |
160 | %> |
|
160 | %> | |
161 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> |
|
161 | <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %> | |
162 | <%= content_tag(:small) do %> |
|
162 | <%= content_tag(:small) do %> | |
163 | <%= week_f.cweek if width >= 16 %> |
|
163 | <%= week_f.cweek if width >= 16 %> | |
164 | <% end %> |
|
164 | <% end %> | |
165 | <% end %> |
|
165 | <% end %> | |
166 | <% |
|
166 | <% | |
167 | left = left + width + 1 |
|
167 | left = left + width + 1 | |
168 | week_f = week_f + 7 |
|
168 | week_f = week_f + 7 | |
169 | %> |
|
169 | %> | |
170 | <% end %> |
|
170 | <% end %> | |
171 | <% end %> |
|
171 | <% end %> | |
172 |
|
172 | |||
173 | <% |
|
173 | <% | |
174 | # |
|
174 | # | |
175 | # Days headers |
|
175 | # Days headers | |
176 | # |
|
176 | # | |
177 | %> |
|
177 | %> | |
178 | <% if show_days %> |
|
178 | <% if show_days %> | |
179 | <% |
|
179 | <% | |
180 | left = 0 |
|
180 | left = 0 | |
181 | height = g_height + header_heigth - 1 |
|
181 | height = g_height + header_heigth - 1 | |
182 | wday = @gantt.date_from.cwday |
|
182 | wday = @gantt.date_from.cwday | |
183 | %> |
|
183 | %> | |
184 | <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %> |
|
184 | <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %> | |
185 | <% width = zoom - 1 %> |
|
185 | <% width = zoom - 1 %> | |
186 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" |
|
186 | <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>" | |
187 | class="gantt_hdr"> |
|
187 | class="gantt_hdr"> | |
188 | <%= day_letter(wday) %> |
|
188 | <%= day_letter(wday) %> | |
189 | </div> |
|
189 | </div> | |
190 | <% |
|
190 | <% | |
191 | left = left + width + 1 |
|
191 | left = left + width + 1 | |
192 | wday = wday + 1 |
|
192 | wday = wday + 1 | |
193 | wday = 1 if wday > 7 |
|
193 | wday = 1 if wday > 7 | |
194 | %> |
|
194 | %> | |
195 | <% end %> |
|
195 | <% end %> | |
196 | <% end %> |
|
196 | <% end %> | |
197 |
|
197 | |||
198 | <%= @gantt.lines.html_safe %> |
|
198 | <%= @gantt.lines.html_safe %> | |
199 |
|
199 | |||
200 | <% |
|
200 | <% ###### Today red line (excluded from cache) ###### %> | |
201 | # |
|
|||
202 | # Today red line (excluded from cache) |
|
|||
203 | # |
|
|||
204 | %> |
|
|||
205 | <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %> |
|
201 | <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %> | |
206 | <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i %>px;width:10px;border-left: 1px dashed red;"> </div> |
|
202 | <% | |
|
203 | style = "" | |||
|
204 | style += "position: absolute;" | |||
|
205 | style += "height: #{g_height}px;" | |||
|
206 | style += "top: #{headers_height + 1}px;" | |||
|
207 | style += "left: #{(((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i}px;" | |||
|
208 | style += "width:10px;" | |||
|
209 | style += "border-left: 1px dashed red;" | |||
|
210 | %> | |||
|
211 | <%= content_tag(:div, ' '.html_safe, :style => style) %> | |||
207 | <% end %> |
|
212 | <% end %> | |
208 |
|
213 | |||
209 | </div> |
|
214 | </div> | |
210 | </td> |
|
215 | </td> | |
211 | </tr> |
|
216 | </tr> | |
212 | </table> |
|
217 | </table> | |
213 |
|
218 | |||
214 | <table style="width:100%"> |
|
219 | <table style="width:100%"> | |
215 | <tr> |
|
220 | <tr> | |
216 | <td align="left"> |
|
221 | <td align="left"> | |
217 | <%= link_to_content_update("\xc2\xab " + l(:label_previous), |
|
222 | <%= link_to_content_update("\xc2\xab " + l(:label_previous), | |
218 | params.merge(@gantt.params_previous)) %> |
|
223 | params.merge(@gantt.params_previous)) %> | |
219 | </td> |
|
224 | </td> | |
220 | <td align="right"> |
|
225 | <td align="right"> | |
221 | <%= link_to_content_update(l(:label_next) + " \xc2\xbb", |
|
226 | <%= link_to_content_update(l(:label_next) + " \xc2\xbb", | |
222 | params.merge(@gantt.params_next)) %> |
|
227 | params.merge(@gantt.params_next)) %> | |
223 | </td> |
|
228 | </td> | |
224 | </tr> |
|
229 | </tr> | |
225 | </table> |
|
230 | </table> | |
226 |
|
231 | |||
227 | <% other_formats_links do |f| %> |
|
232 | <% other_formats_links do |f| %> | |
228 | <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %> |
|
233 | <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %> | |
229 | <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %> |
|
234 | <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %> | |
230 | <% end %> |
|
235 | <% end %> | |
231 | <% end # query.valid? %> |
|
236 | <% end # query.valid? %> | |
232 |
|
237 | |||
233 | <% content_for :sidebar do %> |
|
238 | <% content_for :sidebar do %> | |
234 | <%= render :partial => 'issues/sidebar' %> |
|
239 | <%= render :partial => 'issues/sidebar' %> | |
235 | <% end %> |
|
240 | <% end %> | |
236 |
|
241 | |||
237 | <% html_title(l(:label_gantt)) -%> |
|
242 | <% html_title(l(:label_gantt)) -%> |
General Comments 0
You need to be logged in to leave comments.
Login now