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
load project list destroy confirmation dialog asynchronously
ulferts1b342c555491
diff --git a/app/components/projects/delete_list_modal_component.rb b/app/components/projects/delete_list_modal_component.rbindex 8f2b2cb5af4..ef0720edd10 100644--- a/app/components/projects/delete_list_modal_component.rb+++ b/app/components/projects/delete_list_modal_component.rb@@ -28,7 +28,9 @@# See COPYRIGHT and LICENSE files for more details.# ++-class Projects::DeleteListModalComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+class Projects::DeleteListModalComponent < ApplicationComponent+ include OpTurbo::Streamable+MODAL_ID = "op-project-list-delete-dialog"options :querydiff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erbindex 0878c0e3d59..90cc33a83a6 100644--- a/app/components/projects/index_page_header_component.html.erb+++ b/app/components/projects/index_page_header_component.html.erb@@ -140,9 +140,11 @@if query.persisted?menu.with_item(+ tag: :a,label: t(:button_delete),scheme: :danger,- content_arguments: { 'data-show-dialog-id': Projects::DeleteListModalComponent::MODAL_ID }+ href: destroy_confirmation_modal_project_query_path(query.id),+ content_arguments: { data: { controller: "async-dialog" }}) do |item|item.with_leading_visual_icon(icon: 'trash')end@@ -153,5 +155,4 @@<% if show_state? %><%= render(Projects::ConfigureViewModalComponent.new(query:)) %>- <%= render(Projects::DeleteListModalComponent.new(query:)) if query.persisted? %><% end %>diff --git a/app/controllers/projects/queries_controller.rb b/app/controllers/projects/queries_controller.rbindex 3a1fcd3d5bd..53e1120e311 100644--- a/app/controllers/projects/queries_controller.rb+++ b/app/controllers/projects/queries_controller.rb@@ -29,11 +29,12 @@class Projects::QueriesController < ApplicationControllerinclude Projects::QueryLoadinginclude OpTurbo::ComponentStream+ 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+ no_authorization_required! :show, :new, :create, :rename, :update, :toggle_public, :destroy, :destroy_confirmation_modalbefore_action :require_login- before_action :find_query, only: %i[show rename update destroy toggle_public]+ 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]current_menu_item [:new, :rename, :create, :update] do@@ -101,6 +102,10 @@ class Projects::QueriesController < ApplicationControllerredirect_to projects_pathend+ def destroy_confirmation_modal+ respond_with_dialog Projects::DeleteListModalComponent.new(query: @query)+ end+privatedef render_result(service_call, success_i18n_key:, error_i18n_key:) # rubocop:disable Metrics/AbcSizediff --git a/config/routes.rb b/config/routes.rbindex 0e787b7d514..73f51106c09 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -202,6 +202,7 @@ Rails.application.routes.draw domember doget :renamepost :toggle_public+ get :destroy_confirmation_modalendenddiff --git a/spec/routing/project_queries_routing_spec.rb b/spec/routing/project_queries_routing_spec.rbindex 53e2dc4fefa..055e12d4658 100644--- a/spec/routing/project_queries_routing_spec.rb+++ b/spec/routing/project_queries_routing_spec.rb@@ -41,4 +41,9 @@ RSpec.describe "Project query routes" doexpect(delete("/project_queries/42")).to route_to("projects/queries#destroy",id: "42")end++ it "/project_queries/:id/destroy_confirmation_modal GET routes to projects/queries#destroy_confirmation_modal" do+ expect(get("/project_queries/42/destroy_confirmation_modal")).to route_to("projects/queries#destroy_confirmation_modal",+ id: "42")+ endend