bootstrap_views_generator 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/bootstrap_views_generator/version.rb +1 -1
- data/lib/generators/bootstrap/install_generator.rb +32 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e973e3926bdfd81497bd96490b99c57bd5dd6a9fe092aa4ac3bec53d3433b99a
|
4
|
+
data.tar.gz: ca2ea8938d63e4cd49439fa0173cdc20a443ecf38f2d220378e02689b60c1fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59e59402b519bbd88362cbb8d919d03e80507494551cc398b2a8bdef0790973041196317f994a4bdea12e0ee033d57c599e3f08d8d08f72dec89f463e5bde310
|
7
|
+
data.tar.gz: e1aab4fc44557206d7719935e6bfaad27e1a86748b3f6e39f6a7b150b203d5ff393e788490ab432500895cfc7995031bb9cde25ae57c868b41a7cfd73773a2ff
|
data/README.md
CHANGED
@@ -79,7 +79,12 @@ rails g bootstrap:install --template_engine=slim
|
|
79
79
|
|
80
80
|
Ensure you have [Pagy](https://github.com/ddnexus/pagy) gem installed
|
81
81
|
```ruby
|
82
|
+
# Gemfile
|
82
83
|
gem 'pagy'
|
84
|
+
|
85
|
+
# Make sure you have the bootstrap pagy helper included
|
86
|
+
# config/initializers/pagy.rb
|
87
|
+
require 'pagy/extras/bootstrap'
|
83
88
|
```
|
84
89
|
|
85
90
|
|
@@ -35,43 +35,45 @@ module Bootstrap
|
|
35
35
|
|
36
36
|
# Inject Bootstrap helpers into teh application_helper file
|
37
37
|
def inject_helpers
|
38
|
-
|
38
|
+
pagy_helper = (options[:pagination] ? 'include Pagy::Frontend' : '')
|
39
|
+
helper_str = <<~HELPER
|
40
|
+
#{pagy_helper}
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
# https://gist.github.com/fjahr/b3828b9f4e333e74ba1894687d65e055
|
43
|
+
def bootstrap_class_for(flash_type)
|
44
|
+
{ success: 'alert-success', error: 'alert-danger', alert: 'alert-warning', notice: 'alert-info' }.stringify_keys[flash_type.to_s] || flash_type.to_s
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
def flash_messages(_opts = [])
|
48
|
+
return '' unless flash.any?
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
+
flash.each do |msg_type, message|
|
51
|
+
next unless !message.nil? && message.to_s.length.positive?
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
concat(content_tag(:div, message, class: "alert \#{bootstrap_class_for(msg_type)}", role: 'alert') do
|
54
|
+
concat content_tag(:button, 'x', class: 'close', data: { dismiss: 'alert' })
|
55
|
+
concat message
|
56
|
+
end)
|
57
|
+
end
|
58
|
+
nil
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
61
|
+
# for outputting an objects error messages
|
62
|
+
def errors_for(object)
|
63
|
+
return '' unless object.errors.any?
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
content_tag(:div, class: 'card border-danger') do
|
66
|
+
concat(content_tag(:div, class: 'card-header bg-danger text-white') do
|
67
|
+
concat "\#{pluralize(object.errors.count, 'error')} prohibited this \#{object.class.name.downcase} from being saved:"
|
68
|
+
end)
|
69
|
+
concat(content_tag(:ul, class: 'mb-0 list-group list-group-flush') do
|
70
|
+
object.errors.full_messages.each do |msg|
|
71
|
+
concat content_tag(:li, msg, class: 'list-group-item')
|
72
|
+
end
|
73
|
+
end)
|
74
|
+
end
|
70
75
|
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
HELPER
|
76
|
+
HELPER
|
75
77
|
|
76
78
|
inject_into_file 'app/helpers/application_helper.rb', helper_str, after: "module ApplicationHelper\n"
|
77
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_views_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hicks
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap
|