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

update index component to send visibility to the relation component

Behrokh Satarnejad79eba9822665
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 fcedb75f462..ad2cddb2127 100644
--- a/app/components/work_package_relations_tab/index_component.html.erb
+++ b/app/components/work_package_relations_tab/index_component.html.erb
@@ -58,17 +58,25 @@
key_namespace = "#{I18N_NAMESPACE}.relations"
# Relations
- directionally_aware_grouped_relations.each do |relation_type, relations_of_type|
- base_key = "#{key_namespace}.label_#{relation_type}"
+ directionally_aware_grouped_relations.each do |relation_group|
+ base_key = "#{I18N_NAMESPACE}.relations.label_#{relation_group.type}"
+
+ # Combine visible and invisible relations into a single list
+ all_relations = relation_group.visible_relations.map { |r| [r, :visible] } +
+ relation_group.invisible_relations.map { |r| [r, :ghost] }
flex.with_row(mb: 4) do
render_relation_group(
title: t("#{base_key}_plural").capitalize,
- relation_type:,
- items: relations_of_type
- ) do |relation|
- render(WorkPackageRelationsTab::RelationComponent.new(work_package:,
- relation:))
+ relation_type: relation_group.type,
+ items: all_relations
+ ) do |relation, visibility|
+ # Render each relation with its visibility
+ render(WorkPackageRelationsTab::RelationComponent.new(
+ work_package: work_package,
+ relation: relation,
+ visibility: visibility
+ ))
end
end
end
@@ -85,7 +93,8 @@
) do |child|
render(WorkPackageRelationsTab::RelationComponent.new(work_package:,
relation: nil,
- child:))
+ child:,
+ visibility: :visible))
end
end
end
diff --git a/app/components/work_package_relations_tab/index_component.rb b/app/components/work_package_relations_tab/index_component.rb
index 63a4c316360..6a3b37d6bd3 100644
--- a/app/components/work_package_relations_tab/index_component.rb
+++ b/app/components/work_package_relations_tab/index_component.rb
@@ -15,10 +15,14 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
include Turbo::FramesHelper
include OpTurbo::Streamable
- attr_reader :relations_mediator, :directionally_aware_grouped_relations, :relation_to_scroll_to
-
- delegate :work_package, :relations, :children, :any_relations?, to: :relations_mediator
-
+ attr_reader :relations_mediator, :relation_to_scroll_to
+
+ delegate :work_package,
+ :visible_relations,
+ :children,
+ :directionally_aware_grouped_relations,
+ :any_relations?,
+ to: :relations_mediator
# Initialize the component with required data
#
# @param work_package [WorkPackage] The work package whose relations are being displayed
@@ -27,7 +31,6 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
super()
@relations_mediator = WorkPackageRelationsTab::RelationsMediator.new(work_package:)
- @directionally_aware_grouped_relations = group_relations_by_directional_context
@relation_to_scroll_to = relation_to_scroll_to
end
@@ -51,12 +54,6 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
should_render_add_child? || should_render_add_relations?
end
- def group_relations_by_directional_context
- relations.group_by do |relation|
- relation.relation_type_for(work_package)
- end
- end
-
def render_relation_group(title:, relation_type:, items:, &_block)
render(border_box_container(
padding: :condensed,
@@ -81,12 +78,12 @@ class WorkPackageRelationsTab::IndexComponent < ApplicationComponent
end
def render_items(border_box, items)
- items.each do |item|
+ items.each do |relation, visibility|
border_box.with_row(
- test_selector: row_test_selector(item),
- data: data_attribute(item)
+ test_selector: row_test_selector(relation),
+ data: data_attribute(relation)
) do
- yield(item)
+ yield(relation, visibility)
end
end
end