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
Base respond_with_dialog on OpTurbo::ComponentStream
Jan Sandbrinkef6fdb29d5ed
diff --git a/app/controllers/concerns/op_turbo/dialog_stream_helper.rb b/app/controllers/concerns/op_turbo/dialog_stream_helper.rbindex 0eec3f4f1eb..9dbfef59aa9 100644--- a/app/controllers/concerns/op_turbo/dialog_stream_helper.rb+++ b/app/controllers/concerns/op_turbo/dialog_stream_helper.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -29,13 +31,9 @@module OpTurbomodule DialogStreamHelperdef respond_with_dialog(dialog_component, status: :ok, &format_block)- respond_to do |format|- format.turbo_stream do- render turbo_stream: dialog_component.render_as_turbo_stream(view_context:, action: :dialog), status:- end+ modify_via_turbo_stream(component: dialog_component, action: :dialog, status:)- yield(format) if format_block- end+ respond_to_with_turbo_streams(&format_block)endendenddiff --git a/app/controllers/projects/settings/general_controller.rb b/app/controllers/projects/settings/general_controller.rbindex f4432d0bad9..2318c0f363b 100644--- a/app/controllers/projects/settings/general_controller.rb+++ b/app/controllers/projects/settings/general_controller.rb@@ -29,6 +29,7 @@#++class Projects::Settings::GeneralController < Projects::SettingsController+ include OpTurbo::ComponentStreaminclude OpTurbo::DialogStreamHelpermenu_item :settings_generaldiff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rbindex 55dc5234c2c..12e3c69d7a5 100644--- a/app/controllers/projects_controller.rb+++ b/app/controllers/projects_controller.rb@@ -28,6 +28,7 @@class ProjectsController < ApplicationControllerinclude OpTurbo::ComponentStream+ include OpTurbo::DialogStreamHelpermenu_item :overviewmenu_item :roadmap, only: :roadmap@@ -47,7 +48,6 @@ class ProjectsController < ApplicationControllerinclude QueriesHelperinclude ProjectsHelperinclude Queries::Loading- include OpTurbo::DialogStreamHelperhelper_method :has_managed_project_folders?diff --git a/lookbook/docs/patterns/05-dialogs.md.erb b/lookbook/docs/patterns/05-dialogs.md.erbindex b3cf7b675b6..c17d61aa34a 100644--- a/lookbook/docs/patterns/05-dialogs.md.erb+++ b/lookbook/docs/patterns/05-dialogs.md.erb@@ -28,7 +28,8 @@ The async-controller stimulus controller will ensure that a loading progress bar```rubyclass TestController < ApplicationControler- # include the helper module+ # include the helper modules+ include OpTurbo::ComponentStreaminclude OpTurbo::DialogStreamHelper# ...@@ -39,7 +40,7 @@ class TestController < ApplicationControlerend```-For this to work, the `OpTurbo::Streamable` module needs to be included in the modal component, along with the `OpTurbo::DialogStreamHelper` module in the corresponding controller:+For this to work, the `OpTurbo::Streamable` module needs to be included in the modal component, along with the `OpTurbo::DialogStreamHelper` and `OpTurbo::ComponentStream` modules in the corresponding controller:```rubyclass MyDialogComponent < ApplicationControler@@ -70,9 +71,6 @@ You can also render the dialog in a manual turbo_stream template:```rubyclass TestController < ApplicationControler- # include the helper module- include OpTurbo::DialogStreamHelper-# ...def dialog; end@@ -144,7 +142,8 @@ Referring to the example above (see "Dialogs with separate forms"), a controller```rubyclass TestController < ApplicationControler- # include the helper module+ # include the helper modules+ include OpTurbo::ComponentStreaminclude OpTurbo::DialogStreamHelper# ...