effective_bootstrap 1.14.17 → 1.15.0
Sign up to get free protection for your applications and to get access to all the features.
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
|
@@ -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
|
-
['price', 'discount', '_fee'].any? { |p| name.to_s.include?(p) }
|
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
|
@@ -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
|