effective_bootstrap 1.14.16 → 1.15.0
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/overrides.scss +0 -2
- data/app/models/effective/table_builder.rb +24 -7
- data/app/models/effective/table_row.rb +5 -1
- data/app/models/effective/table_rows/boolean.rb +1 -1
- data/app/models/effective/table_rows/content_for.rb +1 -1
- data/app/models/effective/table_rows/text_area.rb +10 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- 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: 442b343d986c2abfc78b503e56521f307e3e51eabd58ed6e67a31dc8f5b9ca67
|
4
|
+
data.tar.gz: 874bef73010622b095cb1fc4413d4c490c2ad27a705d6f8dd0e78a728ad57c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02b45df0e1b4216b6f7fe2d29f56fca696e80ed3de540dc7677bdc16f2d34cd4f79abe8ada082791a6ae9c95687d5b5503ecf1e6ed8419d5eaadf53631690edf
|
7
|
+
data.tar.gz: ed77c531eaaf62f71224f5b4851e0188ebea3ef14f7ae1288d404d3a731f139a8874df9832d44b4df838e25725452a0471cd6edf1d35d4027c02fe7bfa45bf14
|
@@ -12,5 +12,3 @@ ul.nav.nav-tabs { margin-bottom: 1rem; }
|
|
12
12
|
.custom-control-input:disabled ~ .custom-control-label { cursor: no-drop; }
|
13
13
|
.custom-control-input:disabled ~ .custom-control-label::after { cursor: no-drop; }
|
14
14
|
.custom-control-input:disabled ~ .custom-control-label::before { cursor: no-drop; }
|
15
|
-
|
16
|
-
.effective-table-summary th { width: 200px; }
|
@@ -27,17 +27,25 @@ module Effective
|
|
27
27
|
# This runs the form partial over this table builder
|
28
28
|
capture(&block) if block_given?
|
29
29
|
|
30
|
-
#
|
31
|
-
build_resource_rows if rows.blank? && !block_given?
|
32
|
-
|
30
|
+
# Consider content
|
33
31
|
only = Array(options[:only])
|
34
32
|
except = Array(options[:except])
|
33
|
+
additionally = Array(options[:additionally])
|
35
34
|
filtered = filter_parameters
|
36
35
|
|
36
|
+
# Rows are created when we use the block syntax and call a f.text_field or other f.form_field
|
37
|
+
# Using = f.content_for does not create a row.
|
38
|
+
# So rows wille be blank when using the default syntax
|
39
|
+
# And rows will be present when we render a form, or any form fields
|
40
|
+
build_resource_rows(only: only, except: except) if rows.blank?
|
41
|
+
|
42
|
+
# This gives us a second run through the rows, if you pass additionally
|
43
|
+
build_resource_rows(only: additionally) if additionally.present?
|
44
|
+
|
45
|
+
# Use f.content_for :name to override the content
|
37
46
|
content = rows.merge(content_fors)
|
38
47
|
|
39
|
-
|
40
|
-
content = content.except(*except) if except.present?
|
48
|
+
# Filter out some hardcoded ones
|
41
49
|
content = content.except(*filtered) if filtered.present?
|
42
50
|
|
43
51
|
content_tag(:table, class: options.fetch(:class, 'table table-sm table-striped table-hover effective-table-summary')) do
|
@@ -54,8 +62,11 @@ module Effective
|
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
57
|
-
def build_resource_rows
|
65
|
+
def build_resource_rows(only: nil, except: nil)
|
58
66
|
Effective::Resource.new(object).resource_attributes.each do |name, options|
|
67
|
+
next if only.present? && only.exclude?(name)
|
68
|
+
next if except.present? && except.include?(name)
|
69
|
+
|
59
70
|
case options.first
|
60
71
|
when :belongs_to
|
61
72
|
belongs_to(name)
|
@@ -64,7 +75,13 @@ module Effective
|
|
64
75
|
when :boolean
|
65
76
|
boolean_row(name)
|
66
77
|
when :integer
|
67
|
-
|
78
|
+
if ['price', 'discount', '_fee'].any? { |p| name.to_s.include?(p) }
|
79
|
+
price_field(name)
|
80
|
+
elsif ['_percent'].any? { |p| name.to_s.include?(p) }
|
81
|
+
percent_field(name)
|
82
|
+
else
|
83
|
+
text_field(name)
|
84
|
+
end
|
68
85
|
when :string
|
69
86
|
name.to_s.include?('email') ? email_field(name) : text_field(name)
|
70
87
|
when :text
|
@@ -25,9 +25,13 @@ module Effective
|
|
25
25
|
value
|
26
26
|
end
|
27
27
|
|
28
|
+
def tr_class
|
29
|
+
"row-#{name}" # This matches datatables which is "col-#{name}"
|
30
|
+
end
|
31
|
+
|
28
32
|
# Render method
|
29
33
|
def to_html(&block)
|
30
|
-
content_tag(:tr, class:
|
34
|
+
content_tag(:tr, class: tr_class) do
|
31
35
|
content_tag(:th, label_content) + content_tag(:td, content.presence || '-')
|
32
36
|
end
|
33
37
|
end
|
@@ -5,7 +5,7 @@ module Effective
|
|
5
5
|
class Boolean < Effective::TableRow
|
6
6
|
|
7
7
|
def to_html(&block)
|
8
|
-
content_tag(:tr, class:
|
8
|
+
content_tag(:tr, class: tr_class) do
|
9
9
|
content_tag(:td, colspan: 2) do
|
10
10
|
content_tag(:span, content.presence || '-') + label_content
|
11
11
|
end
|
@@ -5,7 +5,7 @@ module Effective
|
|
5
5
|
class ContentFor < Effective::TableRow
|
6
6
|
|
7
7
|
def to_html(&block)
|
8
|
-
content_tag(:tr, class:
|
8
|
+
content_tag(:tr, class: tr_class) do
|
9
9
|
content_tag(:th, label_content) + content_tag(:td, template.capture(&block))
|
10
10
|
end
|
11
11
|
end
|
@@ -5,7 +5,16 @@ module Effective
|
|
5
5
|
class TextArea < Effective::TableRow
|
6
6
|
|
7
7
|
def content
|
8
|
-
|
8
|
+
return unless value.present?
|
9
|
+
|
10
|
+
# Might be an Array or Hash. Serialized something.
|
11
|
+
return value.to_s unless value.kind_of?(String)
|
12
|
+
|
13
|
+
if value.start_with?('<') && value.end_with?('>')
|
14
|
+
value.html_safe
|
15
|
+
else
|
16
|
+
template.simple_format(value)
|
17
|
+
end
|
9
18
|
end
|
10
19
|
|
11
20
|
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: 1.
|
4
|
+
version: 1.15.0
|
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: 2023-
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|