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
Close with turbo stream
Oliver Günther6a93033325b8
diff --git a/app/components/work_packages/details/tab_component.html.erb b/app/components/work_packages/details/tab_component.html.erbindex 80381b7e1ef..0bee0932f43 100644--- a/app/components/work_packages/details/tab_component.html.erb+++ b/app/components/work_packages/details/tab_component.html.erb@@ -29,7 +29,8 @@flex.with_column(classes: "op-work-package-details-tab-component--action") dorender(Primer::Beta::IconButton.new(icon: :x,tag: :a,- href: url_helpers.send(base_route),+ href: url_for(action: :close_split_view),+ data: { 'turbo-stream': true },scheme: :invisible,test_selector: "wp-details-tab-component--close",aria: { label: I18n.t(:button_close) }))diff --git a/app/controllers/concerns/work_packages/with_split_view.rb b/app/controllers/concerns/work_packages/with_split_view.rbnew file mode 100644index 00000000000..010f5c16caa--- /dev/null+++ b/app/controllers/concerns/work_packages/with_split_view.rb@@ -0,0 +1,52 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module WorkPackages+ module WithSplitView+ extend ActiveSupport::Concern++ def close_split_view+ id = params[:work_package_id].to_i++ respond_to do |format|+ format.turbo_stream { render turbo_stream: turbo_stream.remove("work-package-details-#{id}") }+ format.html { redirect_to public_send(params[:base_route]) }+ end+ 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", helpers.split_view_instance.render_in(view_context))+ end++ yield(format) if format_block+ end+ end+ end+enddiff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rbindex 9e8a54cfd8d..173b7b709cc 100644--- a/app/controllers/notifications_controller.rb+++ b/app/controllers/notifications_controller.rb@@ -27,10 +27,11 @@#++class NotificationsController < ApplicationController- include WorkPackages::SplitViewHelper+ include WorkPackages::WithSplitView+before_action :require_loginbefore_action :filtered_query, only: :mark_all_read- no_authorization_required! :index, :split_view, :mark_all_read, :date_alerts, :share_upsale+ no_authorization_required! :index, :split_view, :close_split_view, :mark_all_read, :date_alerts, :share_upsaledef indexrender_notifications_layoutdiff --git a/app/helpers/work_packages/split_view_helper.rb b/app/helpers/work_packages/split_view_helper.rbindex 4f5a901dcd5..4f2d12e138d 100644--- a/app/helpers/work_packages/split_view_helper.rb+++ b/app/helpers/work_packages/split_view_helper.rb@@ -12,14 +12,4 @@ module WorkPackages::SplitViewHelpertab: 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- endenddiff --git a/config/routes.rb b/config/routes.rbindex e5ad775555e..6d522e2ab95 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -707,6 +707,11 @@ Rails.application.routes.draw doas: :details,work_package_split_view: true,base_route: options.fetch(:base_route)++ get "/:work_package_id/close",+ on: :collection,+ action: :close_split_view,+ base_route: options.fetch(:base_route)endresources :notifications, only: :index dodiff --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.tsindex d55a8285af7..479677996cd 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@@ -233,7 +233,7 @@ export class IanCenterService extends UntilDestroyedMixin {openSplitScreen(workPackageId:string, tabIdentifier:string = 'activity'):void {const link = this.pathHelper.notificationsDetailsPath(workPackageId, tabIdentifier) + window.location.search;- Turbo.visit(link, { acceptsStreamResponse: true } as never);+ Turbo.visit(link, { action: 'replace', acceptsStreamResponse: true } as never);}openFullView(workPackageId:string|null):void {