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

chore[Op#54749]: relocate form for consistency

Kabiru Mwenjad69cfe8e72e8
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.erb
index dd510515138..817a44612ec 100644
--- 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.erb
@@ -1,44 +1,5 @@
<%=
component_wrapper do
- new_project_mapping_form = Class.new(ApplicationForm) do
- form do |f|
- f.group(layout: :horizontal) do |f_group|
- f_group.project_autocompleter(
- name: :id,
- label: Project.model_name.human,
- visually_hide_label: true,
- autocomplete_options: {
- openDirectly: false,
- focusDirectly: false,
- dropdownPosition: 'bottom',
- disabledProjects: projects_with_custom_field_mapping,
- inputName: 'project_custom_field_project_mapping[project_id]'
- }
- )
-
- f_group.check_box(
- name: :include_sub_projects,
- label: I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.include_sub_projects"),
- checked: false
- )
- end
- end
-
- def initialize(project_custom_field:)
- super()
- @project_custom_field = project_custom_field
- end
-
- private
-
- def projects_with_custom_field_mapping
- ProjectCustomFieldProjectMapping
- .where(project_custom_field: @project_custom_field)
- .pluck(:project_id)
- .to_h { |id| [id, id] }
- end
- end
-
render(
Primer::Alpha::Dialog.new(
id: dialog_id,
@@ -68,7 +29,7 @@
id: dialog_body_id, test_selector: dialog_body_id, aria: { label: title },
style: "min-height: 300px"
)) do
- render(new_project_mapping_form.new(form, project_custom_field: @project_custom_field))
+ render(Projects::CustomFields::CustomFieldMappingForm.new(form, project_custom_field: @project_custom_field))
end)
concat(render(Primer::Alpha::Dialog::Footer.new(show_divider: false)) do
diff --git a/app/forms/projects/custom_fields/custom_field_mapping_form.rb b/app/forms/projects/custom_fields/custom_field_mapping_form.rb
new file mode 100644
index 00000000000..65084926c10
--- /dev/null
+++ b/app/forms/projects/custom_fields/custom_field_mapping_form.rb
@@ -0,0 +1,68 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Projects::CustomFields
+ class CustomFieldMappingForm < ApplicationForm
+ form do |f|
+ f.group(layout: :horizontal) do |f_group|
+ f_group.project_autocompleter(
+ name: :id,
+ label: Project.model_name.human,
+ visually_hide_label: true,
+ autocomplete_options: {
+ openDirectly: false,
+ focusDirectly: false,
+ dropdownPosition: "bottom",
+ disabledProjects: projects_with_custom_field_mapping,
+ inputName: "project_custom_field_project_mapping[project_id]"
+ }
+ )
+
+ f_group.check_box(
+ name: :include_sub_projects,
+ label: I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.include_sub_projects"),
+ checked: false
+ )
+ end
+ end
+
+ def initialize(project_custom_field:)
+ super()
+ @project_custom_field = project_custom_field
+ end
+
+ private
+
+ def projects_with_custom_field_mapping
+ ProjectCustomFieldProjectMapping
+ .where(project_custom_field: @project_custom_field)
+ .pluck(:project_id)
+ .to_h { |id| [id, id] }
+ end
+ end
+end