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

respond with a turbo stream to a turbo request if there are any errors

as-op39cd21990429
diff --git a/app/helpers/work_packages_controller_helper.rb b/app/helpers/work_packages_controller_helper.rb
index b9a9f6f166e..79cf7eec9a0 100644
--- a/app/helpers/work_packages_controller_helper.rb
+++ b/app/helpers/work_packages_controller_helper.rb
@@ -55,13 +55,25 @@ module WorkPackagesControllerHelper
end
def load_and_validate_query
+ # rubocop:disable Rails/HelperInstanceVariable
@query ||= retrieve_query(@project)
@query.name = params[:title] if params[:title].present?
+ respond_query_error(@query.errors.full_messages.join(". ")) unless @query.valid?
+ # rubocop:enable Rails/HelperInstanceVariable
+ end
+
+ def respond_query_error(message)
+ respond_to do |format|
+ format.turbo_stream do
+ render_error_flash_message_via_turbo_stream(message:)
+ response.status = :unprocessable_entity
+ respond_with_turbo_streams
+ end
- unless @query.valid?
- # Ensure outputting an html response
- request.format = "html"
- render_400(message: @query.errors.full_messages.join(". "))
+ format.any do
+ request.format = "html"
+ render_400(message:)
+ end
end
end