bullet_train-super_scaffolding 1.7.15 → 1.7.17

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: 5ea880cbb7581cf68490a82a28f7e5ab5c1a1ce317bea5086d558b33ebb7054f
4
- data.tar.gz: be72d3230e34d1934e4406c1d999acfd8ec2acc2ecceab09275d8ccab29d6c8f
3
+ metadata.gz: fe1409d374421a05f03e3a685f540ce5dc28d1861aa8037594efbe1210fdc527
4
+ data.tar.gz: 5e9cc70b508fe1829130471dbc78a06a4058f1c930d17d59007ef9d4c88078cc
5
5
  SHA512:
6
- metadata.gz: 16e6d92b847291c57d7ebfe8fd95fa2930e158dc40c383fbce651536e07282dac0a12a019cea97aeb1c735ab087cde4cc7ddde5584d6c4b17a05d9c5f556eead
7
- data.tar.gz: f584d4c1af771af4e05e8ab7d2b732004fa674c823ab35f9d766d4701466d7f6d7697049c39793c53b69e8efb71398af0da5e8b16cf6470757b1f1c9226ac0a3
6
+ metadata.gz: 22c6d0f8f599ac0419a29fb6fd92bb7722b6981780552e3d55a84d88982687365cb5c815ee18accc7b6ba4e2679b539b9e09c18c186600af5052a97c3efea8d3
7
+ data.tar.gz: c8dce7b4508b7c003a3f6aeb67f7dd76b877836d14242293116b23873da5731f3a775bd6d516b7f8ba1b8e1e12acba9f60dba0e71e379e3a8118b48262410c0b
@@ -7,7 +7,7 @@
7
7
  <% pagy, creative_concepts = pagy(creative_concepts, page_param: :creative_concepts_page) unless pagy %>
8
8
 
9
9
  <%= cable_ready_updates_for context, :scaffolding_absolutely_abstract_creative_concepts do %>
10
- <%= render 'account/shared/box' do |box| %>
10
+ <%= render 'account/shared/box', pagy: pagy do |box| %>
11
11
  <% box.title t(".contexts.#{context.class.name.underscore}.header") %>
12
12
  <% box.description do %>
13
13
  <%= t(".contexts.#{context.class.name.underscore}.description").html_safe %>
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.7.15"
3
+ VERSION = "1.7.17"
4
4
  end
5
5
  end
@@ -96,6 +96,22 @@ class Scaffolding::Attribute
96
96
  original_type == "boolean"
97
97
  end
98
98
 
99
+ def file_field?
100
+ type == "file_field"
101
+ end
102
+
103
+ def image?
104
+ type == "image"
105
+ end
106
+
107
+ def cloudinary_image?
108
+ image? && cloudinary_enabled?
109
+ end
110
+
111
+ def active_storage_image?
112
+ image? && !cloudinary_enabled?
113
+ end
114
+
99
115
  # Sometimes we need all the magic of a `*_id` field, but without the scoping stuff.
100
116
  # Possibly only ever used internally by `join-model`.
101
117
  def is_unscoped?
@@ -969,7 +969,7 @@ class Scaffolding::Transformer
969
969
  ].each do |file|
970
970
  if attribute.is_ids? || attribute.is_multiple?
971
971
  scaffold_add_line_to_file(file, "#{attribute.name}: [],", RUBY_NEW_ARRAYS_HOOK, prepend: true)
972
- if attribute.type == "file_field"
972
+ if attribute.file_field? || attribute.active_storage_image?
973
973
  scaffold_add_line_to_file(file, "#{attribute.name}_removal: [],", RUBY_NEW_ARRAYS_HOOK, prepend: true)
974
974
  end
975
975
  elsif attribute.type == "address_field"
@@ -988,7 +988,7 @@ class Scaffolding::Transformer
988
988
  scaffold_add_line_to_file(file, address_strong_params, RUBY_NEW_ARRAYS_HOOK, prepend: true)
989
989
  else
990
990
  scaffold_add_line_to_file(file, ":#{attribute.name},", RUBY_NEW_FIELDS_HOOK, prepend: true)
991
- if attribute.type == "file_field"
991
+ if attribute.file_field? || attribute.active_storage_image?
992
992
  scaffold_add_line_to_file(file, ":#{attribute.name}_removal,", RUBY_NEW_FIELDS_HOOK, prepend: true)
993
993
  end
994
994
  end
@@ -1234,7 +1234,7 @@ class Scaffolding::Transformer
1234
1234
  end
1235
1235
 
1236
1236
  case attribute.type
1237
- when "file_field"
1237
+ when "file_field", "image"
1238
1238
  remove_file_methods = if attribute.is_multiple?
1239
1239
  <<~RUBY
1240
1240
  def #{attribute.name}_removal?
@@ -1247,7 +1247,7 @@ class Scaffolding::Transformer
1247
1247
 
1248
1248
  def #{attribute.name}=(attachables)
1249
1249
  attachables = Array(attachables).compact_blank
1250
-
1250
+
1251
1251
  if attachables.any?
1252
1252
  attachment_changes["#{attribute.name}"] =
1253
1253
  ActiveStorage::Attached::Changes::CreateMany.new("#{attribute.name}", self, #{attribute.name}.blobs + attachables)
@@ -1264,6 +1264,7 @@ class Scaffolding::Transformer
1264
1264
  def remove_#{attribute.name}
1265
1265
  #{attribute.name}.purge
1266
1266
  end
1267
+
1267
1268
  RUBY
1268
1269
  end
1269
1270
 
@@ -1280,13 +1281,16 @@ class Scaffolding::Transformer
1280
1281
  model_without_attached_hook.each { |line| f.write(line) }
1281
1282
  end
1282
1283
 
1283
- hook_type = attribute.is_multiple? ? HAS_MANY_HOOK : HAS_ONE_HOOK
1284
- scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", reflection_declaration, hook_type, prepend: true)
1284
+ # Cloudinary images don't need all of the removal boilerplate since that's handled by the cloudinary JS
1285
+ unless attribute.cloudinary_image?
1286
+ hook_type = attribute.is_multiple? ? HAS_MANY_HOOK : HAS_ONE_HOOK
1287
+ scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", reflection_declaration, hook_type, prepend: true)
1285
1288
 
1286
- # TODO: We may need to edit these depending on how we save multiple files.
1287
- scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "attr_accessor :#{attribute.name}_removal", ATTR_ACCESSORS_HOOK, prepend: true)
1288
- scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", remove_file_methods, METHODS_HOOK, prepend: true)
1289
- scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "after_validation :remove_#{attribute.name}, if: :#{attribute.name}_removal?", CALLBACKS_HOOK, prepend: true)
1289
+ # TODO: We may need to edit these depending on how we save multiple files.
1290
+ scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "attr_accessor :#{attribute.name}_removal", ATTR_ACCESSORS_HOOK, prepend: true)
1291
+ scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", remove_file_methods, METHODS_HOOK, prepend: true)
1292
+ scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "after_validation :remove_#{attribute.name}, if: :#{attribute.name}_removal?", CALLBACKS_HOOK, prepend: true)
1293
+ end
1290
1294
  when "trix_editor"
1291
1295
  scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "has_rich_text :#{attribute.name}", HAS_ONE_HOOK, prepend: true)
1292
1296
  when "address_field"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-super_scaffolding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.15
4
+ version: 1.7.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-01 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  - !ruby/object:Gem::Version
216
216
  version: '0'
217
217
  requirements: []
218
- rubygems_version: 3.5.3
218
+ rubygems_version: 3.5.11
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: Bullet Train Super Scaffolding