helper_methods 1.0.0.rc1 → 1.0.0.rc2
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 +4 -4
- data/lib/helper_methods/flash_messages.rb +23 -12
- data/lib/helper_methods/version.rb +1 -1
- 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: e0ee6329a068146220ee5900ac1e03fa7ec36f27
|
4
|
+
data.tar.gz: 5e32c9df7985a78d53b7690a1fbd89dc23af0a85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16853644b3f4d62f2b0289791f38b59dcaa0d41ae15176703558c64dcfd63bc4f663abd3fe6d8aa7ddb0f91ef86f3f10b173002f9f5bc0b59dbb05dc8842c8a5
|
7
|
+
data.tar.gz: 8f33fff02fe4ad877f3771fc7a85d29a89ba7364f311a08dcd3bd4d4806c07d1eac6078bd84765af06ec3e70e9998aa81bff5527c8f059a662e5f7ae52c1d7d5
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module HelperMethods
|
2
2
|
|
3
|
-
def error_messages_for(resource
|
3
|
+
def error_messages_for(resource:, style: 'danger')
|
4
4
|
if resource.errors.any?
|
5
|
-
content_tag :div, class: "alert alert-#{style} alert-
|
5
|
+
content_tag :div, class: "alert alert-#{styles[style]} alert-dismissible" do
|
6
6
|
content_tag :ol do
|
7
7
|
resource.errors.collect do |key, value|
|
8
8
|
content_tag :li, value
|
@@ -13,17 +13,28 @@ module HelperMethods
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def flash_messages
|
16
|
-
|
17
|
-
content_tag :div, class: "alert alert
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
flash.collect do |key, value|
|
17
|
+
content_tag :div, class: "alert alert-#{styles[key]} alert-dismissable", role: "alert" do
|
18
|
+
[close_button, value].join.html_safe
|
19
|
+
end unless [true, false, nil].include?(value)
|
20
|
+
end.join.html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
def close_button
|
24
|
+
content_tag :button, type: 'button', class: 'close', data: { dismiss: 'alert' } do
|
25
|
+
content_tag(:span, '×', aria: { hidden: 'true' }) + content_tag(:span, 'Close', class: 'sr-only')
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def styles
|
30
|
+
{
|
31
|
+
'notice' => 'success',
|
32
|
+
'alert' => 'warning',
|
33
|
+
'success' => 'success',
|
34
|
+
'info' => 'info',
|
35
|
+
'warning' => 'warning',
|
36
|
+
'danger' => 'danger'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
29
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helper_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francisco Martins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|