##// END OF EJS Templates
Use JSON so we don't have to parse data-rels manually (#3436)....
Jean-Philippe Lang -
r10889:59ddbf8c09a7
parent child
Show More
@@ -1,922 +1,918
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module Redmine
18 module Redmine
19 module Helpers
19 module Helpers
20 # Simple class to handle gantt chart data
20 # Simple class to handle gantt chart data
21 class Gantt
21 class Gantt
22 include ERB::Util
22 include ERB::Util
23 include Redmine::I18n
23 include Redmine::I18n
24 include Redmine::Utils::DateCalculation
24 include Redmine::Utils::DateCalculation
25
25
26 # Relation types that are rendered
26 # Relation types that are rendered
27 DRAW_TYPES = {
27 DRAW_TYPES = {
28 IssueRelation::TYPE_BLOCKS => { :landscape_margin => 16, :color => '#F34F4F' },
28 IssueRelation::TYPE_BLOCKS => { :landscape_margin => 16, :color => '#F34F4F' },
29 IssueRelation::TYPE_PRECEDES => { :landscape_margin => 20, :color => '#628FEA' }
29 IssueRelation::TYPE_PRECEDES => { :landscape_margin => 20, :color => '#628FEA' }
30 }.freeze
30 }.freeze
31
31
32 # :nodoc:
32 # :nodoc:
33 # Some utility methods for the PDF export
33 # Some utility methods for the PDF export
34 class PDF
34 class PDF
35 MaxCharactorsForSubject = 45
35 MaxCharactorsForSubject = 45
36 TotalWidth = 280
36 TotalWidth = 280
37 LeftPaneWidth = 100
37 LeftPaneWidth = 100
38
38
39 def self.right_pane_width
39 def self.right_pane_width
40 TotalWidth - LeftPaneWidth
40 TotalWidth - LeftPaneWidth
41 end
41 end
42 end
42 end
43
43
44 attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months, :truncated, :max_rows
44 attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months, :truncated, :max_rows
45 attr_accessor :query
45 attr_accessor :query
46 attr_accessor :project
46 attr_accessor :project
47 attr_accessor :view
47 attr_accessor :view
48
48
49 def initialize(options={})
49 def initialize(options={})
50 options = options.dup
50 options = options.dup
51 if options[:year] && options[:year].to_i >0
51 if options[:year] && options[:year].to_i >0
52 @year_from = options[:year].to_i
52 @year_from = options[:year].to_i
53 if options[:month] && options[:month].to_i >=1 && options[:month].to_i <= 12
53 if options[:month] && options[:month].to_i >=1 && options[:month].to_i <= 12
54 @month_from = options[:month].to_i
54 @month_from = options[:month].to_i
55 else
55 else
56 @month_from = 1
56 @month_from = 1
57 end
57 end
58 else
58 else
59 @month_from ||= Date.today.month
59 @month_from ||= Date.today.month
60 @year_from ||= Date.today.year
60 @year_from ||= Date.today.year
61 end
61 end
62 zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
62 zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
63 @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
63 @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
64 months = (options[:months] || User.current.pref[:gantt_months]).to_i
64 months = (options[:months] || User.current.pref[:gantt_months]).to_i
65 @months = (months > 0 && months < 25) ? months : 6
65 @months = (months > 0 && months < 25) ? months : 6
66 # Save gantt parameters as user preference (zoom and months count)
66 # Save gantt parameters as user preference (zoom and months count)
67 if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] ||
67 if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] ||
68 @months != User.current.pref[:gantt_months]))
68 @months != User.current.pref[:gantt_months]))
69 User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
69 User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
70 User.current.preference.save
70 User.current.preference.save
71 end
71 end
72 @date_from = Date.civil(@year_from, @month_from, 1)
72 @date_from = Date.civil(@year_from, @month_from, 1)
73 @date_to = (@date_from >> @months) - 1
73 @date_to = (@date_from >> @months) - 1
74 @subjects = ''
74 @subjects = ''
75 @lines = ''
75 @lines = ''
76 @number_of_rows = nil
76 @number_of_rows = nil
77 @issue_ancestors = []
77 @issue_ancestors = []
78 @truncated = false
78 @truncated = false
79 if options.has_key?(:max_rows)
79 if options.has_key?(:max_rows)
80 @max_rows = options[:max_rows]
80 @max_rows = options[:max_rows]
81 else
81 else
82 @max_rows = Setting.gantt_items_limit.blank? ? nil : Setting.gantt_items_limit.to_i
82 @max_rows = Setting.gantt_items_limit.blank? ? nil : Setting.gantt_items_limit.to_i
83 end
83 end
84 end
84 end
85
85
86 def common_params
86 def common_params
87 { :controller => 'gantts', :action => 'show', :project_id => @project }
87 { :controller => 'gantts', :action => 'show', :project_id => @project }
88 end
88 end
89
89
90 def params
90 def params
91 common_params.merge({:zoom => zoom, :year => year_from,
91 common_params.merge({:zoom => zoom, :year => year_from,
92 :month => month_from, :months => months})
92 :month => month_from, :months => months})
93 end
93 end
94
94
95 def params_previous
95 def params_previous
96 common_params.merge({:year => (date_from << months).year,
96 common_params.merge({:year => (date_from << months).year,
97 :month => (date_from << months).month,
97 :month => (date_from << months).month,
98 :zoom => zoom, :months => months})
98 :zoom => zoom, :months => months})
99 end
99 end
100
100
101 def params_next
101 def params_next
102 common_params.merge({:year => (date_from >> months).year,
102 common_params.merge({:year => (date_from >> months).year,
103 :month => (date_from >> months).month,
103 :month => (date_from >> months).month,
104 :zoom => zoom, :months => months})
104 :zoom => zoom, :months => months})
105 end
105 end
106
106
107 # Returns the number of rows that will be rendered on the Gantt chart
107 # Returns the number of rows that will be rendered on the Gantt chart
108 def number_of_rows
108 def number_of_rows
109 return @number_of_rows if @number_of_rows
109 return @number_of_rows if @number_of_rows
110 rows = projects.inject(0) {|total, p| total += number_of_rows_on_project(p)}
110 rows = projects.inject(0) {|total, p| total += number_of_rows_on_project(p)}
111 rows > @max_rows ? @max_rows : rows
111 rows > @max_rows ? @max_rows : rows
112 end
112 end
113
113
114 # Returns the number of rows that will be used to list a project on
114 # Returns the number of rows that will be used to list a project on
115 # the Gantt chart. This will recurse for each subproject.
115 # the Gantt chart. This will recurse for each subproject.
116 def number_of_rows_on_project(project)
116 def number_of_rows_on_project(project)
117 return 0 unless projects.include?(project)
117 return 0 unless projects.include?(project)
118 count = 1
118 count = 1
119 count += project_issues(project).size
119 count += project_issues(project).size
120 count += project_versions(project).size
120 count += project_versions(project).size
121 count
121 count
122 end
122 end
123
123
124 # Renders the subjects of the Gantt chart, the left side.
124 # Renders the subjects of the Gantt chart, the left side.
125 def subjects(options={})
125 def subjects(options={})
126 render(options.merge(:only => :subjects)) unless @subjects_rendered
126 render(options.merge(:only => :subjects)) unless @subjects_rendered
127 @subjects
127 @subjects
128 end
128 end
129
129
130 # Renders the lines of the Gantt chart, the right side
130 # Renders the lines of the Gantt chart, the right side
131 def lines(options={})
131 def lines(options={})
132 render(options.merge(:only => :lines)) unless @lines_rendered
132 render(options.merge(:only => :lines)) unless @lines_rendered
133 @lines
133 @lines
134 end
134 end
135
135
136 # Returns issues that will be rendered
136 # Returns issues that will be rendered
137 def issues
137 def issues
138 @issues ||= @query.issues(
138 @issues ||= @query.issues(
139 :include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
139 :include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
140 :order => "#{Project.table_name}.lft ASC, #{Issue.table_name}.id ASC",
140 :order => "#{Project.table_name}.lft ASC, #{Issue.table_name}.id ASC",
141 :limit => @max_rows
141 :limit => @max_rows
142 )
142 )
143 end
143 end
144
144
145 # Returns a hash of the relations between the issues that are present on the gantt
145 # Returns a hash of the relations between the issues that are present on the gantt
146 # and that should be displayed, grouped by issue ids.
146 # and that should be displayed, grouped by issue ids.
147 def relations
147 def relations
148 return @relations if @relations
148 return @relations if @relations
149 if issues.any?
149 if issues.any?
150 issue_ids = issues.map(&:id)
150 issue_ids = issues.map(&:id)
151 @relations = IssueRelation.
151 @relations = IssueRelation.
152 where(:issue_from_id => issue_ids, :issue_to_id => issue_ids, :relation_type => DRAW_TYPES.keys).
152 where(:issue_from_id => issue_ids, :issue_to_id => issue_ids, :relation_type => DRAW_TYPES.keys).
153 group_by(&:issue_from_id)
153 group_by(&:issue_from_id)
154 else
154 else
155 @relations = {}
155 @relations = {}
156 end
156 end
157 end
157 end
158
158
159 # Return all the project nodes that will be displayed
159 # Return all the project nodes that will be displayed
160 def projects
160 def projects
161 return @projects if @projects
161 return @projects if @projects
162 ids = issues.collect(&:project).uniq.collect(&:id)
162 ids = issues.collect(&:project).uniq.collect(&:id)
163 if ids.any?
163 if ids.any?
164 # All issues projects and their visible ancestors
164 # All issues projects and their visible ancestors
165 @projects = Project.visible.all(
165 @projects = Project.visible.all(
166 :joins => "LEFT JOIN #{Project.table_name} child ON #{Project.table_name}.lft <= child.lft AND #{Project.table_name}.rgt >= child.rgt",
166 :joins => "LEFT JOIN #{Project.table_name} child ON #{Project.table_name}.lft <= child.lft AND #{Project.table_name}.rgt >= child.rgt",
167 :conditions => ["child.id IN (?)", ids],
167 :conditions => ["child.id IN (?)", ids],
168 :order => "#{Project.table_name}.lft ASC"
168 :order => "#{Project.table_name}.lft ASC"
169 ).uniq
169 ).uniq
170 else
170 else
171 @projects = []
171 @projects = []
172 end
172 end
173 end
173 end
174
174
175 # Returns the issues that belong to +project+
175 # Returns the issues that belong to +project+
176 def project_issues(project)
176 def project_issues(project)
177 @issues_by_project ||= issues.group_by(&:project)
177 @issues_by_project ||= issues.group_by(&:project)
178 @issues_by_project[project] || []
178 @issues_by_project[project] || []
179 end
179 end
180
180
181 # Returns the distinct versions of the issues that belong to +project+
181 # Returns the distinct versions of the issues that belong to +project+
182 def project_versions(project)
182 def project_versions(project)
183 project_issues(project).collect(&:fixed_version).compact.uniq
183 project_issues(project).collect(&:fixed_version).compact.uniq
184 end
184 end
185
185
186 # Returns the issues that belong to +project+ and are assigned to +version+
186 # Returns the issues that belong to +project+ and are assigned to +version+
187 def version_issues(project, version)
187 def version_issues(project, version)
188 project_issues(project).select {|issue| issue.fixed_version == version}
188 project_issues(project).select {|issue| issue.fixed_version == version}
189 end
189 end
190
190
191 def render(options={})
191 def render(options={})
192 options = {:top => 0, :top_increment => 20,
192 options = {:top => 0, :top_increment => 20,
193 :indent_increment => 20, :render => :subject,
193 :indent_increment => 20, :render => :subject,
194 :format => :html}.merge(options)
194 :format => :html}.merge(options)
195 indent = options[:indent] || 4
195 indent = options[:indent] || 4
196 @subjects = '' unless options[:only] == :lines
196 @subjects = '' unless options[:only] == :lines
197 @lines = '' unless options[:only] == :subjects
197 @lines = '' unless options[:only] == :subjects
198 @number_of_rows = 0
198 @number_of_rows = 0
199 Project.project_tree(projects) do |project, level|
199 Project.project_tree(projects) do |project, level|
200 options[:indent] = indent + level * options[:indent_increment]
200 options[:indent] = indent + level * options[:indent_increment]
201 render_project(project, options)
201 render_project(project, options)
202 break if abort?
202 break if abort?
203 end
203 end
204 @subjects_rendered = true unless options[:only] == :lines
204 @subjects_rendered = true unless options[:only] == :lines
205 @lines_rendered = true unless options[:only] == :subjects
205 @lines_rendered = true unless options[:only] == :subjects
206 render_end(options)
206 render_end(options)
207 end
207 end
208
208
209 def render_project(project, options={})
209 def render_project(project, options={})
210 subject_for_project(project, options) unless options[:only] == :lines
210 subject_for_project(project, options) unless options[:only] == :lines
211 line_for_project(project, options) unless options[:only] == :subjects
211 line_for_project(project, options) unless options[:only] == :subjects
212 options[:top] += options[:top_increment]
212 options[:top] += options[:top_increment]
213 options[:indent] += options[:indent_increment]
213 options[:indent] += options[:indent_increment]
214 @number_of_rows += 1
214 @number_of_rows += 1
215 return if abort?
215 return if abort?
216 issues = project_issues(project).select {|i| i.fixed_version.nil?}
216 issues = project_issues(project).select {|i| i.fixed_version.nil?}
217 sort_issues!(issues)
217 sort_issues!(issues)
218 if issues
218 if issues
219 render_issues(issues, options)
219 render_issues(issues, options)
220 return if abort?
220 return if abort?
221 end
221 end
222 versions = project_versions(project)
222 versions = project_versions(project)
223 versions.each do |version|
223 versions.each do |version|
224 render_version(project, version, options)
224 render_version(project, version, options)
225 end
225 end
226 # Remove indent to hit the next sibling
226 # Remove indent to hit the next sibling
227 options[:indent] -= options[:indent_increment]
227 options[:indent] -= options[:indent_increment]
228 end
228 end
229
229
230 def render_issues(issues, options={})
230 def render_issues(issues, options={})
231 @issue_ancestors = []
231 @issue_ancestors = []
232 issues.each do |i|
232 issues.each do |i|
233 subject_for_issue(i, options) unless options[:only] == :lines
233 subject_for_issue(i, options) unless options[:only] == :lines
234 line_for_issue(i, options) unless options[:only] == :subjects
234 line_for_issue(i, options) unless options[:only] == :subjects
235 options[:top] += options[:top_increment]
235 options[:top] += options[:top_increment]
236 @number_of_rows += 1
236 @number_of_rows += 1
237 break if abort?
237 break if abort?
238 end
238 end
239 options[:indent] -= (options[:indent_increment] * @issue_ancestors.size)
239 options[:indent] -= (options[:indent_increment] * @issue_ancestors.size)
240 end
240 end
241
241
242 def render_version(project, version, options={})
242 def render_version(project, version, options={})
243 # Version header
243 # Version header
244 subject_for_version(version, options) unless options[:only] == :lines
244 subject_for_version(version, options) unless options[:only] == :lines
245 line_for_version(version, options) unless options[:only] == :subjects
245 line_for_version(version, options) unless options[:only] == :subjects
246 options[:top] += options[:top_increment]
246 options[:top] += options[:top_increment]
247 @number_of_rows += 1
247 @number_of_rows += 1
248 return if abort?
248 return if abort?
249 issues = version_issues(project, version)
249 issues = version_issues(project, version)
250 if issues
250 if issues
251 sort_issues!(issues)
251 sort_issues!(issues)
252 # Indent issues
252 # Indent issues
253 options[:indent] += options[:indent_increment]
253 options[:indent] += options[:indent_increment]
254 render_issues(issues, options)
254 render_issues(issues, options)
255 options[:indent] -= options[:indent_increment]
255 options[:indent] -= options[:indent_increment]
256 end
256 end
257 end
257 end
258
258
259 def render_end(options={})
259 def render_end(options={})
260 case options[:format]
260 case options[:format]
261 when :pdf
261 when :pdf
262 options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
262 options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
263 end
263 end
264 end
264 end
265
265
266 def subject_for_project(project, options)
266 def subject_for_project(project, options)
267 case options[:format]
267 case options[:format]
268 when :html
268 when :html
269 html_class = ""
269 html_class = ""
270 html_class << 'icon icon-projects '
270 html_class << 'icon icon-projects '
271 html_class << (project.overdue? ? 'project-overdue' : '')
271 html_class << (project.overdue? ? 'project-overdue' : '')
272 s = view.link_to_project(project).html_safe
272 s = view.link_to_project(project).html_safe
273 subject = view.content_tag(:span, s,
273 subject = view.content_tag(:span, s,
274 :class => html_class).html_safe
274 :class => html_class).html_safe
275 html_subject(options, subject, :css => "project-name")
275 html_subject(options, subject, :css => "project-name")
276 when :image
276 when :image
277 image_subject(options, project.name)
277 image_subject(options, project.name)
278 when :pdf
278 when :pdf
279 pdf_new_page?(options)
279 pdf_new_page?(options)
280 pdf_subject(options, project.name)
280 pdf_subject(options, project.name)
281 end
281 end
282 end
282 end
283
283
284 def line_for_project(project, options)
284 def line_for_project(project, options)
285 # Skip versions that don't have a start_date or due date
285 # Skip versions that don't have a start_date or due date
286 if project.is_a?(Project) && project.start_date && project.due_date
286 if project.is_a?(Project) && project.start_date && project.due_date
287 options[:zoom] ||= 1
287 options[:zoom] ||= 1
288 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
288 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
289 coords = coordinates(project.start_date, project.due_date, nil, options[:zoom])
289 coords = coordinates(project.start_date, project.due_date, nil, options[:zoom])
290 label = h(project)
290 label = h(project)
291 case options[:format]
291 case options[:format]
292 when :html
292 when :html
293 html_task(options, coords, :css => "project task", :label => label, :markers => true)
293 html_task(options, coords, :css => "project task", :label => label, :markers => true)
294 when :image
294 when :image
295 image_task(options, coords, :label => label, :markers => true, :height => 3)
295 image_task(options, coords, :label => label, :markers => true, :height => 3)
296 when :pdf
296 when :pdf
297 pdf_task(options, coords, :label => label, :markers => true, :height => 0.8)
297 pdf_task(options, coords, :label => label, :markers => true, :height => 0.8)
298 end
298 end
299 else
299 else
300 ActiveRecord::Base.logger.debug "Gantt#line_for_project was not given a project with a start_date"
300 ActiveRecord::Base.logger.debug "Gantt#line_for_project was not given a project with a start_date"
301 ''
301 ''
302 end
302 end
303 end
303 end
304
304
305 def subject_for_version(version, options)
305 def subject_for_version(version, options)
306 case options[:format]
306 case options[:format]
307 when :html
307 when :html
308 html_class = ""
308 html_class = ""
309 html_class << 'icon icon-package '
309 html_class << 'icon icon-package '
310 html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " "
310 html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " "
311 html_class << (version.overdue? ? 'version-overdue' : '')
311 html_class << (version.overdue? ? 'version-overdue' : '')
312 s = view.link_to_version(version).html_safe
312 s = view.link_to_version(version).html_safe
313 subject = view.content_tag(:span, s,
313 subject = view.content_tag(:span, s,
314 :class => html_class).html_safe
314 :class => html_class).html_safe
315 html_subject(options, subject, :css => "version-name")
315 html_subject(options, subject, :css => "version-name")
316 when :image
316 when :image
317 image_subject(options, version.to_s_with_project)
317 image_subject(options, version.to_s_with_project)
318 when :pdf
318 when :pdf
319 pdf_new_page?(options)
319 pdf_new_page?(options)
320 pdf_subject(options, version.to_s_with_project)
320 pdf_subject(options, version.to_s_with_project)
321 end
321 end
322 end
322 end
323
323
324 def line_for_version(version, options)
324 def line_for_version(version, options)
325 # Skip versions that don't have a start_date
325 # Skip versions that don't have a start_date
326 if version.is_a?(Version) && version.start_date && version.due_date
326 if version.is_a?(Version) && version.start_date && version.due_date
327 options[:zoom] ||= 1
327 options[:zoom] ||= 1
328 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
328 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
329 coords = coordinates(version.start_date,
329 coords = coordinates(version.start_date,
330 version.due_date, version.completed_percent,
330 version.due_date, version.completed_percent,
331 options[:zoom])
331 options[:zoom])
332 label = "#{h version} #{h version.completed_percent.to_i.to_s}%"
332 label = "#{h version} #{h version.completed_percent.to_i.to_s}%"
333 label = h("#{version.project} -") + label unless @project && @project == version.project
333 label = h("#{version.project} -") + label unless @project && @project == version.project
334 case options[:format]
334 case options[:format]
335 when :html
335 when :html
336 html_task(options, coords, :css => "version task", :label => label, :markers => true)
336 html_task(options, coords, :css => "version task", :label => label, :markers => true)
337 when :image
337 when :image
338 image_task(options, coords, :label => label, :markers => true, :height => 3)
338 image_task(options, coords, :label => label, :markers => true, :height => 3)
339 when :pdf
339 when :pdf
340 pdf_task(options, coords, :label => label, :markers => true, :height => 0.8)
340 pdf_task(options, coords, :label => label, :markers => true, :height => 0.8)
341 end
341 end
342 else
342 else
343 ActiveRecord::Base.logger.debug "Gantt#line_for_version was not given a version with a start_date"
343 ActiveRecord::Base.logger.debug "Gantt#line_for_version was not given a version with a start_date"
344 ''
344 ''
345 end
345 end
346 end
346 end
347
347
348 def subject_for_issue(issue, options)
348 def subject_for_issue(issue, options)
349 while @issue_ancestors.any? && !issue.is_descendant_of?(@issue_ancestors.last)
349 while @issue_ancestors.any? && !issue.is_descendant_of?(@issue_ancestors.last)
350 @issue_ancestors.pop
350 @issue_ancestors.pop
351 options[:indent] -= options[:indent_increment]
351 options[:indent] -= options[:indent_increment]
352 end
352 end
353 output = case options[:format]
353 output = case options[:format]
354 when :html
354 when :html
355 css_classes = ''
355 css_classes = ''
356 css_classes << ' issue-overdue' if issue.overdue?
356 css_classes << ' issue-overdue' if issue.overdue?
357 css_classes << ' issue-behind-schedule' if issue.behind_schedule?
357 css_classes << ' issue-behind-schedule' if issue.behind_schedule?
358 css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
358 css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
359 s = "".html_safe
359 s = "".html_safe
360 if issue.assigned_to.present?
360 if issue.assigned_to.present?
361 assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
361 assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
362 s << view.avatar(issue.assigned_to,
362 s << view.avatar(issue.assigned_to,
363 :class => 'gravatar icon-gravatar',
363 :class => 'gravatar icon-gravatar',
364 :size => 10,
364 :size => 10,
365 :title => assigned_string).to_s.html_safe
365 :title => assigned_string).to_s.html_safe
366 end
366 end
367 s << view.link_to_issue(issue).html_safe
367 s << view.link_to_issue(issue).html_safe
368 subject = view.content_tag(:span, s, :class => css_classes).html_safe
368 subject = view.content_tag(:span, s, :class => css_classes).html_safe
369 html_subject(options, subject, :css => "issue-subject",
369 html_subject(options, subject, :css => "issue-subject",
370 :title => issue.subject) + "\n"
370 :title => issue.subject) + "\n"
371 when :image
371 when :image
372 image_subject(options, issue.subject)
372 image_subject(options, issue.subject)
373 when :pdf
373 when :pdf
374 pdf_new_page?(options)
374 pdf_new_page?(options)
375 pdf_subject(options, issue.subject)
375 pdf_subject(options, issue.subject)
376 end
376 end
377 unless issue.leaf?
377 unless issue.leaf?
378 @issue_ancestors << issue
378 @issue_ancestors << issue
379 options[:indent] += options[:indent_increment]
379 options[:indent] += options[:indent_increment]
380 end
380 end
381 output
381 output
382 end
382 end
383
383
384 def line_for_issue(issue, options)
384 def line_for_issue(issue, options)
385 # Skip issues that don't have a due_before (due_date or version's due_date)
385 # Skip issues that don't have a due_before (due_date or version's due_date)
386 if issue.is_a?(Issue) && issue.due_before
386 if issue.is_a?(Issue) && issue.due_before
387 coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom])
387 coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom])
388 label = "#{issue.status.name} #{issue.done_ratio}%"
388 label = "#{issue.status.name} #{issue.done_ratio}%"
389 case options[:format]
389 case options[:format]
390 when :html
390 when :html
391 html_task(options, coords,
391 html_task(options, coords,
392 :css => "task " + (issue.leaf? ? 'leaf' : 'parent'),
392 :css => "task " + (issue.leaf? ? 'leaf' : 'parent'),
393 :label => label, :issue => issue,
393 :label => label, :issue => issue,
394 :markers => !issue.leaf?)
394 :markers => !issue.leaf?)
395 when :image
395 when :image
396 image_task(options, coords, :label => label)
396 image_task(options, coords, :label => label)
397 when :pdf
397 when :pdf
398 pdf_task(options, coords, :label => label)
398 pdf_task(options, coords, :label => label)
399 end
399 end
400 else
400 else
401 ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
401 ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
402 ''
402 ''
403 end
403 end
404 end
404 end
405
405
406 # Generates a gantt image
406 # Generates a gantt image
407 # Only defined if RMagick is avalaible
407 # Only defined if RMagick is avalaible
408 def to_image(format='PNG')
408 def to_image(format='PNG')
409 date_to = (@date_from >> @months) - 1
409 date_to = (@date_from >> @months) - 1
410 show_weeks = @zoom > 1
410 show_weeks = @zoom > 1
411 show_days = @zoom > 2
411 show_days = @zoom > 2
412 subject_width = 400
412 subject_width = 400
413 header_height = 18
413 header_height = 18
414 # width of one day in pixels
414 # width of one day in pixels
415 zoom = @zoom * 2
415 zoom = @zoom * 2
416 g_width = (@date_to - @date_from + 1) * zoom
416 g_width = (@date_to - @date_from + 1) * zoom
417 g_height = 20 * number_of_rows + 30
417 g_height = 20 * number_of_rows + 30
418 headers_height = (show_weeks ? 2 * header_height : header_height)
418 headers_height = (show_weeks ? 2 * header_height : header_height)
419 height = g_height + headers_height
419 height = g_height + headers_height
420 imgl = Magick::ImageList.new
420 imgl = Magick::ImageList.new
421 imgl.new_image(subject_width + g_width + 1, height)
421 imgl.new_image(subject_width + g_width + 1, height)
422 gc = Magick::Draw.new
422 gc = Magick::Draw.new
423 gc.font = Redmine::Configuration['rmagick_font_path'] || ""
423 gc.font = Redmine::Configuration['rmagick_font_path'] || ""
424 # Subjects
424 # Subjects
425 gc.stroke('transparent')
425 gc.stroke('transparent')
426 subjects(:image => gc, :top => (headers_height + 20), :indent => 4, :format => :image)
426 subjects(:image => gc, :top => (headers_height + 20), :indent => 4, :format => :image)
427 # Months headers
427 # Months headers
428 month_f = @date_from
428 month_f = @date_from
429 left = subject_width
429 left = subject_width
430 @months.times do
430 @months.times do
431 width = ((month_f >> 1) - month_f) * zoom
431 width = ((month_f >> 1) - month_f) * zoom
432 gc.fill('white')
432 gc.fill('white')
433 gc.stroke('grey')
433 gc.stroke('grey')
434 gc.stroke_width(1)
434 gc.stroke_width(1)
435 gc.rectangle(left, 0, left + width, height)
435 gc.rectangle(left, 0, left + width, height)
436 gc.fill('black')
436 gc.fill('black')
437 gc.stroke('transparent')
437 gc.stroke('transparent')
438 gc.stroke_width(1)
438 gc.stroke_width(1)
439 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
439 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
440 left = left + width
440 left = left + width
441 month_f = month_f >> 1
441 month_f = month_f >> 1
442 end
442 end
443 # Weeks headers
443 # Weeks headers
444 if show_weeks
444 if show_weeks
445 left = subject_width
445 left = subject_width
446 height = header_height
446 height = header_height
447 if @date_from.cwday == 1
447 if @date_from.cwday == 1
448 # date_from is monday
448 # date_from is monday
449 week_f = date_from
449 week_f = date_from
450 else
450 else
451 # find next monday after date_from
451 # find next monday after date_from
452 week_f = @date_from + (7 - @date_from.cwday + 1)
452 week_f = @date_from + (7 - @date_from.cwday + 1)
453 width = (7 - @date_from.cwday + 1) * zoom
453 width = (7 - @date_from.cwday + 1) * zoom
454 gc.fill('white')
454 gc.fill('white')
455 gc.stroke('grey')
455 gc.stroke('grey')
456 gc.stroke_width(1)
456 gc.stroke_width(1)
457 gc.rectangle(left, header_height, left + width, 2 * header_height + g_height - 1)
457 gc.rectangle(left, header_height, left + width, 2 * header_height + g_height - 1)
458 left = left + width
458 left = left + width
459 end
459 end
460 while week_f <= date_to
460 while week_f <= date_to
461 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
461 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
462 gc.fill('white')
462 gc.fill('white')
463 gc.stroke('grey')
463 gc.stroke('grey')
464 gc.stroke_width(1)
464 gc.stroke_width(1)
465 gc.rectangle(left.round, header_height, left.round + width, 2 * header_height + g_height - 1)
465 gc.rectangle(left.round, header_height, left.round + width, 2 * header_height + g_height - 1)
466 gc.fill('black')
466 gc.fill('black')
467 gc.stroke('transparent')
467 gc.stroke('transparent')
468 gc.stroke_width(1)
468 gc.stroke_width(1)
469 gc.text(left.round + 2, header_height + 14, week_f.cweek.to_s)
469 gc.text(left.round + 2, header_height + 14, week_f.cweek.to_s)
470 left = left + width
470 left = left + width
471 week_f = week_f + 7
471 week_f = week_f + 7
472 end
472 end
473 end
473 end
474 # Days details (week-end in grey)
474 # Days details (week-end in grey)
475 if show_days
475 if show_days
476 left = subject_width
476 left = subject_width
477 height = g_height + header_height - 1
477 height = g_height + header_height - 1
478 wday = @date_from.cwday
478 wday = @date_from.cwday
479 (date_to - @date_from + 1).to_i.times do
479 (date_to - @date_from + 1).to_i.times do
480 width = zoom
480 width = zoom
481 gc.fill(non_working_week_days.include?(wday) ? '#eee' : 'white')
481 gc.fill(non_working_week_days.include?(wday) ? '#eee' : 'white')
482 gc.stroke('#ddd')
482 gc.stroke('#ddd')
483 gc.stroke_width(1)
483 gc.stroke_width(1)
484 gc.rectangle(left, 2 * header_height, left + width, 2 * header_height + g_height - 1)
484 gc.rectangle(left, 2 * header_height, left + width, 2 * header_height + g_height - 1)
485 left = left + width
485 left = left + width
486 wday = wday + 1
486 wday = wday + 1
487 wday = 1 if wday > 7
487 wday = 1 if wday > 7
488 end
488 end
489 end
489 end
490 # border
490 # border
491 gc.fill('transparent')
491 gc.fill('transparent')
492 gc.stroke('grey')
492 gc.stroke('grey')
493 gc.stroke_width(1)
493 gc.stroke_width(1)
494 gc.rectangle(0, 0, subject_width + g_width, headers_height)
494 gc.rectangle(0, 0, subject_width + g_width, headers_height)
495 gc.stroke('black')
495 gc.stroke('black')
496 gc.rectangle(0, 0, subject_width + g_width, g_height + headers_height - 1)
496 gc.rectangle(0, 0, subject_width + g_width, g_height + headers_height - 1)
497 # content
497 # content
498 top = headers_height + 20
498 top = headers_height + 20
499 gc.stroke('transparent')
499 gc.stroke('transparent')
500 lines(:image => gc, :top => top, :zoom => zoom,
500 lines(:image => gc, :top => top, :zoom => zoom,
501 :subject_width => subject_width, :format => :image)
501 :subject_width => subject_width, :format => :image)
502 # today red line
502 # today red line
503 if Date.today >= @date_from and Date.today <= date_to
503 if Date.today >= @date_from and Date.today <= date_to
504 gc.stroke('red')
504 gc.stroke('red')
505 x = (Date.today - @date_from + 1) * zoom + subject_width
505 x = (Date.today - @date_from + 1) * zoom + subject_width
506 gc.line(x, headers_height, x, headers_height + g_height - 1)
506 gc.line(x, headers_height, x, headers_height + g_height - 1)
507 end
507 end
508 gc.draw(imgl)
508 gc.draw(imgl)
509 imgl.format = format
509 imgl.format = format
510 imgl.to_blob
510 imgl.to_blob
511 end if Object.const_defined?(:Magick)
511 end if Object.const_defined?(:Magick)
512
512
513 def to_pdf
513 def to_pdf
514 pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
514 pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
515 pdf.SetTitle("#{l(:label_gantt)} #{project}")
515 pdf.SetTitle("#{l(:label_gantt)} #{project}")
516 pdf.alias_nb_pages
516 pdf.alias_nb_pages
517 pdf.footer_date = format_date(Date.today)
517 pdf.footer_date = format_date(Date.today)
518 pdf.AddPage("L")
518 pdf.AddPage("L")
519 pdf.SetFontStyle('B', 12)
519 pdf.SetFontStyle('B', 12)
520 pdf.SetX(15)
520 pdf.SetX(15)
521 pdf.RDMCell(PDF::LeftPaneWidth, 20, project.to_s)
521 pdf.RDMCell(PDF::LeftPaneWidth, 20, project.to_s)
522 pdf.Ln
522 pdf.Ln
523 pdf.SetFontStyle('B', 9)
523 pdf.SetFontStyle('B', 9)
524 subject_width = PDF::LeftPaneWidth
524 subject_width = PDF::LeftPaneWidth
525 header_height = 5
525 header_height = 5
526 headers_height = header_height
526 headers_height = header_height
527 show_weeks = false
527 show_weeks = false
528 show_days = false
528 show_days = false
529 if self.months < 7
529 if self.months < 7
530 show_weeks = true
530 show_weeks = true
531 headers_height = 2 * header_height
531 headers_height = 2 * header_height
532 if self.months < 3
532 if self.months < 3
533 show_days = true
533 show_days = true
534 headers_height = 3 * header_height
534 headers_height = 3 * header_height
535 end
535 end
536 end
536 end
537 g_width = PDF.right_pane_width
537 g_width = PDF.right_pane_width
538 zoom = (g_width) / (self.date_to - self.date_from + 1)
538 zoom = (g_width) / (self.date_to - self.date_from + 1)
539 g_height = 120
539 g_height = 120
540 t_height = g_height + headers_height
540 t_height = g_height + headers_height
541 y_start = pdf.GetY
541 y_start = pdf.GetY
542 # Months headers
542 # Months headers
543 month_f = self.date_from
543 month_f = self.date_from
544 left = subject_width
544 left = subject_width
545 height = header_height
545 height = header_height
546 self.months.times do
546 self.months.times do
547 width = ((month_f >> 1) - month_f) * zoom
547 width = ((month_f >> 1) - month_f) * zoom
548 pdf.SetY(y_start)
548 pdf.SetY(y_start)
549 pdf.SetX(left)
549 pdf.SetX(left)
550 pdf.RDMCell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
550 pdf.RDMCell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
551 left = left + width
551 left = left + width
552 month_f = month_f >> 1
552 month_f = month_f >> 1
553 end
553 end
554 # Weeks headers
554 # Weeks headers
555 if show_weeks
555 if show_weeks
556 left = subject_width
556 left = subject_width
557 height = header_height
557 height = header_height
558 if self.date_from.cwday == 1
558 if self.date_from.cwday == 1
559 # self.date_from is monday
559 # self.date_from is monday
560 week_f = self.date_from
560 week_f = self.date_from
561 else
561 else
562 # find next monday after self.date_from
562 # find next monday after self.date_from
563 week_f = self.date_from + (7 - self.date_from.cwday + 1)
563 week_f = self.date_from + (7 - self.date_from.cwday + 1)
564 width = (7 - self.date_from.cwday + 1) * zoom-1
564 width = (7 - self.date_from.cwday + 1) * zoom-1
565 pdf.SetY(y_start + header_height)
565 pdf.SetY(y_start + header_height)
566 pdf.SetX(left)
566 pdf.SetX(left)
567 pdf.RDMCell(width + 1, height, "", "LTR")
567 pdf.RDMCell(width + 1, height, "", "LTR")
568 left = left + width + 1
568 left = left + width + 1
569 end
569 end
570 while week_f <= self.date_to
570 while week_f <= self.date_to
571 width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom
571 width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom
572 pdf.SetY(y_start + header_height)
572 pdf.SetY(y_start + header_height)
573 pdf.SetX(left)
573 pdf.SetX(left)
574 pdf.RDMCell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
574 pdf.RDMCell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
575 left = left + width
575 left = left + width
576 week_f = week_f + 7
576 week_f = week_f + 7
577 end
577 end
578 end
578 end
579 # Days headers
579 # Days headers
580 if show_days
580 if show_days
581 left = subject_width
581 left = subject_width
582 height = header_height
582 height = header_height
583 wday = self.date_from.cwday
583 wday = self.date_from.cwday
584 pdf.SetFontStyle('B', 7)
584 pdf.SetFontStyle('B', 7)
585 (self.date_to - self.date_from + 1).to_i.times do
585 (self.date_to - self.date_from + 1).to_i.times do
586 width = zoom
586 width = zoom
587 pdf.SetY(y_start + 2 * header_height)
587 pdf.SetY(y_start + 2 * header_height)
588 pdf.SetX(left)
588 pdf.SetX(left)
589 pdf.RDMCell(width, height, day_name(wday).first, "LTR", 0, "C")
589 pdf.RDMCell(width, height, day_name(wday).first, "LTR", 0, "C")
590 left = left + width
590 left = left + width
591 wday = wday + 1
591 wday = wday + 1
592 wday = 1 if wday > 7
592 wday = 1 if wday > 7
593 end
593 end
594 end
594 end
595 pdf.SetY(y_start)
595 pdf.SetY(y_start)
596 pdf.SetX(15)
596 pdf.SetX(15)
597 pdf.RDMCell(subject_width + g_width - 15, headers_height, "", 1)
597 pdf.RDMCell(subject_width + g_width - 15, headers_height, "", 1)
598 # Tasks
598 # Tasks
599 top = headers_height + y_start
599 top = headers_height + y_start
600 options = {
600 options = {
601 :top => top,
601 :top => top,
602 :zoom => zoom,
602 :zoom => zoom,
603 :subject_width => subject_width,
603 :subject_width => subject_width,
604 :g_width => g_width,
604 :g_width => g_width,
605 :indent => 0,
605 :indent => 0,
606 :indent_increment => 5,
606 :indent_increment => 5,
607 :top_increment => 5,
607 :top_increment => 5,
608 :format => :pdf,
608 :format => :pdf,
609 :pdf => pdf
609 :pdf => pdf
610 }
610 }
611 render(options)
611 render(options)
612 pdf.Output
612 pdf.Output
613 end
613 end
614
614
615 private
615 private
616
616
617 def coordinates(start_date, end_date, progress, zoom=nil)
617 def coordinates(start_date, end_date, progress, zoom=nil)
618 zoom ||= @zoom
618 zoom ||= @zoom
619 coords = {}
619 coords = {}
620 if start_date && end_date && start_date < self.date_to && end_date > self.date_from
620 if start_date && end_date && start_date < self.date_to && end_date > self.date_from
621 if start_date > self.date_from
621 if start_date > self.date_from
622 coords[:start] = start_date - self.date_from
622 coords[:start] = start_date - self.date_from
623 coords[:bar_start] = start_date - self.date_from
623 coords[:bar_start] = start_date - self.date_from
624 else
624 else
625 coords[:bar_start] = 0
625 coords[:bar_start] = 0
626 end
626 end
627 if end_date < self.date_to
627 if end_date < self.date_to
628 coords[:end] = end_date - self.date_from
628 coords[:end] = end_date - self.date_from
629 coords[:bar_end] = end_date - self.date_from + 1
629 coords[:bar_end] = end_date - self.date_from + 1
630 else
630 else
631 coords[:bar_end] = self.date_to - self.date_from + 1
631 coords[:bar_end] = self.date_to - self.date_from + 1
632 end
632 end
633 if progress
633 if progress
634 progress_date = start_date + (end_date - start_date + 1) * (progress / 100.0)
634 progress_date = start_date + (end_date - start_date + 1) * (progress / 100.0)
635 if progress_date > self.date_from && progress_date > start_date
635 if progress_date > self.date_from && progress_date > start_date
636 if progress_date < self.date_to
636 if progress_date < self.date_to
637 coords[:bar_progress_end] = progress_date - self.date_from
637 coords[:bar_progress_end] = progress_date - self.date_from
638 else
638 else
639 coords[:bar_progress_end] = self.date_to - self.date_from + 1
639 coords[:bar_progress_end] = self.date_to - self.date_from + 1
640 end
640 end
641 end
641 end
642 if progress_date < Date.today
642 if progress_date < Date.today
643 late_date = [Date.today, end_date].min
643 late_date = [Date.today, end_date].min
644 if late_date > self.date_from && late_date > start_date
644 if late_date > self.date_from && late_date > start_date
645 if late_date < self.date_to
645 if late_date < self.date_to
646 coords[:bar_late_end] = late_date - self.date_from + 1
646 coords[:bar_late_end] = late_date - self.date_from + 1
647 else
647 else
648 coords[:bar_late_end] = self.date_to - self.date_from + 1
648 coords[:bar_late_end] = self.date_to - self.date_from + 1
649 end
649 end
650 end
650 end
651 end
651 end
652 end
652 end
653 end
653 end
654 # Transforms dates into pixels witdh
654 # Transforms dates into pixels witdh
655 coords.keys.each do |key|
655 coords.keys.each do |key|
656 coords[key] = (coords[key] * zoom).floor
656 coords[key] = (coords[key] * zoom).floor
657 end
657 end
658 coords
658 coords
659 end
659 end
660
660
661 # Sorts a collection of issues by start_date, due_date, id for gantt rendering
661 # Sorts a collection of issues by start_date, due_date, id for gantt rendering
662 def sort_issues!(issues)
662 def sort_issues!(issues)
663 issues.sort! { |a, b| gantt_issue_compare(a, b) }
663 issues.sort! { |a, b| gantt_issue_compare(a, b) }
664 end
664 end
665
665
666 # TODO: top level issues should be sorted by start date
666 # TODO: top level issues should be sorted by start date
667 def gantt_issue_compare(x, y)
667 def gantt_issue_compare(x, y)
668 if x.root_id == y.root_id
668 if x.root_id == y.root_id
669 x.lft <=> y.lft
669 x.lft <=> y.lft
670 else
670 else
671 x.root_id <=> y.root_id
671 x.root_id <=> y.root_id
672 end
672 end
673 end
673 end
674
674
675 def current_limit
675 def current_limit
676 if @max_rows
676 if @max_rows
677 @max_rows - @number_of_rows
677 @max_rows - @number_of_rows
678 else
678 else
679 nil
679 nil
680 end
680 end
681 end
681 end
682
682
683 def abort?
683 def abort?
684 if @max_rows && @number_of_rows >= @max_rows
684 if @max_rows && @number_of_rows >= @max_rows
685 @truncated = true
685 @truncated = true
686 end
686 end
687 end
687 end
688
688
689 def pdf_new_page?(options)
689 def pdf_new_page?(options)
690 if options[:top] > 180
690 if options[:top] > 180
691 options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
691 options[:pdf].Line(15, options[:top], PDF::TotalWidth, options[:top])
692 options[:pdf].AddPage("L")
692 options[:pdf].AddPage("L")
693 options[:top] = 15
693 options[:top] = 15
694 options[:pdf].Line(15, options[:top] - 0.1, PDF::TotalWidth, options[:top] - 0.1)
694 options[:pdf].Line(15, options[:top] - 0.1, PDF::TotalWidth, options[:top] - 0.1)
695 end
695 end
696 end
696 end
697
697
698 def html_subject(params, subject, options={})
698 def html_subject(params, subject, options={})
699 style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;"
699 style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;"
700 style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
700 style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width]
701 output = view.content_tag('div', subject,
701 output = view.content_tag('div', subject,
702 :class => options[:css], :style => style,
702 :class => options[:css], :style => style,
703 :title => options[:title])
703 :title => options[:title])
704 @subjects << output
704 @subjects << output
705 output
705 output
706 end
706 end
707
707
708 def pdf_subject(params, subject, options={})
708 def pdf_subject(params, subject, options={})
709 params[:pdf].SetY(params[:top])
709 params[:pdf].SetY(params[:top])
710 params[:pdf].SetX(15)
710 params[:pdf].SetX(15)
711 char_limit = PDF::MaxCharactorsForSubject - params[:indent]
711 char_limit = PDF::MaxCharactorsForSubject - params[:indent]
712 params[:pdf].RDMCell(params[:subject_width] - 15, 5,
712 params[:pdf].RDMCell(params[:subject_width] - 15, 5,
713 (" " * params[:indent]) +
713 (" " * params[:indent]) +
714 subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'),
714 subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'),
715 "LR")
715 "LR")
716 params[:pdf].SetY(params[:top])
716 params[:pdf].SetY(params[:top])
717 params[:pdf].SetX(params[:subject_width])
717 params[:pdf].SetX(params[:subject_width])
718 params[:pdf].RDMCell(params[:g_width], 5, "", "LR")
718 params[:pdf].RDMCell(params[:g_width], 5, "", "LR")
719 end
719 end
720
720
721 def image_subject(params, subject, options={})
721 def image_subject(params, subject, options={})
722 params[:image].fill('black')
722 params[:image].fill('black')
723 params[:image].stroke('transparent')
723 params[:image].stroke('transparent')
724 params[:image].stroke_width(1)
724 params[:image].stroke_width(1)
725 params[:image].text(params[:indent], params[:top] + 2, subject)
725 params[:image].text(params[:indent], params[:top] + 2, subject)
726 end
726 end
727
727
728 def issue_relations(issue)
728 def issue_relations(issue)
729 rels = {}
729 rels = {}
730 if relations[issue.id]
730 if relations[issue.id]
731 relations[issue.id].each do |relation|
731 relations[issue.id].each do |relation|
732 (rels[relation.relation_type] ||= []) << relation.issue_to_id
732 (rels[relation.relation_type] ||= []) << relation.issue_to_id
733 end
733 end
734 end
734 end
735 rels
735 rels
736 end
736 end
737
737
738 def html_task(params, coords, options={})
738 def html_task(params, coords, options={})
739 output = ''
739 output = ''
740 # Renders the task bar, with progress and late
740 # Renders the task bar, with progress and late
741 if coords[:bar_start] && coords[:bar_end]
741 if coords[:bar_start] && coords[:bar_end]
742 width = coords[:bar_end] - coords[:bar_start] - 2
742 width = coords[:bar_end] - coords[:bar_start] - 2
743 style = ""
743 style = ""
744 style << "top:#{params[:top]}px;"
744 style << "top:#{params[:top]}px;"
745 style << "left:#{coords[:bar_start]}px;"
745 style << "left:#{coords[:bar_start]}px;"
746 style << "width:#{width}px;"
746 style << "width:#{width}px;"
747 html_id = "task-todo-issue-#{options[:issue].id}" if options[:issue]
747 html_id = "task-todo-issue-#{options[:issue].id}" if options[:issue]
748 content_opt = {:style => style,
748 content_opt = {:style => style,
749 :class => "#{options[:css]} task_todo",
749 :class => "#{options[:css]} task_todo",
750 :id => html_id}
750 :id => html_id}
751 if options[:issue]
751 if options[:issue]
752 rels_hash = {}
752 content_opt[:data] = {"rels" => issue_relations(options[:issue]).to_json}
753 issue_relations(options[:issue]).each do |k, v|
754 rels_hash[k] = v.join(',')
755 end
756 content_opt[:data] = {"rels" => rels_hash}
757 end
753 end
758 output << view.content_tag(:div, '&nbsp;'.html_safe, content_opt)
754 output << view.content_tag(:div, '&nbsp;'.html_safe, content_opt)
759 if coords[:bar_late_end]
755 if coords[:bar_late_end]
760 width = coords[:bar_late_end] - coords[:bar_start] - 2
756 width = coords[:bar_late_end] - coords[:bar_start] - 2
761 style = ""
757 style = ""
762 style << "top:#{params[:top]}px;"
758 style << "top:#{params[:top]}px;"
763 style << "left:#{coords[:bar_start]}px;"
759 style << "left:#{coords[:bar_start]}px;"
764 style << "width:#{width}px;"
760 style << "width:#{width}px;"
765 output << view.content_tag(:div, '&nbsp;'.html_safe,
761 output << view.content_tag(:div, '&nbsp;'.html_safe,
766 :style => style,
762 :style => style,
767 :class => "#{options[:css]} task_late")
763 :class => "#{options[:css]} task_late")
768 end
764 end
769 if coords[:bar_progress_end]
765 if coords[:bar_progress_end]
770 width = coords[:bar_progress_end] - coords[:bar_start] - 2
766 width = coords[:bar_progress_end] - coords[:bar_start] - 2
771 style = ""
767 style = ""
772 style << "top:#{params[:top]}px;"
768 style << "top:#{params[:top]}px;"
773 style << "left:#{coords[:bar_start]}px;"
769 style << "left:#{coords[:bar_start]}px;"
774 style << "width:#{width}px;"
770 style << "width:#{width}px;"
775 output << view.content_tag(:div, '&nbsp;'.html_safe,
771 output << view.content_tag(:div, '&nbsp;'.html_safe,
776 :style => style,
772 :style => style,
777 :class => "#{options[:css]} task_done")
773 :class => "#{options[:css]} task_done")
778 end
774 end
779 end
775 end
780 # Renders the markers
776 # Renders the markers
781 if options[:markers]
777 if options[:markers]
782 if coords[:start]
778 if coords[:start]
783 style = ""
779 style = ""
784 style << "top:#{params[:top]}px;"
780 style << "top:#{params[:top]}px;"
785 style << "left:#{coords[:start]}px;"
781 style << "left:#{coords[:start]}px;"
786 style << "width:15px;"
782 style << "width:15px;"
787 output << view.content_tag(:div, '&nbsp;'.html_safe,
783 output << view.content_tag(:div, '&nbsp;'.html_safe,
788 :style => style,
784 :style => style,
789 :class => "#{options[:css]} marker starting")
785 :class => "#{options[:css]} marker starting")
790 end
786 end
791 if coords[:end]
787 if coords[:end]
792 style = ""
788 style = ""
793 style << "top:#{params[:top]}px;"
789 style << "top:#{params[:top]}px;"
794 style << "left:#{coords[:end] + params[:zoom]}px;"
790 style << "left:#{coords[:end] + params[:zoom]}px;"
795 style << "width:15px;"
791 style << "width:15px;"
796 output << view.content_tag(:div, '&nbsp;'.html_safe,
792 output << view.content_tag(:div, '&nbsp;'.html_safe,
797 :style => style,
793 :style => style,
798 :class => "#{options[:css]} marker ending")
794 :class => "#{options[:css]} marker ending")
799 end
795 end
800 end
796 end
801 # Renders the label on the right
797 # Renders the label on the right
802 if options[:label]
798 if options[:label]
803 style = ""
799 style = ""
804 style << "top:#{params[:top]}px;"
800 style << "top:#{params[:top]}px;"
805 style << "left:#{(coords[:bar_end] || 0) + 8}px;"
801 style << "left:#{(coords[:bar_end] || 0) + 8}px;"
806 style << "width:15px;"
802 style << "width:15px;"
807 output << view.content_tag(:div, options[:label],
803 output << view.content_tag(:div, options[:label],
808 :style => style,
804 :style => style,
809 :class => "#{options[:css]} label")
805 :class => "#{options[:css]} label")
810 end
806 end
811 # Renders the tooltip
807 # Renders the tooltip
812 if options[:issue] && coords[:bar_start] && coords[:bar_end]
808 if options[:issue] && coords[:bar_start] && coords[:bar_end]
813 s = view.content_tag(:span,
809 s = view.content_tag(:span,
814 view.render_issue_tooltip(options[:issue]).html_safe,
810 view.render_issue_tooltip(options[:issue]).html_safe,
815 :class => "tip")
811 :class => "tip")
816 style = ""
812 style = ""
817 style << "position: absolute;"
813 style << "position: absolute;"
818 style << "top:#{params[:top]}px;"
814 style << "top:#{params[:top]}px;"
819 style << "left:#{coords[:bar_start]}px;"
815 style << "left:#{coords[:bar_start]}px;"
820 style << "width:#{coords[:bar_end] - coords[:bar_start]}px;"
816 style << "width:#{coords[:bar_end] - coords[:bar_start]}px;"
821 style << "height:12px;"
817 style << "height:12px;"
822 output << view.content_tag(:div, s.html_safe,
818 output << view.content_tag(:div, s.html_safe,
823 :style => style,
819 :style => style,
824 :class => "tooltip")
820 :class => "tooltip")
825 end
821 end
826 @lines << output
822 @lines << output
827 output
823 output
828 end
824 end
829
825
830 def pdf_task(params, coords, options={})
826 def pdf_task(params, coords, options={})
831 height = options[:height] || 2
827 height = options[:height] || 2
832 # Renders the task bar, with progress and late
828 # Renders the task bar, with progress and late
833 if coords[:bar_start] && coords[:bar_end]
829 if coords[:bar_start] && coords[:bar_end]
834 params[:pdf].SetY(params[:top] + 1.5)
830 params[:pdf].SetY(params[:top] + 1.5)
835 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
831 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
836 params[:pdf].SetFillColor(200, 200, 200)
832 params[:pdf].SetFillColor(200, 200, 200)
837 params[:pdf].RDMCell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
833 params[:pdf].RDMCell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
838 if coords[:bar_late_end]
834 if coords[:bar_late_end]
839 params[:pdf].SetY(params[:top] + 1.5)
835 params[:pdf].SetY(params[:top] + 1.5)
840 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
836 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
841 params[:pdf].SetFillColor(255, 100, 100)
837 params[:pdf].SetFillColor(255, 100, 100)
842 params[:pdf].RDMCell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
838 params[:pdf].RDMCell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
843 end
839 end
844 if coords[:bar_progress_end]
840 if coords[:bar_progress_end]
845 params[:pdf].SetY(params[:top] + 1.5)
841 params[:pdf].SetY(params[:top] + 1.5)
846 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
842 params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
847 params[:pdf].SetFillColor(90, 200, 90)
843 params[:pdf].SetFillColor(90, 200, 90)
848 params[:pdf].RDMCell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
844 params[:pdf].RDMCell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
849 end
845 end
850 end
846 end
851 # Renders the markers
847 # Renders the markers
852 if options[:markers]
848 if options[:markers]
853 if coords[:start]
849 if coords[:start]
854 params[:pdf].SetY(params[:top] + 1)
850 params[:pdf].SetY(params[:top] + 1)
855 params[:pdf].SetX(params[:subject_width] + coords[:start] - 1)
851 params[:pdf].SetX(params[:subject_width] + coords[:start] - 1)
856 params[:pdf].SetFillColor(50, 50, 200)
852 params[:pdf].SetFillColor(50, 50, 200)
857 params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1)
853 params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1)
858 end
854 end
859 if coords[:end]
855 if coords[:end]
860 params[:pdf].SetY(params[:top] + 1)
856 params[:pdf].SetY(params[:top] + 1)
861 params[:pdf].SetX(params[:subject_width] + coords[:end] - 1)
857 params[:pdf].SetX(params[:subject_width] + coords[:end] - 1)
862 params[:pdf].SetFillColor(50, 50, 200)
858 params[:pdf].SetFillColor(50, 50, 200)
863 params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1)
859 params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1)
864 end
860 end
865 end
861 end
866 # Renders the label on the right
862 # Renders the label on the right
867 if options[:label]
863 if options[:label]
868 params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5)
864 params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5)
869 params[:pdf].RDMCell(30, 2, options[:label])
865 params[:pdf].RDMCell(30, 2, options[:label])
870 end
866 end
871 end
867 end
872
868
873 def image_task(params, coords, options={})
869 def image_task(params, coords, options={})
874 height = options[:height] || 6
870 height = options[:height] || 6
875 # Renders the task bar, with progress and late
871 # Renders the task bar, with progress and late
876 if coords[:bar_start] && coords[:bar_end]
872 if coords[:bar_start] && coords[:bar_end]
877 params[:image].fill('#aaa')
873 params[:image].fill('#aaa')
878 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
874 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
879 params[:top],
875 params[:top],
880 params[:subject_width] + coords[:bar_end],
876 params[:subject_width] + coords[:bar_end],
881 params[:top] - height)
877 params[:top] - height)
882 if coords[:bar_late_end]
878 if coords[:bar_late_end]
883 params[:image].fill('#f66')
879 params[:image].fill('#f66')
884 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
880 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
885 params[:top],
881 params[:top],
886 params[:subject_width] + coords[:bar_late_end],
882 params[:subject_width] + coords[:bar_late_end],
887 params[:top] - height)
883 params[:top] - height)
888 end
884 end
889 if coords[:bar_progress_end]
885 if coords[:bar_progress_end]
890 params[:image].fill('#00c600')
886 params[:image].fill('#00c600')
891 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
887 params[:image].rectangle(params[:subject_width] + coords[:bar_start],
892 params[:top],
888 params[:top],
893 params[:subject_width] + coords[:bar_progress_end],
889 params[:subject_width] + coords[:bar_progress_end],
894 params[:top] - height)
890 params[:top] - height)
895 end
891 end
896 end
892 end
897 # Renders the markers
893 # Renders the markers
898 if options[:markers]
894 if options[:markers]
899 if coords[:start]
895 if coords[:start]
900 x = params[:subject_width] + coords[:start]
896 x = params[:subject_width] + coords[:start]
901 y = params[:top] - height / 2
897 y = params[:top] - height / 2
902 params[:image].fill('blue')
898 params[:image].fill('blue')
903 params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
899 params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
904 end
900 end
905 if coords[:end]
901 if coords[:end]
906 x = params[:subject_width] + coords[:end] + params[:zoom]
902 x = params[:subject_width] + coords[:end] + params[:zoom]
907 y = params[:top] - height / 2
903 y = params[:top] - height / 2
908 params[:image].fill('blue')
904 params[:image].fill('blue')
909 params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
905 params[:image].polygon(x - 4, y, x, y - 4, x + 4, y, x, y + 4)
910 end
906 end
911 end
907 end
912 # Renders the label on the right
908 # Renders the label on the right
913 if options[:label]
909 if options[:label]
914 params[:image].fill('black')
910 params[:image].fill('black')
915 params[:image].text(params[:subject_width] + (coords[:bar_end] || 0) + 5,
911 params[:image].text(params[:subject_width] + (coords[:bar_end] || 0) + 5,
916 params[:top] + 1,
912 params[:top] + 1,
917 options[:label])
913 options[:label])
918 end
914 end
919 end
915 end
920 end
916 end
921 end
917 end
922 end
918 end
@@ -1,114 +1,111
1 var draw_gantt = null;
1 var draw_gantt = null;
2 var draw_top;
2 var draw_top;
3 var draw_right;
3 var draw_right;
4 var draw_left;
4 var draw_left;
5
5
6 var rels_stroke_width = 2;
6 var rels_stroke_width = 2;
7
7
8 function setDrawArea() {
8 function setDrawArea() {
9 draw_top = $("#gantt_draw_area").position().top;
9 draw_top = $("#gantt_draw_area").position().top;
10 draw_right = $("#gantt_draw_area").width();
10 draw_right = $("#gantt_draw_area").width();
11 draw_left = $("#gantt_area").scrollLeft();
11 draw_left = $("#gantt_area").scrollLeft();
12 }
12 }
13
13
14 function getRelationsArray() {
14 function getRelationsArray() {
15 var arr = new Array();
15 var arr = new Array();
16 $.each($('div.task_todo'), function(index_div, element) {
16 $.each($('div.task_todo'), function(index_div, element) {
17 var element_id = $(element).attr("id");
17 var element_id = $(element).attr("id");
18 if (element_id != null) {
18 if (element_id != null) {
19 var issue_id = element_id.replace("task-todo-issue-", "");
19 var issue_id = element_id.replace("task-todo-issue-", "");
20 var data_rels = $(element).data("rels");
20 var data_rels = $(element).data("rels");
21 if (data_rels != null) {
21 if (data_rels != null) {
22 for (rel_type_key in issue_relation_type) {
22 for (rel_type_key in data_rels) {
23 if (rel_type_key in data_rels) {
23 $.each(data_rels[rel_type_key], function(index_issue, element_issue) {
24 var issue_arr = data_rels[rel_type_key].toString().split(",");
24 arr.push({issue_from: issue_id, issue_to: element_issue,
25 $.each(issue_arr, function(index_issue, element_issue) {
25 rel_type: rel_type_key});
26 arr.push({issue_from: issue_id, issue_to: element_issue,
26 });
27 rel_type: rel_type_key});
28 });
29 }
30 }
27 }
31 }
28 }
32 }
29 }
33 });
30 });
34 return arr;
31 return arr;
35 }
32 }
36
33
37 function drawRelations() {
34 function drawRelations() {
38 var arr = getRelationsArray();
35 var arr = getRelationsArray();
39 $.each(arr, function(index_issue, element_issue) {
36 $.each(arr, function(index_issue, element_issue) {
40 var issue_from = $("#task-todo-issue-" + element_issue["issue_from"]);
37 var issue_from = $("#task-todo-issue-" + element_issue["issue_from"]);
41 var issue_to = $("#task-todo-issue-" + element_issue["issue_to"]);
38 var issue_to = $("#task-todo-issue-" + element_issue["issue_to"]);
42 if (issue_from.size() == 0 || issue_to.size() == 0) {
39 if (issue_from.size() == 0 || issue_to.size() == 0) {
43 return;
40 return;
44 }
41 }
45 var issue_height = issue_from.height();
42 var issue_height = issue_from.height();
46 var issue_from_top = issue_from.position().top + (issue_height / 2) - draw_top;
43 var issue_from_top = issue_from.position().top + (issue_height / 2) - draw_top;
47 var issue_from_right = issue_from.position().left + issue_from.width();
44 var issue_from_right = issue_from.position().left + issue_from.width();
48 var issue_to_top = issue_to.position().top + (issue_height / 2) - draw_top;
45 var issue_to_top = issue_to.position().top + (issue_height / 2) - draw_top;
49 var issue_to_left = issue_to.position().left;
46 var issue_to_left = issue_to.position().left;
50 var color = issue_relation_type[element_issue["rel_type"]]["color"];
47 var color = issue_relation_type[element_issue["rel_type"]]["color"];
51 var landscape_margin = issue_relation_type[element_issue["rel_type"]]["landscape_margin"];
48 var landscape_margin = issue_relation_type[element_issue["rel_type"]]["landscape_margin"];
52 var issue_from_right_rel = issue_from_right + landscape_margin;
49 var issue_from_right_rel = issue_from_right + landscape_margin;
53 var issue_to_left_rel = issue_to_left - landscape_margin;
50 var issue_to_left_rel = issue_to_left - landscape_margin;
54 draw_gantt.path(["M", issue_from_right + draw_left, issue_from_top,
51 draw_gantt.path(["M", issue_from_right + draw_left, issue_from_top,
55 "L", issue_from_right_rel + draw_left, issue_from_top])
52 "L", issue_from_right_rel + draw_left, issue_from_top])
56 .attr({stroke: color,
53 .attr({stroke: color,
57 "stroke-width": rels_stroke_width
54 "stroke-width": rels_stroke_width
58 });
55 });
59 if (issue_from_right_rel < issue_to_left_rel) {
56 if (issue_from_right_rel < issue_to_left_rel) {
60 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_from_top,
57 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_from_top,
61 "L", issue_from_right_rel + draw_left, issue_to_top])
58 "L", issue_from_right_rel + draw_left, issue_to_top])
62 .attr({stroke: color,
59 .attr({stroke: color,
63 "stroke-width": rels_stroke_width
60 "stroke-width": rels_stroke_width
64 });
61 });
65 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_to_top,
62 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_to_top,
66 "L", issue_to_left + draw_left, issue_to_top])
63 "L", issue_to_left + draw_left, issue_to_top])
67 .attr({stroke: color,
64 .attr({stroke: color,
68 "stroke-width": rels_stroke_width
65 "stroke-width": rels_stroke_width
69 });
66 });
70 } else {
67 } else {
71 var issue_middle_top = issue_to_top +
68 var issue_middle_top = issue_to_top +
72 (issue_height *
69 (issue_height *
73 ((issue_from_top > issue_to_top) ? 1 : -1));
70 ((issue_from_top > issue_to_top) ? 1 : -1));
74 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_from_top,
71 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_from_top,
75 "L", issue_from_right_rel + draw_left, issue_middle_top])
72 "L", issue_from_right_rel + draw_left, issue_middle_top])
76 .attr({stroke: color,
73 .attr({stroke: color,
77 "stroke-width": rels_stroke_width
74 "stroke-width": rels_stroke_width
78 });
75 });
79 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_middle_top,
76 draw_gantt.path(["M", issue_from_right_rel + draw_left, issue_middle_top,
80 "L", issue_to_left_rel + draw_left, issue_middle_top])
77 "L", issue_to_left_rel + draw_left, issue_middle_top])
81 .attr({stroke: color,
78 .attr({stroke: color,
82 "stroke-width": rels_stroke_width
79 "stroke-width": rels_stroke_width
83 });
80 });
84 draw_gantt.path(["M", issue_to_left_rel + draw_left, issue_middle_top,
81 draw_gantt.path(["M", issue_to_left_rel + draw_left, issue_middle_top,
85 "L", issue_to_left_rel + draw_left, issue_to_top])
82 "L", issue_to_left_rel + draw_left, issue_to_top])
86 .attr({stroke: color,
83 .attr({stroke: color,
87 "stroke-width": rels_stroke_width
84 "stroke-width": rels_stroke_width
88 });
85 });
89 draw_gantt.path(["M", issue_to_left_rel + draw_left, issue_to_top,
86 draw_gantt.path(["M", issue_to_left_rel + draw_left, issue_to_top,
90 "L", issue_to_left + draw_left, issue_to_top])
87 "L", issue_to_left + draw_left, issue_to_top])
91 .attr({stroke: color,
88 .attr({stroke: color,
92 "stroke-width": rels_stroke_width
89 "stroke-width": rels_stroke_width
93 });
90 });
94 }
91 }
95 draw_gantt.path(["M", issue_to_left + draw_left, issue_to_top,
92 draw_gantt.path(["M", issue_to_left + draw_left, issue_to_top,
96 "l", -4 * rels_stroke_width, -2 * rels_stroke_width,
93 "l", -4 * rels_stroke_width, -2 * rels_stroke_width,
97 "l", 0, 4 * rels_stroke_width, "z"])
94 "l", 0, 4 * rels_stroke_width, "z"])
98 .attr({stroke: "none",
95 .attr({stroke: "none",
99 fill: color,
96 fill: color,
100 "stroke-linecap": "butt",
97 "stroke-linecap": "butt",
101 "stroke-linejoin": "miter",
98 "stroke-linejoin": "miter",
102 });
99 });
103 });
100 });
104 }
101 }
105
102
106 function drawGanttHandler() {
103 function drawGanttHandler() {
107 var folder = document.getElementById('gantt_draw_area');
104 var folder = document.getElementById('gantt_draw_area');
108 if(draw_gantt != null)
105 if(draw_gantt != null)
109 draw_gantt.clear();
106 draw_gantt.clear();
110 else
107 else
111 draw_gantt = Raphael(folder);
108 draw_gantt = Raphael(folder);
112 setDrawArea();
109 setDrawArea();
113 drawRelations();
110 drawRelations();
114 }
111 }
General Comments 0
You need to be logged in to leave comments. Login now