Commit 8f7da034 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Gantt code cleanup.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4521 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 27f76d20
...@@ -587,22 +587,9 @@ module Redmine ...@@ -587,22 +587,9 @@ module Redmine
if issue.is_a?(Issue) && issue.due_before if issue.is_a?(Issue) && issue.due_before
case options[:format] case options[:format]
when :html when :html
output = ''
css = "task " + (issue.leaf? ? 'leaf' : 'parent')
coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom]) coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom])
if coords[:bar_start] && coords[:bar_end] css = "task " + (issue.leaf? ? 'leaf' : 'parent')
output << html_task(options[:top], coords, css) output = html_task(options[:top], coords, :css => css, :label => "#{ issue.status.name } #{ issue.done_ratio }%", :issue => issue)
output << "<div class='tooltip' style='position: absolute;top:#{ options[:top] }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] }px;height:12px;'>"
output << '<span class="tip">'
output << view.render_issue_tooltip(issue)
output << "</span></div>"
end
output << "<div style='top:#{ options[:top] }px;left:#{ (coords[:bar_end] || 0) + 5 }px;' class='#{css} label issue-name'>"
output << "#{ issue.status.name } #{ issue.done_ratio }%"
output << "</div>"
@lines << output @lines << output
output output
...@@ -1017,14 +1004,31 @@ module Redmine ...@@ -1017,14 +1004,31 @@ module Redmine
end end
end end
def html_task(top, coords, css) def html_task(top, coords, options={})
output = "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] - 2}px;' class='#{css} task_todo'>&nbsp;</div>" output = ''
# Renders the task bar, with progress and late
if coords[:bar_late_end] if coords[:bar_start] && coords[:bar_end]
output << "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_late_end] - coords[:bar_start] - 2}px;' class='#{css} task_late'>&nbsp;</div>" output << "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_todo'>&nbsp;</div>"
if coords[:bar_late_end]
output << "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_late_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_late'>&nbsp;</div>"
end
if coords[:bar_progress_end]
output << "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_progress_end] - coords[:bar_start] - 2}px;' class='#{options[:css]} task_done'>&nbsp;</div>"
end
end
# Renders the label on the right
if options[:label]
output << "<div style='top:#{ top }px;left:#{ (coords[:bar_end] || 0) + 5 }px;' class='#{options[:css]} label'>"
output << options[:label]
output << "</div>"
end end
if coords[:bar_progress_end] # Renders the tooltip
output << "<div style='top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_progress_end] - coords[:bar_start] - 2}px;' class='#{css} task_done'>&nbsp;</div>" if options[:issue] && coords[:bar_start] && coords[:bar_end]
output << "<div class='tooltip' style='position: absolute;top:#{ top }px;left:#{ coords[:bar_start] }px;width:#{ coords[:bar_end] - coords[:bar_start] }px;height:12px;'>"
output << '<span class="tip">'
output << view.render_issue_tooltip(options[:issue])
output << "</span></div>"
end end
output output
......
...@@ -235,7 +235,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase ...@@ -235,7 +235,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
context "issue" do context "issue" do
should "be rendered" do should "be rendered" do
assert_select "div.task_todo" assert_select "div.task_todo"
assert_select "div.label.issue-name", /#{@issue.done_ratio}/ assert_select "div.task.label", /#{@issue.done_ratio}/
assert_select "div.tooltip", /#{@issue.subject}/ assert_select "div.tooltip", /#{@issue.subject}/
end end
end end
...@@ -692,17 +692,17 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase ...@@ -692,17 +692,17 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
@gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.issue-name", true, @response.body assert_select "div.task.label", true, @response.body
end end
should "show the issue status" do should "show the issue status" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.issue-name", /#{@issue.status.name}/ assert_select "div.task.label", /#{@issue.status.name}/
end end
should "show the percent complete" do should "show the percent complete" do
@response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4}) @response.body = @gantt.line_for_issue(@issue, {:format => :html, :zoom => 4})
assert_select "div.issue-name", /30%/ assert_select "div.task.label", /30%/
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment