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
<%#-- 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.
++#%>
<% format_dependent = OpenProject::CustomFieldFormatDependent.new(@custom_field.field_format) %>
<section
class="form--section"
id="custom_field_form">
<%= f.hidden_field :field_format if @custom_field.new_record? %>
<div class="form--field -required" id="custom_field_name_attributes">
<%= f.text_field :name,
required: true,
container_class: "-middle",
"data-test-selector": "op-custom-fields--new-custom-field-name" %>
</div>
<% if @custom_field.type == 'ProjectCustomField' %>
<div class="form--field -required">
<%= f.select :custom_field_section_id,
ProjectCustomFieldSection.all.collect { |s| [s.name, s.id] },
{ container_class: "-slim" },
required: true %>
</div>
<% end %>
<div class="form--grouping" id="custom_field_length" <%= format_dependent.attributes(: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" %>
</div>
<div class="form--field -wide-label">
<%= f.number_field :max_length,
container_class: "-xslim" %>
</div>
</div>
</div>
<div class="form--field" <%= format_dependent.attributes(:regexp) %>>
<%= f.text_field :regexp,
size: 50,
container_class: "-wide" %>
<span class="form--field-instructions">
<%= t(:text_regexp_info) %>
</span>
</div>
<% if @custom_field.new_record? || @custom_field.multi_value_possible? %>
<div class="form--field" <%= format_dependent.attributes(:multiSelect) %>>
<%= f.check_box :multi_value,
data: { action: "admin--custom-fields#checkOnlyOne" } %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.multi_select") %></p>
</div>
</div>
<fieldset class="form--fieldset" <%= format_dependent.attributes(:possibleValues) %>>
<legend class="form--fieldset-legend"><%= I18n.t("activerecord.attributes.custom_field.possible_values") %></legend>
<% if @custom_field.persisted? %>
<div class="form--toolbar">
<span class="form--toolbar-item">
<%= link_to t("custom_fields.reorder_alphabetical"),
{ action: :reorder_alphabetical },
data: {
turbo_method: :post,
turbo_confirm: t("custom_fields.reorder_confirmation")
} %>
</span>
</div>
<% end %>
<div class="form--field">
<%= render partial: "custom_fields/custom_options", locals: { custom_field: @custom_field, f: f } %>
<%=
render Primer::Beta::Button.new(
scheme: :link,
test_selector: "add-custom-option",
data: { action: "admin--custom-fields#addOption" },
mt: 2
) do |button|
button.with_leading_visual_icon(icon: :plus)
t(:button_add)
end
%>
</div>
</fieldset>
<% end %>
<% if @custom_field.new_record? || @custom_field.allow_non_open_versions_possible? %>
<div class="form--field" <%= format_dependent.attributes(:allowNonOpenVersions) %>>
<%= f.check_box :allow_non_open_versions %>
</div>
<% end %>
<% if @custom_field.new_record? || !%w[text bool].include?(@custom_field.field_format) %>
<div class="form--field" id="default_value_text" <%= format_dependent.attributes(:defaultText) %>>
<%= f.text_field :default_value,
id: "custom_fields_default_value_text",
for: "custom_fields_default_value_text",
container_class: "-wide" %>
</div>
<% end %>
<% if @custom_field.new_record? || @custom_field.field_format == 'bool' %>
<div class="form--field" <%= format_dependent.attributes(:defaultBool) %>>
<%= f.check_box :default_value,
id: "custom_fields_default_value_bool",
for: "custom_fields_default_value_bool" %>
</div>
<% end %>
<% if @custom_field.new_record? || @custom_field.field_format == 'text' %>
<div class="form--field" <%= format_dependent.attributes(:defaultLongText) %>>
<%= f.text_area :default_value,
id: "custom_fields_default_value_longtext",
for: "custom_fields_default_value_longtext",
cols: 100,
rows: 20,
class: "wiki-edit",
macros: "none",
with_text_formatting: true %>
</div>
<% end %>
<%= call_hook(:view_custom_fields_form_upper_box, custom_field: @custom_field, form: f) %>
</section>
<section class="form--section">
<% case @custom_field.class.name
when "WorkPackageCustomField" %>
<div class="form--field">
<%= f.check_box :is_required %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_required") %></p>
</div>
</div>
<div class="form--field">
<%= f.check_box :is_for_all %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_for_all") %></p>
</div>
</div>
<div class="form--field">
<%= f.check_box :is_filter %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_filter") %></p>
</div>
</div>
<div class="form--field" <%= format_dependent.attributes(:searchable) %>>
<%= f.check_box :searchable %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.searchable") %></p>
</div>
</div>
<div class="form--field" <%= format_dependent.attributes(:textOrientation) %>>
<%= f.check_box :content_right_to_left %>
</div>
<% when "UserCustomField" %>
<div class="form--field">
<%= f.check_box :is_required %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_required") %></p>
</div>
</div>
<div class="form--field">
<%= f.check_box :admin_only %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.admin_only") %></p>
</div>
</div>
<div class="form--field">
<%= f.check_box :editable %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.editable") %></p>
</div>
</div>
<% when "ProjectCustomField" %>
<div class="form--field">
<%= f.check_box :is_required %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_required_for_project") %></p>
</div>
</div>
<div class="form--field">
<%= f.check_box :admin_only %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.admin_only") %></p>
</div>
</div>
<div class="form--field" <%= format_dependent.attributes(:searchable) %>>
<%= f.check_box :searchable %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.searchable_for_project") %></p>
</div>
</div>
<% when "TimeEntryCustomField" %>
<div class="form--field">
<%= f.check_box :is_required %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_required") %></p>
</div>
</div>
<% else %>
<div class="form--field">
<%= f.check_box :is_required %>
<div class="form--field-instructions">
<p><%= t("custom_fields.instructions.is_required") %></p>
</div>
</div>
<% end %>
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", custom_field: @custom_field, form: f) %>
</section>