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
WIP[Op#54749]: Lay out blueprint of project add modal
Kabiru Mwenja7ea0cb550cc1
diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erbnew file mode 100644index 00000000000..75c0e713ce2--- /dev/null+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.html.erb@@ -0,0 +1,53 @@+<%+ new_project_mapping_form = Class.new(ApplicationForm) do+ form do |f|+ f.project_autocompleter(+ name: :id,+ label: Project.model_name.human,+ visually_hide_label: true,+ autocomplete_options: {+ openDirectly: false,+ focusDirectly: false,+ dropdownPosition: 'bottom',+ disabledProjects: Project.visible.take(10).pluck(:id).to_h { |id| [id, "Disabled reason!"] }+ }+ )+ end+ end+%>++<%=+ render(+ Primer::Alpha::Dialog.new(+ id: dialog_id,+ title:,+ test_selector: dialog_id+ )+ ) do |dialog|+ dialog.with_show_button(icon: :project, aria: { label: show_button_text }) { show_button_text }++ dialog.with_header(+ show_divider: false,+ visually_hide_title: false+ )++ render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-oauth-client-form')) do+ primer_form_with(+ model: @project_mapping,+ url: link_admin_settings_project_custom_field_path(@project_custom_field),+ method: :post+ ) do |form|+ concat(render(Primer::Alpha::Dialog::Body.new(+ id: dialog_body_id, test_selector: dialog_body_id, aria: { label: title }+ )) do+ render(new_project_mapping_form.new(form))+ end)++ concat(render(Primer::Alpha::Dialog::Footer.new(show_divider: false)) do+ concat(render(Primer::ButtonComponent.new(data: { 'close-dialog-id': dialog_id })) { cancel_button_text })+ concat(render(Primer::ButtonComponent.new(scheme: :primary)) { submit_button_text })+ end)+ end+ end+ end+%>diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.rb b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.rbnew file mode 100644index 00000000000..093061c08bc--- /dev/null+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/new_project_mapping_component.rb@@ -0,0 +1,62 @@+#-- 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 Settings+ module ProjectCustomFields+ module ProjectCustomFieldMapping+ class NewProjectMappingComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+ options dialog_id: "settings--new-project-custom-field-mapping-component",+ dialog_body_id: "settings--new-project-custom-field-mapping-body-component"++ def initialize(project_mapping:, project_custom_field:, **)+ @project_mapping = project_mapping+ @project_custom_field = project_custom_field+ super(@project_mapping, **)+ end++ private++ def title+ "Add projects"+ end++ def show_button_text+ "Add projects"+ end++ def cancel_button_text+ I18n.t("button_cancel")+ end++ def submit_button_text+ I18n.t("button_add")+ end+ end+ end+ end+enddiff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rbindex 188395ad404..00830c436d2 100644--- a/app/controllers/admin/settings/project_custom_fields_controller.rb+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb@@ -68,7 +68,28 @@ module Admin::Settingsdef edit; end- def project_mappings; end+ def project_mappings+ @project_mapping = ProjectCustomFieldProjectMapping.new(project_custom_field: @custom_field)+ end++ def link+ @project_mapping = ProjectCustomFieldProjectMapping.new(permitted_params.project_custom_field_project_mapping)++ create_service = ProjectCustomFieldProjectMappings::CreateService+ .new(user: current_user, model: @project_mapping)+ .call++ create_service.on_success { render_unlink_response(project: @project_mapping.project) }++ create_service.on_failure do+ update_flash_message_via_turbo_stream(+ message: join_flash_messages(create_service.errors.full_messages),+ full: true, dismiss_scheme: :hide, scheme: :danger+ )+ end++ respond_to_with_turbo_streams(status: create_service.success? ? :ok : :unprocessable_entity)+ enddef unlinkdelete_service = ProjectCustomFieldProjectMappings::DeleteServicediff --git a/app/views/admin/settings/project_custom_fields/project_mappings.html.erb b/app/views/admin/settings/project_custom_fields/project_mappings.html.erbindex b5ca90e77db..325c1891711 100644--- a/app/views/admin/settings/project_custom_fields/project_mappings.html.erb+++ b/app/views/admin/settings/project_custom_fields/project_mappings.html.erb@@ -35,7 +35,13 @@ See COPYRIGHT and LICENSE files for more details.%><%=+ render(Settings::ProjectCustomFields::ProjectCustomFieldMapping::NewProjectMappingComponent.new(+ project_mapping: @project_mapping,+ project_custom_field: @custom_field+ ))+%>+<%=if @custom_field.required?render Primer::Beta::Blankslate.new(border: true) do |component|component.with_visual_icon(icon: :checklist)diff --git a/config/routes.rb b/config/routes.rbindex 06c8a660b8b..9ac3deb4dee 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -464,6 +464,7 @@ Rails.application.routes.draw doput :dropget :project_mappings+ post :linkdelete :unlinkendend