To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / views / gantts / show.html.erb @ 1298:4f746d8966dd

History | View | Annotate | Download (9.63 KB)

1 22:40f7cfd4df19 chris
<% @gantt.view = self %>
2 245:051f544170fe Chris
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
3 0:513646585e45 Chris
4 1115:433d4f72a19b Chris
<%= form_tag({:controller => 'gantts', :action => 'show',
5
             :project_id => @project, :month => params[:month],
6
             :year => params[:year], :months => params[:months]},
7
             :method => :get, :id => 'query_form') do %>
8 441:cbce1fd3b1b7 Chris
<%= hidden_field_tag 'set_filter', '1' %>
9 245:051f544170fe Chris
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
10 0:513646585e45 Chris
  <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
11 909:cbb26bc654de Chris
  <div style="<%= @query.new_record? ? "" : "display: none;" %>">
12 0:513646585e45 Chris
    <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
13
  </div>
14
</fieldset>
15 1295:622f24f53b42 Chris
<fieldset class="collapsible collapsed">
16
  <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
17
  <div style="display: none;">
18
    <table>
19
      <tr>
20
        <td>
21
          <fieldset>
22
            <legend><%= l(:label_related_issues) %></legend>
23
            <label>
24
              <%= check_box_tag "draw_rels", params["draw_rels"], params[:set_filter].blank? || params[:draw_rels] %>
25
              <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
26
              <% rels.each do |rel| %>
27
                <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
28
                <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
29
                                :style => "background-color: #{color}") %>
30
                <%= l(IssueRelation::TYPES[rel][:name]) %>
31
              <% end %>
32
            </label>
33
          </fieldset>
34
        </td>
35
        <td>
36
          <fieldset>
37
            <legend><%= l(:label_gantt_progress_line) %></legend>
38
            <label>
39
              <%= check_box_tag "draw_progress_line", params[:draw_progress_line], params[:draw_progress_line] %>
40
              <%= l(:label_display) %>
41
            </label>
42
          </fieldset>
43
        </td>
44
      </tr>
45
    </table>
46
  </div>
47
</fieldset>
48 0:513646585e45 Chris
49 37:94944d00e43c chris
<p class="contextual">
50 0:513646585e45 Chris
  <%= gantt_zoom_link(@gantt, :in) %>
51
  <%= gantt_zoom_link(@gantt, :out) %>
52
</p>
53
54
<p class="buttons">
55
<%= text_field_tag 'months', @gantt.months, :size => 2 %>
56
<%= l(:label_months_from) %>
57
<%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
58
<%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
59
<%= hidden_field_tag 'zoom', @gantt.zoom %>
60
61 1115:433d4f72a19b Chris
<%= link_to_function l(:button_apply), '$("#query_form").submit()',
62
                     :class => 'icon icon-checked' %>
63
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
64
            :class => 'icon icon-reload' %>
65 0:513646585e45 Chris
</p>
66
<% end %>
67
68
<%= error_messages_for 'query' %>
69
<% if @query.valid? %>
70 1115:433d4f72a19b Chris
<%
71
  zoom = 1
72
  @gantt.zoom.times { zoom = zoom * 2 }
73 0:513646585e45 Chris

74 1115:433d4f72a19b Chris
  subject_width = 330
75 1295:622f24f53b42 Chris
  header_height = 18
76 0:513646585e45 Chris

77 1295:622f24f53b42 Chris
  headers_height = header_height
78 1115:433d4f72a19b Chris
  show_weeks = false
79
  show_days  = false
80 0:513646585e45 Chris

81 1115:433d4f72a19b Chris
  if @gantt.zoom > 1
82 0:513646585e45 Chris
    show_weeks = true
83 1295:622f24f53b42 Chris
    headers_height = 2 * header_height
84 0:513646585e45 Chris
    if @gantt.zoom > 2
85
        show_days = true
86 1295:622f24f53b42 Chris
        headers_height = 3 * header_height
87 0:513646585e45 Chris
    end
88 1115:433d4f72a19b Chris
  end
89 0:513646585e45 Chris

90 1115:433d4f72a19b Chris
  # Width of the entire chart
91
  g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
92
  @gantt.render(:top => headers_height + 8,
93
                :zoom => zoom,
94
                :g_width => g_width,
95
                :subject_width => subject_width)
96
  g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
97
  t_height = g_height + headers_height
98 0:513646585e45 Chris
%>
99 119:8661b858af72 Chris
100
<% if @gantt.truncated %>
101 909:cbb26bc654de Chris
  <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
102 119:8661b858af72 Chris
<% end %>
103
104 1115:433d4f72a19b Chris
<table style="width:100%; border:0; border-collapse: collapse;">
105 0:513646585e45 Chris
<tr>
106
<td style="width:<%= subject_width %>px; padding:0px;">
107 1115:433d4f72a19b Chris
  <%
108
    style  = ""
109
    style += "position:relative;"
110
    style += "height: #{t_height + 24}px;"
111
    style += "width: #{subject_width + 1}px;"
112
  %>
113
  <%= content_tag(:div, :style => style) do %>
114
    <%
115
      style  = ""
116
      style += "right:-2px;"
117
      style += "width: #{subject_width}px;"
118
      style += "height: #{headers_height}px;"
119
      style += 'background: #eee;'
120
    %>
121
    <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
122
    <%
123
      style  = ""
124
      style += "right:-2px;"
125
      style += "width: #{subject_width}px;"
126
      style += "height: #{t_height}px;"
127
      style += 'border-left: 1px solid #c0c0c0;'
128
      style += 'overflow: hidden;'
129
    %>
130
    <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
131
    <%= content_tag(:div, :class => "gantt_subjects") do %>
132
      <%= @gantt.subjects.html_safe %>
133
    <% end %>
134
  <% end %>
135
</td>
136 0:513646585e45 Chris
137 1115:433d4f72a19b Chris
<td>
138 1295:622f24f53b42 Chris
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
139 1115:433d4f72a19b Chris
<%
140
  style  = ""
141
  style += "width: #{g_width - 1}px;"
142
  style += "height: #{headers_height}px;"
143
  style += 'background: #eee;'
144
%>
145
<%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
146 22:40f7cfd4df19 chris
147 1115:433d4f72a19b Chris
<% ###### Months headers ###### %>
148
<%
149
  month_f = @gantt.date_from
150
  left = 0
151 1295:622f24f53b42 Chris
  height = (show_weeks ? header_height : header_height + g_height)
152 1115:433d4f72a19b Chris
%>
153
<% @gantt.months.times do %>
154
  <%
155
    width = (((month_f >> 1) - month_f) * zoom - 1).to_i
156
    style  = ""
157
    style += "left: #{left}px;"
158
    style += "width: #{width}px;"
159
    style += "height: #{height}px;"
160
  %>
161
  <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
162
    <%= link_to h("#{month_f.year}-#{month_f.month}"),
163
                @gantt.params.merge(:year => month_f.year, :month => month_f.month),
164
                :title => "#{month_name(month_f.month)} #{month_f.year}" %>
165
  <% end %>
166
  <%
167
    left = left + width + 1
168
    month_f = month_f >> 1
169
  %>
170
<% end %>
171 22:40f7cfd4df19 chris
172 1115:433d4f72a19b Chris
<% ###### Weeks headers ###### %>
173
<% if show_weeks %>
174
  <%
175
    left = 0
176 1295:622f24f53b42 Chris
    height = (show_days ? header_height - 1 : header_height - 1 + g_height)
177 1115:433d4f72a19b Chris
  %>
178
  <% if @gantt.date_from.cwday == 1 %>
179
    <%
180
      # @date_from is monday
181
      week_f = @gantt.date_from
182
    %>
183
  <% else %>
184
    <%
185
      # find next monday after @date_from
186
      week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
187
      width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
188
      style  = ""
189
      style += "left: #{left}px;"
190
      style += "top: 19px;"
191
      style += "width: #{width}px;"
192
      style += "height: #{height}px;"
193
    %>
194
    <%= content_tag(:div, '&nbsp;'.html_safe,
195
                    :style => style, :class => "gantt_hdr") %>
196
    <% left = left + width + 1 %>
197
  <% end %>
198
  <% while week_f <= @gantt.date_to %>
199
    <%
200
      width = ((week_f + 6 <= @gantt.date_to) ?
201
                  7 * zoom - 1 :
202
                  (@gantt.date_to - week_f + 1) * zoom - 1).to_i
203
      style  = ""
204
      style += "left: #{left}px;"
205
      style += "top: 19px;"
206
      style += "width: #{width}px;"
207
      style += "height: #{height}px;"
208
    %>
209
    <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
210
      <%= content_tag(:small) do %>
211
        <%= week_f.cweek if width >= 16 %>
212
      <% end %>
213
    <% end %>
214
    <%
215
      left = left + width + 1
216
      week_f = week_f + 7
217
    %>
218
  <% end %>
219
<% end %>
220 0:513646585e45 Chris
221 1115:433d4f72a19b Chris
<% ###### Days headers ####### %>
222
<% if show_days %>
223
  <%
224
    left = 0
225 1295:622f24f53b42 Chris
    height = g_height + header_height - 1
226 1115:433d4f72a19b Chris
    wday = @gantt.date_from.cwday
227 909:cbb26bc654de Chris
  %>
228 1115:433d4f72a19b Chris
  <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
229
    <%
230
      width =  zoom - 1
231
      style  = ""
232
      style += "left: #{left}px;"
233
      style += "top:37px;"
234
      style += "width: #{width}px;"
235
      style += "height: #{height}px;"
236
      style += "font-size:0.7em;"
237
      clss = "gantt_hdr"
238
      clss << " nwday" if @gantt.non_working_week_days.include?(wday)
239 909:cbb26bc654de Chris
    %>
240 1115:433d4f72a19b Chris
    <%= content_tag(:div, :style => style, :class => clss) do %>
241
      <%= day_letter(wday) %>
242
    <% end %>
243 909:cbb26bc654de Chris
    <%
244 1115:433d4f72a19b Chris
      left = left + width + 1
245
      wday = wday + 1
246
      wday = 1 if wday > 7
247 909:cbb26bc654de Chris
    %>
248 1115:433d4f72a19b Chris
  <% end %>
249
<% end %>
250 0:513646585e45 Chris
251 909:cbb26bc654de Chris
<%= @gantt.lines.html_safe %>
252 0:513646585e45 Chris
253 1115:433d4f72a19b Chris
<% ###### Today red line (excluded from cache) ###### %>
254
<% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
255
  <%
256
    today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
257
    style  = ""
258
    style += "position: absolute;"
259
    style += "height: #{g_height}px;"
260
    style += "top: #{headers_height + 1}px;"
261
    style += "left: #{today_left}px;"
262
    style += "width:10px;"
263
    style += "border-left: 1px dashed red;"
264
  %>
265 1295:622f24f53b42 Chris
  <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
266 0:513646585e45 Chris
<% end %>
267 1295:622f24f53b42 Chris
<%
268
  style  = ""
269
  style += "position: absolute;"
270
  style += "height: #{g_height}px;"
271
  style += "top: #{headers_height + 1}px;"
272
  style += "left: 0px;"
273
  style += "width: #{g_width - 1}px;"
274
%>
275
<%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
276 0:513646585e45 Chris
</div>
277
</td>
278
</tr>
279
</table>
280
281 1115:433d4f72a19b Chris
<table style="width:100%">
282 0:513646585e45 Chris
<tr>
283 1115:433d4f72a19b Chris
  <td align="left">
284
    <%= link_to_content_update("\xc2\xab " + l(:label_previous),
285
                               params.merge(@gantt.params_previous)) %>
286
  </td>
287
  <td align="right">
288
    <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
289
                               params.merge(@gantt.params_next)) %>
290
  </td>
291 0:513646585e45 Chris
</tr>
292
</table>
293
294
<% other_formats_links do |f| %>
295 909:cbb26bc654de Chris
  <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
296
  <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
297 0:513646585e45 Chris
<% end %>
298
<% end # query.valid? %>
299
300
<% content_for :sidebar do %>
301 1115:433d4f72a19b Chris
  <%= render :partial => 'issues/sidebar' %>
302 0:513646585e45 Chris
<% end %>
303
304
<% html_title(l(:label_gantt)) -%>
305 1295:622f24f53b42 Chris
306
<% content_for :header_tags do %>
307
  <%= javascript_include_tag 'raphael' %>
308
  <%= javascript_include_tag 'gantt' %>
309
<% end %>
310
311
<%= javascript_tag do %>
312
  var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
313
  $(document).ready(drawGanttHandler);
314
  $(window).resize(drawGanttHandler);
315
  $(function() {
316
    $("#draw_rels").change(drawGanttHandler);
317
    $("#draw_progress_line").change(drawGanttHandler);
318
  });
319
<% end %>