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