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

[#64220] Refactor tab controllers (#19383)

Yauheni Suhakou3aa73e4c2f7a
diff --git a/app/controllers/work_package_types/form_configuration_tab_controller.rb b/app/controllers/work_package_types/form_configuration_tab_controller.rb
index f5c4a2d655f..3edf8c3b1ef 100644
--- a/app/controllers/work_package_types/form_configuration_tab_controller.rb
+++ b/app/controllers/work_package_types/form_configuration_tab_controller.rb
@@ -29,15 +29,11 @@
#++
module WorkPackageTypes
- class FormConfigurationTabController < ApplicationController
+ class FormConfigurationTabController < BaseTabController
include PaginationHelper
layout "admin"
- before_action :require_admin
- before_action :find_type
- before_action :assign_tab, only: :update
-
current_menu_item [:edit, :update] do
:types
end
@@ -64,10 +60,6 @@ module WorkPackageTypes
show_error_not_found unless @type
end
- def assign_tab
- params[:tab] = "form_configuration" unless params[:tab]
- end
-
def permitted_type_params
# having to call #to_unsafe_h as a query hash the attribute_groups
# parameters would otherwise still be an ActiveSupport::Parameter
diff --git a/app/controllers/work_package_types/projects_tab_controller.rb b/app/controllers/work_package_types/projects_tab_controller.rb
index e99c1f54755..54695a4ad7c 100644
--- a/app/controllers/work_package_types/projects_tab_controller.rb
+++ b/app/controllers/work_package_types/projects_tab_controller.rb
@@ -45,7 +45,6 @@ module WorkPackageTypes
if result.success?
redirect_to edit_type_projects_path(type_id: @type.id), notice: I18n.t(:notice_successful_update)
else
- params[:tab] = "projects"
flash_error(result)
load_projects
render :edit, status: :unprocessable_entity
@@ -62,10 +61,6 @@ module WorkPackageTypes
@projects = Project.all
end
- def find_type
- @type = ::Type.find(params[:type_id])
- end
-
def permitted_project_params
# TODO: once the input is correctly delivered just return: params.expect(type: [:project_ids])
diff --git a/app/controllers/work_package_types/settings_tab_controller.rb b/app/controllers/work_package_types/settings_tab_controller.rb
index b67d362f34c..951a6ea4750 100644
--- a/app/controllers/work_package_types/settings_tab_controller.rb
+++ b/app/controllers/work_package_types/settings_tab_controller.rb
@@ -29,12 +29,9 @@
#++
module WorkPackageTypes
- class SettingsTabController < ApplicationController
+ class SettingsTabController < BaseTabController
layout "admin"
- before_action :require_admin
- before_action :find_type
-
current_menu_item %i[edit update] do
:types
end
@@ -48,17 +45,12 @@ module WorkPackageTypes
if result.success?
redirect_to edit_type_settings_path(type_id: @type.id), notice: I18n.t(:notice_successful_update)
else
- params[:tab] = "settings"
render :edit, status: :unprocessable_entity
end
end
private
- def find_type
- @type = ::Type.find(params[:type_id])
- end
-
def permitted_settings_params
params.expect(type: %i[name color_id description is_milestone is_in_roadmap is_default])
end