Project

General

Profile

Feature #14275 » 0002-Show-a-custom-field-description-as-a-placeholder.patch

Go MAEDA, 2021-05-30 07:25

View differences:

app/helpers/custom_fields_helper.rb
81 81
  def custom_field_tag(prefix, custom_value)
82 82
    cf = custom_value.custom_field
83 83
    css = cf.css_classes
84
    placeholder = cf.description
85
    placeholder&.tr!("\n", ' ') if cf.field_format != 'text'
84 86
    data = nil
85 87
    if cf.full_text_formatting?
86 88
      css += ' wiki-edit'
......
94 96
      custom_field_tag_name(prefix, cf),
95 97
      custom_value,
96 98
      :class => css,
99
      :placeholder => placeholder,
97 100
      :data => data)
98 101
  end
99 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
(4-4/4)