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 @ 1531:ae8145b28b2b

History | View | Annotate | Download (10.3 KB)

1
<% @gantt.view = self %>
2
<div class="contextual">
3
<% if !@query.new_record? && @query.editable_by?(User.current) %>
4
  <%= link_to l(:button_edit), edit_query_path(@query, :gantt => 1), :class => 'icon icon-edit' %>
5
  <%= delete_link query_path(@query, :gantt => 1) %>
6
<% end %>
7
</div>
8

    
9
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
10

    
11
<%= form_tag({:controller => 'gantts', :action => 'show',
12
             :project_id => @project, :month => params[:month],
13
             :year => params[:year], :months => params[:months]},
14
             :method => :get, :id => 'query_form') do %>
15
<%= hidden_field_tag 'set_filter', '1' %>
16
<%= hidden_field_tag 'gantt', '1' %>
17
<fieldset id="filters" class="collapsible <%= @query.new_record? ? "" : "collapsed" %>">
18
  <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
19
  <div style="<%= @query.new_record? ? "" : "display: none;" %>">
20
    <%= render :partial => 'queries/filters', :locals => {:query => @query} %>
21
  </div>
22
</fieldset>
23
<fieldset class="collapsible collapsed">
24
  <legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
25
  <div style="display: none;">
26
    <table>
27
      <tr>
28
        <td>
29
          <fieldset>
30
            <legend><%= l(:label_related_issues) %></legend>
31
            <label for="draw_relations">
32
              <%= check_box 'query', 'draw_relations', :id => 'draw_relations' %>
33
              <% rels = [IssueRelation::TYPE_BLOCKS, IssueRelation::TYPE_PRECEDES] %>
34
              <% rels.each do |rel| %>
35
                <% color = Redmine::Helpers::Gantt::DRAW_TYPES[rel][:color] %>
36
                <%= content_tag(:span, '&nbsp;&nbsp;&nbsp;'.html_safe,
37
                                :style => "background-color: #{color}") %>
38
                <%= l(IssueRelation::TYPES[rel][:name]) %>
39
              <% end %>
40
            </label>
41
          </fieldset>
42
        </td>
43
        <td>
44
          <fieldset>
45
            <legend><%= l(:label_gantt_progress_line) %></legend>
46
            <label for="draw_progress_line">
47
              <%= check_box 'query', 'draw_progress_line', :id => 'draw_progress_line' %>
48
              <%= l(:label_display) %>
49
            </label>
50
          </fieldset>
51
        </td>
52
      </tr>
53
    </table>
54
  </div>
55
</fieldset>
56

    
57
<p class="contextual">
58
  <%= gantt_zoom_link(@gantt, :in) %>
59
  <%= gantt_zoom_link(@gantt, :out) %>
60
</p>
61

    
62
<p class="buttons">
63
<%= text_field_tag 'months', @gantt.months, :size => 2 %>
64
<%= l(:label_months_from) %>
65
<%= select_month(@gantt.month_from, :prefix => "month", :discard_type => true) %>
66
<%= select_year(@gantt.year_from, :prefix => "year", :discard_type => true) %>
67
<%= hidden_field_tag 'zoom', @gantt.zoom %>
68

    
69
<%= link_to_function l(:button_apply), '$("#query_form").submit()',
70
                     :class => 'icon icon-checked' %>
71
<%= link_to l(:button_clear), { :project_id => @project, :set_filter => 1 },
72
            :class => 'icon icon-reload' %>
73
<% if @query.new_record? && User.current.allowed_to?(:save_queries, @project, :global => true) %>
74
  <%= link_to_function l(:button_save),
75
                       "$('#query_form').attr('action', '#{ @project ? new_project_query_path(@project) : new_query_path }').submit();",
76
                       :class => 'icon icon-save' %>
77
<% end %>
78
</p>
79
<% end %>
80

    
81
<%= error_messages_for 'query' %>
82
<% if @query.valid? %>
83
<%
84
  zoom = 1
85
  @gantt.zoom.times { zoom = zoom * 2 }
86

87
  subject_width = 330
88
  header_height = 18
89

90
  headers_height = header_height
91
  show_weeks = false
92
  show_days  = false
93

94
  if @gantt.zoom > 1
95
    show_weeks = true
96
    headers_height = 2 * header_height
97
    if @gantt.zoom > 2
98
        show_days = true
99
        headers_height = 3 * header_height
100
    end
101
  end
102

103
  # Width of the entire chart
104
  g_width = ((@gantt.date_to - @gantt.date_from + 1) * zoom).to_i
105
  @gantt.render(:top => headers_height + 8,
106
                :zoom => zoom,
107
                :g_width => g_width,
108
                :subject_width => subject_width)
109
  g_height = [(20 * (@gantt.number_of_rows + 6)) + 150, 206].max
110
  t_height = g_height + headers_height
111
%>
112

    
113
<% if @gantt.truncated %>
114
  <p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
115
<% end %>
116

    
117
<table style="width:100%; border:0; border-collapse: collapse;">
118
<tr>
119
<td style="width:<%= subject_width %>px; padding:0px;">
120
  <%
121
    style  = ""
122
    style += "position:relative;"
123
    style += "height: #{t_height + 24}px;"
124
    style += "width: #{subject_width + 1}px;"
125
  %>
126
  <%= content_tag(:div, :style => style) do %>
127
    <%
128
      style  = ""
129
      style += "right:-2px;"
130
      style += "width: #{subject_width}px;"
131
      style += "height: #{headers_height}px;"
132
      style += 'background: #eee;'
133
    %>
134
    <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
135
    <%
136
      style  = ""
137
      style += "right:-2px;"
138
      style += "width: #{subject_width}px;"
139
      style += "height: #{t_height}px;"
140
      style += 'border-left: 1px solid #c0c0c0;'
141
      style += 'overflow: hidden;'
142
    %>
143
    <%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
144
    <%= content_tag(:div, :class => "gantt_subjects") do %>
145
      <%= @gantt.subjects.html_safe %>
146
    <% end %>
147
  <% end %>
148
</td>
149

    
150
<td>
151
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
152
<%
153
  style  = ""
154
  style += "width: #{g_width - 1}px;"
155
  style += "height: #{headers_height}px;"
156
  style += 'background: #eee;'
157
%>
158
<%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :class => "gantt_hdr") %>
159

    
160
<% ###### Months headers ###### %>
161
<%
162
  month_f = @gantt.date_from
163
  left = 0
164
  height = (show_weeks ? header_height : header_height + g_height)
165
%>
166
<% @gantt.months.times do %>
167
  <%
168
    width = (((month_f >> 1) - month_f) * zoom - 1).to_i
169
    style  = ""
170
    style += "left: #{left}px;"
171
    style += "width: #{width}px;"
172
    style += "height: #{height}px;"
173
  %>
174
  <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
175
    <%= link_to h("#{month_f.year}-#{month_f.month}"),
176
                @gantt.params.merge(:year => month_f.year, :month => month_f.month),
177
                :title => "#{month_name(month_f.month)} #{month_f.year}" %>
178
  <% end %>
179
  <%
180
    left = left + width + 1
181
    month_f = month_f >> 1
182
  %>
183
<% end %>
184

    
185
<% ###### Weeks headers ###### %>
186
<% if show_weeks %>
187
  <%
188
    left = 0
189
    height = (show_days ? header_height - 1 : header_height - 1 + g_height)
190
  %>
191
  <% if @gantt.date_from.cwday == 1 %>
192
    <%
193
      # @date_from is monday
194
      week_f = @gantt.date_from
195
    %>
196
  <% else %>
197
    <%
198
      # find next monday after @date_from
199
      week_f = @gantt.date_from + (7 - @gantt.date_from.cwday + 1)
200
      width = (7 - @gantt.date_from.cwday + 1) * zoom - 1
201
      style  = ""
202
      style += "left: #{left}px;"
203
      style += "top: 19px;"
204
      style += "width: #{width}px;"
205
      style += "height: #{height}px;"
206
    %>
207
    <%= content_tag(:div, '&nbsp;'.html_safe,
208
                    :style => style, :class => "gantt_hdr") %>
209
    <% left = left + width + 1 %>
210
  <% end %>
211
  <% while week_f <= @gantt.date_to %>
212
    <%
213
      width = ((week_f + 6 <= @gantt.date_to) ?
214
                  7 * zoom - 1 :
215
                  (@gantt.date_to - week_f + 1) * zoom - 1).to_i
216
      style  = ""
217
      style += "left: #{left}px;"
218
      style += "top: 19px;"
219
      style += "width: #{width}px;"
220
      style += "height: #{height}px;"
221
    %>
222
    <%= content_tag(:div, :style => style, :class => "gantt_hdr") do %>
223
      <%= content_tag(:small) do %>
224
        <%= week_f.cweek if width >= 16 %>
225
      <% end %>
226
    <% end %>
227
    <%
228
      left = left + width + 1
229
      week_f = week_f + 7
230
    %>
231
  <% end %>
232
<% end %>
233

    
234
<% ###### Days headers ####### %>
235
<% if show_days %>
236
  <%
237
    left = 0
238
    height = g_height + header_height - 1
239
    wday = @gantt.date_from.cwday
240
  %>
241
  <% (@gantt.date_to - @gantt.date_from + 1).to_i.times do %>
242
    <%
243
      width =  zoom - 1
244
      style  = ""
245
      style += "left: #{left}px;"
246
      style += "top:37px;"
247
      style += "width: #{width}px;"
248
      style += "height: #{height}px;"
249
      style += "font-size:0.7em;"
250
      clss = "gantt_hdr"
251
      clss << " nwday" if @gantt.non_working_week_days.include?(wday)
252
    %>
253
    <%= content_tag(:div, :style => style, :class => clss) do %>
254
      <%= day_letter(wday) %>
255
    <% end %>
256
    <%
257
      left = left + width + 1
258
      wday = wday + 1
259
      wday = 1 if wday > 7
260
    %>
261
  <% end %>
262
<% end %>
263

    
264
<%= @gantt.lines.html_safe %>
265

    
266
<% ###### Today red line (excluded from cache) ###### %>
267
<% if Date.today >= @gantt.date_from and Date.today <= @gantt.date_to %>
268
  <%
269
    today_left = (((Date.today - @gantt.date_from + 1) * zoom).floor() - 1).to_i
270
    style  = ""
271
    style += "position: absolute;"
272
    style += "height: #{g_height}px;"
273
    style += "top: #{headers_height + 1}px;"
274
    style += "left: #{today_left}px;"
275
    style += "width:10px;"
276
    style += "border-left: 1px dashed red;"
277
  %>
278
  <%= content_tag(:div, '&nbsp;'.html_safe, :style => style, :id => 'today_line') %>
279
<% end %>
280
<%
281
  style  = ""
282
  style += "position: absolute;"
283
  style += "height: #{g_height}px;"
284
  style += "top: #{headers_height + 1}px;"
285
  style += "left: 0px;"
286
  style += "width: #{g_width - 1}px;"
287
%>
288
<%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %>
289
</div>
290
</td>
291
</tr>
292
</table>
293

    
294
<table style="width:100%">
295
<tr>
296
  <td style="text-align:left;">
297
    <%= link_to_content_update("\xc2\xab " + l(:label_previous),
298
                               params.merge(@gantt.params_previous)) %>
299
  </td>
300
  <td style="text-align:right;">
301
    <%= link_to_content_update(l(:label_next) + " \xc2\xbb",
302
                               params.merge(@gantt.params_next)) %>
303
  </td>
304
</tr>
305
</table>
306

    
307
<% other_formats_links do |f| %>
308
  <%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
309
  <%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
310
<% end %>
311
<% end # query.valid? %>
312

    
313
<% content_for :sidebar do %>
314
  <%= render :partial => 'issues/sidebar' %>
315
<% end %>
316

    
317
<% html_title(l(:label_gantt)) -%>
318

    
319
<% content_for :header_tags do %>
320
  <%= javascript_include_tag 'raphael' %>
321
  <%= javascript_include_tag 'gantt' %>
322
<% end %>
323

    
324
<%= javascript_tag do %>
325
  var issue_relation_type = <%= raw Redmine::Helpers::Gantt::DRAW_TYPES.to_json %>;
326
  $(document).ready(drawGanttHandler);
327
  $(window).resize(drawGanttHandler);
328
  $(function() {
329
    $("#draw_relations").change(drawGanttHandler);
330
    $("#draw_progress_line").change(drawGanttHandler);
331
  });
332
<% end %>