|
|
|
@ -92,12 +92,15 @@ module CustomFieldsHelper |
|
|
|
|
|
|
|
|
|
tag = case field_format.try(:edit_as) |
|
|
|
|
when 'date' |
|
|
|
|
styled_text_field_tag(field_name, custom_value.value, id: field_id, class: '-augmented-datepicker', size: 10, container_class: '-slim', required: custom_field.is_required) |
|
|
|
|
styled_text_field_tag(field_name, custom_value.value, id: field_id, class: '-augmented-datepicker', size: 10, |
|
|
|
|
container_class: '-slim', required: custom_field.is_required) |
|
|
|
|
when 'text' |
|
|
|
|
styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3, container_class: '-middle', required: custom_field.is_required) |
|
|
|
|
styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3, container_class: '-middle', |
|
|
|
|
required: custom_field.is_required) |
|
|
|
|
when 'bool' |
|
|
|
|
hidden_tag = hidden_field_tag(field_name, '0') |
|
|
|
|
checkbox_tag = styled_check_box_tag(field_name, '1', custom_value.typed_value, id: field_id, required: custom_field.is_required) |
|
|
|
|
checkbox_tag = styled_check_box_tag(field_name, '1', custom_value.typed_value, id: field_id, |
|
|
|
|
required: custom_field.is_required) |
|
|
|
|
hidden_tag + checkbox_tag |
|
|
|
|
when 'list' |
|
|
|
|
blank_option = if custom_field.is_required? && custom_field.default_value.blank? |
|
|
|
@ -108,26 +111,30 @@ module CustomFieldsHelper |
|
|
|
|
'<option></option>' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value) |
|
|
|
|
options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), |
|
|
|
|
custom_value.value) |
|
|
|
|
|
|
|
|
|
styled_select_tag(field_name, options, id: field_id, container_class: '-middle', required: custom_field.is_required) |
|
|
|
|
else |
|
|
|
|
styled_text_field_tag(field_name, custom_value.value, id: field_id, container_class: '-middle', required: custom_field.is_required) |
|
|
|
|
styled_text_field_tag(field_name, custom_value.value, id: field_id, container_class: '-middle', |
|
|
|
|
required: custom_field.is_required) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
tag = content_tag :span, tag, lang: custom_field.name_locale, class: 'form--field-container' |
|
|
|
|
|
|
|
|
|
custom_value.errors.empty? ? |
|
|
|
|
tag : |
|
|
|
|
if custom_value.errors.empty? |
|
|
|
|
tag |
|
|
|
|
else |
|
|
|
|
ActionView::Base.wrap_with_error_span(tag, custom_value, 'value') |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Return custom field label tag |
|
|
|
|
def custom_field_label_tag(name, custom_value) |
|
|
|
|
content_tag 'label', h(custom_value.custom_field.name) + |
|
|
|
|
(custom_value.custom_field.is_required? ? content_tag('span', ' *', class: 'required') : ''), |
|
|
|
|
for: "#{name}_custom_field_values_#{custom_value.custom_field.id}", |
|
|
|
|
class: "form--label #{(custom_value.errors.empty? ? nil : 'error')}", |
|
|
|
|
class: "form--label #{custom_value.errors.empty? ? nil : 'error'}", |
|
|
|
|
lang: custom_value.custom_field.name_locale |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -151,7 +158,7 @@ module CustomFieldsHelper |
|
|
|
|
custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def custom_field_tag_for_bulk_edit(name, custom_field, project=nil) |
|
|
|
|
def custom_field_tag_for_bulk_edit(name, custom_field, project = nil) |
|
|
|
|
field_name = "#{name}[custom_field_values][#{custom_field.id}]" |
|
|
|
|
field_id = "#{name}_custom_field_values_#{custom_field.id}" |
|
|
|
|
field_format = OpenProject::CustomFieldFormat.find_by_name(custom_field.field_format) |
|
|
|
@ -165,7 +172,8 @@ module CustomFieldsHelper |
|
|
|
|
[I18n.t(:general_text_yes), '1'], |
|
|
|
|
[I18n.t(:general_text_no), '0']]), id: field_id) |
|
|
|
|
when 'list' |
|
|
|
|
styled_select_tag(field_name, options_for_select([[I18n.t(:label_no_change_option), '']] + custom_field.possible_values_options(project)), id: field_id) |
|
|
|
|
styled_select_tag(field_name, |
|
|
|
|
options_for_select([[I18n.t(:label_no_change_option), '']] + custom_field.possible_values_options(project)), id: field_id) |
|
|
|
|
else |
|
|
|
|
styled_text_field_tag(field_name, '', id: field_id) |
|
|
|
|
end |
|
|
|
|