To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 82 / 82b21e972ba488af04b89b832125d370772e13c3.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (5.8 KB)
| 1 |
<% @gantt.view = self %> |
|---|---|
| 2 |
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2> |
| 3 |
|
| 4 |
<% form_tag({:controller => 'gantts', :action => 'show', :project_id => @project, :month => params[:month], :year => params[:year], :months => params[:months]}, :method => :get, :id => 'query_form') do %>
|
| 5 |
<%= hidden_field_tag 'set_filter', '1' %> |
| 6 |
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>"> |
| 7 |
<legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend> |
| 8 |
<div style="<%= @query.new_record? ? "" : "display: none;" %>"> |
| 9 |
<%= render :partial => 'queries/filters', :locals => {:query => @query} %>
|
| 10 |
</div> |
| 11 |
</fieldset> |
| 12 |
|
| 13 |
<p class="contextual"> |
| 14 |
<%= gantt_zoom_link(@gantt, :in) %> |
| 15 |
<%= gantt_zoom_link(@gantt, :out) %> |
| 16 |
</p> |
| 17 |
|
| 18 |
<p class="buttons"> |
| 19 |
<%= text_field_tag 'months', @gantt.months, :size => 2 %> |
| 20 |
<%= l(:label_months_from) %> |
| 21 |
<%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %> |
| 22 |
<%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %> |
| 23 |
<%= hidden_field_tag 'zoom', @gantt.zoom %> |
| 24 |
|
| 25 |
<%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %>
|
| 26 |
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 }, :class => 'icon icon-reload' %>
|
| 27 |
</p> |
| 28 |
<% end %> |
| 29 |
|
| 30 |
<%= error_messages_for 'query' %> |
| 31 |
<% if @query.valid? %> |
| 32 |
<% zoom = 1 |
| 33 |
@gantt.zoom.times { zoom = zoom * 2 }
|
| 34 |
|
| 35 |
subject_width = 330 |
| 36 |
header_heigth = 18 |
| 37 |
|
| 38 |
headers_height = header_heigth |
| 39 |
show_weeks = false |
| 40 |
show_days = false |
| 41 |
|
| 42 |
if @gantt.zoom >1 |
| 43 |
show_weeks = true |
| 44 |
headers_height = 2*header_heigth |
| 45 |
if @gantt.zoom > 2 |
| 46 |
show_days = true |
| 47 |
headers_height = 3*header_heigth |
| 48 |
end |
| 49 |
end |
| 50 |
|
| 51 |
# Width of the entire chart |
| 52 |
g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom |
| 53 |
|
| 54 |
@gantt.render(:top => headers_height + 8, :zoom => zoom, :g_width => g_width, :subject_width => subject_width) |
| 55 |
|
| 56 |
g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max |
| 57 |
t_height = g_height + headers_height |
| 58 |
|
| 59 |
|
| 60 |
%> |
| 61 |
|
| 62 |
<% if @gantt.truncated %> |
| 63 |
<p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p> |
| 64 |
<% end %> |
| 65 |
|
| 66 |
<table width="100%" style="border:0; border-collapse: collapse;"> |
| 67 |
<tr> |
| 68 |
<td style="width:<%= subject_width %>px; padding:0px;"> |
| 69 |
|
| 70 |
<div style="position:relative;height:<%= t_height + 24 %>px;width:<%= subject_width + 1 %>px;"> |
| 71 |
<div style="right:-2px;width:<%= subject_width %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"></div> |
| 72 |
<div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div> |
| 73 |
|
| 74 |
<div class="gantt_subjects"> |
| 75 |
<%= @gantt.subjects.html_safe %> |
| 76 |
</div> |
| 77 |
|
| 78 |
</div> |
| 79 |
</td> |
| 80 |
<td> |
| 81 |
|
| 82 |
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;"> |
| 83 |
<div style="width:<%= g_width-1 %>px;height:<%= headers_height %>px;background: #eee;" class="gantt_hdr"> </div> |
| 84 |
<% |
| 85 |
# |
| 86 |
# Months headers |
| 87 |
# |
| 88 |
month_f = @gantt.date_from |
| 89 |
left = 0 |
| 90 |
height = (show_weeks ? header_heigth : header_heigth + g_height) |
| 91 |
@gantt.months.times do |
| 92 |
width = ((month_f >> 1) - month_f) * zoom - 1 |
| 93 |
%> |
| 94 |
<div style="left:<%= left %>px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> |
| 95 |
<%= 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}"%>
|
| 96 |
</div> |
| 97 |
<% |
| 98 |
left = left + width + 1 |
| 99 |
month_f = month_f >> 1 |
| 100 |
end %> |
| 101 |
|
| 102 |
<% |
| 103 |
# |
| 104 |
# Weeks headers |
| 105 |
# |
| 106 |
if show_weeks |
| 107 |
left = 0 |
| 108 |
height = (show_days ? header_heigth-1 : header_heigth-1 + g_height) |
| 109 |
if @gantt.date_from.cwday == 1 |
| 110 |
# @date_from is monday |
| 111 |
week_f = @gantt.date_from |
| 112 |
else |
| 113 |
# find next monday after @date_from |
| 114 |
week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1) |
| 115 |
width = (7 - @gantt.date_from.cwday + 1) * zoom-1 |
| 116 |
%> |
| 117 |
<div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> </div> |
| 118 |
<% |
| 119 |
left = left + width+1 |
| 120 |
end %> |
| 121 |
<% |
| 122 |
while week_f <= @gantt.date_to |
| 123 |
width = (week_f + 6 <= @gantt.date_to) ? 7 * zoom -1 : (@gantt.date_to - week_f + 1) * zoom-1 |
| 124 |
%> |
| 125 |
<div style="left:<%= left %>px;top:19px;width:<%= width %>px;height:<%= height %>px;" class="gantt_hdr"> |
| 126 |
<small><%= week_f.cweek if width >= 16 %></small> |
| 127 |
</div> |
| 128 |
<% |
| 129 |
left = left + width+1 |
| 130 |
week_f = week_f+7 |
| 131 |
end |
| 132 |
end %> |
| 133 |
|
| 134 |
<% |
| 135 |
# |
| 136 |
# Days headers |
| 137 |
# |
| 138 |
if show_days |
| 139 |
left = 0 |
| 140 |
height = g_height + header_heigth - 1 |
| 141 |
wday = @gantt.date_from.cwday |
| 142 |
(@gantt.date_to - @gantt.date_from + 1).to_i.times do |
| 143 |
width = zoom - 1 |
| 144 |
%> |
| 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"> |
| 146 |
<%= day_name(wday).first %> |
| 147 |
</div> |
| 148 |
<% |
| 149 |
left = left + width+1 |
| 150 |
wday = wday + 1 |
| 151 |
wday = 1 if wday > 7 |
| 152 |
end |
| 153 |
end %> |
| 154 |
|
| 155 |
<%= @gantt.lines.html_safe %> |
| 156 |
|
| 157 |
<% |
| 158 |
# |
| 159 |
# Today red line (excluded from cache) |
| 160 |
# |
| 161 |
if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %> |
| 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;"> </div> |
| 163 |
<% end %> |
| 164 |
|
| 165 |
</div> |
| 166 |
</td> |
| 167 |
</tr> |
| 168 |
</table> |
| 169 |
|
| 170 |
<table width="100%"> |
| 171 |
<tr> |
| 172 |
<td align="left"><%= link_to_content_update("\xc2\xab " + l(:label_previous), params.merge(@gantt.params_previous)) %></td>
|
| 173 |
<td align="right"><%= link_to_content_update(l(:label_next) + " \xc2\xbb", params.merge(@gantt.params_next)) %></td> |
| 174 |
</tr> |
| 175 |
</table> |
| 176 |
|
| 177 |
<% other_formats_links do |f| %> |
| 178 |
<%= f.link_to 'PDF', :url => params.merge(@gantt.params) %> |
| 179 |
<%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
|
| 180 |
<% end %> |
| 181 |
<% end # query.valid? %> |
| 182 |
|
| 183 |
<% content_for :sidebar do %> |
| 184 |
<%= render :partial => 'issues/sidebar' %> |
| 185 |
<% end %> |
| 186 |
|
| 187 |
<% html_title(l(:label_gantt)) -%> |