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: af2549f2ba32f64fc74a0ae241dd5ff3e5f426f36f5af01680de3f14adcd6c3b
4
- data.tar.gz: ec2bebf9c1c4c7f6b94e9f655960e186908d01f4b5f2d35de995c299f52c5d5d
3
+ metadata.gz: 442b343d986c2abfc78b503e56521f307e3e51eabd58ed6e67a31dc8f5b9ca67
4
+ data.tar.gz: 874bef73010622b095cb1fc4413d4c490c2ad27a705d6f8dd0e78a728ad57c03
5
5
  SHA512:
6
- metadata.gz: '09b9c54ade1926de6b3643665d375ef2490c0b2bee23415b719f98fae8aed04d414bc499f569d95c3aade9f6639c5f7783f6ffba619afa4136f8cde2ec0e45a9'
7
- data.tar.gz: d2b3953a4470819ad35324b503b29046635c84ba736f9d11808ef172ccc2f8791366510f411050a3e03403f6d1252e88de2e4c53f6a24e7bac1f2b16bfc8863f
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
- # Build from the resource if we didn't do anything in the block
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
- content = content.slice(*only) if only.present?
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) } ? price_field(name) : text_field(name)
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
- template.simple_format(value) if value.kind_of?(String)
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.14.17'.freeze
2
+ VERSION = '1.15.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.17
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect