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

introducing project custom field create and edit

Jonas Jabaria7a3f98a3055
diff --git a/app/components/settings/project_attributes/header_component.html.erb b/app/components/settings/project_attributes/header_component.html.erb
index 0e244cdfd0a..c126ee29a61 100644
--- a/app/components/settings/project_attributes/header_component.html.erb
+++ b/app/components/settings/project_attributes/header_component.html.erb
@@ -14,7 +14,7 @@
action_buttons_container.with_column(mr: 2) do
render(Primer::Beta::Button.new(
tag: :a,
- href: new_custom_field_path(type: "ProjectCustomField"),
+ href: new_admin_settings_project_custom_field_path(type: "ProjectCustomField"),
scheme: :primary,
data: { 'turbo-frame': 'true' }
)) do |button|
diff --git a/app/components/settings/project_attributes/section/project_custom_field_component.rb b/app/components/settings/project_attributes/section/project_custom_field_component.rb
index 78bb056482d..fe70d54ecb1 100644
--- a/app/components/settings/project_attributes/section/project_custom_field_component.rb
+++ b/app/components/settings/project_attributes/section/project_custom_field_component.rb
@@ -44,7 +44,7 @@ module Settings
def edit_action_item(menu)
menu.with_item(label: t("label_edit"),
- href: edit_custom_field_path(@project_custom_field)) do |item|
+ href: edit_admin_settings_project_custom_field_path(@project_custom_field)) do |item|
item.with_leading_visual_icon(icon: :pencil)
end
end
diff --git a/app/components/settings/project_custom_fields/edit_form_header_component.html.erb b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
new file mode 100644
index 00000000000..c8b61164efa
--- /dev/null
+++ b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
@@ -0,0 +1,50 @@
+<%#-- 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.
+
+++#%>
+<%=
+ flex_layout(pb: 2, border: :bottom) do |header_container|
+ header_container.with_row(mb: 2, flex_layout: true, align_items: :center) do |title_row_container|
+ title_row_container.with_column(mr: 2) do
+ render(Primer::Beta::IconButton.new(
+ tag: :a,
+ href: admin_settings_project_custom_fields_path,
+ scheme: :invisible,
+ icon: "arrow-left",
+ size: :large,
+ "aria-label": t("back")
+ ))
+ end
+ title_row_container.with_column(mr: 2) do
+ render(Primer::Beta::Heading.new(tag: :h1)) { @project_custom_field.name }
+ end
+ end
+ header_container.with_row(mb: 2) do
+ render(Primer::Beta::Text.new(color: :muted)) { t('settings.project_attributes.edit.description') }
+ end
+ end
+%>
diff --git a/app/components/settings/project_custom_fields/edit_form_header_component.rb b/app/components/settings/project_custom_fields/edit_form_header_component.rb
new file mode 100644
index 00000000000..5dc70d8f8a8
--- /dev/null
+++ b/app/components/settings/project_custom_fields/edit_form_header_component.rb
@@ -0,0 +1,42 @@
+#-- 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
+ class EditFormHeaderComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+
+ def initialize(project_custom_field: ProjectCustomField.new)
+ super
+
+ @project_custom_field = project_custom_field
+ end
+ end
+ end
+end
diff --git a/app/components/settings/project_custom_fields/form_component.html.erb b/app/components/settings/project_custom_fields/form_component.html.erb
new file mode 100644
index 00000000000..17ed778aa26
--- /dev/null
+++ b/app/components/settings/project_custom_fields/form_component.html.erb
@@ -0,0 +1,208 @@
+<%#-- 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.
+
+++#%>
+<%= @project_custom_field.errors.inspect %>
+<%= primer_form_with(**form_config) do |f| %>
+ <section class="form--section" id="custom_field_form">
+ <div class="form--field -required" id="custom_field_name_attributes">
+ <%= f.text_field :name, required: true, container_class: '-middle' %>
+ </div>
+ <div class="form--field">
+ <%= f.select :project_custom_field_section_id,
+ ProjectCustomFieldSection.all.collect { |s| [s.name, s.id] },
+ { container_class: '-slim' }
+ %>
+ </div>
+ <div class="form--field">
+ <%= f.select :field_format,
+ custom_field_formats_for_select(@project_custom_field),
+ { container_class: '-slim' },
+ disabled: !@project_custom_field.new_record?,
+ data: {
+ action: 'admin--custom-fields#formatChanged',
+ 'admin--custom-fields-target': 'format'
+ }
+ %>
+ </div>
+ <div class="form--grouping" id="custom_field_length">
+ <div class="form--grouping-label">
+ <%= t(:label_min_max_length) %> <br>
+ <small>(<%= t(:text_min_max_length_info) %>)</small>
+ </div>
+ <div class="form--grouping-row">
+ <div class="form--field -wide-label">
+ <%= f.number_field :min_length,
+ container_class: '-xslim',
+ data: { 'admin--custom-fields-target': 'length' } %>
+ </div>
+ <div class="form--field -wide-label">
+ <%= f.number_field :max_length,
+ container_class: '-xslim',
+ data: { 'admin--custom-fields-target': 'length' } %>
+ </div>
+ </div>
+ </div>
+
+ <div class="form--field">
+ <%= f.text_field :regexp,
+ size: 50,
+ container_class: '-wide',
+ data: { 'admin--custom-fields-target': 'regexp' } %>
+ <span class="form--field-instructions">
+ <%= t(:text_regexp_info) %>
+ </span>
+ </div>
+
+ <% if @project_custom_field.new_record? || @project_custom_field.list? || @project_custom_field.multi_value_possible? %>
+ <div class="form--field" hidden>
+ <%= f.check_box :multi_value,
+ data: {
+ 'admin--custom-fields-target': 'multiSelect',
+ action: 'admin--custom-fields#checkOnlyOne'
+ } %>
+ </div>
+
+ <fieldset class="form--fieldset" data-admin--custom-fields-target="possibleValues">
+ <legend class="form--fieldset-legend"><%= I18n.t("activerecord.attributes.custom_field.possible_values") %></legend>
+ <% if false %>
+ <div class="form--toolbar">
+ <span class="form--toolbar-item">
+ <%= link_to t('custom_fields.reorder_alphabetical'),
+ { action: :reorder_alphabetical },
+ method: :post,
+ data: { confirm: t('custom_fields.reorder_confirmation') } %>
+ </span>
+ </div>
+ <% end %>
+ <% if false %>
+ <div class="form--field">
+ <%= render partial: "custom_fields/custom_options", locals: { custom_field: @project_custom_field, f: f } %>
+ <button
+ type="button"
+ class="spot-link"
+ data-test-selector="add-custom-option"
+ data-action="admin--custom-fields#addOption"
+ >
+ <span class="spot-icon spot-icon_1_25 spot-icon_add"></span>
+ <span><%= t(:button_add) %></span>
+ </button>
+ </div>
+ <% end %>
+ </fieldset>
+ <% end %>
+ <div data-admin--custom-fields-target="defaultValue">
+ <div class="form--field" id="default_value_text">
+ <% if @project_custom_field.new_record? || !%w[text bool].include?(@project_custom_field.field_format) %>
+ <%= f.text_field :default_value,
+ id: 'custom_fields_default_value_text',
+ for: 'custom_fields_default_value_text',
+ data: { 'admin--custom-fields-target': 'defaultText' },
+ container_class: '-wide' %>
+ <% end %>
+ </div>
+ <div class="form--field" hidden>
+ <% if @project_custom_field.new_record? || @project_custom_field.field_format == 'bool' %>
+ <%= f.check_box :default_value,
+ id: 'custom_fields_default_value_bool',
+ data: { 'admin--custom-fields-target': 'defaultBool' },
+ for: 'custom_fields_default_value_bool' %>
+ <% end %>
+ </div>
+ <div class="form--field" hidden>
+ <% if @project_custom_field.new_record? || @project_custom_field.field_format == 'text' %>
+ <%= f.text_area :default_value,
+ id: 'custom_fields_default_value_longtext',
+ data: { 'admin--custom-fields-target': 'defaultLongText' },
+ for: 'custom_fields_default_value_longtext',
+ cols: 100,
+ rows: 20,
+ class: 'wiki-edit',
+ with_text_formatting: true %>
+ <% end %>
+ </div>
+ </div>
+ <%= call_hook(:view_custom_fields_form_upper_box, custom_field: @project_custom_field, form: f) %>
+ </section>
+
+ <section class="form--section">
+ <% case @project_custom_field.class.name
+ when "WorkPackageCustomField" %>
+ <div class="form--field">
+ <%= f.check_box :is_required %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :is_for_all %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :is_filter %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :searchable,
+ data: { 'admin--custom-fields-target': 'searchable' }%>
+ </div>
+ <div class="form--field" hidden>
+ <%= f.check_box :content_right_to_left,
+ data: { 'admin--custom-fields-target': 'textOrientation' } %>
+ </div>
+ <% when "UserCustomField" %>
+ <div class="form--field">
+ <%= f.check_box :is_required %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :visible %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :editable %>
+ </div>
+ <% when "ProjectCustomField" %>
+ <div class="form--field">
+ <%= f.check_box :is_required %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :visible %>
+ </div>
+ <div class="form--field">
+ <%= f.check_box :searchable,
+ data: { 'admin--custom-fields-target': 'searchable' }%>
+ </div>
+ <% when "TimeEntryCustomField" %>
+ <div class="form--field">
+ <%= f.check_box :is_required %>
+ </div>
+ <% else %>
+ <div class="form--field">
+ <%= f.check_box :is_required %>
+ </div>
+ <% end %>
+ <%= call_hook(:"view_custom_fields_form_#{@project_custom_field.type.to_s.underscore}", custom_field: @project_custom_field, form: f) %>
+
+ <%= render(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do %>
+ <%= t("button_save") %>
+ <% end %>
+ </section>
+<% end %>
diff --git a/app/components/settings/project_custom_fields/form_component.rb b/app/components/settings/project_custom_fields/form_component.rb
new file mode 100644
index 00000000000..bb4b1952dcc
--- /dev/null
+++ b/app/components/settings/project_custom_fields/form_component.rb
@@ -0,0 +1,55 @@
+#-- 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
+ class FormComponent < ApplicationComponent
+ include ApplicationHelper
+ include CustomFieldsHelper
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ def initialize(project_custom_field: ProjectCustomField.new)
+ super
+
+ @project_custom_field = project_custom_field
+ end
+
+ private
+
+ def form_config
+ {
+ model: @project_custom_field,
+ scope: :custom_field,
+ method: @project_custom_field.persisted? ? :put : :post,
+ url: @project_custom_field.persisted? ? admin_settings_project_custom_field_path(@project_custom_field) : admin_settings_project_custom_fields_path
+ }
+ end
+ end
+ end
+end
diff --git a/app/components/settings/project_custom_fields/new_form_header_component.html.erb b/app/components/settings/project_custom_fields/new_form_header_component.html.erb
new file mode 100644
index 00000000000..19559fdeb6a
--- /dev/null
+++ b/app/components/settings/project_custom_fields/new_form_header_component.html.erb
@@ -0,0 +1,50 @@
+<%#-- 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.
+
+++#%>
+<%=
+ flex_layout(pb: 2, border: :bottom) do |header_container|
+ header_container.with_row(mb: 2, flex_layout: true, align_items: :center) do |title_row_container|
+ title_row_container.with_column(mr: 2) do
+ render(Primer::Beta::IconButton.new(
+ tag: :a,
+ href: admin_settings_project_custom_fields_path,
+ scheme: :invisible,
+ icon: "arrow-left",
+ size: :large,
+ "aria-label": t("back")
+ ))
+ end
+ title_row_container.with_column(mr: 2) do
+ render(Primer::Beta::Heading.new(tag: :h1)) { t('settings.project_attributes.new.heading') }
+ end
+ end
+ header_container.with_row(mb: 2) do
+ render(Primer::Beta::Text.new(color: :muted)) { t('settings.project_attributes.new.description') }
+ end
+ end
+%>
diff --git a/app/components/settings/project_custom_fields/new_form_header_component.rb b/app/components/settings/project_custom_fields/new_form_header_component.rb
new file mode 100644
index 00000000000..1a138fb0e26
--- /dev/null
+++ b/app/components/settings/project_custom_fields/new_form_header_component.rb
@@ -0,0 +1,40 @@
+#-- 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
+ class NewFormHeaderComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+
+ def initialize
+ super
+ end
+ end
+ end
+end
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index 999c32fb75a..37c78fc49ae 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -33,8 +33,8 @@ module Admin::Settings
menu_item :project_custom_field_settings
- before_action :set_sections, only: %i[index move drop]
- before_action :set_project_custom_field, only: %i[move drop]
+ before_action :set_sections, only: %i[index edit update move drop]
+ before_action :set_project_custom_field, only: %i[edit update move drop]
def default_breadcrumb
t(:label_project_attributes_plural)
@@ -44,6 +44,42 @@ module Admin::Settings
respond_to :html
end
+ def new
+ @project_custom_field = ProjectCustomField.new
+
+ respond_to :html
+ end
+
+ def edit
+ respond_to :html
+ end
+
+ def create
+ @project_custom_field = ProjectCustomField.new(project_custom_field_params.except(:project_custom_field_section_id))
+
+ if @project_custom_field.save
+ @project_custom_field.project_custom_field_section = ProjectCustomFieldSection.find(project_custom_field_params[:project_custom_field_section_id])
+
+ redirect_to admin_settings_project_custom_fields_path
+ else
+ render action: 'new'
+ end
+ end
+
+ def update
+ if project_custom_field_params[:project_custom_field_section_id]&.to_i != @project_custom_field.project_custom_field_section_id
+ mapping = @project_custom_field.project_custom_field_section_mapping
+ mapping.remove_from_list
+ @project_custom_field.project_custom_field_section = ProjectCustomFieldSection.find(project_custom_field_params[:project_custom_field_section_id])
+ end
+
+ if @project_custom_field.update(project_custom_field_params.except(:project_custom_field_section_id))
+ redirect_to admin_settings_project_custom_fields_path
+ else
+ render action: 'edit'
+ end
+ end
+
def move
mapping = @project_custom_field.project_custom_field_section_mapping
mapping.move_to = params[:move_to]&.to_sym
@@ -94,5 +130,9 @@ module Admin::Settings
def set_project_custom_field
@project_custom_field = ProjectCustomField.find(params[:id])
end
+
+ def project_custom_field_params
+ permitted_params.custom_field
+ end
end
end
diff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rb
index 00109e0d1ed..3b8a5f23aa6 100644
--- a/app/models/permitted_params.rb
+++ b/app/models/permitted_params.rb
@@ -466,6 +466,7 @@ class PermittedParams
:possible_values,
:multi_value,
:content_right_to_left,
+ :project_custom_field_section_id,
{ custom_options_attributes: %i(id value default_value position) },
{ type_ids: [] }
],
diff --git a/app/models/project_custom_field.rb b/app/models/project_custom_field.rb
index 33da45d776d..bd27c10091e 100644
--- a/app/models/project_custom_field.rb
+++ b/app/models/project_custom_field.rb
@@ -38,6 +38,8 @@ class ProjectCustomField < CustomField
has_many :project_custom_field_sections,
through: :project_custom_field_section_mappings
+ accepts_nested_attributes_for :project_custom_field_sections
+
validate :exactly_one_section_mapped
def type_name
@@ -53,6 +55,8 @@ class ProjectCustomField < CustomField
end
def exactly_one_section_mapped
+ return unless persisted?
+
unless project_custom_field_sections.count == 1
errors.add(:base, "Exactly one section must be mapped to this custom field.")
end
@@ -66,6 +70,10 @@ class ProjectCustomField < CustomField
project_custom_field_sections.first
end
+ def project_custom_field_section_id
+ project_custom_field_section&.id
+ end
+
def project_custom_field_section=(section)
# without this reload, a nil assignment is not recovered properly
project_custom_field_sections.reload
diff --git a/app/views/admin/settings/project_custom_fields/edit.html.erb b/app/views/admin/settings/project_custom_fields/edit.html.erb
new file mode 100644
index 00000000000..852e11dcb02
--- /dev/null
+++ b/app/views/admin/settings/project_custom_fields/edit.html.erb
@@ -0,0 +1,32 @@
+<%#-- 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.
+
+++#%>
+<turbo-frame id="admin-settings-project-custom-fields">
+ <%= render(Settings::ProjectCustomFields::EditFormHeaderComponent.new(project_custom_field: @project_custom_field)) %>
+ <%= render(Settings::ProjectCustomFields::FormComponent.new(project_custom_field: @project_custom_field)) %>
+</turbo-frame>
diff --git a/app/views/admin/settings/project_custom_fields/index.html.erb b/app/views/admin/settings/project_custom_fields/index.html.erb
index 36e54678325..dd9ec6c0415 100644
--- a/app/views/admin/settings/project_custom_fields/index.html.erb
+++ b/app/views/admin/settings/project_custom_fields/index.html.erb
@@ -27,6 +27,8 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<div data-turbo="true">
- <%= render(Settings::ProjectAttributes::HeaderComponent.new()) %>
- <%= render(Settings::ProjectAttributes::Section::IndexComponent.new(sections: @sections)) %>
+ <turbo-frame id="admin-settings-project-custom-fields" data-turbo-action="advance">
+ <%= render(Settings::ProjectAttributes::HeaderComponent.new()) %>
+ <%= render(Settings::ProjectAttributes::Section::IndexComponent.new(sections: @sections)) %>
+ </turbo-frame>
</div>
diff --git a/app/views/admin/settings/project_custom_fields/new.html.erb b/app/views/admin/settings/project_custom_fields/new.html.erb
new file mode 100644
index 00000000000..cee5c4fc715
--- /dev/null
+++ b/app/views/admin/settings/project_custom_fields/new.html.erb
@@ -0,0 +1,32 @@
+<%#-- 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.
+
+++#%>
+<turbo-frame id="admin-settings-project-custom-fields">
+ <%= render(Settings::ProjectCustomFields::NewFormHeaderComponent.new()) %>
+ <%= render(Settings::ProjectCustomFields::FormComponent.new(project_custom_field: @project_custom_field)) %>
+</turbo-frame>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0978eeb62b1..86d30f31b5a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2902,6 +2902,11 @@ en:
label_section_actions: "Section actions"
heading_description: "These project attributes appear in the project overview of each project. You can add new attributes and group them into sections. Individual attributes can be enabled or disabled at a project level."
label_project_custom_field_actions: "Project attribute actions"
+ edit:
+ description: "Set the details of the project attribute that will be selectable by project administrators in each individual project settings."
+ new:
+ heading: "New attribute"
+ description: "Set the details of the project attribute that will be selectable by project administrators in each individual project settings."
projects:
section_new_projects: "Settings for new projects"
section_project_overview: "Settings for project overview list"
diff --git a/config/routes.rb b/config/routes.rb
index 9e1108ccf30..a03141d2934 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -419,7 +419,7 @@ OpenProject::Application.routes.draw do
resource :work_packages, controller: '/admin/settings/work_packages_settings', only: %i[show update]
resource :projects, controller: '/admin/settings/projects_settings', only: %i[show update]
resources :project_custom_fields, controller: '/admin/settings/project_custom_fields',
- only: %i[index show update] do
+ only: %i[index show new create edit update] do
member do
put :move
put :drop