Merge pull request #2933 from myabc/fix/19428-label-truncation

[19428] Remove label truncation [fixup]
pull/3004/merge
Florian Kraft 10 years ago
commit 8a503a86d2
  1. 2
      app/assets/stylesheets/content/_forms.md
  2. 1
      app/assets/stylesheets/content/_forms.sass
  3. 2
      app/views/work_packages/_two_column_attributes.html.erb
  4. 3
      lib/tabular_form_builder.rb
  5. 25
      spec/lib/tabular_form_builder_spec.rb

@ -57,7 +57,7 @@
</div>
</div>
<div class="form--field">
<label class="form--label">Email:</label>
<label class="form--label -required">Email:</label>
<div class="form--field-container">
<div class="form--text-field-container">
<input type="email" class="form--text-field" placeholder="a valid email">

@ -254,6 +254,7 @@ fieldset.form--fieldset
@include grid-size(shrink)
max-width: none
&.-required,
.form--field.-required > &
&::after
@include default-transition

@ -28,7 +28,7 @@ See doc/COPYRIGHT.rdoc for more details.
++#%>
<% left_attributes, right_attributes = attributes.in_groups(2, false) %>
<div class="grid-block">
<div class="grid-block wrap">
<div class="form--column">
<% left_attributes.each do |attribute| %>
<%= attribute.field %>

@ -190,13 +190,12 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
label_options = { class: '',
title: text }
text += @template.content_tag('span', ' *', class: 'required') if options.delete(:required)
id = element_id(translation_form) if translation_form
# FIXME: reenable the error handling
label_options[:class] << 'error' if false && @object && @object.respond_to?(:errors) && @object.errors[field] # FIXME
label_options[:class] << 'form--label'
label_options[:class] << ' -required' if options.delete(:required)
label_options[:for] = if options[:for]
options[:for]
elsif options[:multi_locale] && id

@ -538,18 +538,14 @@ JJ Abrams</textarea>
describe 'labels for fields' do
let(:options) { {} }
shared_examples_for "generated label" do
def remove_form_field_container(string)
string.gsub(/<span class="form--field-container">.+<\/span>/m,'')
end
def expected_label_like(expected_title)
expect(remove_form_field_container(output)).to be_html_eql(%{
<label class="form--label"
def expected_label_like(expected_title, expected_classes = 'form--label')
expect(output).to be_html_eql(%{
<label class="#{expected_classes}"
for="user_name"
title="#{expected_title}">
#{expected_title}
</label>
})
}).at_path('label')
end
context 'with a label specified as string' do
@ -598,6 +594,19 @@ JJ Abrams</textarea>
expected_label_like(User.human_attribute_name(:name))
end
end
context 'when required, with a label specified as symbol' do
let(:text) { :name }
before do
options[:label] = text
options[:required] = true
end
it 'uses the label' do
expected_label_like(I18n.t(:name), 'form--label -required')
end
end
end
%w{ text_field

Loading…
Cancel
Save