@@ -300,64 +300,10 module Redmine | |||||
300 |
|
300 | |||
301 | case options[:format] |
|
301 | case options[:format] | |
302 | when :html |
|
302 | when :html | |
303 | output = '' |
|
303 | coords = coordinates(project.start_date, project.due_date, project.completed_percent(:include_subprojects => true), options[:zoom]) | |
304 | i_left = ((project.start_date - self.date_from)*options[:zoom]).floor |
|
304 | label = "#{h project } #{h project.completed_percent(:include_subprojects => true).to_i.to_s}%" | |
305 |
|
305 | output = html_task(options[:top], coords, :css => "project task", :label => label, :markers => true) | ||
306 | start_date = project.start_date |
|
|||
307 | start_date ||= self.date_from |
|
|||
308 | start_left = ((start_date - self.date_from)*options[:zoom]).floor |
|
|||
309 |
|
||||
310 | i_end_date = ((project.due_date <= self.date_to) ? project.due_date : self.date_to ) |
|
|||
311 | i_done_date = start_date + ((project.due_date - start_date+1)* project.completed_percent(:include_subprojects => true)/100).floor |
|
|||
312 | i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date ) |
|
|||
313 | i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date ) |
|
|||
314 |
|
||||
315 | i_late_date = [i_end_date, Date.today].min if start_date < Date.today |
|
|||
316 | i_end = ((i_end_date - self.date_from) * options[:zoom]).floor |
|
|||
317 |
|
||||
318 | i_width = (i_end - i_left + 1).floor - 2 # total width of the issue (- 2 for left and right borders) |
|
|||
319 | d_width = ((i_done_date - start_date)*options[:zoom]).floor - 2 # done width |
|
|||
320 | l_width = i_late_date ? ((i_late_date - start_date+1)*options[:zoom]).floor - 2 : 0 # delay width |
|
|||
321 |
|
||||
322 | # Bar graphic |
|
|||
323 |
|
||||
324 | # Make sure that negative i_left and i_width don't |
|
|||
325 | # overflow the subject |
|
|||
326 | if i_end > 0 && i_left <= options[:g_width] |
|
|||
327 | output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ i_width }px;' class='task project_todo'> </div>" |
|
|||
328 | end |
|
|||
329 |
|
306 | |||
330 | if l_width > 0 && i_left <= options[:g_width] |
|
|||
331 | output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ l_width }px;' class='task project_late'> </div>" |
|
|||
332 | end |
|
|||
333 | if d_width > 0 && i_left <= options[:g_width] |
|
|||
334 | output<< "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ d_width }px;' class='task project_done'> </div>" |
|
|||
335 | end |
|
|||
336 |
|
||||
337 |
|
||||
338 | # Starting diamond |
|
|||
339 | if start_left <= options[:g_width] && start_left > 0 |
|
|||
340 | output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:15px;' class='task project-line starting'> </div>" |
|
|||
341 | output << "<div style='top:#{ options[:top] }px;left:#{ start_left + 12 }px;' class='task label'>" |
|
|||
342 | output << "</div>" |
|
|||
343 | end |
|
|||
344 |
|
||||
345 | # Ending diamond |
|
|||
346 | # Don't show items too far ahead |
|
|||
347 | if i_end <= options[:g_width] && i_end > 0 |
|
|||
348 | output << "<div style='top:#{ options[:top] }px;left:#{ i_end }px;width:15px;' class='task project-line ending'> </div>" |
|
|||
349 | end |
|
|||
350 |
|
||||
351 | # DIsplay the Project name and % |
|
|||
352 | if i_end <= options[:g_width] |
|
|||
353 | # Display the status even if it's floated off to the left |
|
|||
354 | status_px = i_end + 12 # 12px for the diamond |
|
|||
355 | status_px = 0 if status_px <= 0 |
|
|||
356 |
|
||||
357 | output << "<div style='top:#{ options[:top] }px;left:#{ status_px }px;' class='task label project-name'>" |
|
|||
358 | output << "<strong>#{h project } #{h project.completed_percent(:include_subprojects => true).to_i.to_s}%</strong>" |
|
|||
359 | output << "</div>" |
|
|||
360 | end |
|
|||
361 | @lines << output |
|
307 | @lines << output | |
362 | output |
|
308 | output | |
363 | when :image |
|
309 | when :image |
@@ -791,6 +791,7 background-image:url('../images/close_hl.png'); | |||||
791 | } |
|
791 | } | |
792 |
|
792 | |||
793 | .task.label {width:100%;} |
|
793 | .task.label {width:100%;} | |
|
794 | .task.label.project, .task.label.version { font-weight: bold; } | |||
794 |
|
795 | |||
795 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } |
|
796 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } | |
796 | .task_done { background:#00c600 url(../images/task_done.png); border: 1px solid #00c600; } |
|
797 | .task_done { background:#00c600 url(../images/task_done.png); border: 1px solid #00c600; } | |
@@ -806,10 +807,10 background-image:url('../images/close_hl.png'); | |||||
806 | .version.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;} |
|
807 | .version.task_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 | .version.marker { background-image:url(../images/version_marker.png); background-repeat: no-repeat; border: 0; } | |
808 |
|
809 | |||
809 | .project-line { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; } |
|
810 | .project.task_late { background:#f66 url(../images/milestone_late.png); border: 1px solid #f66; height: 2px; margin-top: 3px;} | |
810 |
.project |
|
811 | .project.task_done { background:#00c600 url(../images/milestone_done.png); border: 1px solid #00c600; height: 2px; margin-top: 3px;} | |
811 |
.project_do |
|
812 | .project.task_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;} | |
812 | .project_todo { background:#fff url(../images/milestone_todo.png); border: 1px solid #fff; height: 2px; margin-top: 3px;} |
|
813 | .project.marker { background-image:url(../images/project_marker.png); background-repeat: no-repeat; border: 0; } | |
813 |
|
814 | |||
814 | .version-behind-schedule a, .issue-behind-schedule a {color: #f66914;} |
|
815 | .version-behind-schedule a, .issue-behind-schedule a {color: #f66914;} | |
815 | .version-overdue a, .issue-overdue a, .project-overdue a {color: #f00;} |
|
816 | .version-overdue a, .issue-overdue a, .project-overdue a {color: #f00;} |
@@ -216,10 +216,10 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
216 |
|
216 | |||
217 | context "project" do |
|
217 | context "project" do | |
218 | should "be rendered" do |
|
218 | should "be rendered" do | |
219 | assert_select "div.project_todo" |
|
219 | assert_select "div.project.task_todo" | |
220 |
assert_select "div.project |
|
220 | assert_select "div.project.starting" | |
221 |
assert_select "div.project |
|
221 | assert_select "div.project.ending" | |
222 |
assert_select "div.label.project |
|
222 | assert_select "div.label.project", /#{@project.name}/ | |
223 | end |
|
223 | end | |
224 | end |
|
224 | end | |
225 |
|
225 | |||
@@ -310,7 +310,7 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
310 | :tracker => @tracker, |
|
310 | :tracker => @tracker, | |
311 | :project => @project, |
|
311 | :project => @project, | |
312 | :done_ratio => 30, |
|
312 | :done_ratio => 30, | |
313 |
:start_date => |
|
313 | :start_date => 1.week.ago.to_date, | |
314 | :due_date => 1.week.from_now.to_date) |
|
314 | :due_date => 1.week.from_now.to_date) | |
315 | end |
|
315 | end | |
316 |
|
316 | |||
@@ -318,12 +318,12 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
318 | context "todo line" do |
|
318 | context "todo line" do | |
319 | should "start from the starting point on the left" do |
|
319 | should "start from the starting point on the left" do | |
320 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
320 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
321 |
assert_select "div.project_todo[style*=left: |
|
321 | assert_select "div.project.task_todo[style*=left:28px]", true, @response.body | |
322 | end |
|
322 | end | |
323 |
|
323 | |||
324 | should "be the total width of the project" do |
|
324 | should "be the total width of the project" do | |
325 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
325 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
326 |
assert_select "div.project_todo[style*=width: |
|
326 | assert_select "div.project.task_todo[style*=width:58px]", true, @response.body | |
327 | end |
|
327 | end | |
328 |
|
328 | |||
329 | end |
|
329 | end | |
@@ -331,24 +331,24 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
331 | context "late line" do |
|
331 | context "late line" do | |
332 | should "start from the starting point on the left" do |
|
332 | should "start from the starting point on the left" do | |
333 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
333 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
334 |
assert_select "div.project_late[style*=left: |
|
334 | assert_select "div.project.task_late[style*=left:28px]", true, @response.body | |
335 | end |
|
335 | end | |
336 |
|
336 | |||
337 | should "be the total delayed width of the project" do |
|
337 | should "be the total delayed width of the project" do | |
338 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
338 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
339 |
assert_select "div.project_late[style*=width: |
|
339 | assert_select "div.project.task_late[style*=width:30px]", true, @response.body | |
340 | end |
|
340 | end | |
341 | end |
|
341 | end | |
342 |
|
342 | |||
343 | context "done line" do |
|
343 | context "done line" do | |
344 | should "start from the starting point on the left" do |
|
344 | should "start from the starting point on the left" do | |
345 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
345 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
346 |
assert_select "div.project_done[style*=left: |
|
346 | assert_select "div.project.task_done[style*=left:28px]", true, @response.body | |
347 | end |
|
347 | end | |
348 |
|
348 | |||
349 | should "Be the total done width of the project" do |
|
349 | should "Be the total done width of the project" do | |
350 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
350 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
351 |
assert_select "div.project_done[style*= |
|
351 | assert_select "div.project.task_done[style*=width:18px]", true, @response.body | |
352 | end |
|
352 | end | |
353 | end |
|
353 | end | |
354 |
|
354 | |||
@@ -358,12 +358,12 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
358 | @gantt.instance_variable_set('@date_from', Date.today) |
|
358 | @gantt.instance_variable_set('@date_from', Date.today) | |
359 |
|
359 | |||
360 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
360 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
361 |
assert_select "div.project |
|
361 | assert_select "div.project.starting", false, @response.body | |
362 | end |
|
362 | end | |
363 |
|
363 | |||
364 | should "appear at the starting point" do |
|
364 | should "appear at the starting point" do | |
365 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
365 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
366 |
assert_select "div.project |
|
366 | assert_select "div.project.starting[style*=left:28px]", true, @response.body | |
367 | end |
|
367 | end | |
368 | end |
|
368 | end | |
369 |
|
369 | |||
@@ -373,13 +373,13 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
373 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
373 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | |
374 |
|
374 | |||
375 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
375 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
376 |
assert_select "div.project |
|
376 | assert_select "div.project.ending", false, @response.body | |
377 |
|
377 | |||
378 | end |
|
378 | end | |
379 |
|
379 | |||
380 | should "appear at the end of the date range" do |
|
380 | should "appear at the end of the date range" do | |
381 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
381 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
382 |
assert_select "div.project |
|
382 | assert_select "div.project.ending[style*=left:84px]", true, @response.body | |
383 | end |
|
383 | end | |
384 | end |
|
384 | end | |
385 |
|
385 | |||
@@ -388,17 +388,17 class Redmine::Helpers::GanttTest < ActiveSupport::TestCase | |||||
388 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) |
|
388 | @gantt.instance_variable_set('@date_to', 2.weeks.ago.to_date) | |
389 |
|
389 | |||
390 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
390 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
391 |
assert_select "div.project |
|
391 | assert_select "div.project.label", /#{@project.name}/ | |
392 | end |
|
392 | end | |
393 |
|
393 | |||
394 | should "show the project name" do |
|
394 | should "show the project name" do | |
395 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
395 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
396 |
assert_select "div.project |
|
396 | assert_select "div.project.label", /#{@project.name}/ | |
397 | end |
|
397 | end | |
398 |
|
398 | |||
399 | should "show the percent complete" do |
|
399 | should "show the percent complete" do | |
400 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) |
|
400 | @response.body = @gantt.line_for_project(@project, {:format => :html, :zoom => 4}) | |
401 |
assert_select "div.project |
|
401 | assert_select "div.project.label", /0%/ | |
402 | end |
|
402 | end | |
403 | end |
|
403 | end | |
404 | end |
|
404 | end |
General Comments 0
You need to be logged in to leave comments.
Login now