bullet_train-super_scaffolding 1.7.16 → 1.7.17

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: b8cba07bbe66e0e722c0bea983663ba70c2919f8bcf51f6f97cdcfe03c5d7224
4
- data.tar.gz: 751ae4a52840f96d9fd2381167e0c58479b31a777da9cb43e8f90868e13603bc
3
+ metadata.gz: fe1409d374421a05f03e3a685f540ce5dc28d1861aa8037594efbe1210fdc527
4
+ data.tar.gz: 5e9cc70b508fe1829130471dbc78a06a4058f1c930d17d59007ef9d4c88078cc
5
5
  SHA512:
6
- metadata.gz: 4064061867621b97b8ae7551a3d56f4a11bfa237378957e4f4b2f8239a86efa78a3f2c688489280c441a25fe41b4d6a296fef0d66129f07eb10d7e0fa11853ed
7
- data.tar.gz: 1356a54ea61aebcef5bee3b1bb20a52a30bec03fc003bb2ba6194ab917a0c7e6b0ef053d90028ecf58b06dd9f8f7c0179cd4fecf7b8c13ea812869b905d3a47b
6
+ metadata.gz: 22c6d0f8f599ac0419a29fb6fd92bb7722b6981780552e3d55a84d88982687365cb5c815ee18accc7b6ba4e2679b539b9e09c18c186600af5052a97c3efea8d3
7
+ data.tar.gz: c8dce7b4508b7c003a3f6aeb67f7dd76b877836d14242293116b23873da5731f3a775bd6d516b7f8ba1b8e1e12acba9f60dba0e71e379e3a8118b48262410c0b
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.7.16"
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.16
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-09 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