effective_bootstrap 0.13.5 → 0.13.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b85c9a43f0ea2e678b77110864386344bfc738bbd199a8cf1a7199aad0475c8d
4
- data.tar.gz: c13a58b9778f127a64907d13d3ceea1a1653399da29b99dfa0f002ccbeecd754
3
+ metadata.gz: 284baa0c03bb5e8427d7e4ac3ce4fb6725e359ab3bea1f6f267e4c7d2b6b0e5e
4
+ data.tar.gz: bb1d75ae10d211fb2c145e7351be9a63b0610360e1c628a00dac1c73de7bbc78
5
5
  SHA512:
6
- metadata.gz: b0242f4304b077bea11d982d163ead7a0c04b17af250f3f29e277d3470215e63392d8f0acefedc60e9dd692f278f3aafabff16538e989531bbe4e21a142b3f96
7
- data.tar.gz: 7e402ffa6c5474842c436ab47bfbdfcb06fc807bd99b5d918bd79e8cb5b020d7350c5c03304de2862b7f40b2e43c0d2dc39b851080d856353159d3e1ba368619
6
+ metadata.gz: fac47682801276341b664baae31f366030d80c16273bca7bf66c10a4983c6276e57c67431a3f4f12b7bb62f91b00a7ec44422642761bd9bc7f2ac0a2b40c85bd
7
+ data.tar.gz: b01e15de8b3d61360fc72c48e58b4557091c723fa73d8dc712e0c0f62db0969dfda9e01ff4baa81fe9986d6c7c781a31ef094592730d39aa91755ee2fa75f0f9
@@ -72,27 +72,19 @@ div.form-group > label + .btn-group { display: block; }
72
72
  .form-control-file { border: none !important; }
73
73
 
74
74
  // Radios
75
- form fieldset.effective-radios {
76
- margin-top: 0;
77
- margin-bottom: 0;
78
- }
79
-
80
- form fieldset.effective-checks {
81
- margin-top: 0;
82
- margin-bottom: 0;
83
- }
84
-
85
75
  form fieldset.effective-radios legend {
86
76
  font-size: 1rem;
87
- font-weight: inherit;
88
77
  margin-top: 0.5rem;
89
78
  margin-bottom: 1rem;
90
79
  }
91
80
 
81
+ form fieldset.effective-radios {
82
+ > label { margin-bottom: 0.5rem; }
83
+ }
84
+
92
85
  // Checks
93
86
  form fieldset.effective-checks > label {
94
87
  font-size: 1rem;
95
- font-weight: inherit;
96
88
  margin-top: 0.5rem;
97
89
  margin-bottom: 1rem;
98
90
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Effective
4
4
  class TableBuilder
5
- FILTER_PARAMETERS = [:password, :password_confirmation, :created_at, :updated_at]
5
+ FILTER_PARAMETERS = [:password, :password_confirmation, :status_steps, :wizard_steps, :token, :created_at, :updated_at]
6
6
 
7
7
  attr_accessor :object, :template, :options
8
8
 
@@ -54,14 +54,20 @@ module Effective
54
54
  end
55
55
 
56
56
  def build_resource_rows
57
- Effective::Resource.new(object).klass_attributes(sort: true).each do |name, options|
57
+ Effective::Resource.new(object).resource_attributes.each do |name, options|
58
58
  case options.first
59
+ when :belongs_to
60
+ belongs_to(name)
61
+ when :effective_address
62
+ effective_address(name)
59
63
  when :boolean
60
64
  boolean_row(name)
65
+ when :integer
66
+ name.to_s.end_with?('price') ? price_field(name) : text_field(name)
67
+ when :string
68
+ name.to_s.include?('email') ? email_field(name) : text_field(name)
61
69
  when :text
62
70
  text_area(name)
63
- when :string
64
- (name.to_s.include?('email') && value(name).to_s.include?('@')) ? email_field(name) : text_field(name)
65
71
  else default_row(name)
66
72
  end
67
73
  end
@@ -109,6 +115,10 @@ module Effective
109
115
  alias_method :checks, :collection_row
110
116
  alias_method :radios, :collection_row
111
117
 
118
+ def belongs_to(name, options = {})
119
+ rows[name] = TableRows::BelongsTo.new(name, options, builder: self).to_html
120
+ end
121
+
112
122
  def email_field(name, options = {})
113
123
  rows[name] = TableRows::EmailField.new(name, options, builder: self).to_html
114
124
  end
@@ -16,6 +16,10 @@ module Effective
16
16
  @options = options
17
17
  end
18
18
 
19
+ def controller_namespace
20
+ Effective::Resource.new(template.controller.controller_path).namespace
21
+ end
22
+
19
23
  # Intended for override
20
24
  def content
21
25
  value
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ module TableRows
5
+ class BelongsTo < Effective::TableRow
6
+
7
+ def content
8
+ if value.present?
9
+ content_tag(:div) { link_to_edit || link_to_show || value.to_s }
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def effective_resource
16
+ @effective_resource ||= Effective::Resource.new(value, namespace: controller_namespace)
17
+ end
18
+
19
+ def link_to_edit
20
+ return unless EffectiveResources.authorized?(template, :edit, value)
21
+
22
+ path = effective_resource.action_path(:edit, value)
23
+ return unless path.present?
24
+
25
+ link_to(value.to_s, path, title: value.to_s, target: '_blank')
26
+ end
27
+
28
+ def link_to_show
29
+ return unless EffectiveResources.authorized?(template, :show, value)
30
+
31
+ path = effective_resource.action_path(:show, value)
32
+ return unless path.present?
33
+
34
+ link_to(value.to_s, path, title: value.to_s, target: '_blank')
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -5,7 +5,7 @@ module Effective
5
5
  class TextArea < Effective::TableRow
6
6
 
7
7
  def content
8
- template.simple_format(value) if value.present?
8
+ template.simple_format(value) if value.kind_of?(String)
9
9
  end
10
10
 
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.13.5'.freeze
2
+ VERSION = '0.13.7'.freeze
3
3
  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.13.5
4
+ version: 0.13.7
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-04-14 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -696,6 +696,7 @@ files:
696
696
  - app/models/effective/form_logics/show_if_any.rb
697
697
  - app/models/effective/table_builder.rb
698
698
  - app/models/effective/table_row.rb
699
+ - app/models/effective/table_rows/belongs_to.rb
699
700
  - app/models/effective/table_rows/boolean.rb
700
701
  - app/models/effective/table_rows/collection.rb
701
702
  - app/models/effective/table_rows/content_for.rb