effective_bootstrap 1.20.4 → 1.21.0

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: 45befc8608b2cb217428f6334eeec9e99cc6c1517d239a6816ccbd94cc102463
4
- data.tar.gz: b2a83268855dc4ea9859cd5d3720baaef6260ad85ff8e09ae8cbdcffb8dea9f8
3
+ metadata.gz: 9f01c075e89faa738c6f28de62d9a092c3d5b73611be79c3099d8e5d8305ffb8
4
+ data.tar.gz: 002d792f358b25088cf6977d025d12867123bc13f62df05a3b4a817c7dfcd67e
5
5
  SHA512:
6
- metadata.gz: 98000cfc6a2c14ceec869c35bc3ff134efdf9f39ab7e98d061c7f0e3446c4b9ecc325ebb1c743f7bb82d6a2ba03bb8a5ea4cbfe7466c3bca15f88154c4ab250b
7
- data.tar.gz: 2f27e64309abdfec704ae774a510f25459a5d4680e190da3a9da5949f5559dfb450a30d89468851ba27d67cda21112222ca01a0c79e589c9fc397f3ec0bb8592
6
+ metadata.gz: 3225e0a9918a11bd6dbe7e1edb07b7711df0ae108f254cdc903ff801168e3f26302bbf75d730531706a9c67ee124aa115a259d364913f0d8dc946cb7c202fc79
7
+ data.tar.gz: 8c20e178bef5c7805e52b8ffe774a731ca15bb2c975c324d7dbc9c6f79a5152a5d14316d2182a31491449255bd8a6e247c967df3dc67b4304d1504d92da465ae
@@ -14,13 +14,19 @@
14
14
  .form-has-many { display: none; }
15
15
  }
16
16
 
17
- .form-has-many.tight {
17
+ .form-has-many.tight, .form-has-many[tight=true] {
18
18
  .has-many-remove { margin-top: 0; }
19
19
  .has-many-move { margin-top: 0.5rem; }
20
20
  }
21
21
 
22
+ .form-has-many[cards=true]{
23
+ .has-many-remove { margin-top: 0; margin-bottom: 0; }
24
+ .has-many-move { margin-top: 0.5rem; }
25
+ h4 { margin-top: 0.25rem; }
26
+ }
27
+
22
28
  .form-has-many .has-many-remove {
23
- margin-top: 0;
29
+ margin-top: 1.75rem;
24
30
  margin-bottom: 1rem;
25
31
  .eb-icon { height: 1.0rem; width: 1.0rem; margin-bottom: 2px; }
26
32
  }
@@ -158,9 +158,9 @@ module Effective
158
158
  end
159
159
 
160
160
  opts = if resource.marked_for_destruction? && resource.errors.blank?
161
- { class: 'has-many-fields marked-for-destruction', style: 'display: none;' }
161
+ { class: ['has-many-fields', "has-many-fields-#{display}", 'marked-for-destruction'].join(' '), style: 'display: none;' }
162
162
  else
163
- { class: 'has-many-fields' }
163
+ { class: ['has-many-fields', "has-many-fields-#{display}"].join(' ') }
164
164
  end
165
165
 
166
166
  content_tag(:div, insert + render_fields(content, remove + reorder), opts)
@@ -232,10 +232,20 @@ module Effective
232
232
 
233
233
  # Has Many
234
234
  def has_many(name, collection = nil, options = {}, &block)
235
- value(name).each_with_index do |object, index|
236
- builder = TableBuilder.new(object, template, options.reverse_merge(prefix: template.et(object) + " ##{index+1}"))
237
- builder.render(&block)
238
- builder.rows.each { |child, content| rows["#{name}_#{child}_#{index}".to_sym] = content }
235
+ options = collection if options.blank? && collection.kind_of?(Hash)
236
+
237
+ if options[:cards]
238
+ value(name).each_with_index do |object, index|
239
+ builder = TableBuilder.new(object, template, options)
240
+ rows["#{name}_#{index}".to_sym] = TableRows::HasManyCard.new(name, options.merge(index: index), builder: builder).to_html(&block)
241
+ end
242
+ else
243
+ value(name).each_with_index do |object, index|
244
+ builder = TableBuilder.new(object, template, options.reverse_merge(prefix: template.et(object) + " ##{index+1}"))
245
+ builder.render(&block)
246
+
247
+ builder.rows.each { |child, content| rows["#{name}_#{child}_#{index}".to_sym] = content }
248
+ end
239
249
  end
240
250
  end
241
251
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Effective
4
+ module TableRows
5
+ class HasManyCard < Effective::TableRow
6
+
7
+ def to_html(&block)
8
+ table = builder.render(&block)
9
+
10
+ content_tag(:tr, class: "#{tr_class}-#{index+1}") do
11
+ content_tag(:td, colspan: 2) do
12
+ content_tag(:div, class: 'card my-3') do
13
+ content_tag(:div, table, class: 'card-body') do
14
+ content_tag(:h5, template.et(object) + " ##{index+1}", class: 'card-title') + table
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ def index
22
+ options[:index] || 0
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '1.20.4'.freeze
2
+ VERSION = '1.21.0'.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: 1.20.4
4
+ version: 1.21.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: 2025-05-27 00:00:00.000000000 Z
11
+ date: 2025-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -721,6 +721,7 @@ files:
721
721
  - app/models/effective/table_rows/effective_address.rb
722
722
  - app/models/effective/table_rows/email_field.rb
723
723
  - app/models/effective/table_rows/file_field.rb
724
+ - app/models/effective/table_rows/has_many_card.rb
724
725
  - app/models/effective/table_rows/percent_field.rb
725
726
  - app/models/effective/table_rows/phone_field.rb
726
727
  - app/models/effective/table_rows/price_field.rb