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

handle error in project custom fields controller move and drop actions

Ivan Kuchin4fcc08f9b2a4
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index 0a3a2848662..e6d25ed0066 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -114,29 +114,33 @@ module Admin::Settings
end
def move
- call = CustomFields::UpdateService.new(user: current_user, model: @custom_field).call(
+ result = CustomFields::UpdateService.new(user: current_user, model: @custom_field).call(
move_to: params[:move_to]&.to_sym
)
- if call.success?
+ if result.success?
update_sections_via_turbo_stream(project_custom_field_sections: @project_custom_field_sections)
else
- # TODO: handle error
+ render_error_flash_message_via_turbo_stream(
+ message: join_flash_messages(result.errors)
+ )
end
respond_with_turbo_streams
end
def drop
- call = ::ProjectCustomFields::DropService.new(user: current_user, project_custom_field: @custom_field).call(
+ result = ::ProjectCustomFields::DropService.new(user: current_user, project_custom_field: @custom_field).call(
target_id: params[:target_id],
position: params[:position]
)
- if call.success?
- drop_success_streams(call)
+ if result.success?
+ drop_success_streams(result)
else
- # TODO: handle error
+ render_error_flash_message_via_turbo_stream(
+ message: join_flash_messages(result.errors)
+ )
end
respond_with_turbo_streams