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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 746aecc1ab2ad42de660621e9a13dee05d152060
4
- data.tar.gz: a33a211dc9e608310669960a79321c8f26be5bcf
3
+ metadata.gz: 579c5aef03d33a767c2f0d02f24d7cf29ef3cd97
4
+ data.tar.gz: bf26772ceca3807d70109b0efd1ab9fcf7b3e8ff
5
5
  SHA512:
6
- metadata.gz: 9db0417675c8b5828fba257608246c47a2f613e07660be98a9037eac44c46195fc228b1d8b10512aa3efb4d13952271fd59a0ce150694ea3c2b6dea6c268ba02
7
- data.tar.gz: 39a302b1b00e5c0e76f08183ed942b51d97bc0fd1c8386b558b2b29de8d16cad59a9081750848148d8c822b9612f0ffdb1da3276fe08e1b262549b207e275624
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
@@ -8,7 +8,7 @@ module Rails
8
8
  def render
9
9
  # We can't use content_tag with a block (no self.output_buffer)
10
10
  # so we pass in content
11
- container(angular_error_list_html)
11
+ container(angular_error_list_html) unless validators.empty?
12
12
  end
13
13
 
14
14
  private
@@ -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
- ng_model_name(options["id"])
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(id)
53
- id.camelize(:lower)
53
+ def ng_model_name(name)
54
+ name.camelize(:lower)
54
55
  end
55
56
 
56
57
  module ClassMethods
@@ -7,6 +7,7 @@ module Rails
7
7
  eager_autoload do
8
8
  autoload :TagCommon
9
9
  autoload :NgTextField
10
+ autoload :NgSelect
10
11
  autoload :NgTextArea
11
12
  autoload :NgEmailField
12
13
  autoload :NgValidationErrors
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Angulate
3
- VERSION = "0.0.5.rc2"
3
+ VERSION = "0.0.5.rc3"
4
4
  end
5
5
  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.rc2
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-09 00:00:00.000000000 Z
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