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
Move following_phases to the Phase model.
Dombi Attilad84cac6c9a56
diff --git a/app/models/project/phase.rb b/app/models/project/phase.rbindex 5951d65b7f2..fc6587b2511 100644--- a/app/models/project/phase.rb+++ b/app/models/project/phase.rb@@ -85,10 +85,6 @@ class Project::Phase < ApplicationRecordDay.working.from_range(from: start_date, to: finish_date).countend- def follows_previous_phase?- !!previous_phase&.date_range_set?- end-def default_start_datereturn @default_start_date if defined?(@default_start_date)@@ -96,14 +92,23 @@ class Project::Phase < ApplicationRecord@default_start_date = previous_finish_date && Day.next_working(from: previous_finish_date).dateend- private+ def previous_phases+ return @previous_phases if defined?(@previous_phases)++ @previous_phases = project.available_phases.select { it.position < position }+ enddef previous_phase- return @previous_phase if defined?(@previous_phase)+ previous_phases.last+ end++ def follows_previous_phase?+ !!previous_phase&.date_range_set?+ end++ def following_phases+ return @following_phases if defined?(@following_phases)- @previous_phase = project- .available_phases- .select { it.position < position }- .last+ @following_phases = project.available_phases.select { it.position > position }endenddiff --git a/app/services/project_phases/update_service.rb b/app/services/project_phases/update_service.rbindex f9768126560..a62bf1b3a83 100644--- a/app/services/project_phases/update_service.rb+++ b/app/services/project_phases/update_service.rb@@ -44,15 +44,11 @@ module ProjectPhasesdef reschedule_following_phasesRescheduleService.new(user:, project:)- .call(phases: following_phases, from: initial_reschedule_date)+ .call(phases: model.following_phases, from: initial_reschedule_date)enddef initial_reschedule_datemodel.active? ? Day.next_working(from: model.finish_date).date : model.start_dateend-- def following_phases- project.available_phases.select { it.position > model.position }- endendend