formbuilder-rb 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/formbuilder/response_field.rb +20 -0
- data/lib/formbuilder/version.rb +1 -1
- data/lib/formbuilder/views/form_field.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0237c994ea6bf9a2fa67cf0a5693a89a047b984
|
4
|
+
data.tar.gz: a54619515112c3d9a35bee51a422ad315d90f643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3ac88c11bf6057fa288a168c34f7b20bf6a5d4bbdf62ce0c041cf5e73ba1a43e6d704116464fd6c30f770f773e41a9e00d7162a92a4c6e7ccb2346c2f280be1
|
7
|
+
data.tar.gz: 540b867ba74f7abe13288be88621a5ca9ed74e7b4ab02462b6958a6ed51a49d2a3582e2bff1bda92e2c68c6b5e82854eab461011d0b8155eddb05427e386f241
|
@@ -53,6 +53,18 @@ module Formbuilder
|
|
53
53
|
length_validations(false).any?
|
54
54
|
end
|
55
55
|
|
56
|
+
def min_max_length_units
|
57
|
+
field_options[:min_max_length_units] || 'characters'
|
58
|
+
end
|
59
|
+
|
60
|
+
def minlength
|
61
|
+
field_options[:minlength].presence
|
62
|
+
end
|
63
|
+
|
64
|
+
def maxlength
|
65
|
+
field_options[:maxlength].presence
|
66
|
+
end
|
67
|
+
|
56
68
|
def min_max_validations
|
57
69
|
return_hash = {
|
58
70
|
min: field_options[:min],
|
@@ -62,6 +74,14 @@ module Formbuilder
|
|
62
74
|
return_hash.select { |k, v| v.present? }
|
63
75
|
end
|
64
76
|
|
77
|
+
def min
|
78
|
+
field_options[:min].presence
|
79
|
+
end
|
80
|
+
|
81
|
+
def max
|
82
|
+
field_options[:max].presence
|
83
|
+
end
|
84
|
+
|
65
85
|
def render_input(value, opts = {})
|
66
86
|
raise 'Not implemented'
|
67
87
|
end
|
data/lib/formbuilder/version.rb
CHANGED
@@ -11,6 +11,8 @@ module Formbuilder
|
|
11
11
|
render_label if @response_field.input_field
|
12
12
|
rawtext @response_field.render_input(@value, entry: @entry)
|
13
13
|
div.clear
|
14
|
+
render_min_max_lengths
|
15
|
+
render_min_max
|
14
16
|
render_error if @response_field.input_field && @entry.error_for(@response_field)
|
15
17
|
render_description if @response_field.input_field && @response_field[:field_options]["description"].present?
|
16
18
|
}
|
@@ -40,6 +42,40 @@ module Formbuilder
|
|
40
42
|
}
|
41
43
|
end
|
42
44
|
|
45
|
+
def render_min_max_lengths
|
46
|
+
return unless @response_field.input_field && @response_field.has_length_validations?
|
47
|
+
|
48
|
+
div.min_max {
|
49
|
+
if @response_field.minlength && @response_field.maxlength
|
50
|
+
text "Between #{@response_field.minlength} and #{@response_field.maxlength} #{@response_field.min_max_length_units}."
|
51
|
+
elsif @response_field.minlength
|
52
|
+
text "More than #{@response_field.minlength} #{@response_field.min_max_length_units}."
|
53
|
+
elsif @response_field.maxlength
|
54
|
+
text "Less than #{@response_field.maxlength} #{@response_field.min_max_length_units}."
|
55
|
+
end
|
56
|
+
|
57
|
+
text ' Current count: '
|
58
|
+
code.min_max_counter
|
59
|
+
text " #{@response_field.min_max_length_units}."
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def render_min_max
|
64
|
+
return unless @response_field.input_field && @response_field.min_max_validations.present?
|
65
|
+
|
66
|
+
div.min_max {
|
67
|
+
div.min_max_info {
|
68
|
+
if @response_field.min && @response_field.max
|
69
|
+
text "Between #{@response_field.min} and #{@response_field.max}."
|
70
|
+
elsif @response_field.min
|
71
|
+
text "More than #{@response_field.min}."
|
72
|
+
elsif @response_field.max
|
73
|
+
text "Less than #{@response_field.max}."
|
74
|
+
end
|
75
|
+
}
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
43
79
|
end
|
44
80
|
end
|
45
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formbuilder-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|