##// END OF EJS Templates
Gantt code cleanup....
Jean-Philippe Lang -
r4408:98c7c179ca3f
parent child
Show More
@@ -435,65 +435,11 module Redmine
435
435
436 case options[:format]
436 case options[:format]
437 when :html
437 when :html
438 output = ''
438 coords = coordinates(version.fixed_issues.minimum('start_date'), version.due_date, version.completed_pourcent, options[:zoom])
439 i_left = ((version.start_date - self.date_from)*options[:zoom]).floor
439 label = "#{h version } #{h version.completed_pourcent.to_i.to_s}%"
440 # TODO: or version.fixed_issues.collect(&:start_date).min
440 label = h("#{version.project} -") + label unless @project && @project == version.project
441 start_date = version.fixed_issues.minimum('start_date') if version.fixed_issues.present?
441 output = html_task(options[:top], coords, :css => "version task", :label => label, :markers => true)
442 start_date ||= self.date_from
443 start_left = ((start_date - self.date_from)*options[:zoom]).floor
444
445 i_end_date = ((version.due_date <= self.date_to) ? version.due_date : self.date_to )
446 i_done_date = start_date + ((version.due_date - start_date+1)* version.completed_pourcent/100).floor
447 i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
448 i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
449
442
450 i_late_date = [i_end_date, Date.today].min if start_date < Date.today
451
452 i_width = (i_left - start_left + 1).floor - 2 # total width of the issue (- 2 for left and right borders)
453 d_width = ((i_done_date - start_date)*options[:zoom]).floor - 2 # done width
454 l_width = i_late_date ? ((i_late_date - start_date+1)*options[:zoom]).floor - 2 : 0 # delay width
455
456 i_end = ((i_end_date - self.date_from) * options[:zoom]).floor # Ending pixel
457
458 # Bar graphic
459
460 # Make sure that negative i_left and i_width don't
461 # overflow the subject
462 if i_width > 0 && i_left <= options[:g_width]
463 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ i_width }px;' class='task milestone_todo'>&nbsp;</div>"
464 end
465 if l_width > 0 && i_left <= options[:g_width]
466 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ l_width }px;' class='task milestone_late'>&nbsp;</div>"
467 end
468 if d_width > 0 && i_left <= options[:g_width]
469 output<< "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ d_width }px;' class='task milestone_done'>&nbsp;</div>"
470 end
471
472
473 # Starting diamond
474 if start_left <= options[:g_width] && start_left > 0
475 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:15px;' class='task milestone starting'>&nbsp;</div>"
476 output << "<div style='top:#{ options[:top] }px;left:#{ start_left + 12 }px;background:#fff;' class='task'>"
477 output << "</div>"
478 end
479
480 # Ending diamond
481 # Don't show items too far ahead
482 if i_left <= options[:g_width] && i_end > 0
483 output << "<div style='top:#{ options[:top] }px;left:#{ i_end }px;width:15px;' class='task milestone ending'>&nbsp;</div>"
484 end
485
486 # Display the Version name and %
487 if i_end <= options[:g_width]
488 # Display the status even if it's floated off to the left
489 status_px = i_end + 12 # 12px for the diamond
490 status_px = 0 if status_px <= 0
491
492 output << "<div style='top:#{ options[:top] }px;left:#{ status_px }px;' class='task label version-name'>"
493 output << h("#{version.project} -") unless @project && @project == version.project
494 output << "<strong>#{h version } #{h version.completed_pourcent.to_i.to_s}%</strong>"
495 output << "</div>"
496 end
497 @lines << output
443 @lines << output
498 output
444 output
499 when :image
445 when :image
@@ -1017,6 +963,15 module Redmine
1017 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>"
963 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>"
1018 end
964 end
1019 end
965 end
966 # Renders the markers
967 if options[:markers]
968 if coords[:start]
969 output << "<div style='top:#{ top }px;left:#{ coords[:start] }px;width:15px;' class='#{options[:css]} marker starting'>&nbsp;</div>"
970 end
971 if coords[:end]
972 output << "<div style='top:#{ top }px;left:#{ coords[:end] }px;width:15px;' class='#{options[:css]} marker ending'>&nbsp;</div>"
973 end
974 end
1020 # Renders the label on the right
975 # Renders the label on the right
1021 if options[:label]
976 if options[:label]
1022 output << "<div style='top:#{ top }px;left:#{ (coords[:bar_end] || 0) + 5 }px;' class='#{options[:css]} label'>"
977 output << "<div style='top:#{ top }px;left:#{ (coords[:bar_end] || 0) + 5 }px;' class='#{options[:css]} label'>"
@@ -801,10 +801,11 background-image:url('../images/close_hl.png');
801 .task_todo.parent .left { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-left: -5px; left: 0px; top: -1px;}
801 .task_todo.parent .left { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-left: -5px; left: 0px; top: -1px;}
802 .task_todo.parent .right { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-right: -5px; right: 0px; top: -1px;}
802 .task_todo.parent .right { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-right: -5px; right: 0px; top: -1px;}
803
803
804 .milestone { background-image:url(../images/version_marker.png); background-repeat: no-repeat; border: 0; }
804 .version.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
805 .milestone_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
805 .version.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
806 .milestone_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
806 .version.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;}
807 .milestone_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;}
807 .version.marker { background-image:url(../images/version_marker.png); background-repeat: no-repeat; border: 0; }
808
808 .project-line { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; }
809 .project-line { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; }
809 .project_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
810 .project_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;}
810 .project_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
811 .project_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;}
@@ -225,10 +225,10 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
225
225
226 context "version" do
226 context "version" do
227 should "be rendered" do
227 should "be rendered" do
228 assert_select "div.milestone_todo"
228 assert_select "div.version.task_todo"
229 assert_select "div.milestone.starting"
229 assert_select "div.version.starting"
230 assert_select "div.milestone.ending"
230 assert_select "div.version.ending"
231 assert_select "div.label.version-name", /#{@version.name}/
231 assert_select "div.label.version", /#{@version.name}/
232 end
232 end
233 end
233 end
234
234
@@ -477,7 +477,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
477 :tracker => @tracker,
477 :tracker => @tracker,
478 :project => @project,
478 :project => @project,
479 :done_ratio => 30,
479 :done_ratio => 30,
480 :start_date => Date.yesterday,
480 :start_date => 1.week.ago.to_date,
481 :due_date => 1.week.from_now.to_date)
481 :due_date => 1.week.from_now.to_date)
482 end
482 end
483
483
@@ -485,12 +485,12 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
485 context "todo line" do
485 context "todo line" do
486 should "start from the starting point on the left" do
486 should "start from the starting point on the left" do
487 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
487 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
488 assert_select "div.milestone_todo[style*=left:52px]"
488 assert_select "div.version.task_todo[style*=left:28px]", true, @response.body
489 end
489 end
490
490
491 should "be the total width of the version" do
491 should "be the total width of the version" do
492 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
492 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
493 assert_select "div.milestone_todo[style*=width:31px]"
493 assert_select "div.version.task_todo[style*=width:58px]", true, @response.body
494 end
494 end
495
495
496 end
496 end
@@ -498,24 +498,24 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
498 context "late line" do
498 context "late line" do
499 should "start from the starting point on the left" do
499 should "start from the starting point on the left" do
500 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
500 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
501 assert_select "div.milestone_late[style*=left:52px]"
501 assert_select "div.version.task_late[style*=left:28px]", true, @response.body
502 end
502 end
503
503
504 should "be the total delayed width of the version" do
504 should "be the total delayed width of the version" do
505 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
505 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
506 assert_select "div.milestone_late[style*=width:6px]"
506 assert_select "div.version.task_late[style*=width:30px]", true, @response.body
507 end
507 end
508 end
508 end
509
509
510 context "done line" do
510 context "done line" do
511 should "start from the starting point on the left" do
511 should "start from the starting point on the left" do
512 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
512 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
513 assert_select "div.milestone_done[style*=left:52px]"
513 assert_select "div.version.task_done[style*=left:28px]", true, @response.body
514 end
514 end
515
515
516 should "Be the total done width of the version" do
516 should "Be the total done width of the version" do
517 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
517 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
518 assert_select "div.milestone_done[style*=left:52px]"
518 assert_select "div.version.task_done[style*=width:18px]", true, @response.body
519 end
519 end
520 end
520 end
521
521
@@ -525,12 +525,12 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
525 @gantt.instance_variable_set('@date_from', Date.today)
525 @gantt.instance_variable_set('@date_from', Date.today)
526
526
527 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
527 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
528 assert_select "div.milestone.starting", false
528 assert_select "div.version.starting", false
529 end
529 end
530
530
531 should "appear at the starting point" do
531 should "appear at the starting point" do
532 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
532 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
533 assert_select "div.milestone.starting[style*=left:52px]"
533 assert_select "div.version.starting[style*=left:28px]", true, @response.body
534 end
534 end
535 end
535 end
536
536
@@ -540,13 +540,13 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
540 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
540 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
541
541
542 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
542 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
543 assert_select "div.milestone.ending", false
543 assert_select "div.version.ending", false
544
544
545 end
545 end
546
546
547 should "appear at the end of the date range" do
547 should "appear at the end of the date range" do
548 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
548 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
549 assert_select "div.milestone.ending[style*=left:84px]"
549 assert_select "div.version.ending[style*=left:84px]", true, @response.body
550 end
550 end
551 end
551 end
552
552
@@ -555,17 +555,17 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase
555 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
555 @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date)
556
556
557 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
557 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
558 assert_select "div.version-name", /#{@version.name}/
558 assert_select "div.version.label", /#{@version.name}/
559 end
559 end
560
560
561 should "show the version name" do
561 should "show the version name" do
562 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
562 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
563 assert_select "div.version-name", /#{@version.name}/
563 assert_select "div.version.label", /#{@version.name}/
564 end
564 end
565
565
566 should "show the percent complete" do
566 should "show the percent complete" do
567 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
567 @response.body = @gantt.line_for_version(@version, {:format => :html, :zoom => 4})
568 assert_select "div.version-name", /30%/
568 assert_select "div.version.label", /30%/
569 end
569 end
570 end
570 end
571 end
571 end
General Comments 0
You need to be logged in to leave comments. Login now