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
Fix enumeration sorting links
Oliver Günther1c9318547f0d
diff --git a/app/components/enumerations/row_component.rb b/app/components/enumerations/row_component.rbindex 4b9230ade04..60dd4041ca9 100644--- a/app/components/enumerations/row_component.rb+++ b/app/components/enumerations/row_component.rb@@ -51,7 +51,7 @@ module Enumerationsenddef sort- helpers.reorder_links('enumeration', { action: 'update', id: enumeration }, method: :put)+ helpers.reorder_links('enumeration', { action: 'move', id: enumeration }, method: :post)enddef button_linksdiff --git a/app/components/enumerations/table_component.rb b/app/components/enumerations/table_component.rbindex 7283ed7597e..9d2ca664cb9 100644--- a/app/components/enumerations/table_component.rb+++ b/app/components/enumerations/table_component.rb@@ -38,6 +38,10 @@ module Enumerationsendend+ def sortable?+ false+ end+def headers[['name', { caption: Enumeration.human_attribute_name(:name) }],diff --git a/app/controllers/enumerations_controller.rb b/app/controllers/enumerations_controller.rbindex eaca5109b56..f72ea6235b3 100644--- a/app/controllers/enumerations_controller.rb+++ b/app/controllers/enumerations_controller.rb@@ -30,7 +30,7 @@ class EnumerationsController < ApplicationControllerlayout 'admin'before_action :require_admin- before_action :find_enumeration, only: %i[edit update destroy]+ before_action :find_enumeration, only: %i[edit update move destroy]include CustomFieldsHelper@@ -90,6 +90,16 @@ class EnumerationsController < ApplicationController@enumerations = @enumeration.class.all - [@enumeration]end+ def move+ if @enumeration.update(permitted_params.enumerations_move)+ flash[:notice] = I18n.t(:notice_successful_update)+ redirect_to enumerations_path+ else+ flash.now[:error] = I18n.t(:error_type_could_not_be_saved)+ render action: 'edit'+ end+ end+protecteddef default_breadcrumbdiff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rbindex 0eb47da4726..614c629acee 100644--- a/app/models/permitted_params.rb+++ b/app/models/permitted_params.rb@@ -240,6 +240,10 @@ class PermittedParamsparams.require(:type).permit(*self.class.permitted_attributes[:move_to])end+ def enumerations_move+ params.require(:enumeration).permit(*self.class.permitted_attributes[:move_to])+ end+def searchparams.permit(*self.class.permitted_attributes[:search])enddiff --git a/config/routes.rb b/config/routes.rbindex a84dc7af56f..c4fb99c4d53 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -352,7 +352,9 @@ OpenProject::Application.routes.draw dodelete 'enterprise/delete_trial_key' => 'enterprises#delete_trial_key'endend- resources :enumerations+ resources :enumerations do+ post 'move/:id', action: 'move', on: :collection+ enddelete 'design/logo' => 'custom_styles#logo_delete', as: 'custom_style_logo_delete'delete 'design/export_logo' => 'custom_styles#export_logo_delete', as: 'custom_style_export_logo_delete'