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

disable project custom field management through custom fields UI

Jonas Jabarif7f3b2b16b10
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb
index a9217b74da2..1c00b16886e 100644
--- a/app/controllers/custom_fields_controller.rb
+++ b/app/controllers/custom_fields_controller.rb
@@ -27,7 +27,7 @@
#++
class CustomFieldsController < ApplicationController
- include CustomFields::SharedActions
+ include CustomFields::SharedActions # share logic with ProjectCustomFieldsControlller
layout 'admin'
before_action :require_admin
@@ -37,7 +37,10 @@ class CustomFieldsController < ApplicationController
def index
# loading wp cfs exclicity to allow for eager loading
- @custom_fields_by_type = CustomField.all.where.not(type: 'WorkPackageCustomField').group_by { |f| f.class.name }
+ @custom_fields_by_type = CustomField.all
+ .where.not(type: 'WorkPackageCustomField')
+ .where.not(type: 'ProjectCustomField') # ProjecCustomFields now managed in a different UI
+ .group_by { |f| f.class.name }
@custom_fields_by_type['WorkPackageCustomField'] = WorkPackageCustomField.includes(:types).all
@tab = params[:tab] || 'WorkPackageCustomField'
@@ -46,13 +49,12 @@ class CustomFieldsController < ApplicationController
def new
@custom_field = new_custom_field
- if @custom_field.nil?
- flash[:error] = 'Invalid CF type'
- redirect_to action: :index
- end
+ check_custom_field
end
- def edit; end
+ def edit
+ check_custom_field
+ end
protected
@@ -73,4 +75,12 @@ class CustomFieldsController < ApplicationController
rescue ActiveRecord::RecordNotFound
render_404
end
+
+ def check_custom_field
+ if @custom_field.nil? || @custom_field.type == 'ProjectCustomField'
+ # ProjecCustomFields now managed in a different UI
+ flash[:error] = 'Invalid CF type'
+ redirect_to action: :index
+ end
+ end
end
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 09db112430e..8007f98c026 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -41,12 +41,13 @@ module CustomFieldsHelper
path: custom_fields_path(tab: :TimeEntryCustomField),
label: :label_spent_time
},
- {
- name: 'ProjectCustomField',
- partial: 'custom_fields/tab',
- path: custom_fields_path(tab: :ProjectCustomField),
- label: :label_project_plural
- },
+ # ProjecCustomFields now managed in a different UI
+ # {
+ # name: 'ProjectCustomField',
+ # partial: 'custom_fields/tab',
+ # path: custom_fields_path(tab: :ProjectCustomField),
+ # label: :label_project_plural
+ # },
{
name: 'VersionCustomField',
partial: 'custom_fields/tab',