populate-me 0.14.0 → 0.15.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85deae1b12e76c47c378e2f3843d5e840d06b95cc5359edd130fd64ffa9b88d0
|
4
|
+
data.tar.gz: 7078d10da19910b9962bfd3656c3543dd5389be624d11896e8248246f4170eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44c9c3cabe40c90112e0cc4af8e4e1b9f3105f9c7baff24e568cda0e3fb697c84ad00f62e2812fa323ac18475fe3d9d85b711409b1a07f8ba3077b0d9e8973b2
|
7
|
+
data.tar.gz: 3a9f806d103a25e7444cda57035bcd5fbfd6fbfa4492458b340c4a56324a4bca990f5e65c3f489728a0d07aa28e62f8c855c9a9cb602b7abc71ba12622d565e4
|
@@ -117,7 +117,14 @@
|
|
117
117
|
</script>
|
118
118
|
|
119
119
|
<script id="template-string-field" type="x-tmpl-mustache">
|
120
|
-
<input name='{{input_name}}' value='{{input_value}}' {{#required}}required{{/required}}{{{build_input_attributes}}} />
|
120
|
+
<input name='{{input_name}}' value='{{input_value}}' {{#required}}required{{/required}}{{{build_input_attributes}}} {{#autocomplete.length}}list='datalist-{{id}}'{{/autocomplete.length}} />
|
121
|
+
{{#autocomplete.length}}
|
122
|
+
<datalist id='datalist-{{id}}'>
|
123
|
+
{{#autocomplete}}
|
124
|
+
<option value='{{.}}' />
|
125
|
+
{{/autocomplete}}
|
126
|
+
</datalist>
|
127
|
+
{{/autocomplete.length}}
|
121
128
|
</script>
|
122
129
|
|
123
130
|
<script id="template-text-field" type="x-tmpl-mustache">
|
@@ -21,6 +21,14 @@ module PopulateMe
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def outcast_string field, item, o={}
|
25
|
+
if item.key? :autocomplete
|
26
|
+
item = item.dup
|
27
|
+
item[:autocomplete] = WebUtils.deep_copy(WebUtils.get_value(item[:autocomplete],self))
|
28
|
+
end
|
29
|
+
item
|
30
|
+
end
|
31
|
+
|
24
32
|
def outcast_list field, item, o={}
|
25
33
|
item = item.dup
|
26
34
|
item[:items] = self.__send__(field).map do |nested|
|
data/lib/populate_me/version.rb
CHANGED
data/populate-me.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency 'sinatra', '~> 2'
|
22
22
|
s.add_dependency 'json', '~> 2.1'
|
23
23
|
|
24
|
-
s.add_development_dependency 'bundler', '
|
24
|
+
s.add_development_dependency 'bundler', '>= 2.2.10'
|
25
25
|
s.add_development_dependency 'minitest', '~> 5.8'
|
26
26
|
s.add_development_dependency 'rack-test', '~> 0.6'
|
27
27
|
s.add_development_dependency 'rack-cerberus', '~> 1.0'
|
@@ -6,6 +6,7 @@ class Outcasted < PopulateMe::Document
|
|
6
6
|
set :default_attachment_class, PopulateMe::Attachment
|
7
7
|
|
8
8
|
field :name
|
9
|
+
field :category, autocomplete: ['Fish', 'Cat', 'Bunny']
|
9
10
|
field :size, type: :select, select_options: [
|
10
11
|
{description: 'small', value: 's'},
|
11
12
|
{description: 'medium', value: 'm'},
|
@@ -23,6 +24,10 @@ class Outcasted < PopulateMe::Document
|
|
23
24
|
field :weirdo, type: :strange
|
24
25
|
field :price, type: :price
|
25
26
|
|
27
|
+
def get_category_autocomplete_list
|
28
|
+
['Horse', 'Bear']
|
29
|
+
end
|
30
|
+
|
26
31
|
def get_size_options
|
27
32
|
[
|
28
33
|
[:small, :s],
|
@@ -65,6 +70,36 @@ describe PopulateMe::Document, 'Outcasting' do
|
|
65
70
|
|
66
71
|
end
|
67
72
|
|
73
|
+
describe '#outcast_string' do
|
74
|
+
|
75
|
+
it 'Generates the autocomplete options when needed' do
|
76
|
+
original = Outcasted.fields[:category]
|
77
|
+
output = Outcasted.new.outcast(:category, original, {input_name_prefix: 'data'})
|
78
|
+
assert_equal ['Fish', 'Cat', 'Bunny'], output[:autocomplete]
|
79
|
+
refute original.equal?(output)
|
80
|
+
|
81
|
+
original = Outcasted.fields[:name]
|
82
|
+
output = Outcasted.new.outcast(:name, original, {input_name_prefix: 'data'})
|
83
|
+
refute output.key?(:autocomplete)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'Generates the autocomplete options from a proc' do
|
87
|
+
original = Outcasted.fields[:category].dup
|
88
|
+
original[:autocomplete] = proc{ ['Dog', 'Snake'] }
|
89
|
+
output = Outcasted.new.outcast(:category, original, {input_name_prefix: 'data'})
|
90
|
+
assert_equal ['Dog', 'Snake'], output[:autocomplete]
|
91
|
+
assert original[:autocomplete].is_a?(Proc)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'Generates the autocomplete options from a method name' do
|
95
|
+
original = Outcasted.fields[:category].dup
|
96
|
+
original[:autocomplete] = :get_category_autocomplete_list
|
97
|
+
output = Outcasted.new.outcast(:category, original, {input_name_prefix: 'data'})
|
98
|
+
assert_equal ['Horse', 'Bear'], output[:autocomplete]
|
99
|
+
assert original[:autocomplete].is_a?(Symbol)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
68
103
|
describe '#outcast_list' do
|
69
104
|
|
70
105
|
it 'Has no value and an empty list of items when list is empty' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populate-me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.2.10
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.2.10
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|