@@ -62,6 +62,8 g_width = (@gantt.date_to - @gantt.date_from + 1)*zoom | |||
|
62 | 62 | # Collect the number of issues on Versions |
|
63 | 63 | g_height = [(20 * (@gantt.number_of_rows + 6))+150, 206].max |
|
64 | 64 | t_height = g_height + headers_height |
|
65 | ||
|
66 | @gantt.render(:headers_height => headers_height, :top => headers_height + 8, :zoom => zoom, :g_width => g_width) | |
|
65 | 67 | %> |
|
66 | 68 | <table width="100%" style="border:0; border-collapse: collapse;"> |
|
67 | 69 | <tr> |
@@ -72,7 +74,7 t_height = g_height + headers_height | |||
|
72 | 74 | <div style="right:-2px;width:<%= subject_width %>px;height:<%= t_height %>px;border-left: 1px solid #c0c0c0;overflow:hidden;" class="gantt_hdr"></div> |
|
73 | 75 | <% top = headers_height + 8 %> |
|
74 | 76 | |
|
75 | <%= @gantt.subjects(:headers_height => headers_height, :top => top, :g_width => g_width) %> | |
|
77 | <%= @gantt.subjects %> | |
|
76 | 78 | |
|
77 | 79 | </div> |
|
78 | 80 | </td> |
@@ -153,7 +155,7 end %> | |||
|
153 | 155 | |
|
154 | 156 | <% top = headers_height + 10 %> |
|
155 | 157 | |
|
156 | <%= @gantt.lines(:top => top, :zoom => zoom, :g_width => g_width ) %> | |
|
158 | <%= @gantt.lines %> | |
|
157 | 159 | |
|
158 | 160 | <% |
|
159 | 161 | # |
@@ -67,6 +67,9 module Redmine | |||
|
67 | 67 | |
|
68 | 68 | @date_from = Date.civil(@year_from, @month_from, 1) |
|
69 | 69 | @date_to = (@date_from >> @months) - 1 |
|
70 | ||
|
71 | @subjects = '' | |
|
72 | @lines = '' | |
|
70 | 73 | end |
|
71 | 74 | |
|
72 | 75 | def common_params |
@@ -128,34 +131,32 module Redmine | |||
|
128 | 131 | |
|
129 | 132 | # Renders the subjects of the Gantt chart, the left side. |
|
130 | 133 | def subjects(options={}) |
|
131 | options = {:indent => 4, :render => :subject, :format => :html}.merge(options) | |
|
132 | ||
|
133 | output = '' | |
|
134 | if @project | |
|
135 | output << render_project(@project, options) | |
|
136 | else | |
|
137 | Project.roots.visible.each do |project| | |
|
138 | output << render_project(project, options) | |
|
139 | end | |
|
140 | end | |
|
141 | ||
|
142 | output | |
|
134 | render(options.merge(:only => :subjects)) unless @subjects_rendered | |
|
135 | @subjects | |
|
143 | 136 | end |
|
144 | 137 | |
|
145 | 138 | # Renders the lines of the Gantt chart, the right side |
|
146 | 139 | def lines(options={}) |
|
147 | options = {:indent => 4, :render => :line, :format => :html}.merge(options) | |
|
148 | output = '' | |
|
149 | ||
|
140 | render(options.merge(:only => :lines)) unless @lines_rendered | |
|
141 | @lines | |
|
142 | end | |
|
143 | ||
|
144 | def render(options={}) | |
|
145 | options = {:indent => 4, :render => :subject, :format => :html}.merge(options) | |
|
146 | ||
|
147 | @subjects = '' unless options[:only] == :lines | |
|
148 | @lines = '' unless options[:only] == :subjects | |
|
149 | ||
|
150 | 150 | if @project |
|
151 |
|
|
|
151 | render_project(@project, options) | |
|
152 | 152 | else |
|
153 | 153 | Project.roots.visible.each do |project| |
|
154 |
|
|
|
154 | render_project(project, options) | |
|
155 | 155 | end |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | output | |
|
158 | @subjects_rendered = true unless options[:only] == :lines | |
|
159 | @lines_rendered = true unless options[:only] == :subjects | |
|
159 | 160 | end |
|
160 | 161 | |
|
161 | 162 | def render_project(project, options={}) |
@@ -163,15 +164,8 module Redmine | |||
|
163 | 164 | options[:indent_increment] = 20 unless options.key? :indent_increment |
|
164 | 165 | options[:top_increment] = 20 unless options.key? :top_increment |
|
165 | 166 | |
|
166 | output = '' | |
|
167 | # Project Header | |
|
168 | project_header = if options[:render] == :subject | |
|
169 | subject_for_project(project, options) | |
|
170 | else | |
|
171 | # :line | |
|
172 | line_for_project(project, options) | |
|
173 | end | |
|
174 | output << project_header if options[:format] == :html | |
|
167 | subject_for_project(project, options) unless options[:only] == :lines | |
|
168 | line_for_project(project, options) unless options[:only] == :subjects | |
|
175 | 169 | |
|
176 | 170 | options[:top] += options[:top_increment] |
|
177 | 171 | options[:indent] += options[:indent_increment] |
@@ -180,54 +174,36 module Redmine | |||
|
180 | 174 | issues = project.issues.for_gantt.without_version.with_query(@query) |
|
181 | 175 | sort_issues!(issues) |
|
182 | 176 | if issues |
|
183 |
|
|
|
184 | output << issue_rendering if options[:format] == :html | |
|
177 | render_issues(issues, options) | |
|
185 | 178 | end |
|
186 | 179 | |
|
187 | 180 | # Third, Versions |
|
188 | 181 | project.versions.sort.each do |version| |
|
189 |
|
|
|
190 | output << version_rendering if options[:format] == :html | |
|
182 | render_version(version, options) | |
|
191 | 183 | end |
|
192 | 184 | |
|
193 | 185 | # Fourth, subprojects |
|
194 | 186 | project.children.visible.each do |project| |
|
195 |
|
|
|
196 | output << subproject_rendering if options[:format] == :html | |
|
187 | render_project(project, options) | |
|
197 | 188 | end |
|
198 | 189 | |
|
199 | 190 | # Remove indent to hit the next sibling |
|
200 | 191 | options[:indent] -= options[:indent_increment] |
|
201 | ||
|
202 | output | |
|
203 | 192 | end |
|
204 | 193 | |
|
205 | 194 | def render_issues(issues, options={}) |
|
206 | output = '' | |
|
207 | 195 | issues.each do |i| |
|
208 | issue_rendering = if options[:render] == :subject | |
|
209 | subject_for_issue(i, options) | |
|
210 | else | |
|
211 | # :line | |
|
212 | line_for_issue(i, options) | |
|
213 | end | |
|
214 | output << issue_rendering if options[:format] == :html | |
|
196 | subject_for_issue(i, options) unless options[:only] == :lines | |
|
197 | line_for_issue(i, options) unless options[:only] == :subjects | |
|
198 | ||
|
215 | 199 | options[:top] += options[:top_increment] |
|
216 | 200 | end |
|
217 | output | |
|
218 | 201 | end |
|
219 | 202 | |
|
220 | 203 | def render_version(version, options={}) |
|
221 | output = '' | |
|
222 | 204 | # Version header |
|
223 | version_rendering = if options[:render] == :subject | |
|
224 | subject_for_version(version, options) | |
|
225 | else | |
|
226 | # :line | |
|
227 | line_for_version(version, options) | |
|
228 | end | |
|
229 | ||
|
230 | output << version_rendering if options[:format] == :html | |
|
205 | subject_for_version(version, options) unless options[:only] == :lines | |
|
206 | line_for_version(version, options) unless options[:only] == :subjects | |
|
231 | 207 | |
|
232 | 208 | options[:top] += options[:top_increment] |
|
233 | 209 | |
@@ -241,11 +217,9 module Redmine | |||
|
241 | 217 | sort_issues!(issues) |
|
242 | 218 | # Indent issues |
|
243 | 219 | options[:indent] += options[:indent_increment] |
|
244 |
|
|
|
220 | render_issues(issues, options) | |
|
245 | 221 | options[:indent] -= options[:indent_increment] |
|
246 | 222 | end |
|
247 | ||
|
248 | output | |
|
249 | 223 | end |
|
250 | 224 | |
|
251 | 225 | def subject_for_project(project, options) |
@@ -263,7 +237,7 module Redmine | |||
|
263 | 237 | '' |
|
264 | 238 | end |
|
265 | 239 | output << "</small></div>" |
|
266 | ||
|
240 | @subjects << output | |
|
267 | 241 | output |
|
268 | 242 | when :image |
|
269 | 243 | |
@@ -351,7 +325,7 module Redmine | |||
|
351 | 325 | output << "<strong>#{h project } #{h project.completed_percent(:include_subprojects => true).to_i.to_s}%</strong>" |
|
352 | 326 | output << "</div>" |
|
353 | 327 | end |
|
354 | ||
|
328 | @lines << output | |
|
355 | 329 | output |
|
356 | 330 | when :image |
|
357 | 331 | options[:image].stroke('transparent') |
@@ -399,7 +373,7 module Redmine | |||
|
399 | 373 | '' |
|
400 | 374 | end |
|
401 | 375 | output << "</small></div>" |
|
402 | ||
|
376 | @subjects << output | |
|
403 | 377 | output |
|
404 | 378 | when :image |
|
405 | 379 | options[:image].fill('black') |
@@ -486,7 +460,7 module Redmine | |||
|
486 | 460 | output << "<strong>#{h version } #{h version.completed_pourcent.to_i.to_s}%</strong>" |
|
487 | 461 | output << "</div>" |
|
488 | 462 | end |
|
489 | ||
|
463 | @lines << output | |
|
490 | 464 | output |
|
491 | 465 | when :image |
|
492 | 466 | options[:image].stroke('transparent') |
@@ -553,6 +527,7 module Redmine | |||
|
553 | 527 | end |
|
554 | 528 | |
|
555 | 529 | output << "</div>" |
|
530 | @subjects << output | |
|
556 | 531 | output |
|
557 | 532 | when :image |
|
558 | 533 | options[:image].fill('black') |
@@ -625,6 +600,7 module Redmine | |||
|
625 | 600 | output << '<span class="tip">' |
|
626 | 601 | output << view.render_issue_tooltip(issue) |
|
627 | 602 | output << "</span></div>" |
|
603 | @lines << output | |
|
628 | 604 | output |
|
629 | 605 | |
|
630 | 606 | when :image |
@@ -938,18 +914,21 module Redmine | |||
|
938 | 914 | |
|
939 | 915 | # Tasks |
|
940 | 916 | top = headers_heigth + y_start |
|
941 | pdf_subjects_and_lines(pdf, { | |
|
942 |
|
|
|
943 |
|
|
|
944 |
|
|
|
945 |
|
|
|
946 | }) | |
|
947 | ||
|
917 | options = { | |
|
918 | :top => top, | |
|
919 | :zoom => zoom, | |
|
920 | :subject_width => subject_width, | |
|
921 | :g_width => g_width, | |
|
922 | :indent => 0, | |
|
923 | :indent_increment => 5, | |
|
924 | :top_increment => 3, | |
|
925 | :format => :pdf, | |
|
926 | :pdf => pdf | |
|
927 | } | |
|
928 | render(options) | |
|
948 | 929 | |
|
949 | 930 | pdf.Line(15, top, subject_width+g_width, top) |
|
950 | 931 | pdf.Output |
|
951 | ||
|
952 | ||
|
953 | 932 | end |
|
954 | 933 | |
|
955 | 934 | private |
@@ -964,24 +943,6 module Redmine | |||
|
964 | 943 | cmp |
|
965 | 944 | end |
|
966 | 945 | end |
|
967 | ||
|
968 | # Renders both the subjects and lines of the Gantt chart for the | |
|
969 | # PDF format | |
|
970 | def pdf_subjects_and_lines(pdf, options = {}) | |
|
971 | subject_options = {:indent => 0, :indent_increment => 5, :top_increment => 3, :render => :subject, :format => :pdf, :pdf => pdf}.merge(options) | |
|
972 | line_options = {:indent => 0, :indent_increment => 5, :top_increment => 3, :render => :line, :format => :pdf, :pdf => pdf}.merge(options) | |
|
973 | ||
|
974 | if @project | |
|
975 | render_project(@project, subject_options) | |
|
976 | render_project(@project, line_options) | |
|
977 | else | |
|
978 | Project.roots.each do |project| | |
|
979 | render_project(project, subject_options) | |
|
980 | render_project(project, line_options) | |
|
981 | end | |
|
982 | end | |
|
983 | end | |
|
984 | ||
|
985 | 946 | end |
|
986 | 947 | end |
|
987 | 948 | end |
General Comments 0
You need to be logged in to leave comments.
Login now