Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

change the attr name and set the selector on the row

Behrokh Satarnejadd00aea4eec26
diff --git a/app/components/work_package_relations_tab/index_component.html.erb b/app/components/work_package_relations_tab/index_component.html.erb
index 742eaca0820..cddd410e56b 100644
--- a/app/components/work_package_relations_tab/index_component.html.erb
+++ b/app/components/work_package_relations_tab/index_component.html.erb
@@ -55,8 +55,7 @@
<%=
flex_layout(mb: 3, data: {
"application-target": "dynamic",
- controller: "work-packages--relations-tab--scroll",
- "work-packages--relations-tab--scroll-target-id-value": @scroll_target_id,
+ controller: "work-packages--relations-tab--scroll"
}) do |flex|
if any_relations?
key_namespace = "#{I18N_NAMESPACE}.relations"
diff --git a/app/components/work_package_relations_tab/index_component.rb b/app/components/work_package_relations_tab/index_component.rb
index 91426bf1ed5..4822e594b57 100644
--- a/app/components/work_package_relations_tab/index_component.rb
+++ b/app/components/work_package_relations_tab/index_component.rb
@@ -9,16 +9,16 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
include Turbo::FramesHelper
include OpTurbo::Streamable
- attr_reader :work_package, :relations, :children, :directionally_aware_grouped_relations
+ attr_reader :work_package, :relations, :children, :directionally_aware_grouped_relations, :scroll_to_id
- def initialize(work_package:, relations:, children:, scroll_target_id: nil)
+ def initialize(work_package:, relations:, children:, scroll_to_id: nil)
super()
@work_package = work_package
@relations = relations
@children = children
@directionally_aware_grouped_relations = group_relations_by_directional_context
- @scroll_target_id = scroll_target_id
+ @scroll_to_id = scroll_to_id
end
def self.wrapper_key
@@ -62,7 +62,17 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
end
items.each do |item|
- border_box.with_row(test_selector: row_test_selector(item)) do
+ related_work_package_id = if item.is_a?(Relation)
+ item.from_id == work_package.id ? item.to_id : item.from_id
+ else
+ item.id
+ end
+
+ scroll_active = related_work_package_id.to_s == @scroll_to_id
+ border_box.with_row(
+ test_selector: row_test_selector(item),
+ data: { scroll_active: scroll_active }
+ ) do
yield(item)
end
end
diff --git a/app/controllers/work_package_children_controller.rb b/app/controllers/work_package_children_controller.rb
index a302af0fc4e..17cc55f9548 100644
--- a/app/controllers/work_package_children_controller.rb
+++ b/app/controllers/work_package_children_controller.rb
@@ -59,7 +59,7 @@ class WorkPackageChildrenController < ApplicationController
work_package: @work_package,
relations: @relations,
children: @children,
- scroll_target_id: target_work_package_id
+ scroll_to_id: target_work_package_id
)
replace_via_turbo_stream(component:)
update_flash_message_via_turbo_stream(
diff --git a/app/controllers/work_package_relations_controller.rb b/app/controllers/work_package_relations_controller.rb
index 6815f7c97e7..ca2b6bc06b4 100644
--- a/app/controllers/work_package_relations_controller.rb
+++ b/app/controllers/work_package_relations_controller.rb
@@ -65,7 +65,7 @@ class WorkPackageRelationsController < ApplicationController
component = WorkPackageRelationsTab::IndexComponent.new(work_package: @work_package,
relations: @work_package.relations,
children: @work_package.children,
- scroll_target_id: target_work_package_id)
+ scroll_to_id: target_work_package_id)
replace_via_turbo_stream(component:)
respond_with_turbo_streams
else