You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

show.html.erb 5.7KB

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