bullet_train-super_scaffolding 1.5.1 → 1.5.2
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 +4 -4
- data/lib/bullet_train/super_scaffolding/version.rb +1 -1
- data/lib/scaffolding/attribute.rb +2 -0
- data/lib/scaffolding/script.rb +1 -0
- data/lib/scaffolding/transformer.rb +43 -1
- data/lib/scaffolding.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69058843f0779cdd62cd70d3c1a628efc280339ec7f8056c9e1ee4a0cf3eeac0
|
4
|
+
data.tar.gz: d8b6eba75ba033cdfed28dfac6541c4708195d2fbdcb06fa3fe9c1f4c86d4149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3beaf757781c0522f677b6d40a27bf8cd5804e8079cd4b6e13bf10e3ad7e1119c022fd5ad1a7aa7b58625feee6bd00e079e7bf25b336f2171e1c140acadc3f
|
7
|
+
data.tar.gz: d57c47406f32696055be9834fd388de04ac2df32d3a0f86fd162ce91dce0cb7c684c7cc089625126fc2aa613874f849208d164f365b80d5ee84bbafae49de65a
|
data/lib/scaffolding/script.rb
CHANGED
@@ -870,8 +870,11 @@ class Scaffolding::Transformer
|
|
870
870
|
<td#{cell_attributes}><%= render 'shared/attributes/#{attribute.partial_name}', attribute: :#{attribute.is_vanilla? ? attribute.name : attribute.name_without_id_suffix}#{", #{table_cell_options.join(", ")}" if table_cell_options.any?} %></td>
|
871
871
|
ERB
|
872
872
|
|
873
|
-
|
873
|
+
case attribute.type
|
874
|
+
when "password_field"
|
874
875
|
field_content.gsub!(/\s%>/, ", options: { password: true } %>")
|
876
|
+
when "address_field"
|
877
|
+
field_content.gsub!(/\s%>/, ", one_line: true %>")
|
875
878
|
end
|
876
879
|
|
877
880
|
unless ["Team", "User"].include?(child)
|
@@ -958,6 +961,20 @@ class Scaffolding::Transformer
|
|
958
961
|
if attribute.type == "file_field"
|
959
962
|
scaffold_add_line_to_file(file, "#{attribute.name}_removal: [],", RUBY_NEW_ARRAYS_HOOK, prepend: true)
|
960
963
|
end
|
964
|
+
elsif attribute.type == "address_field"
|
965
|
+
address_strong_params = <<~RUBY
|
966
|
+
#{attribute.name}_attributes: [
|
967
|
+
:id,
|
968
|
+
:_destroy,
|
969
|
+
:address_one,
|
970
|
+
:address_two,
|
971
|
+
:city,
|
972
|
+
:country_id,
|
973
|
+
:region_id,
|
974
|
+
:postal_code
|
975
|
+
],
|
976
|
+
RUBY
|
977
|
+
scaffold_add_line_to_file(file, address_strong_params, RUBY_NEW_ARRAYS_HOOK, prepend: true)
|
961
978
|
else
|
962
979
|
scaffold_add_line_to_file(file, ":#{attribute.name},", RUBY_NEW_FIELDS_HOOK, prepend: true)
|
963
980
|
if attribute.type == "file_field"
|
@@ -969,6 +986,28 @@ class Scaffolding::Transformer
|
|
969
986
|
scaffold_add_line_to_file("./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb", attribute.special_processing, RUBY_NEW_FIELDS_PROCESSING_HOOK, prepend: true) if attribute.special_processing
|
970
987
|
end
|
971
988
|
|
989
|
+
#
|
990
|
+
# ASSOCIATED MODELS
|
991
|
+
#
|
992
|
+
|
993
|
+
unless cli_options["skip-form"] || attribute.options[:readonly]
|
994
|
+
|
995
|
+
# set default values for associated models.
|
996
|
+
case attribute.type
|
997
|
+
when "address_field"
|
998
|
+
scaffold_add_line_to_file("./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb", "before_action :set_default_#{attribute.name}, except: :index", "ApplicationController", increase_indent: true)
|
999
|
+
|
1000
|
+
method_content = <<~RUBY
|
1001
|
+
|
1002
|
+
def set_default_#{attribute.name}
|
1003
|
+
@tangible_thing.#{attribute.name} ||= Address.new
|
1004
|
+
end
|
1005
|
+
RUBY
|
1006
|
+
scaffold_add_line_to_file("./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb", method_content, "end", prepend: true, increase_indent: true, exact_match: true)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
end
|
1010
|
+
|
972
1011
|
#
|
973
1012
|
# API SERIALIZER
|
974
1013
|
#
|
@@ -1246,6 +1285,9 @@ class Scaffolding::Transformer
|
|
1246
1285
|
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)
|
1247
1286
|
when "trix_editor"
|
1248
1287
|
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "has_rich_text :#{attribute.name}", HAS_ONE_HOOK, prepend: true)
|
1288
|
+
when "address_field"
|
1289
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "has_one :#{attribute.name}, class_name: \"Address\", as: :addressable", HAS_ONE_HOOK, prepend: true)
|
1290
|
+
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "accepts_nested_attributes_for :#{attribute.name}", HAS_ONE_HOOK, prepend: true)
|
1249
1291
|
when "buttons"
|
1250
1292
|
if attribute.is_boolean?
|
1251
1293
|
scaffold_add_line_to_file("./app/models/scaffolding/completely_concrete/tangible_thing.rb", "validates :#{attribute.name}, inclusion: [true, false]", VALIDATIONS_HOOK, prepend: true)
|
data/lib/scaffolding.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|