rails-angulate 0.0.5.rc2 → 0.0.5.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails/angulate/helpers/form_builder.rb +5 -0
- data/lib/rails/angulate/helpers/form_helper.rb +4 -0
- data/lib/rails/angulate/helpers/tags/ng_select.rb +31 -0
- data/lib/rails/angulate/helpers/tags/ng_validation_errors.rb +1 -1
- data/lib/rails/angulate/helpers/tags/tag_common.rb +4 -3
- data/lib/rails/angulate/helpers/tags.rb +1 -0
- data/lib/rails/angulate/mappers/numericality_validator_mapper.rb +3 -4
- data/lib/rails/angulate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 579c5aef03d33a767c2f0d02f24d7cf29ef3cd97
|
4
|
+
data.tar.gz: bf26772ceca3807d70109b0efd1ab9fcf7b3e8ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbb013b92260edeae0df09419059e6c62c726663180b8da0a90bf27833aa0216c6653020696c83e5025d5f5df108d471d982796891b3bb52a998041ded54a8aa
|
7
|
+
data.tar.gz: 5dbd378fe0540609cde6f4b255a37131dbcac974ecdede7c702487fdc50dac2986a0915d9e0e6e3dcebfbbb854a1e04f6706baa2a0d8534a4f27a799142ceb6a
|
@@ -32,6 +32,11 @@ module Rails
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def ng_select(object_name, method, choices = {}, options = {}, html_options = {})
|
36
|
+
options = objectify_options(options)
|
37
|
+
@template.ng_select(object_name, method, choices, options, html_options)
|
38
|
+
end
|
39
|
+
|
35
40
|
protected
|
36
41
|
|
37
42
|
def apply_builder_options(options)
|
@@ -25,6 +25,10 @@ module Rails
|
|
25
25
|
Tags::NgEmailField.new(object_name, method, self, options).render
|
26
26
|
end
|
27
27
|
|
28
|
+
def ng_select(object_name, method, choices = {}, options = {}, html_options = {})
|
29
|
+
Tags::NgSelect.new(object_name, method, self, choices, options, html_options).render
|
30
|
+
end
|
31
|
+
|
28
32
|
def ng_error_messages_for(object_name, method, options = {})
|
29
33
|
Tags::NgValidationErrors.new(object_name, method, self, options).render
|
30
34
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Rails
|
2
|
+
module Angulate
|
3
|
+
module Helpers
|
4
|
+
module Tags
|
5
|
+
class NgSelect < ActionView::Helpers::Tags::Select
|
6
|
+
include TagCommon
|
7
|
+
|
8
|
+
def render
|
9
|
+
option_tags_options = {
|
10
|
+
:selected => @options.fetch(:selected) { value(@object) },
|
11
|
+
:disabled => @options[:disabled]
|
12
|
+
}
|
13
|
+
|
14
|
+
option_tags = if grouped_choices?
|
15
|
+
grouped_options_for_select(@choices, option_tags_options)
|
16
|
+
else
|
17
|
+
options_for_select(@choices, option_tags_options)
|
18
|
+
end
|
19
|
+
|
20
|
+
add_default_name_and_id(@options)
|
21
|
+
add_ng_options(@options)
|
22
|
+
add_ng_model(@options)
|
23
|
+
add_ng_validation_attrs(@options)
|
24
|
+
|
25
|
+
select_content_tag(option_tags, @options, @html_options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -44,13 +44,14 @@ module Rails
|
|
44
44
|
def add_ng_model(options)
|
45
45
|
unless options.has_key?("ng-model")
|
46
46
|
options["ng-model"] = options.fetch("ngModel") do
|
47
|
-
|
47
|
+
name = options["id"] || options["name"]
|
48
|
+
ng_model_name(name)
|
48
49
|
end.to_s
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
def ng_model_name(
|
53
|
-
|
53
|
+
def ng_model_name(name)
|
54
|
+
name.camelize(:lower)
|
54
55
|
end
|
55
56
|
|
56
57
|
module ClassMethods
|
@@ -43,6 +43,8 @@ module Rails
|
|
43
43
|
hash[option] = "value % 2 != 0"
|
44
44
|
when :even
|
45
45
|
hash[option] = "value % 2 == 0"
|
46
|
+
when :only_integer
|
47
|
+
hash[option] = %q{value / 1 == value}
|
46
48
|
else
|
47
49
|
case option_value
|
48
50
|
when Proc
|
@@ -56,9 +58,6 @@ module Rails
|
|
56
58
|
hash[option] = "value #{op} #{option_value}"
|
57
59
|
end
|
58
60
|
|
59
|
-
# TODO: hmm, neither isNaN nor a Regex work when called with scope.$eval
|
60
|
-
hash[:only_integer] = %q{!isNaN(+value)} if allow_only_integer?
|
61
|
-
|
62
61
|
hash
|
63
62
|
end
|
64
63
|
end
|
@@ -75,7 +74,7 @@ module Rails
|
|
75
74
|
end
|
76
75
|
|
77
76
|
def numericality_options
|
78
|
-
@numericality_options ||= validator_options.slice(*CHECKS.keys)
|
77
|
+
@numericality_options ||= validator_options.slice(*CHECKS.keys + [:only_integer])
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-angulate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.5.
|
4
|
+
version: 0.0.5.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Bondi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/rails/angulate/helpers/form_helper.rb
|
95
95
|
- lib/rails/angulate/helpers/tags.rb
|
96
96
|
- lib/rails/angulate/helpers/tags/ng_email_field.rb
|
97
|
+
- lib/rails/angulate/helpers/tags/ng_select.rb
|
97
98
|
- lib/rails/angulate/helpers/tags/ng_text_area.rb
|
98
99
|
- lib/rails/angulate/helpers/tags/ng_text_field.rb
|
99
100
|
- lib/rails/angulate/helpers/tags/ng_validation_errors.rb
|