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
Refactored controller as suggested by @dombesz
Jonas Jabarie89446ea1a18
diff --git a/app/controllers/projects/settings/project_custom_fields_controller.rb b/app/controllers/projects/settings/project_custom_fields_controller.rbindex a95e86c5dd2..07dc498dfaa 100644--- a/app/controllers/projects/settings/project_custom_fields_controller.rb+++ b/app/controllers/projects/settings/project_custom_fields_controller.rb@@ -32,10 +32,7 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsContmenu_item :settings_project_custom_fields- before_action :eager_load_project_custom_field_sections, only: %i[show toggle enable_all_of_section disable_all_of_section]- before_action :eager_load_project_custom_fields, only: %i[show toggle enable_all_of_section disable_all_of_section]- before_action :eager_load_project_custom_field_project_mappings,- only: %i[show toggle enable_all_of_section disable_all_of_section]+ before_action :eager_load_project_custom_field_data, only: %i[show toggle enable_all_of_section disable_all_of_section]before_action :set_project_custom_field_section, only: %i[enable_all_of_section disable_all_of_section]@@ -58,7 +55,7 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsContcall = bulk_edit_service.call(action: :enable)if call.success?- eager_load_project_custom_field_project_mappings # reload mappings+ eager_load_project_custom_field_data # reload mappingsupdate_sections_via_turbo_stream # update all sections in order not to mess with stimulus target referenceselse@@ -72,7 +69,7 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsContcall = bulk_edit_service.call(action: :disable)if call.success?- eager_load_project_custom_field_project_mappings # reload mappings+ eager_load_project_custom_field_data # reload mappingsupdate_sections_via_turbo_stream # update all sections in order not to mess with stimulus target referenceselse@@ -84,19 +81,15 @@ class Projects::Settings::ProjectCustomFieldsController < Projects::SettingsContprivate- def eager_load_project_custom_field_sections+ def eager_load_project_custom_field_data@project_custom_field_sections = ProjectCustomFieldSection.all.to_a- end- def eager_load_project_custom_fields@project_custom_fields_grouped_by_section = ProjectCustomField.visible.includes(:project_custom_field_section).sort_by { |pcf| pcf.project_custom_field_section.position }.group_by(&:custom_field_section_id)- end- def eager_load_project_custom_field_project_mappings@project_custom_field_project_mappings = ProjectCustomFieldProjectMapping.where(project_id: @project.id).to_a