##// END OF EJS Templates
Gantt: view cleanup....
Jean-Philippe Lang -
r4359:b17e145d75f9
parent child
Show More
@@ -1,190 +1,187
1 1 <% @gantt.view = self %>
2 2 <h2><%= l(:label_gantt) %></h2>
3 3
4 4 <% form_tag(gantt_path(:month => params[:month], :year => params[:year], :months => params[:months]), :method => :put, :id => 'query_form') do %>
5 5 <%= hidden_field_tag('project_id', @project.to_param) if @project%>
6 6 <fieldset id="filters" class="collapsible">
7 7 <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
8 8 <div>
9 9 <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
10 10 </div>
11 11 </fieldset>
12 12
13 13 <p class="contextual">
14 14 <%= gantt_zoom_link(@gantt, :in) %>
15 15 <%= gantt_zoom_link(@gantt, :out) %>
16 16 </p>
17 17
18 18 <p class="buttons">
19 19 <%= text_field_tag 'months', @gantt.months, :size => 2 %>
20 20 <%= l(:label_months_from) %>
21 21 <%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
22 22 <%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
23 23 <%= hidden_field_tag 'zoom', @gantt.zoom %>
24 24
25 25 <%= link_to_remote l(:button_apply),
26 26 { :url => { :set_filter => (@query.new_record? ? 1 : nil) },
27 27 :update => "content",
28 28 :with => "Form.serialize('query_form')"
29 29 }, :class => 'icon icon-checked' %>
30 30
31 31 <%= link_to_remote l(:button_clear),
32 32 { :url => { :project_id => @project, :set_filter => (@query.new_record? ? 1 : nil) },
33 33 :method => :put,
34 34 :update => "content",
35 35 }, :class => 'icon icon-reload' if @query.new_record? %>
36 36 </p>
37 37 <% end %>
38 38
39 39 <%= error_messages_for 'query' %>
40 40 <% if @query.valid? %>
41 41 <% zoom = 1
42 42 @gantt.zoom.times { zoom = zoom * 2 }
43 43
44 44 subject_width = 330
45 45 header_heigth = 18
46 46
47 47 headers_height = header_heigth
48 48 show_weeks = false
49 49 show_days = false
50 50
51 51 if @gantt.zoom >1
52 52 show_weeks = true
53 53 headers_height = 2*header_heigth
54 54 if @gantt.zoom > 2
55 55 show_days = true
56 56 headers_height = 3*header_heigth
57 57 end
58 58 end
59 59
60 60 # Width of the entire chart
61 61 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom
62 62 # Collect the number of issues on Versions
63 63 g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max
64 64 t_height = g_height + headers_height
65 65
66 @gantt.render(:headers_height => headers_height, :top => headers_height + 8, :zoom => zoom, :g_width => g_width)
66 @gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width)
67 67 %>
68 68 <table width="100%" style="border:0; border-collapse: collapse;">
69 69 <tr>
70 70 <td style="width:<%= subject_width %>px; padding:0px;">
71 71
72 72 <div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;">
73 73 <div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div>
74 74 <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div>
75 <% top = headers_height + 8 %>
76 75
77 76 <%= @gantt.subjects %>
78 77
79 78 </div>
80 79 </td>
81 80 <td>
82 81
83 82 <div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;">
84 83 <div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr">&nbsp;</div>
85 84 <%
86 85 #
87 86 # Months headers
88 87 #
89 88 month_f = @gantt.date_from
90 89 left = 0
91 90 height = (show_weeks ? header_heigth : header_heigth + g_height)
92 91 @gantt.months.times do
93 92 width = ((month_f >> 1) - month_f) * zoom - 1
94 93 %>
95 94 <div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
96 95 <%= link_to "#{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}"%>
97 96 </div>
98 97 <%
99 98 left = left + width + 1
100 99 month_f = month_f >> 1
101 100 end %>
102 101
103 102 <%
104 103 #
105 104 # Weeks headers
106 105 #
107 106 if show_weeks
108 107 left = 0
109 108 height = (show_days ? header_heigth-1 : header_heigth-1 + g_height)
110 109 if @gantt.date_from.cwday == 1
111 110 # @date_from is monday
112 111 week_f = @gantt.date_from
113 112 else
114 113 # find next monday after @date_from
115 114 week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
116 115 width = (7 - @gantt.date_from.cwday + 1) * zoom-1
117 116 %>
118 117 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">&nbsp;</div>
119 118 <%
120 119 left = left + width+1
121 120 end %>
122 121 <%
123 122 while week_f <= @gantt.date_to
124 123 width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1
125 124 %>
126 125 <div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr">
127 126 <small><%= week_f.cweek if width >= 16 %></small>
128 127 </div>
129 128 <%
130 129 left = left + width+1
131 130 week_f = week_f+7
132 131 end
133 132 end %>
134 133
135 134 <%
136 135 #
137 136 # Days headers
138 137 #
139 138 if show_days
140 139 left = 0
141 140 height = g_height + header_heigth - 1
142 141 wday = @gantt.date_from.cwday
143 142 (@gantt.date_to - @gantt.date_from + 1).to_i.times do
144 143 width = zoom - 1
145 144 %>
146 145 <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">
147 146 <%= day_name(wday).first %>
148 147 </div>
149 148 <%
150 149 left = left + width+1
151 150 wday = wday + 1
152 151 wday = 1 if wday > 7
153 152 end
154 153 end %>
155 154
156 <% top = headers_height + 10 %>
157
158 155 <%= @gantt.lines %>
159 156
160 157 <%
161 158 #
162 159 # Today red line (excluded from cache)
163 160 #
164 161 if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
165 162 <div style="position: absolute;height:<%= g_height %>px;top:<%= headers_height + 1 %>px;left:<%= ((Date.today-@gantt.date_from+1)*zoom).floor()-1 %>px;width:10px;border-left: 1px dashed red;">&nbsp;</div>
166 163 <% end %>
167 164
168 165 </div>
169 166 </td>
170 167 </tr>
171 168 </table>
172 169
173 170 <table width="100%">
174 171 <tr>
175 172 <td align="left"><%= link_to_remote ('&#171; ' + l(:label_previous)), {:url => @gantt.params_previous, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_previous)} %></td>
176 173 <td align="right"><%= link_to_remote (l(:label_next) + ' &#187;'), {:url => @gantt.params_next, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, {:href => url_for(@gantt.params_next)} %></td>
177 174 </tr>
178 175 </table>
179 176
180 177 <% other_formats_links do |f| %>
181 178 <%= f.link_to 'PDF', :url => @gantt.params %>
182 179 <%= f.link_to('PNG', :url => @gantt.params) if @gantt.respond_to?('to_image') %>
183 180 <% end %>
184 181 <% end # query.valid? %>
185 182
186 183 <% content_for :sidebar do %>
187 184 <%= render :partial => 'issues/sidebar' %>
188 185 <% end %>
189 186
190 187 <% html_title(l(:label_gantt)) -%>
General Comments 0
You need to be logged in to leave comments. Login now