diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-04 12:07:17 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-04 12:07:17 +0000 |
commit | a925f9603d6b7df86cf7f19f4358c4eb355146f4 (patch) | |
tree | 1250fb2b86dcc73d0ae85edfd64caa6e54700a32 /lib | |
parent | 49b1aeee59d6d7eaa3504cde74d1954c92907086 (diff) | |
download | redmine-a925f9603d6b7df86cf7f19f4358c4eb355146f4.tar.gz redmine-a925f9603d6b7df86cf7f19f4358c4eb355146f4.zip |
Allow collapse/expand in gantt chart (#6417).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17925 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/helpers/gantt.rb | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 312a3133a..35323b0f9 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -195,6 +195,7 @@ module Redmine options = {:top => 0, :top_increment => 20, :indent_increment => 20, :render => :subject, :format => :html}.merge(options) + options[:indent_increment] += 12 if options[:format] == :html indent = options[:indent] || 4 @subjects = '' unless options[:only] == :lines @lines = '' unless options[:only] == :subjects @@ -221,7 +222,9 @@ module Redmine # then render project versions and their issues versions = project_versions(project) self.class.sort_versions!(versions) + indent = options[:indent] versions.each do |version| + options[:indent] = indent render_version(project, version, options) end end @@ -698,21 +701,38 @@ module Redmine end def html_subject(params, subject, object) - style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;" - style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width] content = html_subject_content(object) || subject - tag_options = {:style => style} + tag_options = {} case object when Issue tag_options[:id] = "issue-#{object.id}" tag_options[:class] = "issue-subject hascontextmenu" tag_options[:title] = object.subject + children = object.children & project_issues(object.project) + has_children = children.present? && (children.collect(&:fixed_version).uniq & [object.fixed_version]).present? when Version tag_options[:id] = "version-#{object.id}" tag_options[:class] = "version-name" + has_children = object.fixed_issues.exists? when Project tag_options[:class] = "project-name" + has_children = object.issues.exists? || object.versions.exists? + end + tag_options[:data] = { + :collapse_expand => { + :top_increment => params[:top_increment], + :obj_id => "#{object.class}-#{object.id}".downcase, + }, + } + if has_children + content = view.content_tag(:span, nil, :class => :expander) + content + params = params.dup + params[:indent] -= 12 if params[:indent] >= 12 + tag_options[:class] << ' open' end + style = "position: absolute;top:#{params[:top]}px;left:#{params[:indent]}px;" + style << "width:#{params[:subject_width] - params[:indent]}px;" if params[:subject_width] + tag_options[:style] = style output = view.content_tag(:div, content, tag_options) @subjects << output output @@ -751,6 +771,9 @@ module Redmine def html_task(params, coords, markers, label, object) output = '' + data_options = { + :collapse_expand => "#{object.class}-#{object.id}".downcase, + } css = "task " + case object when Project @@ -774,13 +797,15 @@ module Redmine html_id = "task-todo-version-#{object.id}" if object.is_a?(Version) content_opt = {:style => style, :class => "#{css} task_todo", - :id => html_id} + :id => html_id, + :data => {}} if object.is_a?(Issue) rels = issue_relations(object) if rels.present? content_opt[:data] = {"rels" => rels.to_json} end end + content_opt[:data].merge!(data_options) output << view.content_tag(:div, ' '.html_safe, content_opt) if coords[:bar_late_end] width = coords[:bar_late_end] - coords[:bar_start] - 2 @@ -790,7 +815,8 @@ module Redmine style << "width:#{width}px;" output << view.content_tag(:div, ' '.html_safe, :style => style, - :class => "#{css} task_late") + :class => "#{css} task_late", + :data => data_options) end if coords[:bar_progress_end] width = coords[:bar_progress_end] - coords[:bar_start] - 2 @@ -803,7 +829,8 @@ module Redmine output << view.content_tag(:div, ' '.html_safe, :style => style, :class => "#{css} task_done", - :id => html_id) + :id => html_id, + :data => data_options) end end # Renders the markers @@ -815,7 +842,8 @@ module Redmine style << "width:15px;" output << view.content_tag(:div, ' '.html_safe, :style => style, - :class => "#{css} marker starting") + :class => "#{css} marker starting", + :data => data_options) end if coords[:end] style = "" @@ -824,7 +852,8 @@ module Redmine style << "width:15px;" output << view.content_tag(:div, ' '.html_safe, :style => style, - :class => "#{css} marker ending") + :class => "#{css} marker ending", + :data => data_options) end end # Renders the label on the right @@ -835,7 +864,8 @@ module Redmine style << "width:15px;" output << view.content_tag(:div, label, :style => style, - :class => "#{css} label") + :class => "#{css} label", + :data => data_options) end # Renders the tooltip if object.is_a?(Issue) && coords[:bar_start] && coords[:bar_end] @@ -851,7 +881,8 @@ module Redmine style << "height:12px;" output << view.content_tag(:div, s.html_safe, :style => style, - :class => "tooltip hascontextmenu") + :class => "tooltip hascontextmenu", + :data => data_options) end @lines << output output |