From e2c224bb18b31a8dc1d5d54bbbc6591526d882f8 Mon Sep 17 00:00:00 2001 From: Yuichi HARADA Date: Tue, 16 Feb 2021 11:40:12 +0900 Subject: [PATCH 3/3] Identify the subject and taskbar line --- app/views/gantts/change_duration.js.erb | 9 ++++++++- lib/redmine/helpers/gantt.rb | 7 ++++++- public/javascripts/gantt.js | 10 ++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/views/gantts/change_duration.js.erb b/app/views/gantts/change_duration.js.erb index 26d1e8a60..113ee8c46 100644 --- a/app/views/gantts/change_duration.js.erb +++ b/app/views/gantts/change_duration.js.erb @@ -53,7 +53,14 @@ gantt.query = @query subject_content = subject_content.css(css_subject).to_s.tr("\n",'').gsub(/'/, "\\\\'") -%> if($('<%= elm_subject %>').length){ - $('<%= elm_todo %>').parent().html('<%= raw(todo_content) %>'); + $('<%= elm_todo %>').each(function(_, task) { + var el_parent = $(task).parent(); + el_parent.html('<%= raw(todo_content) %>'); + var number_of_rows = el_parent.attr('data-number-of-rows'); + if(number_of_rows){ + el_parent.find('div[data-number-of-rows]').attr('data-number-of-rows', number_of_rows); + } + }); $('<%= elm_subject %>').replaceWith('<%= raw(subject_content) %>'); <% case obj diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index ccc249fab..d9f25fc05 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -347,6 +347,7 @@ module Redmine if options[:format] == :html data_options = {} data_options[:collapse_expand] = "issue-#{issue.id}" + data_options[:number_of_rows] = number_of_rows style = "position: absolute;top: #{options[:top]}px; font-size: 0.8em;" content = view.content_tag( @@ -781,6 +782,7 @@ module Redmine :top_increment => params[:top_increment], :obj_id => "#{object.class}-#{object.id}".downcase, }, + :number_of_rows => number_of_rows, } end if has_children @@ -836,7 +838,10 @@ module Redmine def html_task(params, coords, markers, label, object) output = +'' data_options = {} - data_options[:collapse_expand] = "#{object.class}-#{object.id}".downcase if object + if object + data_options[:collapse_expand] = "#{object.class}-#{object.id}".downcase + data_options[:number_of_rows] = number_of_rows + end css = "task " + case object when Project diff --git a/public/javascripts/gantt.js b/public/javascripts/gantt.js index 2b292af76..d78da372a 100644 --- a/public/javascripts/gantt.js +++ b/public/javascripts/gantt.js @@ -255,13 +255,16 @@ ganttEntryClick = function(e){ subject.nextAll('div').each(function(_, element){ var el = $(element); var json = el.data('collapse-expand'); + var number_of_rows = el.data('number-of-rows'); + var el_task_bars = '#gantt_area form > div[data-collapse-expand="' + json.obj_id + '"][data-number-of-rows="' + number_of_rows + '"]'; + var el_selected_columns = 'td.gantt_selected_column div[data-collapse-expand="' + json.obj_id + '"][data-number-of-rows="' + number_of_rows + '"]'; if(out_of_hierarchy || parseInt(el.css('left')) <= subject_left){ out_of_hierarchy = true; if(target_shown == null) return false; var new_top_val = parseInt(el.css('top')) + total_height * (target_shown ? -1 : 1); el.css('top', new_top_val); - $('#gantt_area form > div[data-collapse-expand="' + json.obj_id + '"], td.gantt_selected_column div[data-collapse-expand="' + json.obj_id + '"]').each(function(_, el){ + $([el_task_bars, el_selected_columns].join()).each(function(_, el){ $(el).css('top', new_top_val); }); return true; @@ -274,15 +277,14 @@ ganttEntryClick = function(e){ total_height = 0; } if(is_shown == target_shown){ - $('#gantt_area form > div[data-collapse-expand="' + json.obj_id + '"]').each(function(_, task) { + $(el_task_bars).each(function(_, task) { var el_task = $(task); if(!is_shown) el_task.css('top', target_top + total_height); if(!el_task.hasClass('tooltip')) el_task.toggle(!is_shown); }); - $('td.gantt_selected_column div[data-collapse-expand="' + json.obj_id + '"]' - ).each(function (_, attr) { + $(el_selected_columns).each(function (_, attr) { var el_attr = $(attr); if (!is_shown) el_attr.css('top', target_top + total_height); -- 2.24.3 (Apple Git-128)