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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Render start and end dates for predecessor relationships
Aaron Contreras8a3bb0a5ae56
diff --git a/app/components/work_package_relations_tab/relation_component.html.erb b/app/components/work_package_relations_tab/relation_component.html.erbindex fba5021d583..92a18553207 100644--- a/app/components/work_package_relations_tab/relation_component.html.erb+++ b/app/components/work_package_relations_tab/relation_component.html.erb@@ -70,11 +70,17 @@if should_display_start_and_end_dates?flex.with_row(flex_layout: true, justify_content: :flex_start, align_items: :center, style: "gap: 0.25rem;") do |start_and_end_dates_row|start_and_end_dates_row.with_column do- render(Primer::Beta::Octicon.new(icon: :calendar, color: :muted))+ icon = if follows?+ :calendar+ elsif precedes?+ :pin+ end++ render(Primer::Beta::Octicon.new(icon:, color: :muted))endstart_and_end_dates_row.with_column dorender(Primer::Beta::Text.new(color: :muted)) do- format_date(related_work_package.start_date) + " - " + format_date(related_work_package.due_date)+ "#{format_date(related_work_package.start_date)} - #{format_date(related_work_package.due_date)}"endendenddiff --git a/app/components/work_package_relations_tab/relation_component.rb b/app/components/work_package_relations_tab/relation_component.rbindex 19bf080a096..bfc0ecbbfd9 100644--- a/app/components/work_package_relations_tab/relation_component.rb+++ b/app/components/work_package_relations_tab/relation_component.rb@@ -46,6 +46,14 @@ class WorkPackageRelationsTab::RelationComponent < ApplicationComponentrelation.follows? || relation.precedes?end+ def follows?+ relation.relation_type_for(work_package) == Relation::TYPE_FOLLOWS+ end++ def precedes?+ relation.relation_type_for(work_package) == Relation::TYPE_PRECEDES+ end+def edit_pathif parent_child_relationship?raise NotImplementedError, "Children relationships are not editable"diff --git a/spec/features/work_packages/details/relations/primerized_relations_spec.rb b/spec/features/work_packages/details/relations/primerized_relations_spec.rbindex c77a6b2825b..ad245e3892c 100644--- a/spec/features/work_packages/details/relations/primerized_relations_spec.rb+++ b/spec/features/work_packages/details/relations/primerized_relations_spec.rb@@ -45,7 +45,7 @@ RSpec.describe "Primerized work package relations tab",let(:type1) { create(:type) }let(:type2) { create(:type) }- let(:to1) { create(:work_package, type: type1, project:) }+ let(:to1) { create(:work_package, type: type1, project:, start_date: Date.current, due_date: Date.current + 1.week) }let(:to2) { create(:work_package, type: type2, project:) }let(:to3) { create(:work_package, type: type1, project:) }let(:from1) { create(:work_package, type: type1, project:) }@@ -104,36 +104,62 @@ RSpec.describe "Primerized work package relations tab",scroll_to_element relations_panelexpect(page).to have_css(relations_panel_selector)- [relation1, relation2].each do |relation|- target = relation.to == work_package ? "from" : "to"- target_relation_type = target == "from" ? relation.reverse_type : relation.relation_type-- within(relations_panel) do- expect(page).to have_text(relation.to.type.name.upcase)- expect(page).to have_text(relation.to.id)- expect(page).to have_text(relation.to.status.name)- expect(page).to have_text(relation.to.subject)- # We reference the reverse type as the "from" node of the relation- # is the currently visited work package, and the "to" node is the- # relation target. From the current user's perspective on the work package's- # page, this is the "reverse" relation.- expect(page).to have_text(label_for_relation_type(target_relation_type))- end+ target = relation1.to == work_package ? "from" : "to"+ target_relation_type = target == "from" ? relation1.reverse_type : relation1.relation_type++ relation_row = relations_panel.find("[data-test-selector='op-relation-row-#{relation1.id}']")++ within(relations_panel) do+ # We reference the reverse type as the "from" node of the relation+ # is the currently visited work package, and the "to" node is the+ # relation target. From the current user's perspective on the work package's+ # page, this is the "reverse" relation.+ expect(page).to have_text(label_for_relation_type(target_relation_type))+ end+ within(relation_row) do+ expect(page).to have_text(relation1.to.type.name.upcase)+ expect(page).to have_text(relation1.to.id)+ expect(page).to have_text(relation1.to.status.name)+ expect(page).to have_text(relation1.to.subject)+ expect(page).to have_text(I18n.l(relation1.to.start_date))+ expect(page).to have_text(I18n.l(relation1.to.due_date))+ end++ relation_row = relations_panel.find("[data-test-selector='op-relation-row-#{relation2.id}']")++ within(relations_panel) do+ # We reference the reverse type as the "from" node of the relation+ # is the currently visited work package, and the "to" node is the+ # relation target. From the current user's perspective on the work package's+ # page, this is the "reverse" relation.+ expect(page).to have_text(label_for_relation_type(target_relation_type))+ end++ within(relation_row) do+ expect(page).to have_text(relation2.to.type.name.upcase)+ expect(page).to have_text(relation2.to.id)+ expect(page).to have_text(relation2.to.status.name)+ expect(page).to have_text(relation2.to.subject)endtarget = relation3.to == work_package ? "from" : "to"target_relation_type = target == "from" ? relation3.reverse_type : relation3.relation_type+ relation_row = relations_panel.find("[data-test-selector='op-relation-row-#{relation3.id}']")+within(relations_panel) do- expect(page).to have_text(relation3.to.type.name.upcase)- expect(page).to have_text(relation3.to.id)- expect(page).to have_text(relation3.to.status.name)- expect(page).to have_text(relation3.to.subject)# We reference the relation type as the "from" node of the relation# is not the currently visited work package. From the current user's# perspective on the work package's page, this is the "forward" relation.expect(page).to have_text(label_for_relation_type(target_relation_type))end++ within(relation_row) do+ expect(page).to have_text(relation3.to.type.name.upcase)+ expect(page).to have_text(relation3.to.id)+ expect(page).to have_text(relation3.to.status.name)+ expect(page).to have_text(relation3.to.subject)+ endendend