Project

General

Profile

Feature #14275 » 14275.patch

Go MAEDA, 2021-05-13 17:27

View differences:

app/helpers/custom_fields_helper.rb
79 79

  
80 80
  # Return custom field html tag corresponding to its format
81 81
  def custom_field_tag(prefix, custom_value)
82
    css = custom_value.custom_field.css_classes
82
    cf = custom_value.custom_field
83
    css = cf.css_classes
84
    placeholder = cf.description
85
    placeholder&.tr!("\n", ' ') if cf.field_format != 'text'
83 86
    data = nil
84
    if custom_value.custom_field.full_text_formatting?
87
    if cf.full_text_formatting?
85 88
      css += ' wiki-edit'
86 89
      data = {
87 90
        :auto_complete => true
88 91
      }
89 92
    end
90
    custom_value.custom_field.format.edit_tag(
93
    cf.format.edit_tag(
91 94
      self,
92
      custom_field_tag_id(prefix, custom_value.custom_field),
93
      custom_field_tag_name(prefix, custom_value.custom_field),
95
      custom_field_tag_id(prefix, cf),
96
      custom_field_tag_name(prefix, cf),
94 97
      custom_value,
95 98
      :class => css,
99
      :placeholder => placeholder,
96 100
      :data => data)
97 101
  end
98 102

  
public/stylesheets/application.css
510 510
  outline: none;
511 511
}
512 512

  
513
input:placeholder-shown {
514
  text-overflow: ellipsis;
515
}
516

  
513 517
select[multiple=multiple] {background: #fff; padding-right: initial; height: auto;}
514 518
fieldset {border: 1px solid #e4e4e4; margin:0; min-width: inherit;}
515 519
legend {color: #333;}
test/helpers/custom_fields_helper_test.rb
96 96
    assert_select_in custom_field_tag('object', value), "textarea.text_cf.wiki-edit.cf_#{field.id}"
97 97
  end
98 98

  
99
  def test_custom_field_tag_class_should_contain_placeholder
100
    field = IssueCustomField.create!(:name => 'Text', :field_format => 'string', :description => "Foo\nBar\nBaz")
101
    value = CustomValue.new(:value => 'bar', :custom_field => field)
102

  
103
    assert_select_in custom_field_tag('object', value), "input.string_cf.cf_#{field.id}[placeholder=?]", 'Foo Bar Baz'
104
  end
105

  
99 106
  def test_select_type_radio_buttons
100 107
    result = select_type_radio_buttons('UserCustomField')
101 108
    assert_select_in result, 'input[type="radio"]', :count => 10
(1-1/4)