From 8f7da03419071e132bbda1c1983707de15350597 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 17 Dec 2010 12:41:54 +0000 Subject: [PATCH] Gantt code cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4521 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/helpers/gantt.rb | 48 +++++++++++---------- test/unit/lib/redmine/helpers/gantt_test.rb | 8 ++-- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index d84202b5e..ea0140c4d 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -587,22 +587,9 @@ module Redmine if issue.is_a?(Issue) && issue.due_before case options[:format] when :html - output = '' - css = "task " + (issue.leaf? ? 'leaf' : 'parent') - coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, options[:zoom]) - if coords[:bar_start] && coords[:bar_end] - output << html_task(options[:top], coords, css) - - output << "
" - output << '' - output << view.render_issue_tooltip(issue) - output << "
" - end - - output << "
" - output << "#{ issue.status.name } #{ issue.done_ratio }%" - output << "
" + css = "task " + (issue.leaf? ? 'leaf' : 'parent') + output = html_task(options[:top], coords, :css => css, :label => "#{ issue.status.name } #{ issue.done_ratio }%", :issue => issue) @lines << output output @@ -1017,14 +1004,31 @@ module Redmine end end - def html_task(top, coords, css) - output = "
 
" - - if coords[:bar_late_end] - output << "
 
" + def html_task(top, coords, options={}) + output = '' + # Renders the task bar, with progress and late + if coords[:bar_start] && coords[:bar_end] + output << "
 
" + + if coords[:bar_late_end] + output << "
 
" + end + if coords[:bar_progress_end] + output << "
 
" + end + end + # Renders the label on the right + if options[:label] + output << "
" + output << options[:label] + output << "
" end - if coords[:bar_progress_end] - output << "
 
" + # Renders the tooltip + if options[:issue] && coords[:bar_start] && coords[:bar_end] + output << "
" + output << '' + output << view.render_issue_tooltip(options[:issue]) + output << "
" end output diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index d3b65c340..9578b6b43 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -235,7 +235,7 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase context "issue" do should "be rendered" do 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}/ end end @@ -692,17 +692,17 @@ class Redmine::Helpers::GanttTest < ActiveSupport::TestCase @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) @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 should "show the issue status" do @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 should "show the percent complete" do @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 -- 2.39.5