##// END OF EJS Templates
code layout cleanup app/views/gantts/show.html.erb...
Toshi MARUYAMA -
r10126:9c5f339efb2c
parent child
Show More
@@ -1,191 +1,199
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()', :class => 'icon icon-checked' %>
28 <%= link_to_function l(:button_apply), '$("#query_form").submit()',
29 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
29 :class => 'icon icon-checked' %>
30 <%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
31 :class => 'icon icon-reload' %>
30 </p>
32 </p>
31 <% end %>
33 <% end %>
32
34
33 <%= error_messages_for 'query' %>
35 <%= error_messages_for 'query' %>
34 <% if @query.valid? %>
36 <% if @query.valid? %>
35 <%
37 <%
36 zoom = 1
38 zoom = 1
37 @gantt.zoom.times { zoom = zoom * 2 }
39 @gantt.zoom.times { zoom = zoom * 2 }
38
40
39 subject_width = 330
41 subject_width = 330
40 header_heigth = 18
42 header_heigth = 18
41
43
42 headers_height = header_heigth
44 headers_height = header_heigth
43 show_weeks = false
45 show_weeks = false
44 show_days = false
46 show_days = false
45
47
46 if @gantt.zoom > 1
48 if @gantt.zoom > 1
47 show_weeks = true
49 show_weeks = true
48 headers_height = 2 * header_heigth
50 headers_height = 2 * header_heigth
49 if @gantt.zoom > 2
51 if @gantt.zoom > 2
50 show_days = true
52 show_days = true
51 headers_height = 3 * header_heigth
53 headers_height = 3 * header_heigth
52 end
54 end
53 end
55 end
54
56
55 # Width of the entire chart
57 # Width of the entire chart
56 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
57 @gantt.render(:top => headers_height + 8,
59 @gantt.render(:top => headers_height + 8,
58 :zoom => zoom,
60 :zoom => zoom,
59 :g_width => g_width,
61 :g_width => g_width,
60 :subject_width => subject_width)
62 :subject_width => subject_width)
61 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
63 g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
62 t_height = g_height + headers_height
64 t_height = g_height + headers_height
63 %>
65 %>
64
66
65 <% if @gantt.truncated %>
67 <% if @gantt.truncated %>
66 <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>
67 <% end %>
69 <% end %>
68
70
69 <table style="width:100%; border:0; border-collapse: collapse;">
71 <table style="width:100%; border:0; border-collapse: collapse;">
70 <tr>
72 <tr>
71 <td style="width:<%= subject_width %>px; padding:0px;">
73 <td style="width:<%= subject_width %>px; padding:0px;">
72
74
73 <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;">
74 <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>
75 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
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>
76
79
77 <div class="gantt_subjects">
80 <div class="gantt_subjects">
78 <%= @gantt.subjects.html_safe %>
81 <%= @gantt.subjects.html_safe %>
79 </div>
82 </div>
80
83
81 </div>
84 </div>
82 </td>
85 </td>
83 <td>
86 <td>
84
87
85 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
88 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
86 <div style="width:<%= g_width - 1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
89 <div style="width:<%= g_width - 1 %>px;height:<%= headers_height %>px;background: #eee;"
90 class="gantt_hdr">&nbsp;</div>
87 <%
91 <%
88 #
92 #
89 # Months headers
93 # Months headers
90 #
94 #
91 month_f = @gantt.date_from
95 month_f = @gantt.date_from
92 left = 0
96 left = 0
93 height = (show_weeks ? header_heigth : header_heigth + g_height)
97 height = (show_weeks ? header_heigth : header_heigth + g_height)
94 @gantt.months.times do
98 @gantt.months.times do
95 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
99 width = (((month_f >> 1) - month_f) * zoom - 1).to_i
96 %>
100 %>
97 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
101 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
98 <%= link_to h("#{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}"%>
102 <%= link_to h("#{month_f.year}-#{month_f.month}"),
103 @gantt.params.merge(:year => month_f.year, :month => month_f.month),
104 :title => "#{month_name(month_f.month)} #{month_f.year}" %>
99 </div>
105 </div>
100 <%
106 <%
101 left = left + width + 1
107 left = left + width + 1
102 month_f = month_f >> 1
108 month_f = month_f >> 1
103 end %>
109 end %>
104
110
105 <%
111 <%
106 #
112 #
107 # Weeks headers
113 # Weeks headers
108 #
114 #
109 if show_weeks
115 if show_weeks
110 left = 0
116 left = 0
111 height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height)
117 height = (show_days ? header_heigth - 1 : header_heigth - 1 + g_height)
112 if @gantt.date_from.cwday == 1
118 if @gantt.date_from.cwday == 1
113 # @date_from is monday
119 # @date_from is monday
114 week_f = @gantt.date_from
120 week_f = @gantt.date_from
115 else
121 else
116 # find next monday after @date_from
122 # find next monday after @date_from
117 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
123 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
118 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
124 width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
119 %>
125 %>
120 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
126 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;"
127 class="gantt_hdr">&nbsp;</div>
121 <%
128 <%
122 left = left + width + 1
129 left = left + width + 1
123 end %>
130 end %>
124 <%
131 <%
125 while week_f <= @gantt.date_to
132 while week_f <= @gantt.date_to
126 width = ((week_f + 6 <= @gantt.date_to) ? 7 * zoom - 1 : (@gantt.date_to - week_f + 1) * zoom - 1).to_i
133 width = ((week_f + 6 <= @gantt.date_to) ? 7 * zoom - 1 : (@gantt.date_to - week_f + 1) * zoom - 1).to_i
127 %>
134 %>
128 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
135 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
129 <small><%= week_f.cweek if width >= 16 %></small>
136 <small><%= week_f.cweek if width >= 16 %></small>
130 </div>
137 </div>
131 <%
138 <%
132 left = left + width + 1
139 left = left + width + 1
133 week_f = week_f + 7
140 week_f = week_f + 7
134 end
141 end
135 end %>
142 end %>
136
143
137 <%
144 <%
138 #
145 #
139 # Days headers
146 # Days headers
140 #
147 #
141 if show_days
148 if show_days
142 left = 0
149 left = 0
143 height = g_height + header_heigth - 1
150 height = g_height + header_heigth - 1
144 wday = @gantt.date_from.cwday
151 wday = @gantt.date_from.cwday
145 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
152 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
146 width = zoom - 1
153 width = zoom - 1
147 %>
154 %>
148 <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">
155 <div style="left:<%= left %>px;top:37px;width:<%= width %>px;height:<%= height %>px;font-size:0.7em;<%= "background:#f1f1f1;" if wday > 5 %>"
156 class="gantt_hdr">
149 <%= day_letter(wday) %>
157 <%= day_letter(wday) %>
150 </div>
158 </div>
151 <%
159 <%
152 left = left + width + 1
160 left = left + width + 1
153 wday = wday + 1
161 wday = wday + 1
154 wday = 1 if wday > 7
162 wday = 1 if wday > 7
155 end
163 end
156 end %>
164 end %>
157
165
158 <%= @gantt.lines.html_safe %>
166 <%= @gantt.lines.html_safe %>
159
167
160 <%
168 <%
161 #
169 #
162 # Today red line (excluded from cache)
170 # Today red line (excluded from cache)
163 #
171 #
164 %>
172 %>
165 <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
173 <% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
166 <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;">&nbsp;</div>
174 <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;">&nbsp;</div>
167 <% end %>
175 <% end %>
168
176
169 </div>
177 </div>
170 </td>
178 </td>
171 </tr>
179 </tr>
172 </table>
180 </table>
173
181
174 <table style="width:100%">
182 <table style="width:100%">
175 <tr>
183 <tr>
176 <td align="left"><%= link_to_content_update("\xc2\xab " + l(:label_previous), params.merge(@gantt.params_previous)) %></td>
184 <td align="left"><%= link_to_content_update("\xc2\xab " + l(:label_previous), params.merge(@gantt.params_previous)) %></td>
177 <td align="right"><%= link_to_content_update(l(:label_next) + " \xc2\xbb", params.merge(@gantt.params_next)) %></td>
185 <td align="right"><%= link_to_content_update(l(:label_next) + " \xc2\xbb", params.merge(@gantt.params_next)) %></td>
178 </tr>
186 </tr>
179 </table>
187 </table>
180
188
181 <% other_formats_links do |f| %>
189 <% other_formats_links do |f| %>
182 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
190 <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
183 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
191 <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
184 <% end %>
192 <% end %>
185 <% end # query.valid? %>
193 <% end # query.valid? %>
186
194
187 <% content_for :sidebar do %>
195 <% content_for :sidebar do %>
188 <%= render :partial => 'issues/sidebar' %>
196 <%= render :partial => 'issues/sidebar' %>
189 <% end %>
197 <% end %>
190
198
191 <% html_title(l(:label_gantt)) -%>
199 <% html_title(l(:label_gantt)) -%>
General Comments 0
You need to be logged in to leave comments. Login now