effective_bootstrap 0.13.5 → 0.13.6

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: b85c9a43f0ea2e678b77110864386344bfc738bbd199a8cf1a7199aad0475c8d
4
- data.tar.gz: c13a58b9778f127a64907d13d3ceea1a1653399da29b99dfa0f002ccbeecd754
3
+ metadata.gz: 9c5e32c885457e504f462b7e7c02400b36e7959687f4723f33d34684d0a1fcbb
4
+ data.tar.gz: 7e8336c8d3d5765af675158959c315dab44d87d9994575a5983dd77f48106a2c
5
5
  SHA512:
6
- metadata.gz: b0242f4304b077bea11d982d163ead7a0c04b17af250f3f29e277d3470215e63392d8f0acefedc60e9dd692f278f3aafabff16538e989531bbe4e21a142b3f96
7
- data.tar.gz: 7e402ffa6c5474842c436ab47bfbdfcb06fc807bd99b5d918bd79e8cb5b020d7350c5c03304de2862b7f40b2e43c0d2dc39b851080d856353159d3e1ba368619
6
+ metadata.gz: 0ca1da843fae5b7ba017ba36766640ce333e31b43cfb54d632591b31bb9dd1b29ec237af8b7a0d8187840f145e3255c3e00f25f645140b395c818bfed436ffb0
7
+ data.tar.gz: e0aacbffacd46f180fad9bc9ee98c933a542119b8fb39e06fea153c14338acfc213aed3762f30c8de75dfe0aeed52414eadc47c15b78f2d1b6beb8ad3a38c52e
@@ -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
  }
@@ -54,8 +54,12 @@ 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)
61
65
  when :text
@@ -109,6 +113,10 @@ module Effective
109
113
  alias_method :checks, :collection_row
110
114
  alias_method :radios, :collection_row
111
115
 
116
+ def belongs_to(name, options = {})
117
+ rows[name] = TableRows::BelongsTo.new(name, options, builder: self).to_html
118
+ end
119
+
112
120
  def email_field(name, options = {})
113
121
  rows[name] = TableRows::EmailField.new(name, options, builder: self).to_html
114
122
  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.6'.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.6
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