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
Replace project sections async dialog
Oliver Günther1c952f9d6976
diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erbnew file mode 100644index 00000000000..351f040878e--- /dev/null+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_component.html.erb@@ -0,0 +1,22 @@+<%=+ component_wrapper do+ primer_form_with(+ id: "project-section-edit-form",+ model: @project,+ method: :put,+ data: { turbo: true, turbo_stream: true, "test-selector": "async-dialog-content" },+ url: update_project_custom_values_path(project_id: @project.id, section_id: @project_custom_field_section.id),+ ) do |f|+ component_collection do |collection|+ collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3, classes: "Overlay-body_autocomplete_height")) do+ render(Projects::CustomFields::Form.new(+ f,+ project: @project,+ custom_field_section: @project_custom_field_section,+ wrapper_id: "#edit-project-custom-fields-dialog-#{@project_custom_field_section.id}"+ ))+ end+ end+ end+ end+%>diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_component.rb b/modules/overviews/app/components/project_custom_fields/sections/edit_component.rbnew file mode 100644index 00000000000..f4a6068f589--- /dev/null+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_component.rb@@ -0,0 +1,49 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 ProjectCustomFields+ module Sections+ class EditComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(project:,+ project_custom_field_section:)+ super++ @project = project+ @project_custom_field_section = project_custom_field_section+ end++ def wrapper_uniq_by+ @project_custom_field_section.id+ end+ end+ end+enddiff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erbindex ff98a0439d9..e774f34af8c 100644--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb@@ -1,40 +1,29 @@<%=- content_tag("turbo-frame", id: "edit-project-custom-fields-dialog-#{@project_custom_field_section.id}-frame") do- component_wrapper(data: { test_selector: 'async-dialog-content' }) do- primer_form_with(- model: @project,- method: :put,- url: update_project_custom_values_path(project_id: @project.id, section_id: @project_custom_field_section.id),- ) do |f|- component_collection do |collection|- collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3, classes: "Overlay-body_autocomplete_height")) do- render(Projects::CustomFields::Form.new(- f,- project: @project,- custom_field_section: @project_custom_field_section,- wrapper_id: "#edit-project-custom-fields-dialog-#{@project_custom_field_section.id}"- ))- end- collection.with_component(Primer::Alpha::Dialog::Footer.new) do- component_collection do |footer_collection|- footer_collection.with_component(Primer::ButtonComponent.new(- data: {- 'close-dialog-id': "edit-project-custom-fields-dialog-#{@project_custom_field_section.id}"- }- )) do- t("button_cancel")- end- footer_collection.with_component(Primer::ButtonComponent.new(- scheme: :primary,- type: :submit,- data: {- test_selector: 'save-project-attributes-button'- }- )) do- t("button_save")- end- end- end+ render(Primer::Alpha::Dialog.new(title: @project_custom_field_section.name,+ size: :medium_portrait,+ id: "edit-project-custom-fields-dialog-#{@project_custom_field_section.id}")) do |d|+ d.with_header(variant: :large)+ d.with_body(classes: "Overlay-body_autocomplete_height") do+ render(::ProjectCustomFields::Sections::EditComponent.new(project_custom_field_section: @project_custom_field_section, project: @project))+ end+ d.with_footer do+ component_collection do |footer_collection|+ footer_collection.with_component(Primer::ButtonComponent.new(+ data: {+ 'close-dialog-id': "edit-project-custom-fields-dialog-#{@project_custom_field_section.id}"+ }+ )) do+ t("button_cancel")+ end+ footer_collection.with_component(Primer::ButtonComponent.new(+ scheme: :primary,+ type: :submit,+ form: "project-section-edit-form",+ data: {+ test_selector: 'save-project-attributes-button'+ }+ )) do+ t("button_save")endendenddiff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.rb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.rbindex 9e2d7974495..29d2f3d68fd 100644--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.rb+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.rb@@ -40,10 +40,6 @@ module ProjectCustomFields@project = project@project_custom_field_section = project_custom_field_sectionend-- def wrapper_uniq_by- @project_custom_field_section.id- endendendenddiff --git a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erbindex d84f8f3b013..f748b8e8b73 100644--- a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb+++ b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb@@ -10,16 +10,17 @@endheading.with_column do- render(OpTurbo::OpPrimer::AsyncDialogComponent.new(- id: "edit-project-custom-fields-dialog-#{@project_custom_field_section.id}",- src: project_custom_field_section_dialog_path(project_id: @project.id, section_id: @project_custom_field_section.id),- size: :medium_portrait,- title: @project_custom_field_section.name,+ render(Primer::Beta::IconButton.new(+ icon: :pencil,+ tag: :a,+ href: project_custom_field_section_dialog_path(project_id: @project.id, section_id: @project_custom_field_section.id),+ data: {+ controller: 'async-dialog'+ },+ scheme: :invisible,button_icon: :pencil,- button_icon_label: t(:label_edit),- button_attributes: { scheme: :invisible, data: {- test_selector: "project-custom-field-section-edit-button"- } }+ test_selector: "project-custom-field-section-edit-button",+ aria: { label: I18n.t(:label_edit) },))end if allowed_to_edit?end@@ -28,7 +29,7 @@@project_custom_fields.each do |project_custom_field|details_container.with_row(mb: 3) dorender(ProjectCustomFields::Sections::ProjectCustomFields::ShowComponent.new(- project_custom_field: ,+ project_custom_field:,project_custom_field_values: get_eager_loaded_project_custom_field_values_for(project_custom_field.id)))enddiff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rbindex af2eca9b9c2..3eb2090bccb 100644--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb@@ -1,6 +1,7 @@module ::Overviewsclass OverviewsController < ::Grids::BaseInProjectControllerinclude OpTurbo::ComponentStream+ include OpTurbo::DialogStreamHelperbefore_action :jump_to_project_menu_itembefore_action :set_sidebar_enabled@@ -12,12 +13,11 @@ module ::Overviewsenddef project_custom_field_section_dialog- render(+ respond_with_dialog(ProjectCustomFields::Sections::EditDialogComponent.new(project: @project,project_custom_field_section: find_project_custom_field_section- ),- layout: false+ ))end@@ -63,7 +63,7 @@ module ::Overviewsdef handle_errors(project_with_errors, section)update_via_turbo_stream(- component: ProjectCustomFields::Sections::EditDialogComponent.new(+ component: ProjectCustomFields::Sections::EditComponent.new(project: project_with_errors,project_custom_field_section: section)