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.9KB

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