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

Add acts_as_list to LifeCycleStep and Definition

Dombi Attilac5a3caa0469d
diff --git a/app/models/project/life_cycle_step.rb b/app/models/project/life_cycle_step.rb
index 5ad1d8dbed9..97f23f9339c 100644
--- a/app/models/project/life_cycle_step.rb
+++ b/app/models/project/life_cycle_step.rb
@@ -31,13 +31,14 @@ class Project::LifeCycleStep < ApplicationRecord
belongs_to :definition,
optional: false,
class_name: "Project::LifeCycleStepDefinition"
-
has_many :work_packages, inverse_of: :life_cycle_step, dependent: :nullify
attr_readonly :definition_id
validates :type, inclusion: { in: %w[Project::Stage Project::Gate], message: :must_be_a_stage_or_gate }
+ acts_as_list
+
def initialize(*args)
if instance_of? Project::LifeCycleStep
# Do not allow directly instantiating this class
diff --git a/app/models/project/life_cycle_step_definition.rb b/app/models/project/life_cycle_step_definition.rb
index 2006d38d6a9..7dadf61f992 100644
--- a/app/models/project/life_cycle_step_definition.rb
+++ b/app/models/project/life_cycle_step_definition.rb
@@ -32,12 +32,13 @@ class Project::LifeCycleStepDefinition < ApplicationRecord
foreign_key: :definition_id,
dependent: :destroy
has_many :projects, through: :life_cycle_steps
-
belongs_to :color, optional: false
validates :name, presence: true
validates :type, inclusion: { in: %w[Project::StageDefinition Project::GateDefinition], message: :must_be_a_stage_or_gate }
+ acts_as_list
+
def initialize(*args)
if instance_of? Project::LifeCycleStepDefinition
# Do not allow directly instantiating this class
diff --git a/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rb b/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rb
index 79ab5cbd037..a019e15c586 100644
--- a/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rb
+++ b/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rb
@@ -31,6 +31,7 @@ class CreateProjectLifeCycleStepDefinitions < ActiveRecord::Migration[7.1]
create_table :project_life_cycle_step_definitions do |t|
t.string :type
t.string :name
+ t.integer :position, default: 1, null: true
t.references :color, foreign_key: true
t.timestamps
diff --git a/db/migrate/20241105151352_create_project_life_cycle_steps.rb b/db/migrate/20241105151352_create_project_life_cycle_steps.rb
index cb4f7553b27..3858a90d66e 100644
--- a/db/migrate/20241105151352_create_project_life_cycle_steps.rb
+++ b/db/migrate/20241105151352_create_project_life_cycle_steps.rb
@@ -5,6 +5,7 @@ class CreateProjectLifeCycleSteps < ActiveRecord::Migration[7.1]
t.date :start_date
t.date :end_date
t.boolean :active, default: false, null: false
+ t.integer :position, default: 1, null: true
t.references :project, foreign_key: true
t.references :definition, foreign_key: { to_table: :project_life_cycle_step_definitions }