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

have project list export modal be loaded asynchronously

ulferts570478e31bf7
diff --git a/app/components/projects/export_list_modal_component.rb b/app/components/projects/export_list_modal_component.rb
index fa9099bb47b..28085a486ff 100644
--- a/app/components/projects/export_list_modal_component.rb
+++ b/app/components/projects/export_list_modal_component.rb
@@ -28,7 +28,8 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-class Projects::ExportListModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+class Projects::ExportListModalComponent < ApplicationComponent
+ include OpTurbo::Streamable
MODAL_ID = "op-project-list-export-dialog"
options :query
diff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erb
index 997a23469b0..9c5d8140a0d 100644
--- a/app/components/projects/index_page_header_component.html.erb
+++ b/app/components/projects/index_page_header_component.html.erb
@@ -122,8 +122,10 @@
end
menu.with_item(
+ tag: :a,
label: t('js.label_export'),
- content_arguments: { 'data-show-dialog-id': Projects::ExportListModalComponent::MODAL_ID }
+ href: export_list_modal_projects_path(projects_query_params),
+ content_arguments: { data: { controller: "async-dialog" } }
) do |item|
item.with_leading_visual_icon(icon: 'sign-out')
end
@@ -151,5 +153,4 @@
<% if show_state? %>
<%= render(Projects::ConfigureViewModalComponent.new(query:)) %>
<%= render(Projects::DeleteListModalComponent.new(query:)) if query.persisted? %>
- <%= render(Projects::ExportListModalComponent.new(query:)) %>
<% end %>
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 82223e5406b..9a953ba2973 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -30,19 +30,20 @@ class ProjectsController < ApplicationController
menu_item :overview
menu_item :roadmap, only: :roadmap
- before_action :find_project, except: %i[index new]
- before_action :load_query_or_deny_access, only: %i[index]
+ before_action :find_project, except: %i[index new export_list_modal]
+ before_action :load_query_or_deny_access, only: %i[index export_list_modal]
before_action :authorize, only: %i[copy deactivate_work_package_attachments]
before_action :authorize_global, only: %i[new]
before_action :require_admin, only: %i[destroy destroy_info]
- no_authorization_required! :index
+ no_authorization_required! :index, :export_list_modal
include SortHelper
include PaginationHelper
include QueriesHelper
include ProjectsHelper
include Projects::QueryLoading
+ include OpTurbo::DialogStreamHelper
helper_method :has_managed_project_folders?
@@ -105,6 +106,10 @@ class ProjectsController < ApplicationController
end
end
+ def export_list_modal
+ respond_with_dialog Projects::ExportListModalComponent.new(query: @query)
+ end
+
private
def has_managed_project_folders?(project)
diff --git a/app/models/project.rb b/app/models/project.rb
index 3d32c42eeef..cb377c6b5ad 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -44,7 +44,7 @@ class Project < ApplicationRecord
IDENTIFIER_MAX_LENGTH = 100
# reserved identifiers
- RESERVED_IDENTIFIERS = %w[new menu queries].freeze
+ RESERVED_IDENTIFIERS = %w[new menu queries export_list_modal].freeze
has_many :members, -> {
# TODO: check whether this should
diff --git a/config/routes.rb b/config/routes.rb
index c54e101879c..0e787b7d514 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -248,6 +248,10 @@ Rails.application.routes.draw do
post :deactivate_work_package_attachments
end
+ collection do
+ get :export_list_modal
+ end
+
resources :versions, only: %i[new create] do
collection do
put :close_completed
diff --git a/lookbook/docs/patterns/05-dialogs.md.erb b/lookbook/docs/patterns/05-dialogs.md.erb
index e39a97bd432..12e96903868 100644
--- a/lookbook/docs/patterns/05-dialogs.md.erb
+++ b/lookbook/docs/patterns/05-dialogs.md.erb
@@ -38,6 +38,18 @@ class TestController < ApplicationControler
end
```
+For this to work, the `OpTurbo::Streamable` module needs to be included in the modal component:
+
+```ruby
+class MyDialogComponent < ApplicationControler
+ # include the module
+ include OpTurbo::Streamable
+
+ # ...
+end
+```
+
+
Assuming the MyDialogComponent template looks like this:
```erb
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index b2df97acf8d..1c6237428b6 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -79,6 +79,14 @@ RSpec.describe ProjectsController do
end
end
+ describe "export_list_modal" do
+ it do
+ expect(get("/projects/export_list_modal")).to route_to(
+ controller: "projects", action: "export_list_modal"
+ )
+ end
+ end
+
describe "templated" do
it do
expect(delete("/projects/123/templated"))