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 project list configure view dialog asynchronously

ulfertsef9b97b1577a
diff --git a/app/components/projects/configure_view_modal_component.rb b/app/components/projects/configure_view_modal_component.rb
index c28f9f92500..03dcf504b97 100644
--- a/app/components/projects/configure_view_modal_component.rb
+++ b/app/components/projects/configure_view_modal_component.rb
@@ -29,6 +29,8 @@
# ++
class Projects::ConfigureViewModalComponent < ApplicationComponent
+ include OpTurbo::Streamable
+
MODAL_ID = "op-project-list-configure-dialog"
QUERY_FORM_ID = "op-project-list-configure-query-form"
COLUMN_HTML_NAME = "columns"
diff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erb
index 90cc33a83a6..86d6d44f419 100644
--- a/app/components/projects/index_page_header_component.html.erb
+++ b/app/components/projects/index_page_header_component.html.erb
@@ -132,8 +132,10 @@
end
menu.with_item(
+ tag: :a,
label: t(:'queries.configure_view.heading'),
- content_arguments: { 'data-show-dialog-id': Projects::ConfigureViewModalComponent::MODAL_ID }
+ href: configure_view_modal_project_queries_path(projects_query_params),
+ content_arguments: { data: { controller: "async-dialog" }}
) do |item|
item.with_leading_visual_icon(icon: :gear)
end
@@ -152,7 +154,3 @@
end
end
%>
-
-<% if show_state? %>
- <%= render(Projects::ConfigureViewModalComponent.new(query:)) %>
-<% end %>
diff --git a/app/controllers/projects/queries_controller.rb b/app/controllers/projects/queries_controller.rb
index 53e1120e311..4f6dee45e5f 100644
--- a/app/controllers/projects/queries_controller.rb
+++ b/app/controllers/projects/queries_controller.rb
@@ -32,10 +32,11 @@ class Projects::QueriesController < ApplicationController
include OpTurbo::DialogStreamHelper
# No need for a more specific authorization check. That is carried out in the contracts.
- no_authorization_required! :show, :new, :create, :rename, :update, :toggle_public, :destroy, :destroy_confirmation_modal
- before_action :require_login
+ no_authorization_required! :show, :new, :create, :rename, :update, :toggle_public, :destroy, :destroy_confirmation_modal,
+ :configure_view_modal
+ before_action :require_login, except: %i[configure_view_modal]
before_action :find_query, only: %i[show rename update destroy toggle_public destroy_confirmation_modal]
- before_action :build_query_or_deny_access, only: %i[new create]
+ before_action :build_query_or_deny_access, only: %i[new create configure_view_modal]
current_menu_item [:new, :rename, :create, :update] do
:projects
@@ -106,6 +107,10 @@ class Projects::QueriesController < ApplicationController
respond_with_dialog Projects::DeleteListModalComponent.new(query: @query)
end
+ def configure_view_modal
+ respond_with_dialog Projects::ConfigureViewModalComponent.new(query: @query)
+ end
+
private
def render_result(service_call, success_i18n_key:, error_i18n_key:) # rubocop:disable Metrics/AbcSize
diff --git a/config/routes.rb b/config/routes.rb
index 73f51106c09..1c93c57b86d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -204,6 +204,10 @@ Rails.application.routes.draw do
post :toggle_public
get :destroy_confirmation_modal
end
+
+ collection do
+ get :configure_view_modal
+ end
end
namespace :projects do
diff --git a/spec/routing/project_queries_routing_spec.rb b/spec/routing/project_queries_routing_spec.rb
index 055e12d4658..a9e41688fac 100644
--- a/spec/routing/project_queries_routing_spec.rb
+++ b/spec/routing/project_queries_routing_spec.rb
@@ -46,4 +46,8 @@ RSpec.describe "Project query routes" do
expect(get("/project_queries/42/destroy_confirmation_modal")).to route_to("projects/queries#destroy_confirmation_modal",
id: "42")
end
+
+ it "/project_queries/:id/configure_view_modal GET routes to projects/queries#configure_view_modal" do
+ expect(get("/project_queries/configure_view_modal")).to route_to("projects/queries#configure_view_modal")
+ end
end