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

make journaling work

Ivan Kuchinf63e36a23d17
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 93f3b59c205..83c2627873d 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -50,8 +50,8 @@ class Journal < ApplicationRecord
register_journal_formatter OpenProject::JournalFormatter::MeetingStartTime
register_journal_formatter OpenProject::JournalFormatter::MeetingState
register_journal_formatter OpenProject::JournalFormatter::MeetingWorkPackageId
- register_journal_formatter OpenProject::JournalFormatter::ProjectLifeCycleStepActive
- register_journal_formatter OpenProject::JournalFormatter::ProjectLifeCycleStepDates
+ register_journal_formatter OpenProject::JournalFormatter::ProjectPhaseActive
+ register_journal_formatter OpenProject::JournalFormatter::ProjectPhaseDates
register_journal_formatter OpenProject::JournalFormatter::ProjectStatusCode
register_journal_formatter OpenProject::JournalFormatter::ScheduleManually
register_journal_formatter OpenProject::JournalFormatter::SubprojectNamedAssociation
diff --git a/app/models/journal/project_phase_journal.rb b/app/models/journal/project_phase_journal.rb
index e06515c8f54..d59771e9d90 100644
--- a/app/models/journal/project_phase_journal.rb
+++ b/app/models/journal/project_phase_journal.rb
@@ -33,8 +33,6 @@ class Journal::ProjectPhaseJournal < Journal::AssociatedJournal
belongs_to :phase, class_name: "Project::Phase"
- alias_attribute :date, :start_date
-
def date_range
start_date..end_date if start_date || end_date
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 7a3ac83f99f..75575e64e3f 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -146,8 +146,8 @@ class Project < ApplicationRecord
register_journal_formatted_fields "public", formatter_key: :visibility
register_journal_formatted_fields "parent_id", formatter_key: :subproject_named_association
register_journal_formatted_fields /custom_fields_\d+/, formatter_key: :custom_field
- register_journal_formatted_fields /^project_life_cycle_step_\d+_active$/, formatter_key: :project_life_cycle_step_active
- register_journal_formatted_fields /^project_life_cycle_step_\d+_date_range$/, formatter_key: :project_life_cycle_step_dates
+ register_journal_formatted_fields /^project_phase_\d+_active$/, formatter_key: :project_phase_active
+ register_journal_formatted_fields /^project_phase_\d+_date_range$/, formatter_key: :project_phase_dates
has_paper_trail
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0332c1d1e78..c659673f8b2 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1648,7 +1648,7 @@ en:
time_entry: "Spent time"
wiki_edit: "Wiki"
work_package: "Work packages"
- project_life_cycle_step:
+ project_phase:
activated: "activated"
deactivated: "deactivated"
added_date: "set to %{date}"
diff --git a/lib/open_project/journal_formatter/project_life_cycle_step_active.rb b/lib/open_project/journal_formatter/project_phase_active.rb
similarity index 88%
rename from lib/open_project/journal_formatter/project_life_cycle_step_active.rb
rename to lib/open_project/journal_formatter/project_phase_active.rb
index 0f43d0e433d..0fbda2b8136 100644
--- a/lib/open_project/journal_formatter/project_life_cycle_step_active.rb
+++ b/lib/open_project/journal_formatter/project_phase_active.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class OpenProject::JournalFormatter::ProjectLifeCycleStepActive < JournalFormatter::Base
+class OpenProject::JournalFormatter::ProjectPhaseActive < JournalFormatter::Base
def render(key, values, options = { html: true })
return if !values[0] == !values[1]
@@ -44,9 +44,9 @@ class OpenProject::JournalFormatter::ProjectLifeCycleStepActive < JournalFormatt
def activation_message(values:)
if values[1]
- I18n.t("activity.project_life_cycle_step.activated")
+ I18n.t("activity.project_phase.activated")
elsif values[0]
- I18n.t("activity.project_life_cycle_step.deactivated")
+ I18n.t("activity.project_phase.deactivated")
end
end
end
diff --git a/lib/open_project/journal_formatter/project_life_cycle_step_dates.rb b/lib/open_project/journal_formatter/project_phase_dates.rb
similarity index 75%
rename from lib/open_project/journal_formatter/project_life_cycle_step_dates.rb
rename to lib/open_project/journal_formatter/project_phase_dates.rb
index 97377781471..762210d4544 100644
--- a/lib/open_project/journal_formatter/project_life_cycle_step_dates.rb
+++ b/lib/open_project/journal_formatter/project_phase_dates.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class OpenProject::JournalFormatter::ProjectLifeCycleStepDates < JournalFormatter::Base
+class OpenProject::JournalFormatter::ProjectPhaseDates < JournalFormatter::Base
def render(key, values, options = { html: true })
step = Project::Phase.find(key[/\d+/])
@@ -43,20 +43,9 @@ class OpenProject::JournalFormatter::ProjectLifeCycleStepDates < JournalFormatte
private
def date_change_message(values:, step:, options:)
- case step
- when Project::Gate
- if values
- from, to = values.map { format_date(_1&.begin) }
+ from, to = values.map { format_date_range(_1) }
- format_date_change(from:, to:, options:)
- end
- when Project::Stage
- if values
- from, to = values.map { format_date_range(_1) }
-
- format_date_change(from:, to:, options:)
- end
- end
+ format_date_change(from:, to:, options:)
end
def format_date_range(date_range)
@@ -65,13 +54,13 @@ class OpenProject::JournalFormatter::ProjectLifeCycleStepDates < JournalFormatte
def format_date_change(from:, to:, options:)
if from && to
- I18n.t("activity.project_life_cycle_step.changed_date", from:, to:)
+ I18n.t("activity.project_phase.changed_date", from:, to:)
elsif to
- I18n.t("activity.project_life_cycle_step.added_date", date: to)
+ I18n.t("activity.project_phase.added_date", date: to)
elsif from
date = options[:html] ? content_tag("del", from) : from
- I18n.t("activity.project_life_cycle_step.removed_date", date:)
+ I18n.t("activity.project_phase.removed_date", date:)
end
end
end
diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
index 97223846139..4ea270efa6e 100644
--- a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
@@ -36,7 +36,7 @@ module JournalChanges
get_data_changes,
get_attachments_changes,
get_custom_fields_changes,
- get_project_life_cycle_steps_changes,
+ get_project_phases_changes,
get_file_links_changes,
get_agenda_items_changes
].compact
@@ -94,8 +94,8 @@ module JournalChanges
)
end
- def get_project_life_cycle_steps_changes
- return unless journable.respond_to?(:life_cycle_steps)
+ def get_project_phases_changes
+ return unless journable.respond_to?(:phases)
::Acts::Journalized::Differ::Association.new(
predecessor,
@@ -104,7 +104,7 @@ module JournalChanges
id_attribute: :phase_id
).multiple_attributes_changes(
%i[active date_range],
- key_prefix: "project_life_cycle_step"
+ key_prefix: "project_phase"
)
end
diff --git a/spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb b/spec/lib/open_project/journal_formatter/project_phase_active_spec.rb
similarity index 63%
rename from spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb
rename to spec/lib/open_project/journal_formatter/project_phase_active_spec.rb
index cfc8f1446eb..4b1e30cf3c2 100644
--- a/spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb
+++ b/spec/lib/open_project/journal_formatter/project_phase_active_spec.rb
@@ -30,7 +30,7 @@
require "spec_helper"
-RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepActive do
+RSpec.describe OpenProject::JournalFormatter::ProjectPhaseActive do
describe "#render" do
let(:key) { "project_life_cycle_step_#{step.id}_active" }
@@ -40,8 +40,6 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepActive do
allow(Project::Phase).to receive(:find).with(step.id.to_s).and_return(step)
end
- def date(day) = Date.new(2025, 1, day)
-
shared_examples "test result" do
context "with html output" do
let(:html) { true }
@@ -56,59 +54,22 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepActive do
end
end
- describe "for gate changes" do
- let(:step) { build_stubbed(:project_gate, definition:) }
- let(:definition) { build_stubbed(:project_phase_definition, name: "The Gate") }
-
- context "when activated" do
- let(:values) { [false, true] }
- let(:plain_result) { "The Gate activated" }
- let(:html_result) { "<strong>The Gate</strong> activated" }
-
- include_examples "test result"
- end
-
- context "when deactivated" do
- let(:values) { [true, false] }
- let(:plain_result) { "The Gate deactivated" }
- let(:html_result) { "<strong>The Gate</strong> deactivated" }
-
- include_examples "test result"
- end
-
- context "when no change between truthy values" do
- let(:values) { [true, true] }
- let(:plain_result) { nil }
- let(:html_result) { nil }
-
- include_examples "test result"
- end
-
- context "when no change between falsey values" do
- let(:values) { [nil, false] }
- let(:plain_result) { nil }
- let(:html_result) { nil }
-
- include_examples "test result"
- end
- end
-
- describe "for stage changes" do
+ describe "for phase changes" do
let(:step) { build_stubbed(:project_phase, definition:) }
- let(:definition) { build_stubbed(:project_phase_definition, name: "The Stage") }
+ let(:definition) { build_stubbed(:project_phase_definition, name: "The Phase") }
context "when activated" do
let(:values) { [false, true] }
- let(:plain_result) { "The Stage activated" }
- let(:html_result) { "<strong>The Stage</strong> activated" }
+ let(:plain_result) { "The Phase activated" }
+ let(:html_result) { "<strong>The Phase</strong> activated" }
include_examples "test result"
end
context "when deactivated" do
let(:values) { [true, false] }
- let(:plain_result) { "The Stage deactivated" }
- let(:html_result) { "<strong>The Stage</strong> deactivated" }
+ let(:plain_result) { "The Phase deactivated" }
+ let(:html_result) { "<strong>The Phase</strong> deactivated" }
include_examples "test result"
end
diff --git a/spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb b/spec/lib/open_project/journal_formatter/project_phase_dates_spec.rb
similarity index 61%
rename from spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb
rename to spec/lib/open_project/journal_formatter/project_phase_dates_spec.rb
index 586e40e635b..272f6b6b91e 100644
--- a/spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb
+++ b/spec/lib/open_project/journal_formatter/project_phase_dates_spec.rb
@@ -30,7 +30,7 @@
require "spec_helper"
-RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepDates do
+RSpec.describe OpenProject::JournalFormatter::ProjectPhaseDates do
describe "#render" do
let(:key) { "project_life_cycle_step_#{step.id}_date_range" }
@@ -56,67 +56,30 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepDates do
end
end
- describe "for gate changes" do
- let(:step) { build_stubbed(:project_gate, definition:) }
- let(:definition) { build_stubbed(:project_phase_definition, name: "The Gate") }
-
- context "when date added" do
- let(:values) { [nil, date(28)..] }
- let(:plain_result) { "The Gate set to 01/28/2025" }
- let(:html_result) { "<strong>The Gate</strong> set to 01/28/2025" }
-
- include_examples "test result"
- end
-
- context "when date changed" do
- let(:values) { [date(28).., date(29)..] }
- let(:plain_result) { "The Gate changed from 01/28/2025 to 01/29/2025" }
- let(:html_result) { "<strong>The Gate</strong> changed from 01/28/2025 to 01/29/2025" }
-
- include_examples "test result"
- end
-
- context "when date removed" do
- let(:values) { [date(28).., nil] }
- let(:plain_result) { "The Gate date deleted 01/28/2025" }
- let(:html_result) { "<strong>The Gate</strong> date deleted <del>01/28/2025</del>" }
-
- include_examples "test result"
- end
-
- context "when both dates absent" do
- let(:values) { [nil, nil] }
- let(:plain_result) { nil }
- let(:html_result) { nil }
-
- include_examples "test result"
- end
- end
-
- describe "for stage changes" do
+ describe "for phase changes" do
let(:step) { build_stubbed(:project_phase, definition:) }
- let(:definition) { build_stubbed(:project_phase_definition, name: "The Stage") }
+ let(:definition) { build_stubbed(:project_phase_definition, name: "The Phase") }
context "when date range added" do
let(:values) { [nil, date(28)..date(29)] }
- let(:plain_result) { "The Stage set to 01/28/2025 - 01/29/2025" }
- let(:html_result) { "<strong>The Stage</strong> set to 01/28/2025 - 01/29/2025" }
+ let(:plain_result) { "The Phase set to 01/28/2025 - 01/29/2025" }
+ let(:html_result) { "<strong>The Phase</strong> set to 01/28/2025 - 01/29/2025" }
include_examples "test result"
end
context "when date range changed" do
let(:values) { [date(28)..date(29), date(28)..date(30)] }
- let(:plain_result) { "The Stage changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
- let(:html_result) { "<strong>The Stage</strong> changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
+ let(:plain_result) { "The Phase changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
+ let(:html_result) { "<strong>The Phase</strong> changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
include_examples "test result"
end
context "when date range removed" do
let(:values) { [date(28)..date(29), nil] }
- let(:plain_result) { "The Stage date deleted 01/28/2025 - 01/29/2025" }
- let(:html_result) { "<strong>The Stage</strong> date deleted <del>01/28/2025 - 01/29/2025</del>" }
+ let(:plain_result) { "The Phase date deleted 01/28/2025 - 01/29/2025" }
+ let(:html_result) { "<strong>The Phase</strong> date deleted <del>01/28/2025 - 01/29/2025</del>" }
include_examples "test result"
end