diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 12:30:40 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-20 12:30:40 +0000 |
commit | 237f297f03e2f3fac6a41b3c0dadec6d85bcfb12 (patch) | |
tree | 20d3ca02e3460c34bd33549a32a7aba6b5f29e2a /public | |
parent | 30801ca96805a78016a625fefde9f99f51042c78 (diff) | |
download | redmine-237f297f03e2f3fac6a41b3c0dadec6d85bcfb12.tar.gz redmine-237f297f03e2f3fac6a41b3c0dadec6d85bcfb12.zip |
Gantt progress lines (#12122).
Patch by Toshi MARUYAMA.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11210 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r-- | public/javascripts/gantt.js | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/public/javascripts/gantt.js b/public/javascripts/gantt.js index 066a15884..295487c09 100644 --- a/public/javascripts/gantt.js +++ b/public/javascripts/gantt.js @@ -98,6 +98,66 @@ function drawRelations() { }); } +function getProgressLinesArray() { + var arr = new Array(); + var today_left = $('#today_line').position().left; + arr.push({left: today_left, top: 0}); + $.each($('div.issue-subject, div.version-name'), function(index, element) { + var t = $(element).position().top - draw_top ; + var h = ($(element).height() / 9); + var element_top_upper = t - h; + var element_top_center = t + (h * 3); + var element_top_lower = t + (h * 8); + var issue_closed = $(element).children('span').hasClass('issue-closed'); + var version_closed = $(element).children('span').hasClass('version-closed'); + if (issue_closed || version_closed) { + arr.push({left: today_left, top: element_top_center}); + } else { + var issue_done = $("#task-done-" + $(element).attr("id")); + var is_behind_start = $(element).children('span').hasClass('behind-start-date'); + var is_over_end = $(element).children('span').hasClass('over-end-date'); + if (is_over_end) { + arr.push({left: draw_right, top: element_top_upper, is_right_edge: true}); + arr.push({left: draw_right, top: element_top_lower, is_right_edge: true, none_stroke: true}); + } else if (issue_done.size() > 0) { + var done_left = issue_done.first().position().left + + issue_done.first().width(); + arr.push({left: done_left, top: element_top_center}); + } else if (is_behind_start) { + arr.push({left: 0 , top: element_top_upper, is_left_edge: true}); + arr.push({left: 0 , top: element_top_lower, is_left_edge: true, none_stroke: true}); + } else { + var todo_left = today_left; + var issue_todo = $("#task-todo-" + $(element).attr("id")); + if (issue_todo.size() > 0){ + todo_left = issue_todo.first().position().left; + } + arr.push({left: Math.min(today_left, todo_left), top: element_top_center}); + } + } + }); + return arr; +} + +function drawGanttProgressLines() { + var arr = getProgressLinesArray(); + var color = $("#today_line") + .css("border-left-color"); + var i; + for(i = 1 ; i < arr.length ; i++) { + if (!("none_stroke" in arr[i]) && + (!("is_right_edge" in arr[i - 1] && "is_right_edge" in arr[i]) && + !("is_left_edge" in arr[i - 1] && "is_left_edge" in arr[i])) + ) { + var x1 = (arr[i - 1].left == 0) ? 0 : arr[i - 1].left + draw_left; + var x2 = (arr[i].left == 0) ? 0 : arr[i].left + draw_left; + draw_gantt.path(["M", x1, arr[i - 1].top, + "L", x2, arr[i].top]) + .attr({stroke: color, "stroke-width": 2}); + } + } +} + function drawGanttHandler() { var folder = document.getElementById('gantt_draw_area'); if(draw_gantt != null) @@ -105,5 +165,8 @@ function drawGanttHandler() { else draw_gantt = Raphael(folder); setDrawArea(); - drawRelations(); + if ($("#draw_progress_line").attr('checked')) + drawGanttProgressLines(); + if ($("#draw_rels").attr('checked')) + drawRelations(); } |