<%= inline_create_link %>
diff --git a/app/components/table_component.rb b/app/components/table_component.rb
index 369f8a9c69cf..a5ab35781ee9 100644
--- a/app/components/table_component.rb
+++ b/app/components/table_component.rb
@@ -31,8 +31,17 @@
##
# Abstract view component. Subclass this for a concrete table.
class TableComponent < ApplicationComponent
- def initialize(rows: [], **)
+ def initialize(rows: [], table_arguments: {}, **)
super(rows, **)
+
+ @system_arguments = table_arguments
+ @system_arguments[:tag] = :table
+ @system_arguments[:classes] = class_names(
+ @system_arguments[:classes],
+ "generic-table"
+ )
+ @system_arguments[:data] ||= {}
+ @system_arguments[:data][:controller] = "table-highlighting"
end
class << self
diff --git a/app/forms/custom_fields/details/admin_only_form.rb b/app/forms/custom_fields/details/admin_only_form.rb
new file mode 100644
index 000000000000..aa208f4bccb2
--- /dev/null
+++ b/app/forms/custom_fields/details/admin_only_form.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class AdminOnlyForm < BaseForm
+ form do |f|
+ f.check_box(
+ name: :admin_only,
+ label: attribute_name(:admin_only),
+ caption: I18n.t("custom_fields.instructions.admin_only")
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/allow_non_open_versions_form.rb b/app/forms/custom_fields/details/allow_non_open_versions_form.rb
new file mode 100644
index 000000000000..5295758f2ab3
--- /dev/null
+++ b/app/forms/custom_fields/details/allow_non_open_versions_form.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class AllowNonOpenVersionsForm < BaseForm
+ supports_formats only: %i[version]
+
+ form do |f|
+ f.check_box(
+ name: :allow_non_open_versions,
+ label: attribute_name(:allow_non_open_versions)
+ )
+ end
+
+ def render?
+ super && model.allow_non_open_versions_possible?
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/base_form.rb b/app/forms/custom_fields/details/base_form.rb
new file mode 100644
index 000000000000..b6b7bf4bf8a7
--- /dev/null
+++ b/app/forms/custom_fields/details/base_form.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class BaseForm < ApplicationForm
+ ALLOWED_SUPPORTED_FORMATS_OPERATORS = %i[only except].freeze
+ private_constant :ALLOWED_SUPPORTED_FORMATS_OPERATORS
+
+ delegate :supported_formats_config, to: :class, private: true
+
+ class << self
+ def supports_formats(config = {})
+ @supported_formats_config = config.transform_values { |formats| Array(formats).map(&:to_sym) }
+ end
+
+ def supported_formats_config
+ @supported_formats_config ||= {}
+ end
+ end
+
+ def render?
+ supported_format?
+ end
+
+ private
+
+ def instructions_for(attribute)
+ I18n.t(attribute, scope: %i[custom_fields instructions])
+ end
+
+ def supported_format?
+ @supported_format ||= begin
+ field_format = model.field_format.to_sym
+ case supported_formats_config
+ in { only: } then only.include?(field_format)
+ in { except: } then except.exclude?(field_format)
+ else true
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/default_bool_form.rb b/app/forms/custom_fields/details/default_bool_form.rb
new file mode 100644
index 000000000000..b039ca0bb22d
--- /dev/null
+++ b/app/forms/custom_fields/details/default_bool_form.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class DefaultBoolForm < BaseForm
+ supports_formats only: %i[bool]
+
+ form do |f|
+ f.check_box(
+ name: :default_value,
+ label: attribute_name(:default_value)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/default_long_text_form.rb b/app/forms/custom_fields/details/default_long_text_form.rb
new file mode 100644
index 000000000000..e5604257e00d
--- /dev/null
+++ b/app/forms/custom_fields/details/default_long_text_form.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class DefaultLongTextForm < BaseForm
+ supports_formats only: %i[text]
+
+ form do |f|
+ f.rich_text_area(
+ name: :default_value,
+ label: attribute_name(:default_value),
+ rich_text_options: { resource: nil, macros: :none }
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/default_text_form.rb b/app/forms/custom_fields/details/default_text_form.rb
new file mode 100644
index 000000000000..20fb1aecdc13
--- /dev/null
+++ b/app/forms/custom_fields/details/default_text_form.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class DefaultTextForm < BaseForm
+ supports_formats except: %i[list bool date text user version hierarchy calculated_value]
+
+ form do |f|
+ f.text_field(
+ name: :default_value,
+ label: attribute_name(:default_value)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/length_form.rb b/app/forms/custom_fields/details/length_form.rb
new file mode 100644
index 000000000000..61bb40f4438d
--- /dev/null
+++ b/app/forms/custom_fields/details/length_form.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class LengthForm < BaseForm
+ supports_formats except: %i[list bool date user version link hierarchy calculated_value]
+
+ form do |f|
+ f.group(layout: :horizontal) do |g|
+ g.text_field(
+ name: :min_length,
+ type: :number,
+ label: attribute_name(:min_length),
+ caption: I18n.t(:text_min_max_length_info),
+ input_width: :xsmall
+ )
+
+ g.text_field(
+ name: :max_length,
+ type: :number,
+ label: attribute_name(:max_length),
+ caption: I18n.t(:text_min_max_length_info),
+ input_width: :xsmall
+ )
+ end
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/multi_select_form.rb b/app/forms/custom_fields/details/multi_select_form.rb
new file mode 100644
index 000000000000..f7a6bcfc3398
--- /dev/null
+++ b/app/forms/custom_fields/details/multi_select_form.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class MultiSelectForm < BaseForm
+ supports_formats only: %i[list user version hierarchy]
+
+ form do |f|
+ f.check_box(
+ name: :multi_value,
+ label: attribute_name(:multi_value),
+ caption: instructions_for(:multi_select),
+ data: { action: "admin--custom-fields#checkOnlyOne" }
+ )
+ end
+
+ def render?
+ super && model.multi_value_possible?
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/name_form.rb b/app/forms/custom_fields/details/name_form.rb
new file mode 100644
index 000000000000..259ee1083892
--- /dev/null
+++ b/app/forms/custom_fields/details/name_form.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class NameForm < BaseForm
+ form do |f|
+ f.text_field(
+ name: :name,
+ label: attribute_name(:name),
+ required: true,
+ data: { test_selector: "op-custom-fields--new-custom-field-name" }
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/possible_values_form.rb b/app/forms/custom_fields/details/possible_values_form.rb
new file mode 100644
index 000000000000..764502ed3704
--- /dev/null
+++ b/app/forms/custom_fields/details/possible_values_form.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class PossibleValuesForm < BaseForm
+ # supports_formats only: %i[list user version hierarchy]
+
+ form do |f|
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/project_attribute_section_form.rb b/app/forms/custom_fields/details/project_attribute_section_form.rb
new file mode 100644
index 000000000000..b169a103aaca
--- /dev/null
+++ b/app/forms/custom_fields/details/project_attribute_section_form.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class ProjectAttributeSectionForm < BaseForm
+ form do |f|
+ f.select_list(
+ name: :custom_field_section_id,
+ label: ProjectCustomField.human_attribute_name(:custom_field_section),
+ required: true
+ ) do |list|
+ available_attribute_sections.each do |label, value|
+ list.option(label:, value:)
+ end
+ end
+ end
+
+ def render?
+ super && model.is_a?(ProjectCustomField)
+ end
+
+ private
+
+ def available_attribute_sections
+ ProjectCustomFieldSection.pluck(:name, :id)
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/regexp_form.rb b/app/forms/custom_fields/details/regexp_form.rb
new file mode 100644
index 000000000000..e7843c17bfa2
--- /dev/null
+++ b/app/forms/custom_fields/details/regexp_form.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class RegexpForm < BaseForm
+ supports_formats except: %i[list bool date user version hierarchy calculated_value]
+
+ form do |f|
+ f.text_field(
+ name: :regexp,
+ label: attribute_name(:regexp),
+ size: 50,
+ caption: I18n.t(:text_regexp_info)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/required_form.rb b/app/forms/custom_fields/details/required_form.rb
new file mode 100644
index 000000000000..f77541b3c664
--- /dev/null
+++ b/app/forms/custom_fields/details/required_form.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class RequiredForm < BaseForm
+ extend Dry::Initializer
+
+ option :for_project, default: -> { false }
+
+ form do |f|
+ f.check_box(
+ name: :is_required,
+ label: attribute_name(:is_required),
+ caption: for_project ? instructions_for(:is_required_for_project) : instructions_for(:is_required)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/right_to_left_form.rb b/app/forms/custom_fields/details/right_to_left_form.rb
new file mode 100644
index 000000000000..5c375ba20672
--- /dev/null
+++ b/app/forms/custom_fields/details/right_to_left_form.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class RightToLeftForm < BaseForm
+ supports_formats only: %i[text]
+
+ form do |f|
+ f.check_box(
+ name: :content_right_to_left,
+ label: attribute_name(:content_right_to_left)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/searchable_form.rb b/app/forms/custom_fields/details/searchable_form.rb
new file mode 100644
index 000000000000..301f94d2af85
--- /dev/null
+++ b/app/forms/custom_fields/details/searchable_form.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class SearchableForm < BaseForm
+ extend Dry::Initializer
+
+ supports_formats except: %i[bool date float int user version hierarchy calculated_value]
+
+ option :for_project, default: -> { false }
+
+ form do |f|
+ f.check_box(
+ name: :searchable,
+ label: attribute_name(:searchable),
+ caption: for_project ? instructions_for(:searchable_for_project) : instructions_for(:searchable)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/user_custom_field_form.rb b/app/forms/custom_fields/details/user_custom_field_form.rb
new file mode 100644
index 000000000000..13aff78d79de
--- /dev/null
+++ b/app/forms/custom_fields/details/user_custom_field_form.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class UserCustomFieldForm < BaseForm
+ form do |f|
+ f.check_box(
+ name: :admin_only,
+ label: attribute_name(:admin_only),
+ caption: instructions_for(:admin_only)
+ )
+
+ f.check_box(
+ name: :editable,
+ label: attribute_name(:editable),
+ caption: instructions_for(:admin_only)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/details/work_package_custom_field_form.rb b/app/forms/custom_fields/details/work_package_custom_field_form.rb
new file mode 100644
index 000000000000..eee72314fac1
--- /dev/null
+++ b/app/forms/custom_fields/details/work_package_custom_field_form.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ module Details
+ class WorkPackageCustomFieldForm < BaseForm
+ form do |f|
+ f.check_box(
+ name: :is_for_all,
+ label: attribute_name(:is_for_all),
+ caption: instructions_for(:is_for_all)
+ )
+
+ f.check_box(
+ name: :is_filter,
+ label: attribute_name(:is_filter),
+ caption: instructions_for(:is_filter)
+ )
+ end
+ end
+ end
+end
diff --git a/app/forms/custom_fields/save.rb b/app/forms/custom_fields/save.rb
new file mode 100644
index 000000000000..f31f51473815
--- /dev/null
+++ b/app/forms/custom_fields/save.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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 CustomFields
+ class Save < ApplicationForm
+ attr_reader :label, :system_arguments
+
+ form do |f|
+ f.submit(scheme: :primary, name: :submit, label:, **system_arguments)
+ end
+
+ def initialize(label: I18n.t(:button_save), **system_arguments)
+ super()
+
+ @label = label
+ @system_arguments = system_arguments
+ end
+ end
+end
diff --git a/app/views/admin/settings/project_custom_fields/edit.html.erb b/app/views/admin/settings/project_custom_fields/edit.html.erb
index 644f966d3a06..367c86f153d5 100644
--- a/app/views/admin/settings/project_custom_fields/edit.html.erb
+++ b/app/views/admin/settings/project_custom_fields/edit.html.erb
@@ -45,15 +45,20 @@ See COPYRIGHT and LICENSE files for more details.
<% content_controller "admin--custom-fields",
"admin--custom-fields-format-value": @custom_field.field_format,
- "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config %>
+ "admin--custom-fields-item-count-value": @custom_field.custom_options.size %>
- <%= labelled_tabular_form_for @custom_field, as: :custom_field,
- url: admin_settings_project_custom_field_path(@custom_field),
- html: { method: :put, id: "custom_field_form" } do |f| %>
- <%= render partial: "custom_fields/form", locals: { f: f, custom_field: @custom_field } %>
+ <%=
+ settings_primer_form_with(
+ model: @custom_field,
+ scope: :custom_field,
+ url: admin_settings_project_custom_field_path(@custom_field),
+ html: { method: :put, id: "custom_field_form" }
+ ) do |f|
+ %>
+ <%= render partial: "custom_fields/form", locals: { f: } %>
<% if @custom_field.new_record? %>
<%= hidden_field_tag "type", @custom_field.type %>
<% end %>
- <%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %>
+ <%= render CustomFields::Save.new(f) %>
<% end %>
<% end %>
diff --git a/app/views/admin/settings/project_custom_fields/new.html.erb b/app/views/admin/settings/project_custom_fields/new.html.erb
index d36d93794f2c..a4197cac8527 100644
--- a/app/views/admin/settings/project_custom_fields/new.html.erb
+++ b/app/views/admin/settings/project_custom_fields/new.html.erb
@@ -38,15 +38,20 @@ See COPYRIGHT and LICENSE files for more details.
<% content_controller "admin--custom-fields",
"admin--custom-fields-format-value": @custom_field.field_format,
- "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config %>
-
- <%= labelled_tabular_form_for @custom_field, as: :custom_field,
- url: admin_settings_project_custom_fields_path,
- html: { id: "custom_field_form" } do |f| %>
- <%= render partial: "custom_fields/form", locals: { f: f, custom_field: @custom_field } %>
+ "admin--custom-fields-item-count-value": @custom_field.custom_options.size %>
+
+ <%=
+ settings_primer_form_with(
+ model: @custom_field,
+ scope: :custom_field,
+ url: admin_settings_project_custom_fields_path,
+ html: { id: "custom_field_form" }
+ ) do |f|
+ %>
+ <%= render partial: "custom_fields/form", locals: { f: } %>
<% if @custom_field.new_record? %>
<%= hidden_field_tag "type", @custom_field.type %>
<% end %>
- <%= styled_button_tag t(:button_save), class: "-highlight -with-icon icon-checkmark" %>
+ <%= render CustomFields::Save.new(f) %>
<% end %>
<% end %>
diff --git a/app/views/custom_fields/_custom_options.html.erb b/app/views/custom_fields/_custom_options.html.erb
deleted file mode 100644
index 4684985f9b53..000000000000
--- a/app/views/custom_fields/_custom_options.html.erb
+++ /dev/null
@@ -1,159 +0,0 @@
-<%#-- copyright
-OpenProject is an open source project management software.
-Copyright (C) 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.
-
-++#%>
-
-<% custom_field = f.object %>
-<% custom_field.custom_options.build if custom_field.custom_options.empty? %>
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
- <% custom_field.custom_options.each_with_index do |custom_option, i| %>
- <%= f.fields_for :custom_options, custom_option do |co_f| %>
-
- |
-
- <%= co_f.hidden_field :id,
- disabled: true,
- class: "custom-option-id" %>
- <%= co_f.text_field :value,
- disabled: true,
- container_class: "custom-option-value",
- no_label: true %>
- |
-
- <%= co_f.check_box :default_value,
- disabled: true,
- container_class: "custom-option-default-value",
- data: {
- "admin--custom-fields-target": "customOptionDefaults",
- action: "admin--custom-fields#uncheckOtherDefaults"
- },
- no_label: true %>
- |
-
-
-
- <%= op_icon("icon-context icon-sort-up icon-small") %>
-
-
- <%= op_icon("icon-context icon-arrow-up2 icon-small") %>
-
-
- <%= op_icon("icon-context icon-arrow-down2 icon-small") %>
-
-
- <%= op_icon("icon-context icon-sort-down icon-small") %>
-
-
- |
-
- <%= link_to "",
- delete_option_of_custom_field_path(id: custom_field.id || 0, option_id: custom_option.id || 0),
- data: {
- turbo_method: :delete,
- action: "admin--custom-fields#removeOption",
- turbo_confirm: t(:"custom_fields.confirm_destroy_option")
- },
- class: "icon icon-delete delete-custom-option",
- title: t(:button_delete) %>
- |
-
- <% end %>
- <% end %>
-
-
-
-
-
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb
index bab5ef3c4a89..7d1da90ea0e4 100644
--- a/app/views/custom_fields/_form.html.erb
+++ b/app/views/custom_fields/_form.html.erb
@@ -25,227 +25,77 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
-++# %>
-
-<% format_dependent = OpenProject::CustomFieldFormatDependent.new(@custom_field.field_format) %>
-
-