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

Update available select fields that are displayed for the project filter and configuration.

Dombi Attilaeba129581b17
diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rb
index d1aa6fe6077..d178d0f0748 100644
--- a/app/models/project_custom_field.rb
+++ b/app/models/project_custom_field.rb
@@ -46,7 +46,16 @@ class ProjectCustomField < CustomField
if user.admin?
all
else
- where(visible: true)
+ allowed_project_ids = Project.allowed_to(User.current, :view_project_attributes).select(:id).arel
+
+ mapping_table = ProjectCustomFieldProjectMapping.arel_table
+ mapping_query = mapping_table.project(Arel.star)
+ .where(
+ mapping_table[:custom_field_id].eq(ProjectCustomField.arel_table[:id])
+ .and(mapping_table[:project_id].in(allowed_project_ids))
+ )
+
+ ProjectCustomField.where(visible: true).where(mapping_query.exists)
end
end