effective_bootstrap 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/effective_bootstrap/base.scss +1 -0
- data/app/assets/stylesheets/effective_bootstrap/forms.scss +4 -2
- data/app/assets/stylesheets/effective_bootstrap/overrides.scss +6 -0
- data/app/helpers/effective_bootstrap_helper.rb +104 -0
- data/app/helpers/effective_icons_helper.rb +4 -0
- data/app/models/effective/form_builder.rb +1 -0
- data/app/models/effective/form_inputs/date_field.rb +4 -0
- data/app/models/effective/form_inputs/datetime_field.rb +5 -1
- data/app/models/effective/form_inputs/radios.rb +2 -2
- data/app/models/effective/form_inputs/static_field.rb +24 -1
- data/app/models/effective/form_inputs/time_field.rb +4 -0
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaaea45b1e57e497554feb12fc6f67c6a6baec1d
|
4
|
+
data.tar.gz: 58fcb83582beefb8df6f6156d9ddea639042db88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94603f7e4177c8055bf1a195a4cde0ba2e7e015c64cb50067b9d953c0926a0862ed1c5b4fc2fc611572f3afe159eb8296825a78c1be5e3618a988265d95062af
|
7
|
+
data.tar.gz: 99978bffcaceb1735181533e02f7dfc3b7010452371b540e660016170f317cca010e33b9b2d58e70578a3253a901ae43b019456e9710240ecf5e3ae2bb3f1f59
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// Submit buttons
|
2
|
-
.form-actions {
|
2
|
+
.form-actions.form-group {
|
3
3
|
border-top: solid 1px #eee;
|
4
4
|
margin-top: 1rem;
|
5
5
|
|
@@ -7,7 +7,9 @@
|
|
7
7
|
align-items: center;
|
8
8
|
justify-content: flex-end;
|
9
9
|
|
10
|
-
> * {
|
10
|
+
> * {
|
11
|
+
margin: 1rem 0 0 0.5rem;
|
12
|
+
}
|
11
13
|
}
|
12
14
|
|
13
15
|
// Spinner
|
@@ -1,6 +1,110 @@
|
|
1
1
|
# Boostrap4 Helpers
|
2
2
|
|
3
3
|
module EffectiveBootstrapHelper
|
4
|
+
# Button Dropdowns
|
5
|
+
# https://getbootstrap.com/docs/4.0/components/dropdowns/
|
6
|
+
#
|
7
|
+
# = dropdown do
|
8
|
+
# = dropdown_link_to 'Something', root_path
|
9
|
+
# = dropdown_divider
|
10
|
+
# = dropdown_link_to 'Another', root_path
|
11
|
+
#
|
12
|
+
# Button Dropdowns
|
13
|
+
# variations can be :dropup, :dropleft, :dropright
|
14
|
+
# split can be true, false
|
15
|
+
# right is to right align things
|
16
|
+
def dropdown(variation: nil, split: true, btn: 'btn-outline-primary', right: false, &block)
|
17
|
+
raise 'expected a block' unless block_given?
|
18
|
+
|
19
|
+
@_dropdown_link_tos = []; yield
|
20
|
+
|
21
|
+
return @_dropdown_link_tos.first if @_dropdown_link_tos.length <= 1
|
22
|
+
|
23
|
+
retval = if split
|
24
|
+
first = @_dropdown_link_tos.first
|
25
|
+
menu = content_tag(:div, @_dropdown_link_tos[1..-1].join.html_safe, class: ['dropdown-menu', ('dropdown-menu-right' if right)].compact.join(' '))
|
26
|
+
split = content_tag(:button, class: "btn #{btn} dropdown-toggle dropdown-toggle-split", type: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) do
|
27
|
+
content_tag(:span, 'Toggle Dropdown', class: 'sr-only')
|
28
|
+
end
|
29
|
+
|
30
|
+
content_tag(:div, class: 'btn-group') do
|
31
|
+
content_tag(:div, class: ['btn-group', variation.to_s.presence].compact.join(' '), role: 'group') do
|
32
|
+
[:dropleft].include?(variation) ? (split + menu + first) : (first + split + menu)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
raise 'split false is unsupported'
|
37
|
+
end
|
38
|
+
|
39
|
+
@_dropdown_link_tos = nil
|
40
|
+
|
41
|
+
retval
|
42
|
+
end
|
43
|
+
|
44
|
+
# This is a special variant of dropdown
|
45
|
+
# dots do
|
46
|
+
# = dropdown_link_to 'Edit', edit_path(thing)
|
47
|
+
def dots(options = nil, &block)
|
48
|
+
(options ||= {})[:class] = "dropdown dropdown-dots #{options.delete(:class)}".strip
|
49
|
+
|
50
|
+
content_tag(:span, options) do
|
51
|
+
content_tag(:button, class: "btn btn-dots dropdown-toggle #{options.delete(:button_class)}", 'aria-expanded': true, 'aria-haspopup': true, 'data-toggle': 'dropdown', type: 'button') do
|
52
|
+
end + content_tag(:div, capture(&block), class: 'dropdown-menu')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def dots_link_to(label, path, options = {})
|
57
|
+
options[:class] = [options[:class], 'dropdown-item'].compact.join(' ')
|
58
|
+
|
59
|
+
concat link_to(label, path, options)
|
60
|
+
end
|
61
|
+
|
62
|
+
# # Works with dots do and dropdown do
|
63
|
+
def dropdown_link_to(label, path, options = {})
|
64
|
+
unless @_dropdown_link_tos
|
65
|
+
options[:class] = [options[:class], 'dropdown-item'].compact.join(' ')
|
66
|
+
return link_to(label, path, options)
|
67
|
+
end
|
68
|
+
|
69
|
+
if @_dropdown_link_tos.length == 0
|
70
|
+
options[:class] = [options[:class], 'btn btn-outline-primary'].compact.join(' ') unless options[:class].to_s.include?('btn-')
|
71
|
+
else
|
72
|
+
options[:class] = [options[:class], 'dropdown-item'].compact.join(' ')
|
73
|
+
end
|
74
|
+
|
75
|
+
@_dropdown_link_tos << link_to(label, path, options)
|
76
|
+
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
# Works with dots ao and dropdown do
|
81
|
+
def dropdown_divider
|
82
|
+
unless @_dropdown_link_tos
|
83
|
+
content_tag(:div, '', class: 'dropdown-divider')
|
84
|
+
else
|
85
|
+
@_dropdown_link_tos << content_tag(:div, '', class: 'dropdown-divider')
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def list_group(&block)
|
91
|
+
content_tag(:div, yield, class: 'list-group')
|
92
|
+
end
|
93
|
+
|
94
|
+
# List group
|
95
|
+
# = list_group_link_to
|
96
|
+
# Automatically puts in the 'active' class based on request path
|
97
|
+
def list_group_link_to(label, path, opts = {})
|
98
|
+
# Regular link item
|
99
|
+
opts[:class] = if request.fullpath.include?(path)
|
100
|
+
[opts[:class], 'list-group-item active'].compact.join(' ')
|
101
|
+
else
|
102
|
+
[opts[:class], 'list-group-item'].compact.join(' ')
|
103
|
+
end
|
104
|
+
|
105
|
+
link_to(label.to_s, path, opts)
|
106
|
+
end
|
107
|
+
|
4
108
|
# Nav links and dropdowns
|
5
109
|
# Automatically puts in the 'active' class based on request path
|
6
110
|
|
@@ -13,6 +13,10 @@ module EffectiveIconsHelper
|
|
13
13
|
link_to(icon(svg), url, options)
|
14
14
|
end
|
15
15
|
|
16
|
+
def new_icon_to(path, options = {})
|
17
|
+
icon_to('plus', path, { title: 'New' }.merge(options))
|
18
|
+
end
|
19
|
+
|
16
20
|
def show_icon_to(path, options = {})
|
17
21
|
icon_to('eye', path, { title: 'Show' }.merge(options))
|
18
22
|
end
|
@@ -18,7 +18,11 @@ module Effective
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def build_input(&block)
|
21
|
-
@builder.super_text_field(name, options[:input])
|
21
|
+
@builder.super_text_field(name, options[:input].merge(value: datetime_to_s))
|
22
|
+
end
|
23
|
+
|
24
|
+
def datetime_to_s
|
25
|
+
value&.strftime('%F %H:%M')
|
22
26
|
end
|
23
27
|
|
24
28
|
private
|
@@ -21,7 +21,7 @@ module Effective
|
|
21
21
|
|
22
22
|
def build_button_group(&block)
|
23
23
|
if buttons?
|
24
|
-
content_tag(:div, yield, id: button_group_id, class: 'btn-group btn-group-toggle', 'data-toggle': 'buttons')
|
24
|
+
content_tag(:div, yield, id: button_group_id, class: 'btn-group btn-group-toggle effective-radios', 'data-toggle': 'buttons')
|
25
25
|
else
|
26
26
|
yield
|
27
27
|
end
|
@@ -93,7 +93,7 @@ module Effective
|
|
93
93
|
|
94
94
|
def item_label_options
|
95
95
|
if buttons?
|
96
|
-
{ class: 'btn btn-secondary' }
|
96
|
+
{ class: 'btn btn-outline-secondary' }
|
97
97
|
elsif custom?
|
98
98
|
{ class: 'custom-control-label' }
|
99
99
|
else
|
@@ -11,10 +11,33 @@ module Effective
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def build_input(&block)
|
14
|
-
content = block_given?
|
14
|
+
content = if block_given?
|
15
|
+
capture(&block)
|
16
|
+
elsif options[:input][:value]
|
17
|
+
options[:input].delete(:value)
|
18
|
+
elsif resource_path
|
19
|
+
link_to(value, resource_path, title: value.to_s)
|
20
|
+
else
|
21
|
+
value
|
22
|
+
end
|
23
|
+
|
15
24
|
content_tag(:p, content, options[:input].except(:readonly, :required, :value).merge(id: tag_id))
|
16
25
|
end
|
17
26
|
|
27
|
+
def resource_path
|
28
|
+
# I don't want to hardcode effective_resources as a dependency of this gem. But it's so useful...
|
29
|
+
return false unless defined?(EffectiveResources)
|
30
|
+
|
31
|
+
return false unless value.kind_of?(ActiveRecord::Base)
|
32
|
+
|
33
|
+
@_resource_path ||= (
|
34
|
+
Effective::Resource.new(value, namespace: @template.controller_path.split('/').first).action_path(:edit) ||
|
35
|
+
Effective::Resource.new(@template.controller_path).action_path(:edit, value) ||
|
36
|
+
Effective::Resource.new(value, namespace: @template.controller_path.split('/').first).action_path(:show) ||
|
37
|
+
Effective::Resource.new(@template.controller_path).action_path(:show, value)
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
18
41
|
end
|
19
42
|
end
|
20
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,26 +16,26 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bootstrap
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 4.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sass-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Everything you need to get set up with bootstrap 4.
|
70
84
|
email:
|
71
85
|
- info@codeandeffect.com
|
@@ -365,6 +379,7 @@ files:
|
|
365
379
|
- app/assets/stylesheets/effective_bootstrap/base.scss
|
366
380
|
- app/assets/stylesheets/effective_bootstrap/forms.scss
|
367
381
|
- app/assets/stylesheets/effective_bootstrap/icons.scss
|
382
|
+
- app/assets/stylesheets/effective_bootstrap/overrides.scss
|
368
383
|
- app/assets/stylesheets/effective_date/input.scss
|
369
384
|
- app/assets/stylesheets/effective_datetime/bootstrap-datetimepicker.scss
|
370
385
|
- app/assets/stylesheets/effective_datetime/input.scss
|