simple_form_autocomplete 1.0.1 → 1.1.0

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: 90bd40213c5fff4f2ad13333ccf07d5abf7bb3c5
4
- data.tar.gz: 8d023eb2862b5b73db42866d2ebd541d39a5a6be
3
+ metadata.gz: c4c06e7ce6d644d80eb4869681d7d48116d40bf1
4
+ data.tar.gz: 1fe03e4fcb1bb0055509914a3cce8f4cceac1514
5
5
  SHA512:
6
- metadata.gz: d1c6948269158776b8bc3f69b9b237a8842686aef5adc30e4dcb44a2919d3cec2bcdf1bc8bb1b8ec344d1b0e33e7f78aa89eb4720065fdedfa26c3ff224a9eb6
7
- data.tar.gz: 1a1db610a473a10b11f70c2dba29fe25d52c00d6c0753f915ed41ebf553fa9d512060d3022a5fb9234927752737e6cda755106c2aa32cc4d598ec10941a2a70a
6
+ metadata.gz: d9d8ce275ce3c1f571911317f3db63d6137e56aea3d1cbb284d2335ae5c0db37af29eca6ad284eaf94bc1f8601351b8bab8b2197ce0985526f288bc5c6e92a26
7
+ data.tar.gz: 36f954ce80443aa56d0b80cd965bfbb394901f4a6bda5ed43d05ae305ab901cf3b1d6d726ce99e509c25ee529fe3273b56befc9643d3241521a8b69f44335914
data/README.md CHANGED
@@ -25,14 +25,14 @@ Or install it yourself as:
25
25
  Require the Javascript in your `application.js` (or other preferred) file via sprockets:
26
26
 
27
27
  ```javascript
28
- //= require 'simple_form_autocomplete'
28
+ //= require simple_form_autocomplete
29
29
  ```
30
30
 
31
- Alternatively import the CSS in your `application.css.scss` (or other preferred) file. For
31
+ Optionally import the CSS in your `application.css.scss` (or other preferred) file. For
32
32
  sprockets-based apps:
33
33
 
34
34
  ```javascript
35
- //= require 'simple_form_autocomplete';
35
+ //= require simple_form_autocomplete
36
36
  ```
37
37
 
38
38
  For SCSS imports:
@@ -3,8 +3,10 @@ require 'active_support/core_ext/hash/deep_merge'
3
3
  module SimpleForm
4
4
  module Inputs
5
5
  class AutocompleteInput < Base
6
- def input
7
- @builder.text_field(attribute_name, input_html_options) <<
6
+ def input(wrapper_options = nil)
7
+ merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
8
+
9
+ @builder.text_field(attribute_name, merged_input_options) <<
8
10
  @builder.hidden_field(attribute_name, hidden_html_options)
9
11
  end
10
12
 
@@ -21,7 +23,7 @@ module SimpleForm
21
23
 
22
24
  def hidden_html_options
23
25
  {
24
- value: options[:value] || hidden_tag_value
26
+ value: options.key?(:value) ? options[:value] : hidden_tag_value
25
27
  }
26
28
  end
27
29
 
@@ -1,3 +1,3 @@
1
1
  module SimpleFormAutocomplete
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -21,10 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'activesupport'
22
22
  spec.add_dependency 'simple_form'
23
23
 
24
- spec.add_development_dependency 'actionpack'
25
- spec.add_development_dependency 'activemodel'
26
24
  spec.add_development_dependency 'bundler', '~> 1.3'
27
25
  spec.add_development_dependency 'nokogiri'
26
+ spec.add_development_dependency 'rails'
28
27
  spec.add_development_dependency 'rake'
29
28
  spec.add_development_dependency 'rspec'
30
29
  end
@@ -8,9 +8,10 @@ describe SimpleForm::Inputs::AutocompleteInput do
8
8
 
9
9
  let(:record) { Ingredient.new }
10
10
  let(:collection) { %w[cup teaspoon tablespoon] }
11
+ let(:form_options) { {} }
11
12
  let(:options) { {} }
12
13
  let(:form) do
13
- concat(simple_form_for(record) { |f|
14
+ concat(simple_form_for(record, form_options) { |f|
14
15
  concat(f.input :name, { as: :autocomplete, source: ingredients_autocomplete_path }.merge(options))
15
16
  concat(f.input :unit, { as: :autocomplete, source: collection }.merge(options))
16
17
  })
@@ -86,5 +87,37 @@ describe SimpleForm::Inputs::AutocompleteInput do
86
87
  expect(input.attribute('data-source').value).to eq ingredients_autocomplete_path
87
88
  end
88
89
  end
90
+
91
+ describe 'with wrapper options' do
92
+ before do
93
+ SimpleForm.setup do |config|
94
+ config.wrappers :custom, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
95
+ b.use :html5
96
+ b.use :placeholder
97
+ b.optional :maxlength
98
+ b.optional :pattern
99
+ b.optional :min_max
100
+ b.optional :readonly
101
+ b.use :label, class: 'control-label'
102
+
103
+ b.use :input, class: 'form-control'
104
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
105
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
106
+ end
107
+ end
108
+ end
109
+
110
+ let(:form_options) { { wrapper: :custom } }
111
+
112
+ it 'should maintain the custom wrapper class' do
113
+ div = subject.xpath('//div[contains(concat(" ", normalize-space(@class), " "), "ingredient_name")]')
114
+ expect(div.attribute('class').value).to match /\bform-group\b/
115
+ end
116
+
117
+ it 'should maintain the custom input class' do
118
+ input = subject.xpath('//input[@id="ingredient_name_autocomplete"]')
119
+ expect(input.attribute('class').value).to match /\bform-control\b/
120
+ end
121
+ end
89
122
  end
90
123
  end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/object/to_json'
1
+ require 'rails/all'
2
2
  require 'cgi'
3
3
  require 'nokogiri'
4
4
  require 'simple_form'
@@ -1,4 +1,5 @@
1
1
  module AutocompleteSpecHelper
2
+ include ActionDispatch::Routing::UrlFor
2
3
  include ActionController::RecordIdentifier if defined?(ActionController::RecordIdentifier)
3
4
  include ActionView::RecordIdentifier if defined?(ActionView::RecordIdentifier)
4
5
  include ActionView::Helpers::FormHelper
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_autocomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Huggins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: actionpack
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
- name: activemodel
56
+ name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,21 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.3'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.3'
83
- - !ruby/object:Gem::Dependency
84
- name: nokogiri
70
+ name: rails
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -167,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
153
  version: '0'
168
154
  requirements: []
169
155
  rubyforge_project:
170
- rubygems_version: 2.2.2
156
+ rubygems_version: 2.4.5
171
157
  signing_key:
172
158
  specification_version: 4
173
159
  summary: jQuery autocomplete for SimpleForm form fields