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

alwp properties can be conditional in the wp table

Tobias Dillmannd089afad4538
diff --git a/app/models/queries/work_packages/selects/property_select.rb b/app/models/queries/work_packages/selects/property_select.rb
index b87940124c7..008c6e196a2 100644
--- a/app/models/queries/work_packages/selects/property_select.rb
+++ b/app/models/queries/work_packages/selects/property_select.rb
@@ -55,7 +55,16 @@ class Queries::WorkPackages::Selects::PropertySelect < Queries::WorkPackages::Se
association: "project_phase_definition",
group_by_column_name: "project_phase_definition",
sortable: "#{Project::PhaseDefinition.table_name}.position",
- groupable: "#{Project::PhaseDefinition.table_name}.id"
+ groupable: "#{Project::PhaseDefinition.table_name}.id",
+ only_if: ->(project) do
+ if project
+ OpenProject::FeatureDecisions.stages_and_gates_active? &&
+ User.current.allowed_in_project?(:view_project_phases, project)
+ else
+ OpenProject::FeatureDecisions.stages_and_gates_active? &&
+ User.current.allowed_in_any_project?(:view_project_phases)
+ end
+ end
},
parent: {
association: "ancestors_relations",
@@ -150,9 +159,13 @@ class Queries::WorkPackages::Selects::PropertySelect < Queries::WorkPackages::Se
}
}
- def self.instances(_context = nil)
- property_selects.map do |name, options|
- new(name, options)
+ def self.instances(context = nil)
+ property_selects.filter_map do |name, options|
+ condition = options[:only_if]
+
+ if !condition || condition.call(context)
+ new(name, options.except(:only_if))
+ end
end
end
end