volt-fields 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 367e338964108d7f1191e201bd9abe726b9092e2
|
4
|
+
data.tar.gz: 834a3bd03171d6b49c77c090f5295a0c0ca82467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee7343ee75568268dc8837ef993c0e15d3ef9b82263a1df5340d45df7ee90978c40693aeb6edb8244aebc2d32b6f01e2f47d63a2c0bffedb45406d5aafd22729
|
7
|
+
data.tar.gz: d70a0b032a2e7b71c715c8d3f3b2ea1620dfbb4e2af22be79df751b389014211df1691b4f59f5d20829fbbc29f10072372992de6d7bd4349fc2401bd691badf2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -3,20 +3,20 @@ require 'fields/controllers/main_controller'
|
|
3
3
|
module Fields
|
4
4
|
class CheckboxController < MainController
|
5
5
|
before_action :setup_field
|
6
|
-
|
6
|
+
|
7
7
|
def setup_field
|
8
8
|
# Get the name of the field by looking at the method scope
|
9
9
|
@field_name = attrs.checked_last_method.gsub(/^[_]/, '')
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def inline
|
13
13
|
# Get the name of the field by looking at the method scope
|
14
14
|
@field_name = attrs.checked_last_method.gsub(/^[_]/, '')
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Find the parent reactive value that produced the value
|
18
18
|
# (usually just model._field)
|
19
|
-
def
|
19
|
+
def model_inst
|
20
20
|
attrs.checked_parent
|
21
21
|
end
|
22
22
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fields
|
2
2
|
class MainController < Volt::ModelController
|
3
3
|
before_action :setup_field
|
4
|
-
|
4
|
+
|
5
5
|
def setup_field
|
6
6
|
# Default to text fields
|
7
7
|
if attrs.respond_to?(:type)
|
@@ -10,13 +10,18 @@ module Fields
|
|
10
10
|
@type = 'text'
|
11
11
|
end
|
12
12
|
|
13
|
+
unless attrs.value_last_method
|
14
|
+
field_type = self.class.to_s.underscore.gsub(/[_]Controller$/, '')
|
15
|
+
raise "a <:fields:#{field_type} tag was used without passing a value attribute"
|
16
|
+
end
|
17
|
+
|
13
18
|
# Get the name of the field by looking at the method scope
|
14
19
|
@field_name = attrs.value_last_method.gsub(/^[_]/, '')
|
15
20
|
end
|
16
|
-
|
21
|
+
|
17
22
|
# Find the parent reactive value that produced the value
|
18
23
|
# (usually just model._field)
|
19
|
-
def
|
24
|
+
def model_inst
|
20
25
|
attrs.value_parent
|
21
26
|
end
|
22
27
|
|
@@ -26,16 +31,16 @@ module Fields
|
|
26
31
|
|
27
32
|
# Find the errors for this field
|
28
33
|
def errors
|
29
|
-
|
34
|
+
model_inst.marked_errors[@field_name]
|
30
35
|
end
|
31
36
|
|
32
37
|
# When a field goes out of focus, then we want to start checking a field
|
33
38
|
def blur
|
34
|
-
|
39
|
+
model_inst.mark_field!(@field_name)
|
35
40
|
end
|
36
41
|
|
37
42
|
def marked
|
38
|
-
|
43
|
+
model_inst.marked_fields[@field_name]
|
39
44
|
end
|
40
45
|
end
|
41
46
|
end
|
@@ -4,12 +4,12 @@ module Fields
|
|
4
4
|
class RadioController < MainController
|
5
5
|
# When a radio button is clicked, set the value of the field and start checking the field
|
6
6
|
def set_field(value)
|
7
|
-
|
8
|
-
|
7
|
+
model_inst.send("#{@field_name}=", value)
|
8
|
+
model_inst.mark_field!(@field_name)
|
9
9
|
end
|
10
10
|
|
11
11
|
def checked?(value)
|
12
|
-
value ==
|
12
|
+
value == model_inst.send(@field_name)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt-fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|