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

Load split view as turbo stream

Oliver Günthere96bd37bbd4d
diff --git a/app/components/work_packages/split_view_component.html.erb b/app/components/work_packages/split_view_component.html.erb
index 50d4b612881..850b970171e 100644
--- a/app/components/work_packages/split_view_component.html.erb
+++ b/app/components/work_packages/split_view_component.html.erb
@@ -1,6 +1,6 @@
<%=
- content_tag("turbo-frame", id: "work-package-details-#{@id}") do
- flex_layout(h: :full, classes: "op-work-package-split-view-component") do |flex|
+ component_wrapper(class: "op-work-package-split-view") do
+ flex_layout(h: :full) do |flex|
if @work_package.nil?
flex.with_row do
render(Primer::Beta::Blankslate.new(spacious: true)) do |component|
diff --git a/app/components/work_packages/split_view_component.rb b/app/components/work_packages/split_view_component.rb
index 5946b80cd7b..26a84335524 100644
--- a/app/components/work_packages/split_view_component.rb
+++ b/app/components/work_packages/split_view_component.rb
@@ -4,6 +4,8 @@ class WorkPackages::SplitViewComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include OpTurbo::Streamable
+ def self.wrapper_key = :"work-package-details"
+
def initialize(id:, base_route:, tab: "overview")
super
@@ -12,4 +14,8 @@ class WorkPackages::SplitViewComponent < ApplicationComponent
@work_package = WorkPackage.visible.find_by(id:)
@base_route = base_route
end
+
+ def wrapper_uniq_by
+ @id
+ end
end
diff --git a/app/components/work_packages/split_view_component.sass b/app/components/work_packages/split_view_component.sass
index 58d4d72b305..7ba29b5b211 100644
--- a/app/components/work_packages/split_view_component.sass
+++ b/app/components/work_packages/split_view_component.sass
@@ -1,4 +1,5 @@
-.op-work-package-split-view-component
+.op-work-package-split-view
+ height: 100%
justify-content: space-around
border-left: 1px solid var(--borderColor-muted)
border-top: 1px solid var(--borderColor-muted)
diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb
index 742ce9f8e9f..9e8a54cfd8d 100644
--- a/app/controllers/notifications_controller.rb
+++ b/app/controllers/notifications_controller.rb
@@ -27,6 +27,7 @@
#++
class NotificationsController < ApplicationController
+ include WorkPackages::SplitViewHelper
before_action :require_login
before_action :filtered_query, only: :mark_all_read
no_authorization_required! :index, :split_view, :mark_all_read, :date_alerts, :share_upsale
@@ -36,7 +37,7 @@ class NotificationsController < ApplicationController
end
def split_view
- respond_to do |format|
+ respond_to_with_split_view do |format|
format.html do
render :index, layout: "notifications"
end
diff --git a/app/helpers/work_packages/split_view_helper.rb b/app/helpers/work_packages/split_view_helper.rb
index c41f29ad96b..4f5a901dcd5 100644
--- a/app/helpers/work_packages/split_view_helper.rb
+++ b/app/helpers/work_packages/split_view_helper.rb
@@ -3,9 +3,23 @@ module WorkPackages::SplitViewHelper
return unless params[:work_package_split_view]
content_for :content_body_right do
- render WorkPackages::SplitViewComponent.new(id: params[:work_package_id],
- tab: params[:tab],
- base_route: params[:base_route] || work_packages_path)
+ render split_view_instance
+ end
+ end
+
+ def split_view_instance
+ WorkPackages::SplitViewComponent.new(id: params[:work_package_id],
+ tab: params[:tab],
+ base_route: params[:base_route] || work_packages_path)
+ end
+
+ def respond_to_with_split_view(&format_block)
+ respond_to do |format|
+ format.turbo_stream do
+ render turbo_stream: turbo_stream.update("content-bodyRight", split_view_instance.render_in(view_context))
+ end
+
+ yield(format) if format_block
end
end
end
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index afca3f0a3dc..5a4c30dcba1 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -153,11 +153,9 @@ See COPYRIGHT and LICENSE files for more details.
<%= yield %>
<% end %>
</div>
- <% if content_for?(:content_body_right) %>
- <div id="content-bodyRight">
- <%= content_for :content_body_right %>
- </div>
- <% end %>
+ <div id="content-bodyRight">
+ <%= content_for :content_body_right %>
+ </div>
<% end %>
</main>
</div>
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 4b9bb11b2a7..d55a8285af7 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -232,7 +232,8 @@ export class IanCenterService extends UntilDestroyedMixin {
}
openSplitScreen(workPackageId:string, tabIdentifier:string = 'activity'):void {
- window.location.href = this.pathHelper.notificationsDetailsPath(workPackageId, tabIdentifier) + window.location.search;
+ const link = this.pathHelper.notificationsDetailsPath(workPackageId, tabIdentifier) + window.location.search;
+ Turbo.visit(link, { acceptsStreamResponse: true } as never);
}
openFullView(workPackageId:string|null):void {
diff --git a/frontend/src/global_styles/layout/_base.sass b/frontend/src/global_styles/layout/_base.sass
index d1f4077b3ab..de5029c31be 100644
--- a/frontend/src/global_styles/layout/_base.sass
+++ b/frontend/src/global_styles/layout/_base.sass
@@ -131,7 +131,6 @@ $left-space: 20px
#content-bodyRight
grid-area: bodyRight
padding: 0
- width: 580px
overflow: auto
@include styled-scroll-bar