Feature #12122 » gantt-progress-line-html-r10880.diff
app/views/gantts/show.html.erb | ||
---|---|---|
12 | 12 |
<%= render :partial => 'queries/filters', :locals => {:query => @query} %> |
13 | 13 |
</div> |
14 | 14 |
</fieldset> |
15 |
<fieldset id="filters" class="collapsible"> |
|
16 |
<legend onclick="toggleFieldset(this);"><%= l(:label_display) %></legend> |
|
17 |
<div> |
|
18 |
<label> |
|
19 |
<%= check_box_tag "draw_progress_line", 0, params[:draw_progress_line] %> |
|
20 |
<%= l(:label_gantt_progress_line) %> |
|
21 |
</label> |
|
22 |
</div> |
|
23 |
</fieldset> |
|
15 | 24 | |
16 | 25 |
<p class="contextual"> |
17 | 26 |
<%= gantt_zoom_link(@gantt, :in) %> |
config/locales/en.yml | ||
---|---|---|
889 | 889 |
label_cross_project_tree: With project tree |
890 | 890 |
label_cross_project_hierarchy: With project hierarchy |
891 | 891 |
label_cross_project_system: With all projects |
892 |
label_gantt_progress_line: Progress line |
|
892 | 893 | |
893 | 894 |
button_login: Login |
894 | 895 |
button_submit: Submit |
config/locales/ja.yml | ||
---|---|---|
840 | 840 |
label_git_report_last_commit: ファイルとディレクトリの最新コミットを表示する |
841 | 841 |
label_parent_revision: 親 |
842 | 842 |
label_child_revision: 子 |
843 |
label_gantt_progress_line: イナズマ線 |
|
843 | 844 | |
844 | 845 |
button_login: ログイン |
845 | 846 |
button_submit: 送信 |
lib/redmine/helpers/gantt.rb | ||
---|---|---|
289 | 289 |
html_class << 'icon icon-package ' |
290 | 290 |
html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " " |
291 | 291 |
html_class << (version.overdue? ? 'version-overdue' : '') |
292 |
html_class << ' version-closed' unless version.open? |
|
293 |
if version.start_date && version.due_date && version.completed_pourcent |
|
294 |
progress_date = calc_progress_date(version.start_date, |
|
295 |
version.due_date, version.completed_pourcent) |
|
296 |
html_class << ' behind-start-date' if progress_date < self.date_from |
|
297 |
html_class << ' over-end-date' if progress_date > self.date_to |
|
298 |
end |
|
292 | 299 |
s = view.link_to_version(version).html_safe |
293 | 300 |
subject = view.content_tag(:span, s, |
294 | 301 |
:class => html_class).html_safe |
295 |
html_subject(options, subject, :css => "version-name") |
|
302 |
html_subject(options, subject, :css => "version-name", |
|
303 |
:id => "version-#{version.id}") |
|
296 | 304 |
when :image |
297 | 305 |
image_subject(options, version.to_s_with_project) |
298 | 306 |
when :pdf |
... | ... | |
313 | 321 |
label = h("#{version.project} -") + label unless @project && @project == version.project |
314 | 322 |
case options[:format] |
315 | 323 |
when :html |
316 |
html_task(options, coords, :css => "version task", :label => label, :markers => true) |
|
324 |
html_task(options, coords, :css => "version task", |
|
325 |
:label => label, :markers => true, :version => version) |
|
317 | 326 |
when :image |
318 | 327 |
image_task(options, coords, :label => label, :markers => true, :height => 3) |
319 | 328 |
when :pdf |
... | ... | |
336 | 345 |
css_classes << ' issue-overdue' if issue.overdue? |
337 | 346 |
css_classes << ' issue-behind-schedule' if issue.behind_schedule? |
338 | 347 |
css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to |
348 |
css_classes << ' issue-closed' if issue.closed? |
|
349 |
if issue.start_date && issue.due_before && issue.done_ratio |
|
350 |
progress_date = calc_progress_date(issue.start_date, |
|
351 |
issue.due_before, issue.done_ratio) |
|
352 |
css_classes << ' behind-start-date' if progress_date < self.date_from |
|
353 |
css_classes << ' over-end-date' if progress_date > self.date_to |
|
354 |
end |
|
339 | 355 |
s = "".html_safe |
340 | 356 |
if issue.assigned_to.present? |
341 | 357 |
assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name |
... | ... | |
347 | 363 |
s << view.link_to_issue(issue).html_safe |
348 | 364 |
subject = view.content_tag(:span, s, :class => css_classes).html_safe |
349 | 365 |
html_subject(options, subject, :css => "issue-subject", |
350 |
:title => issue.subject) + "\n" |
|
366 |
:title => issue.subject, :id => "issue-#{issue.id}") + "\n"
|
|
351 | 367 |
when :image |
352 | 368 |
image_subject(options, issue.subject) |
353 | 369 |
when :pdf |
... | ... | |
610 | 626 |
coords[:bar_end] = self.date_to - self.date_from + 1 |
611 | 627 |
end |
612 | 628 |
if progress |
613 |
progress_date = start_date + (end_date - start_date + 1) * (progress / 100.0)
|
|
629 |
progress_date = calc_progress_date(start_date, end_date, progress)
|
|
614 | 630 |
if progress_date > self.date_from && progress_date > start_date |
615 | 631 |
if progress_date < self.date_to |
616 | 632 |
coords[:bar_progress_end] = progress_date - self.date_from |
... | ... | |
637 | 653 |
coords |
638 | 654 |
end |
639 | 655 | |
656 |
def calc_progress_date(start_date, end_date, progress) |
|
657 |
start_date + (end_date - start_date + 1) * (progress / 100.0) |
|
658 |
end |
|
659 | ||
640 | 660 |
# Sorts a collection of issues by start_date, due_date, id for gantt rendering |
641 | 661 |
def sort_issues!(issues) |
642 | 662 |
issues.sort! { |a, b| gantt_issue_compare(a, b) } |
... | ... | |
677 | 697 |
def html_subject(params, subject, options={}) |
678 | 698 |
style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;" |
679 | 699 |
style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width] |
680 |
output = view.content_tag('div', subject,
|
|
700 |
output = view.content_tag(:div, subject,
|
|
681 | 701 |
:class => options[:css], :style => style, |
682 |
:title => options[:title]) |
|
702 |
:title => options[:title], |
|
703 |
:id => options[:id]) |
|
683 | 704 |
@subjects << output |
684 | 705 |
output |
685 | 706 |
end |
... | ... | |
713 | 734 |
style << "top:#{params[:top]}px;" |
714 | 735 |
style << "left:#{coords[:bar_start]}px;" |
715 | 736 |
style << "width:#{width}px;" |
737 |
html_id = "task-todo-issue-#{options[:issue].id}" if options[:issue] |
|
738 |
html_id = "task-todo-version-#{options[:version].id}" if options[:version] |
|
716 | 739 |
output << view.content_tag(:div, ' '.html_safe, |
717 | 740 |
:style => style, |
718 |
:class => "#{options[:css]} task_todo") |
|
741 |
:class => "#{options[:css]} task_todo", |
|
742 |
:id => html_id) |
|
719 | 743 |
if coords[:bar_late_end] |
720 | 744 |
width = coords[:bar_late_end] - coords[:bar_start] - 2 |
721 | 745 |
style = "" |
... | ... | |
732 | 756 |
style << "top:#{params[:top]}px;" |
733 | 757 |
style << "left:#{coords[:bar_start]}px;" |
734 | 758 |
style << "width:#{width}px;" |
759 |
html_id = "task-done-issue-#{options[:issue].id}" if options[:issue] |
|
760 |
html_id = "task-done-version-#{options[:version].id}" if options[:version] |
|
735 | 761 |
output << view.content_tag(:div, ' '.html_safe, |
736 | 762 |
:style => style, |
737 |
:class => "#{options[:css]} task_done") |
|
763 |
:class => "#{options[:css]} task_done", |
|
764 |
:id => html_id) |
|
738 | 765 |
end |
739 | 766 |
end |
740 | 767 |
# Renders the markers |
app/views/gantts/show.html.erb | ||
---|---|---|
1 |
<% content_for :header_tags do %> |
|
2 |
<%= javascript_include_tag 'raphael' %> |
|
3 |
<%= javascript_include_tag 'gantt' %> |
|
4 |
<% end %> |
|
5 |
<%= javascript_tag do %> |
|
6 |
$(document).ready(drawGanttLinesHandler); |
|
7 |
$(window).resize(drawGanttLinesHandler); |
|
8 |
$(function() { |
|
9 |
$("#draw_progress_line").change(drawGanttLinesHandler); |
|
10 |
}); |
|
11 | ||
12 |
<% end %> |
|
1 | 13 |
<% @gantt.view = self %> |
2 | 14 |
<h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2> |
3 | 15 | |
... | ... | |
238 | 250 |
style += "width:10px;" |
239 | 251 |
style += "border-left: 1px dashed red;" |
240 | 252 |
%> |
241 |
<%= content_tag(:div, ' '.html_safe, :style => style) %> |
|
253 |
<%= content_tag(:div, ' '.html_safe, :style => style, :id => 'today_line') %>
|
|
242 | 254 |
<% end %> |
243 | ||
255 |
<% |
|
256 |
style = "" |
|
257 |
style += "position: absolute;" |
|
258 |
style += "height: #{g_height}px;" |
|
259 |
style += "top: #{headers_height + 1}px;" |
|
260 |
style += "left: 0px;" |
|
261 |
style += "width: #{g_width - 1}px;" |
|
262 |
%> |
|
263 |
<%= content_tag(:div, '', :style => style, :id => "gantt_draw_area") %> |
|
244 | 264 |
</div> |
245 | 265 |
</td> |
246 | 266 |
</tr> |
public/javascripts/gantt.js | ||
---|---|---|
1 |
var draw_gantt = null; |
|
2 |
var draw_top; |
|
3 |
var draw_right; |
|
4 | ||
5 |
function setDrawArea() { |
|
6 |
draw_top = $("#gantt_draw_area").position().top; |
|
7 |
draw_right = $("#gantt_draw_area").width(); |
|
8 |
} |
|
9 | ||
10 |
function getProgressLinesArray() { |
|
11 |
var arr = new Array(); |
|
12 |
var today_left = $('#today_line').position().left; |
|
13 |
arr.push({left: today_left, top: 0}); |
|
14 |
$.each($('div.issue-subject, div.version-name'), function(index, element) { |
|
15 |
var t = $(element).position().top - draw_top ; |
|
16 |
var h = ($(element).height() / 9); |
|
17 |
var element_top_upper = t - h; |
|
18 |
var element_top_center = t + (h * 3); |
|
19 |
var element_top_lower = t + (h * 8); |
|
20 |
var issue_closed = $(element).children('span').hasClass('issue-closed'); |
|
21 |
var version_closed = $(element).children('span').hasClass('version-closed'); |
|
22 |
if (issue_closed || version_closed) { |
|
23 |
arr.push({left: today_left, top: element_top_center}); |
|
24 |
} else { |
|
25 |
var issue_done = $("#task-done-" + $(element).attr("id")); |
|
26 |
var is_behind_start = $(element).children('span').hasClass('behind-start-date'); |
|
27 |
var is_over_end = $(element).children('span').hasClass('over-end-date'); |
|
28 |
if (is_over_end) { |
|
29 |
arr.push({left: draw_right, top: element_top_upper, is_right_edge: true}); |
|
30 |
arr.push({left: draw_right, top: element_top_lower, is_right_edge: true, none_stroke: true}); |
|
31 |
} else if (issue_done.size() > 0) { |
|
32 |
var done_left = issue_done.first().position().left + |
|
33 |
issue_done.first().width(); |
|
34 |
arr.push({left: done_left, top: element_top_center}); |
|
35 |
} else if (is_behind_start) { |
|
36 |
arr.push({left: 0 , top: element_top_upper, is_left_edge: true}); |
|
37 |
arr.push({left: 0 , top: element_top_lower, is_left_edge: true, none_stroke: true}); |
|
38 |
} else { |
|
39 |
var todo_left = today_left; |
|
40 |
var issue_todo = $("#task-todo-" + $(element).attr("id")); |
|
41 |
if (issue_todo.size() > 0){ |
|
42 |
todo_left = issue_todo.first().position().left; |
|
43 |
} |
|
44 |
arr.push({left: Math.min(today_left, todo_left), top: element_top_center}); |
|
45 |
} |
|
46 |
} |
|
47 |
}); |
|
48 |
return arr; |
|
49 |
} |
|
50 | ||
51 |
function drawGanttLines() { |
|
52 |
var arr = getProgressLinesArray(); |
|
53 |
var i; |
|
54 |
for(i = 1 ; i < arr.length ; i++) { |
|
55 |
if (!("none_stroke" in arr[i]) && |
|
56 |
(!("is_right_edge" in arr[i - 1] && "is_right_edge" in arr[i]) && |
|
57 |
!("is_left_edge" in arr[i - 1] && "is_left_edge" in arr[i])) |
|
58 |
) { |
|
59 |
draw_gantt.path(["M", arr[i - 1].left, arr[i - 1].top, |
|
60 |
"L", arr[i].left, arr[i].top]) |
|
61 |
.attr({stroke: "#ff0000", "stroke-width": 2}); |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 | ||
66 |
function drawGanttLinesHandler() { |
|
67 |
var folder = document.getElementById('gantt_draw_area'); |
|
68 |
if(draw_gantt != null) |
|
69 |
draw_gantt.clear(); |
|
70 |
else |
|
71 |
draw_gantt = Raphael(folder); |
|
72 |
setDrawArea(); |
|
73 |
if ($("#draw_progress_line").attr('checked')) |
|
74 |
drawGanttLines(); |
|
75 |
} |