From 68996be17668f4affeb28aa559978f48a630bfba Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sun, 30 May 2021 14:21:42 +0900 Subject: [PATCH 2/2] Show a custom field description as a placeholder --- app/helpers/custom_fields_helper.rb | 3 +++ public/stylesheets/application.css | 4 ++++ test/helpers/custom_fields_helper_test.rb | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 46762e91f..997e684ff 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -81,6 +81,8 @@ module CustomFieldsHelper def custom_field_tag(prefix, custom_value) cf = custom_value.custom_field css = cf.css_classes + placeholder = cf.description + placeholder&.tr!("\n", ' ') if cf.field_format != 'text' data = nil if cf.full_text_formatting? css += ' wiki-edit' @@ -94,6 +96,7 @@ module CustomFieldsHelper custom_field_tag_name(prefix, cf), custom_value, :class => css, + :placeholder => placeholder, :data => data) end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 91acad5ef..7c3a6f232 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -510,6 +510,10 @@ textarea:focus, textarea:active { outline: none; } +input:placeholder-shown { + text-overflow: ellipsis; +} + select[multiple=multiple] {background: #fff; padding-right: initial; height: auto;} fieldset {border: 1px solid #e4e4e4; margin:0; min-width: inherit;} legend {color: #333;} diff --git a/test/helpers/custom_fields_helper_test.rb b/test/helpers/custom_fields_helper_test.rb index 95b998584..e6d81a925 100644 --- a/test/helpers/custom_fields_helper_test.rb +++ b/test/helpers/custom_fields_helper_test.rb @@ -96,6 +96,13 @@ class CustomFieldsHelperTest < Redmine::HelperTest assert_select_in custom_field_tag('object', value), "textarea.text_cf.wiki-edit.cf_#{field.id}" end + def test_custom_field_tag_class_should_contain_placeholder + field = IssueCustomField.create!(:name => 'Text', :field_format => 'string', :description => "Foo\nBar\nBaz") + value = CustomValue.new(:value => 'bar', :custom_field => field) + + assert_select_in custom_field_tag('object', value), "input.string_cf.cf_#{field.id}[placeholder=?]", 'Foo Bar Baz' + end + def test_select_type_radio_buttons result = select_type_radio_buttons('UserCustomField') assert_select_in result, 'input[type="radio"]', :count => 10 -- 2.31.1