rails-angulate 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 576545c753d58329200048bb33bec86c55d9ce24
4
- data.tar.gz: 88c7ef8625b479fee67aaaff6e73491fdef2c397
3
+ metadata.gz: 6dcb4962532ac0cafd799575cf926491cd8d56cb
4
+ data.tar.gz: b0c5a57ff8b21c43ed22de79aa96beabdd7d64a3
5
5
  SHA512:
6
- metadata.gz: 8cf18883909ca7da685db56e03d65bc7dc98d5d9d841170fab3a4914526e2fc18442822d10fb7e50cbba369830671a115f607c36396a8ba1034de174d50543b7
7
- data.tar.gz: df92fabf45cb2f9a84ebcb05750ece38004082d5986cfd10e4bcf1ea2d1257b3715a34df224ce4896a0db06de4273db3d2b55f49463318354c7f01da4434a43f
6
+ metadata.gz: c8658c6365dff8c50b9f17a023a36ea78d6a46ec2ee5f93febb2dde04cd908ec992ab41e522f36d9a2123e7bb3dc6650dd15c49dd52977439db3790e079245af
7
+ data.tar.gz: 8dae40660d82128ad8db8fb7e8ea7bcf9e6ff62aa9e66570d51bc5214a40f3119dcbda67318df728ee5970e1db2c84c4fd40a2fae888886c8d5b346da101be42
@@ -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(error_list_html) unless validators.empty?
11
+ container(error_list_html) unless validators.empty? && !has_optional_validators?
12
12
  end
13
13
 
14
14
  private
@@ -22,12 +22,32 @@ module Rails
22
22
  end
23
23
 
24
24
  def error_list_html
25
- validators.map do |validator|
25
+ html = ''
26
+
27
+ html << validators.map do |validator|
26
28
  mapper = validator_mapper_for(validator)
27
29
  mapper.error_messages.map do |error_type, msg|
28
30
  content_tag :li, msg, 'ng-show' => "#{form_field_object_name}.$error.#{error_type}"
29
31
  end.join
30
- end.join.html_safe
32
+ end.join
33
+
34
+ html << (extra_validators || '')
35
+ html.html_safe
36
+ end
37
+
38
+ def extra_validators
39
+ options.inject('') do |html, (k, v)|
40
+ k = k.to_s
41
+ html << if k.start_with?('$')
42
+ content_tag(:li, v, 'ng-show' => "#{form_field_object_name}.$error.#{k[1..-1]}")
43
+ else
44
+ ''
45
+ end
46
+ end
47
+ end
48
+
49
+ def has_optional_validators?
50
+ options.keys.any? { |k| k.to_s.start_with?('$') }
31
51
  end
32
52
 
33
53
  def container_attrs
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Angulate
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
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
4
+ version: 0.0.6
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-08-01 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails