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

Correct subproject activity items

Mir Bhatia29414f75d6fc
diff --git a/app/models/project.rb b/app/models/project.rb
index 56540350b29..15d38d18df4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -110,7 +110,7 @@ class Project < ApplicationRecord
register_journal_formatted_fields(:plaintext, 'name')
register_journal_formatted_fields(:diff, 'description')
register_journal_formatted_fields(:visibility, 'public')
- register_journal_formatted_fields(:subproject_named_association, 'parent_id') # Replace with custom for parent?
+ register_journal_formatted_fields(:subproject_named_association, 'parent_id')
register_journal_formatted_fields(:custom_field, /custom_fields_\d+/)
has_paper_trail
diff --git a/config/locales/en.yml b/config/locales/en.yml
index a313782ea87..58e56ba2fd5 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -544,6 +544,7 @@ en:
latest_activity_at: "Latest activity at"
parent: "Subproject of"
parent_without_of: "Subproject"
+ parent_no_longer: "No longer subproject of"
public_value:
title: "Visibility"
true: "public"
@@ -2844,6 +2845,7 @@ en:
text_journal_changed_no_detail: "%{label} updated"
text_journal_changed_with_diff: "%{label} changed (%{link})"
text_journal_deleted: "%{label} deleted (%{old})"
+ text_journal_deleted_custom_subproject: "%{label} (%{old})"
text_journal_deleted_with_diff: "%{label} deleted (%{link})"
text_journal_of: "%{label} %{value}"
text_journal_set_to: "%{label} set to %{value}"
diff --git a/lib/open_project/journal_formatter/subproject_named_association.rb b/lib/open_project/journal_formatter/subproject_named_association.rb
index be0f1bf516b..fa7895edf2e 100644
--- a/lib/open_project/journal_formatter/subproject_named_association.rb
+++ b/lib/open_project/journal_formatter/subproject_named_association.rb
@@ -29,9 +29,10 @@ class OpenProject::JournalFormatter::SubprojectNamedAssociation < JournalFormatt
private
def format_details(key, values, cache:)
- binding.pry
if values.first.nil?
label = label(key)
+ elsif values.last.nil?
+ label = I18n.t("activerecord.attributes.project.parent_no_longer")
else
label = I18n.t("activerecord.attributes.project.parent_without_of")
end
@@ -42,8 +43,7 @@ class OpenProject::JournalFormatter::SubprojectNamedAssociation < JournalFormatt
end
def render_ternary_detail_text(label, value, old_value, options)
- binding.pry
- return I18n.t(:text_journal_deleted, label:, old: old_value) if value.blank?
+ return I18n.t(:text_journal_deleted_custom_subproject, label:, old: old_value) if value.blank?
return I18n.t(:text_journal_of, label:, value:) if old_value.blank?
linebreak = should_linebreak?(old_value.to_s, value.to_s)
diff --git a/spec/models/journal/project_journal_spec.rb b/spec/models/journal/project_journal_spec.rb
index bde9d0fb5ef..8a42c6ba87f 100644
--- a/spec/models/journal/project_journal_spec.rb
+++ b/spec/models/journal/project_journal_spec.rb
@@ -66,7 +66,6 @@ RSpec.describe Journal::ProjectJournal do
end
it 'renders parent field correctly' do
- pending('need to update code')
parent = create(:project)
# Set
@@ -86,9 +85,9 @@ RSpec.describe Journal::ProjectJournal do
# Delete
expect(journal.render_detail(['parent_id', [parent.id, nil]], html: true))
- .to eq("<strong>Subproject of</strong> deleted (<strike><i>#{parent.name}</i></strike>)")
+ .to eq("<strong>No longer subproject of</strong> (<strike><i>#{parent.name}</i></strike>)")
expect(journal.render_detail(['parent_id', [parent.id, nil]], html: false))
- .to eq("Subproject of deleted (#{parent.name})")
+ .to eq("No longer subproject of (#{parent.name})")
end
end
end