hungryform-rails 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e1dbc3db77663b5d70ffed6dc331c8567ddb438
4
- data.tar.gz: 68cb11ae8193f7047e1a4cd74b6c2ac0fe481f26
3
+ metadata.gz: 352c2e9eab241d7cd69e2be42d84cda9961e8f10
4
+ data.tar.gz: 4c3b715e1c945e777710b4277f95a4350f1058a0
5
5
  SHA512:
6
- metadata.gz: 61346d2de43d07701d7375cb85f0982e789e90d752060ae205fadfc8a37b84fb947a898d5935bfdb83fd10148d0e2eb950372212222403b86d90c02df6c19337
7
- data.tar.gz: 3b4da5e9334f8d65bf48a78fee4aa2fe873256fb245d1630ed5febe67a9d9709960dc56098e8d136f154fdc9bd47b0d5f1122de2b1ef61520a61553f063144cd
6
+ metadata.gz: f228d423f2b55ffdd7f8125516ee61d05f83d7cf37364d10ba17a603427b8c8afc598f6fea63bb19c2ed822452131e8898bcfea592e7ff4ece5ba32d43eb7d78
7
+ data.tar.gz: ab002ba6dd14ca41ef1cf1367ec0242f6d382fb121faf2a03b1576b60cbee95bb9affaa1a1ace3d0df6b52359c418c83afed93001ddceec65096e69d65cabbe8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  #Hungryform Rails [![Build Status](https://travis-ci.org/andrba/hungryform-rails.svg?branch=master)](https://travis-ci.org/andrba/hungryform-rails)
2
2
 
3
- This gem is an adaptor between the HungryForm gem and Rails.
3
+ This gem is an adaptor between the [HungryForm](http://github.com/andrba/hungryform) gem and Rails.
4
4
 
5
5
  ##Installation:
6
6
 
@@ -1,8 +1,8 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  concat label_tag field.name, field.label << ("*" if field.required?).to_s
4
4
  concat hidden_field_tag field.name, 0
5
- concat check_box_tag field.name, 1, field.checked?, field.attributes.except(:class, :checked)
5
+ concat check_box_tag field.name, 1, field.checked?, field.input_attributes
6
6
  unless field.error.empty?
7
7
  concat content_tag :span, field.error, class: 'error'
8
8
  end
@@ -1,4 +1,4 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  field.elements.each do |el|
4
4
  concat render partial: "#{views_prefix}/#{el.class.name.demodulize.underscore}", locals: { field: el, views_prefix: views_prefix }
@@ -1,4 +1,4 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do -%>
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do -%>
2
2
 
3
3
  <%= field.value.html_safe %>
4
4
 
@@ -1,8 +1,8 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  concat label_tag field.name, field.label << ("*" if field.required?).to_s
4
4
  field.options.each do |key, value|
5
- concat radio_button_tag key, value, field.value == value, field.attributes.except(:class)
5
+ concat radio_button_tag key, value, field.value == value, field.input_attributes
6
6
  end
7
7
  unless field.error.empty?
8
8
  concat content_tag :span, field.error, class: 'error'
@@ -1,7 +1,7 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  concat label_tag field.name, field.label << ("*" if field.required?).to_s
4
- concat select_tag field.name, options_for_select(field.options.invert, field.value), field.attributes.except(:class)
4
+ concat select_tag field.name, options_for_select(field.options.invert, field.value), field.input_attributes
5
5
  unless field.error.empty?
6
6
  concat content_tag :span, field.error, class: 'error'
7
7
  end
@@ -1,7 +1,7 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  concat label_tag field.name, field.label << ("*" if field.required?).to_s
4
- concat text_area_tag field.name, field.value, field.attributes.except(:class)
4
+ concat text_area_tag field.name, field.value, field.input_attributes
5
5
  unless field.error.empty?
6
6
  concat content_tag :span, field.error, class: 'error'
7
7
  end
@@ -1,7 +1,7 @@
1
- <%= content_tag :div, id: "#{field.name}_wrapper", class: field.html_class, 'data-dependency' => field.dependency_json do
1
+ <%= content_tag :div, id: "#{field.name}_wrapper", class: field.wrapper_class, 'data-dependency' => field.dependency_json do
2
2
 
3
3
  concat label_tag field.name, field.label << ("*" if field.required?).to_s
4
- concat text_field_tag field.name, field.value, field.attributes.except(:class)
4
+ concat text_field_tag field.name, field.value, field.input_attributes
5
5
  unless field.error.empty?
6
6
  concat content_tag :span, field.error, class: 'error'
7
7
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.required_ruby_version = '>= 2.0.0'
23
23
 
24
- spec.add_dependency 'hungryform', '~> 0.0', '>= 0.0.9'
24
+ spec.add_dependency 'hungryform', '~> 0.0', '>= 0.0.10'
25
25
  spec.add_dependency 'rails', '>= 3.2.1'
26
26
 
27
27
  spec.add_development_dependency "rspec", '~> 3.0'
@@ -1,13 +1,18 @@
1
1
  module HungryForm
2
2
  module Rails
3
3
  module Renderable
4
- def html_class
4
+ def wrapper_class
5
5
  classes = []
6
- classes << attributes[:class] if attributes[:class]
6
+ classes << configuration[:wrapper_class] if configuration.key?(:wrapper_class)
7
+ classes << attributes[:wrapper_class] if attributes[:wrapper_class]
7
8
  classes << 'hidden' unless visible?
8
9
  classes << 'invalid' if self.is_a?(HungryForm::Elements::Base::ActiveElement) && self.error.present?
9
10
  classes.join(' ') if classes.any?
10
11
  end
12
+
13
+ def input_attributes
14
+ attributes.except(*[configuration[:input_attributes_except], :wrapper_class].flatten)
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -1,5 +1,5 @@
1
1
  module HungryForm
2
2
  module Rails
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -25,10 +25,9 @@ RSpec.shared_examples 'rendered active element' do
25
25
  end
26
26
  end
27
27
 
28
- # As a class is gonna be in the wrapper
29
- it 'does not have an input with a class attribute' do
30
- attributes[:class] = 'my_class'
28
+ it 'has a wrapper class attribute in the div wrapper' do
29
+ attributes[:wrapper_class] = 'my_class'
31
30
  render render_params
32
- expect(rendered).not_to match /<input.*class="my_class"/
31
+ expect(rendered).to match /<div.*class="my_class"/
33
32
  end
34
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hungryform-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Bazhutkin
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.0.9
22
+ version: 0.0.10
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.0.9
32
+ version: 0.0.10
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rails
35
35
  requirement: !ruby/object:Gem::Requirement