bullet_train-super_scaffolding 1.0.43 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/account/scaffolding/absolutely_abstract/creative_concepts/collaborators_controller.rb +1 -1
  3. data/app/controllers/account/scaffolding/absolutely_abstract/creative_concepts_controller.rb +1 -1
  4. data/app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb +4 -34
  5. data/app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller.rb +78 -0
  6. data/app/views/{account → api/v1}/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder +1 -1
  7. data/app/views/api/v1/scaffolding/completely_concrete/tangible_things/index.json.jbuilder +5 -0
  8. data/app/views/api/v1/scaffolding/completely_concrete/tangible_things/show.json.jbuilder +1 -0
  9. data/config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml +1 -1
  10. data/config/routes.rb +32 -1
  11. data/lib/bullet_train/super_scaffolding/engine.rb +0 -7
  12. data/lib/bullet_train/super_scaffolding/version.rb +1 -1
  13. data/lib/scaffolding/transformer.rb +31 -82
  14. metadata +10 -13
  15. data/app/controllers/api/v1/scaffolding/absolutely_abstract/creative_concepts_endpoint.rb +0 -103
  16. data/app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb +0 -136
  17. data/app/serializers/api/v1/scaffolding/absolutely_abstract/creative_concept_serializer.rb +0 -14
  18. data/app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb +0 -37
  19. data/app/views/account/scaffolding/completely_concrete/tangible_things/index.json.jbuilder +0 -1
  20. data/app/views/account/scaffolding/completely_concrete/tangible_things/show.json.jbuilder +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 695ce6d408d1cb821d6fd5672b9877f5387ee1dbd4baaeac04c6f51933fd3ad4
4
- data.tar.gz: 22fc5ed6ec8df0617560da233a492835354faf636ac010f007116728bd3a36ed
3
+ metadata.gz: ae705c580fe51003c77cefdf8a2f6e12357e873c5c5388922a417a0ccfd146eb
4
+ data.tar.gz: 487c57f917e9d82b4c2f565b3d11c3843c7f503070dfc61b0aaadfd4207623dd
5
5
  SHA512:
6
- metadata.gz: e4c8d5afb02e06b48107ef53bd95bdf42632587f45a886c89ed3f3ad938f6db80294e4025a896dac89c7e5ece79aa527ea67514fe8b3bbff3446f6e1acb99c1e
7
- data.tar.gz: e7a5bfdbda2bccab756affe5b27f82eb94c5d419127be93e6bca0e8dc3f94f9556e6ae8c1bcebf0801e462d4b57c214a7c0d1527b6d9df90f07aa90ec49643ff
6
+ metadata.gz: 2e7832d013870c2afeb5eab6da9e1dabe035b3e0f12d648e58f113e28893fdd41b3e3e0b1e10c1e5476a50dfac540952b29aab12f86386c110d21c0f29c66d39
7
+ data.tar.gz: d54ee3b038292d838e153f51b89b7e0e4fca59f4d346ed154be935de373bebda96ae575ad92ddb5ede7d219b1b6a03c5be773016d7d0b0e4e668521eafde5e72
@@ -61,7 +61,7 @@ class Account::Scaffolding::AbsolutelyAbstract::CreativeConcepts::CollaboratorsC
61
61
 
62
62
  private
63
63
 
64
- # Never trust parameters from the scary internet, only allow the white list through.
64
+ # Only allow a list of trusted parameters through.
65
65
  def collaborator_params
66
66
  role_ids = params.dig(:scaffolding_absolutely_abstract_creative_concepts_collaborator, :role_ids)
67
67
  role_ids = [role_ids] unless role_ids.is_a?(Array)
@@ -68,7 +68,7 @@ class Account::Scaffolding::AbsolutelyAbstract::CreativeConceptsController < Acc
68
68
 
69
69
  private
70
70
 
71
- # Never trust parameters from the scary internet, only allow the white list through.
71
+ # Only allow a list of trusted parameters through.
72
72
  def creative_concept_params
73
73
  params.require(:scaffolding_absolutely_abstract_creative_concept).permit(
74
74
  :name,
@@ -4,13 +4,13 @@ class Account::Scaffolding::CompletelyConcrete::TangibleThingsController < Accou
4
4
  # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things
5
5
  # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things.json
6
6
  def index
7
- # if you only want these objects shown on their parent's show page, uncomment this:
8
- # redirect_to [:account, @absolutely_abstract_creative_concept]
7
+ delegate_json_to_api
9
8
  end
10
9
 
11
10
  # GET /account/scaffolding/completely_concrete/tangible_things/:id
12
11
  # GET /account/scaffolding/completely_concrete/tangible_things/:id.json
13
12
  def show
13
+ delegate_json_to_api
14
14
  end
15
15
 
16
16
  # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things/new
@@ -61,37 +61,9 @@ class Account::Scaffolding::CompletelyConcrete::TangibleThingsController < Accou
61
61
 
62
62
  private
63
63
 
64
- # Never trust parameters from the scary internet, only allow the white list through.
65
- def tangible_thing_params
66
- strong_params = params.require(:scaffolding_completely_concrete_tangible_thing).permit(
67
- # 🚅 skip this section when scaffolding.
68
- :text_field_value,
69
- :action_text_value,
70
- :boolean_button_value,
71
- :button_value,
72
- :color_picker_value,
73
- :cloudinary_image_value,
74
- :date_field_value,
75
- :date_and_time_field_value,
76
- :date_and_time_field_value_time_zone,
77
- :email_field_value,
78
- :file_field_value,
79
- :file_field_value_removal,
80
- :option_value,
81
- :password_field_value,
82
- :phone_field_value,
83
- :super_select_value,
84
- :text_area_value,
85
- # 🚅 stop any skipping we're doing now.
86
- # 🚅 super scaffolding will insert new fields above this line.
87
- # 🚅 skip this section when scaffolding.
88
- multiple_button_values: [],
89
- multiple_option_values: [],
90
- multiple_super_select_values: []
91
- # 🚅 stop any skipping we're doing now.
92
- # 🚅 super scaffolding will insert new arrays above this line.
93
- )
64
+ include strong_parameters_from_api
94
65
 
66
+ def process_params(strong_params)
95
67
  # 🚅 skip this section when scaffolding.
96
68
  assign_boolean(strong_params, :boolean_button_value)
97
69
  assign_date_and_time(strong_params, :date_and_time_field_value)
@@ -100,7 +72,5 @@ class Account::Scaffolding::CompletelyConcrete::TangibleThingsController < Accou
100
72
  assign_select_options(strong_params, :multiple_super_select_values)
101
73
  # 🚅 stop any skipping we're doing now.
102
74
  # 🚅 super scaffolding will insert processing for new fields above this line.
103
-
104
- strong_params
105
75
  end
106
76
  end
@@ -0,0 +1,78 @@
1
+ class Api::V1::Scaffolding::CompletelyConcrete::TangibleThingsController < Api::V1::ApplicationController
2
+ account_load_and_authorize_resource :tangible_thing, through: :absolutely_abstract_creative_concept, through_association: :completely_concrete_tangible_things
3
+
4
+ # GET /api/v1/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things
5
+ def index
6
+ end
7
+
8
+ # GET /api/v1/scaffolding/completely_concrete/tangible_things/:id
9
+ def show
10
+ end
11
+
12
+ # POST /api/v1/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things
13
+ def create
14
+ if @tangible_thing.save
15
+ render :show, status: :created, location: [:api, :v1, @tangible_thing]
16
+ else
17
+ render json: @tangible_thing.errors, status: :unprocessable_entity
18
+ end
19
+ end
20
+
21
+ # PATCH/PUT /api/v1/scaffolding/completely_concrete/tangible_things/:id
22
+ def update
23
+ if @tangible_thing.update(tangible_thing_params)
24
+ render :show
25
+ else
26
+ render json: @tangible_thing.errors, status: :unprocessable_entity
27
+ end
28
+ end
29
+
30
+ # DELETE /api/v1/scaffolding/completely_concrete/tangible_things/:id
31
+ def destroy
32
+ @tangible_thing.destroy
33
+ end
34
+
35
+ private
36
+
37
+ module StrongParameters
38
+ # Only allow a list of trusted parameters through.
39
+ def tangible_thing_params
40
+ strong_params = params.require(:scaffolding_completely_concrete_tangible_thing).permit(
41
+ *permitted_fields,
42
+ # 🚅 skip this section when scaffolding.
43
+ :text_field_value,
44
+ :action_text_value,
45
+ :boolean_button_value,
46
+ :button_value,
47
+ :color_picker_value,
48
+ :cloudinary_image_value,
49
+ :date_field_value,
50
+ :date_and_time_field_value,
51
+ :date_and_time_field_value_time_zone,
52
+ :email_field_value,
53
+ :file_field_value,
54
+ :file_field_value_removal,
55
+ :option_value,
56
+ :password_field_value,
57
+ :phone_field_value,
58
+ :super_select_value,
59
+ :text_area_value,
60
+ # 🚅 stop any skipping we're doing now.
61
+ # 🚅 super scaffolding will insert new fields above this line.
62
+ *permitted_arrays,
63
+ # 🚅 skip this section when scaffolding.
64
+ multiple_button_values: [],
65
+ multiple_option_values: [],
66
+ multiple_super_select_values: []
67
+ # 🚅 stop any skipping we're doing now.
68
+ # 🚅 super scaffolding will insert new arrays above this line.
69
+ )
70
+
71
+ process_params(strong_params)
72
+
73
+ strong_params
74
+ end
75
+ end
76
+
77
+ include StrongParameters
78
+ end
@@ -7,6 +7,7 @@ json.extract! tangible_thing,
7
7
  :color_picker_value,
8
8
  :cloudinary_image_value,
9
9
  :date_field_value,
10
+ :date_and_time_field_value,
10
11
  :email_field_value,
11
12
  :password_field_value,
12
13
  :phone_field_value,
@@ -19,4 +20,3 @@ json.extract! tangible_thing,
19
20
  # 🚅 super scaffolding will insert new fields above this line.
20
21
  :created_at,
21
22
  :updated_at
22
- json.url account_scaffolding_completely_concrete_tangible_thing_url(tangible_thing, format: :json)
@@ -0,0 +1,5 @@
1
+ json.data do
2
+ json.array! @tangible_things, partial: "api/v1/scaffolding/completely_concrete/tangible_things/tangible_thing", as: :tangible_thing
3
+ end
4
+
5
+ render_pagination(json)
@@ -0,0 +1 @@
1
+ json.partial! "api/v1/scaffolding/completely_concrete/tangible_things/tangible_thing", tangible_thing: @tangible_thing
@@ -17,7 +17,7 @@ en:
17
17
  destroy: Delete
18
18
  confirmations:
19
19
  # TODO customize for your use-case.
20
- destroy: Are you sure you want to remove %{tangible_thing_name}? This will also remove it's associated data. This can't be undone.
20
+ destroy: Are you sure you want to remove %{tangible_thing_name}? This will also remove any child resources and can't be undone.
21
21
  fields: &fields
22
22
  id:
23
23
  heading: Tangible Thing ID
data/config/routes.rb CHANGED
@@ -1,5 +1,36 @@
1
1
  Rails.application.routes.draw do
2
- collection_actions = [:index, :new, :create]
2
+ # See `config/routes.rb` for details.
3
+ collection_actions = [:index, :new, :create] # standard:disable Lint/UselessAssignment
4
+ extending = {only: []}
5
+
6
+ namespace :api do
7
+ namespace :v1 do
8
+ shallow do
9
+ resources :teams, extending do
10
+ unless scaffolding_things_disabled?
11
+ namespace :scaffolding do
12
+ namespace :absolutely_abstract do
13
+ resources :creative_concepts do
14
+ scope module: "creative_concepts" do
15
+ resources :collaborators, only: collection_actions
16
+ end
17
+
18
+ namespace :creative_concepts do
19
+ resources :collaborators, except: collection_actions
20
+ end
21
+ end
22
+ end
23
+ resources :absolutely_abstract_creative_concepts, path: "absolutely_abstract/creative_concepts" do
24
+ namespace :completely_concrete do
25
+ resources :tangible_things
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
3
34
 
4
35
  namespace :account do
5
36
  shallow do
@@ -10,13 +10,6 @@ module BulletTrain
10
10
  BulletTrain::SuperScaffolding.template_paths << File.expand_path("../../../..", __FILE__)
11
11
  end
12
12
 
13
- initializer "bullet_train.super_scaffolding.templates.register_api_endpoints" do |app|
14
- if defined?(BulletTrain::Api)
15
- BulletTrain::Api.endpoints << "Api::V1::Scaffolding::AbsolutelyAbstract::CreativeConceptsEndpoint"
16
- BulletTrain::Api.endpoints << "Api::V1::Scaffolding::CompletelyConcrete::TangibleThingsEndpoint"
17
- end
18
- end
19
-
20
13
  initializer "bullet_train.super_scaffolding.register" do |app|
21
14
  # Older versions of Bullet Train have a `BulletTrain` module, but it doesn't have `linked_gems`.
22
15
  if BulletTrain.respond_to?(:linked_gems)
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module SuperScaffolding
3
- VERSION = "1.0.43"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -45,7 +45,6 @@ class Scaffolding::Transformer
45
45
  RUBY_ADDITIONAL_NEW_FIELDS_HOOK = "# 🚅 super scaffolding will also insert new fields above this line."
46
46
  RUBY_EVEN_MORE_NEW_FIELDS_HOOK = "# 🚅 super scaffolding will additionally insert new fields above this line."
47
47
  RUBY_FILES_HOOK = "# 🚅 super scaffolding will insert file-related logic above this line."
48
- ENDPOINTS_HOOK = "# 🚅 super scaffolding will mount new endpoints above this line."
49
48
  ERB_NEW_FIELDS_HOOK = "<%#{RUBY_NEW_FIELDS_HOOK} %>"
50
49
  CONCERNS_HOOK = "# 🚅 add concerns above."
51
50
  ATTR_ACCESSORS_HOOK = "# 🚅 add attribute accessors above."
@@ -715,6 +714,8 @@ class Scaffolding::Transformer
715
714
  "'another.email@test.com'"
716
715
  when "phone_field"
717
716
  "'+19053871234'"
717
+ when "color_picker"
718
+ "'#47E37F'"
718
719
  end
719
720
 
720
721
  # don't do table columns for certain types of fields and attribute partials
@@ -992,7 +993,8 @@ class Scaffolding::Transformer
992
993
 
993
994
  # add attributes to strong params.
994
995
  [
995
- "./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb"
996
+ "./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb",
997
+ "./app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller.rb"
996
998
  ].each do |file|
997
999
  if is_ids || is_multiple
998
1000
  scaffold_add_line_to_file(file, "#{name}: [],", RUBY_NEW_ARRAYS_HOOK, prepend: true)
@@ -1026,38 +1028,6 @@ class Scaffolding::Transformer
1026
1028
  scaffold_add_line_to_file("./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb", special_processing, RUBY_NEW_FIELDS_PROCESSING_HOOK, prepend: true) if special_processing
1027
1029
  end
1028
1030
 
1029
- #
1030
- # API ENDPOINT
1031
- #
1032
-
1033
- unless cli_options["skip-api"]
1034
-
1035
- # add attributes to endpoint.
1036
- if name.match?(/_ids$/)
1037
- scaffold_add_line_to_file("./app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb", "optional :#{name}, type: Array, desc: Api.heading(:#{name})", RUBY_NEW_ARRAYS_HOOK, prepend: true)
1038
- else
1039
- api_type = case type
1040
- when "date_field"
1041
- "Date"
1042
- when "date_and_time_field"
1043
- "DateTime"
1044
- when "buttons"
1045
- if boolean_buttons
1046
- "Boolean"
1047
- else
1048
- "String"
1049
- end
1050
- when "file_field"
1051
- "File"
1052
- else
1053
- "String"
1054
- end
1055
-
1056
- scaffold_add_line_to_file("./app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb", "optional :#{name}, type: #{api_type}, desc: Api.heading(:#{name})", RUBY_NEW_FIELDS_HOOK, prepend: true)
1057
- end
1058
-
1059
- end
1060
-
1061
1031
  #
1062
1032
  # API SERIALIZER
1063
1033
  #
@@ -1066,8 +1036,7 @@ class Scaffolding::Transformer
1066
1036
 
1067
1037
  # TODO The serializers can't handle these `has_rich_text` attributes.
1068
1038
  unless type == "trix_editor"
1069
- scaffold_add_line_to_file("./app/views/account/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder", ":#{name},", RUBY_NEW_FIELDS_HOOK, prepend: true, suppress_could_not_find: true)
1070
- scaffold_add_line_to_file("./app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb", ":#{name},", RUBY_NEW_FIELDS_HOOK, prepend: true) unless type == "file_field"
1039
+ scaffold_add_line_to_file("./app/views/api/v1/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder", ":#{name},", RUBY_NEW_FIELDS_HOOK, prepend: true, suppress_could_not_find: true)
1071
1040
 
1072
1041
  assertion = case type
1073
1042
  when "date_field"
@@ -1075,52 +1044,27 @@ class Scaffolding::Transformer
1075
1044
  when "date_and_time_field"
1076
1045
  "assert_equal_or_nil DateTime.parse(tangible_thing_data['#{name}']), tangible_thing.#{name}"
1077
1046
  when "file_field"
1078
- # TODO: If we want to use Cloudinary to handle our files, we should make sure we're getting a URL.
1079
- "assert tangible_thing_data['#{name}'].match?('foo.txt') unless response.status == 201"
1047
+ # TODO Get this working again.
1048
+ "# assert tangible_thing_data['#{name}'].match?('foo.txt') unless response.status == 201"
1080
1049
  else
1081
1050
  "assert_equal_or_nil tangible_thing_data['#{name}'], tangible_thing.#{name}"
1082
1051
  end
1083
- scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", assertion, RUBY_NEW_FIELDS_HOOK, prepend: true)
1052
+ scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", assertion, RUBY_NEW_FIELDS_HOOK, prepend: true)
1084
1053
  end
1085
1054
 
1086
1055
  # File fields are handled in a specific way when using the jsonapi-serializer.
1087
1056
  if type == "file_field"
1088
- file_name = "./app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb"
1089
- content = <<~RUBY
1090
- attribute :#{name} do |object|
1091
- rails_blob_path(object.#{name}, disposition: "attachment", only_path: true) if object.#{name}.attached?
1092
- end
1093
-
1094
- RUBY
1095
- hook = RUBY_FILES_HOOK
1096
- scaffold_add_line_to_file(file_name, content, hook, prepend: true)
1097
-
1098
- # We also want to make sure we attach the dummy file in the endpoint test on setup
1099
- file_name = "./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb"
1100
- content = "@#{child.underscore}.#{name} = Rack::Test::UploadedFile.new(\"test/support/foo.txt\")"
1101
- scaffold_add_line_to_file(file_name, content, hook, prepend: true)
1057
+ # TODO Get this working again.
1058
+ # We also want to make sure we attach the dummy file in the API test on setup
1059
+ file_name = "./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb"
1060
+ content = "# @#{child.underscore}.#{name} = Rack::Test::UploadedFile.new(\"test/support/foo.txt\")"
1061
+ scaffold_add_line_to_file(file_name, content, RUBY_FILES_HOOK, prepend: true)
1102
1062
  end
1103
1063
 
1104
- # scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", "assert_equal tangible_thing_attributes['#{name.gsub('_', '-')}'], tangible_thing.#{name}", RUBY_NEW_FIELDS_HOOK, prepend: true)
1105
-
1106
1064
  if attribute_assignment
1107
1065
  unless attribute_options[:readonly]
1108
- scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", "#{name}: #{attribute_assignment},", RUBY_ADDITIONAL_NEW_FIELDS_HOOK, prepend: true)
1109
- scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", "assert_equal @tangible_thing.#{name}, #{attribute_assignment}", RUBY_EVEN_MORE_NEW_FIELDS_HOOK, prepend: true)
1110
- end
1111
- end
1112
-
1113
- # We need to update our new Tangible Thing's
1114
- # jbuilder files if it's scoped under "account".
1115
- # TODO: Should we run this if `namespace.present?` instead?
1116
- if namespace == "account"
1117
- target_string = "#{transform_string("scaffolding/completely_concrete/tangible_things")}/#{transform_string("tangible_thing")}"
1118
- replacement_string = "#{namespace}/#{target_string}"
1119
- [
1120
- "app/views/account/completely_concrete/tangible_things/index.json.jbuilder",
1121
- "app/views/account/completely_concrete/tangible_things/show.json.jbuilder"
1122
- ].each do |path|
1123
- scaffold_replace_line_in_file(path, replacement_string, target_string)
1066
+ scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", "#{name}: #{attribute_assignment},", RUBY_ADDITIONAL_NEW_FIELDS_HOOK, prepend: true)
1067
+ scaffold_add_line_to_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", "assert_equal @tangible_thing.#{name}, #{attribute_assignment}", RUBY_EVEN_MORE_NEW_FIELDS_HOOK, prepend: true)
1124
1068
  end
1125
1069
  end
1126
1070
  end
@@ -1307,10 +1251,10 @@ class Scaffolding::Transformer
1307
1251
  [
1308
1252
  "./app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb",
1309
1253
  "./app/views/account/scaffolding/completely_concrete/tangible_things",
1254
+ "./app/views/api/v1/scaffolding/completely_concrete/tangible_things",
1310
1255
  ("./config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml" unless cli_options["skip-locales"]),
1311
- ("./app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb" unless cli_options["skip-api"]),
1312
- ("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb" unless cli_options["skip-api"]),
1313
- ("./app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb" unless cli_options["skip-api"])
1256
+ ("./app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller.rb" unless cli_options["skip-api"]),
1257
+ ("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb" unless cli_options["skip-api"])
1314
1258
  # "./app/filters/scaffolding/completely_concrete/tangible_things_filter.rb"
1315
1259
  ].compact
1316
1260
  end
@@ -1323,13 +1267,6 @@ class Scaffolding::Transformer
1323
1267
  end
1324
1268
  end
1325
1269
 
1326
- unless cli_options["skip-api"]
1327
-
1328
- # add endpoint to the api.
1329
- scaffold_add_line_to_file("./app/controllers/api/v1/root.rb", "mount Api::V1::Scaffolding::CompletelyConcrete::TangibleThingsEndpoint", ENDPOINTS_HOOK, prepend: true)
1330
-
1331
- end
1332
-
1333
1270
  unless cli_options["skip-model"]
1334
1271
  # find the database migration that defines this relationship.
1335
1272
  migration_file_name = `grep "create_table :#{class_names_transformer.table_name} do |t|" db/migrate/*`.split(":").first
@@ -1367,7 +1304,7 @@ class Scaffolding::Transformer
1367
1304
  end
1368
1305
 
1369
1306
  unless cli_options["skip-api"]
1370
- scaffold_replace_line_in_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint_test.rb", build_factory_setup.join("\n"), "# 🚅 super scaffolding will insert factory setup in place of this line.")
1307
+ scaffold_replace_line_in_file("./test/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller_test.rb", build_factory_setup.join("\n"), "# 🚅 super scaffolding will insert factory setup in place of this line.")
1371
1308
  end
1372
1309
 
1373
1310
  # add children to the show page of their parent.
@@ -1466,6 +1403,18 @@ class Scaffolding::Transformer
1466
1403
  end
1467
1404
 
1468
1405
  Scaffolding::FileManipulator.write("config/routes.rb", routes_manipulator.lines)
1406
+
1407
+ unless cli_options["skip-api"]
1408
+ begin
1409
+ api_routes_manipulator = Scaffolding::RoutesFileManipulator.new("config/routes/api/#{BulletTrain::Api.current_version}.rb", child, parent, cli_options)
1410
+ api_routes_manipulator.apply([BulletTrain::Api.current_version.to_sym])
1411
+ rescue => e
1412
+ puts "We weren't able to automatically add your `api/#{BulletTrain::Api.current_version}` routes for you. In theory this should be very rare, so if you could reach out on Slack, you could probably provide context that will help us fix whatever the problem was. In the meantime, to add the routes manually, we've got a guide at https://blog.bullettrain.co/nested-namespaced-rails-routing-examples/ .".send(:yellow)
1413
+ raise e
1414
+ end
1415
+
1416
+ Scaffolding::FileManipulator.write("config/routes/api/#{BulletTrain::Api.current_version}.rb", api_routes_manipulator.lines)
1417
+ end
1469
1418
  end
1470
1419
 
1471
1420
  unless cli_options["skip-parent"]
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.0.43
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-29 00:00:00.000000000 Z
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -85,9 +85,8 @@ files:
85
85
  - app/controllers/api/v1.rb
86
86
  - app/controllers/api/v1/scaffolding.rb
87
87
  - app/controllers/api/v1/scaffolding/absolutely_abstract.rb
88
- - app/controllers/api/v1/scaffolding/absolutely_abstract/creative_concepts_endpoint.rb
89
88
  - app/controllers/api/v1/scaffolding/completely_concrete.rb
90
- - app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb
89
+ - app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_controller.rb
91
90
  - app/controllers/concerns/scaffolding/absolutely_abstract/creative_concepts/controller_support.rb
92
91
  - app/helpers/super_scaffolding_helper.rb
93
92
  - app/models/scaffolding.rb
@@ -99,8 +98,6 @@ files:
99
98
  - app/models/scaffolding/completely_concrete/tangible_thing.rb
100
99
  - app/models/scaffolding/completely_concrete/tangible_things.rb
101
100
  - app/models/scaffolding/completely_concrete/tangible_things/assignment.rb
102
- - app/serializers/api/v1/scaffolding/absolutely_abstract/creative_concept_serializer.rb
103
- - app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb
104
101
  - app/views/account/scaffolding/absolutely_abstract/creative_concepts/_breadcrumbs.html.erb
105
102
  - app/views/account/scaffolding/absolutely_abstract/creative_concepts/_creative_concept.json.jbuilder
106
103
  - app/views/account/scaffolding/absolutely_abstract/creative_concepts/_form.html.erb
@@ -127,13 +124,13 @@ files:
127
124
  - app/views/account/scaffolding/completely_concrete/tangible_things/_form.html.erb
128
125
  - app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb
129
126
  - app/views/account/scaffolding/completely_concrete/tangible_things/_menu_item.html.erb
130
- - app/views/account/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder
131
127
  - app/views/account/scaffolding/completely_concrete/tangible_things/edit.html.erb
132
128
  - app/views/account/scaffolding/completely_concrete/tangible_things/index.html.erb
133
- - app/views/account/scaffolding/completely_concrete/tangible_things/index.json.jbuilder
134
129
  - app/views/account/scaffolding/completely_concrete/tangible_things/new.html.erb
135
130
  - app/views/account/scaffolding/completely_concrete/tangible_things/show.html.erb
136
- - app/views/account/scaffolding/completely_concrete/tangible_things/show.json.jbuilder
131
+ - app/views/api/v1/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder
132
+ - app/views/api/v1/scaffolding/completely_concrete/tangible_things/index.json.jbuilder
133
+ - app/views/api/v1/scaffolding/completely_concrete/tangible_things/show.json.jbuilder
137
134
  - app/views/shared/_bulk_action_select.html.erb
138
135
  - app/views/shared/tables/_checkbox.html.erb
139
136
  - app/views/shared/tables/_select_all.html.erb
@@ -178,7 +175,7 @@ licenses:
178
175
  metadata:
179
176
  homepage_uri: https://github.com/bullet-train-co/bullet_train-super_scaffolding
180
177
  source_code_uri: https://github.com/bullet-train-co/bullet_train-super_scaffolding
181
- post_install_message:
178
+ post_install_message:
182
179
  rdoc_options: []
183
180
  require_paths:
184
181
  - lib
@@ -193,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
190
  - !ruby/object:Gem::Version
194
191
  version: '0'
195
192
  requirements: []
196
- rubygems_version: 3.1.6
197
- signing_key:
193
+ rubygems_version: 3.3.7
194
+ signing_key:
198
195
  specification_version: 4
199
196
  summary: Bullet Train Super Scaffolding
200
197
  test_files: []
@@ -1,103 +0,0 @@
1
- class Api::V1::Scaffolding::AbsolutelyAbstract::CreativeConceptsEndpoint < Api::V1::Root
2
- helpers do
3
- include Scaffolding::AbsolutelyAbstract::CreativeConcepts::ControllerSupport
4
-
5
- params :team_id do
6
- requires :team_id, type: Integer, allow_blank: false, desc: Api.heading(:team_id)
7
- end
8
-
9
- params :id do
10
- requires :id, type: Integer, allow_blank: false, desc: Api.heading(:id)
11
- end
12
-
13
- params :creative_concept do
14
- optional :name, type: String, allow_blank: false, desc: Api.heading(:name)
15
- optional :description, type: String, allow_blank: true, desc: Api.heading(:description)
16
- # 🚅 super scaffolding will insert new fields above this line.
17
- # 🚅 super scaffolding will insert new arrays above this line.
18
-
19
- # 🚅 super scaffolding will insert processing for new fields above this line.
20
- end
21
- end
22
-
23
- # uses shallow routing to support teams
24
- resource :teams, desc: Api.title(:collection_actions) do
25
- after_validation do
26
- load_and_authorize_api_resource Scaffolding::AbsolutelyAbstract::CreativeConcept
27
- end
28
-
29
- desc Api.title(:index), &Api.index_desc
30
- params do
31
- use :team_id
32
- end
33
- oauth2
34
- paginate per_page: 100
35
- get "/:team_id/scaffolding/absolutely_abstract/creative_concepts" do
36
- @paginated_creative_concepts = paginate @creative_concepts
37
- render @paginated_creative_concepts, serializer: Api.serializer, adapter: :attributes
38
- end
39
-
40
- desc Api.title(:create), &Api.create_desc
41
- params do
42
- use :team_id
43
- use :creative_concept
44
- end
45
- route_setting :api_resource_options, permission: :create
46
- oauth2 "write"
47
- post "/:team_id/scaffolding/absolutely_abstract/creative_concepts" do
48
- ensure_current_user_can_manage_creative_concept @creative_concept
49
-
50
- if @creative_concept.save
51
- render @creative_concept, serializer: Api.serializer
52
- else
53
- record_not_saved @creative_concept
54
- end
55
- end
56
- end
57
-
58
- resource "scaffolding/absolutely_abstract/creative_concepts", desc: Api.title(:member_actions) do
59
- after_validation do
60
- load_and_authorize_api_resource Scaffolding::AbsolutelyAbstract::CreativeConcept
61
- end
62
-
63
- desc Api.title(:show), &Api.show_desc
64
- params do
65
- use :id
66
- end
67
- oauth2
68
- route_param :id do
69
- get do
70
- render @creative_concept, serializer: Api.serializer
71
- end
72
- end
73
-
74
- desc Api.title(:update), &Api.update_desc
75
- params do
76
- use :id
77
- use :creative_concept
78
- end
79
- route_setting :api_resource_options, permission: :update
80
- oauth2 "write"
81
- route_param :id do
82
- put do
83
- if @creative_concept.update(declared(params, include_missing: false))
84
- render @creative_concept, serializer: Api.serializer
85
- else
86
- record_not_saved @creative_concept
87
- end
88
- end
89
- end
90
-
91
- desc Api.title(:destroy), &Api.destroy_desc
92
- params do
93
- use :id
94
- end
95
- route_setting :api_resource_options, permission: :destroy
96
- oauth2 "delete"
97
- route_param :id do
98
- delete do
99
- render @creative_concept.destroy, serializer: Api.serializer
100
- end
101
- end
102
- end
103
- end
@@ -1,136 +0,0 @@
1
- class Api::V1::Scaffolding::CompletelyConcrete::TangibleThingsEndpoint < Api::V1::Root
2
- helpers do
3
- params :absolutely_abstract_creative_concept_id do
4
- requires :absolutely_abstract_creative_concept_id, type: Integer, allow_blank: false, desc: "Creative Concept ID"
5
- end
6
-
7
- params :id do
8
- requires :id, type: Integer, allow_blank: false, desc: "Tangible Thing ID"
9
- end
10
-
11
- params :tangible_thing do
12
- # 🚅 skip this section when scaffolding.
13
- optional :text_field_value, type: String, allow_blank: true, desc: Api.heading(:text_field_value)
14
- optional :button_value, type: String, allow_blank: true, desc: Api.heading(:button_value)
15
- optional :cloudinary_image_value, type: String, allow_blank: true, desc: Api.heading(:cloudinary_image_value)
16
- optional :date_field_value, type: Date, allow_blank: true, desc: Api.heading(:date_field_value)
17
- optional :date_and_time_field_value, type: DateTime, allow_blank: true, desc: Api.heading(:date_and_time_field_value)
18
- optional :email_field_value, type: String, allow_blank: true, desc: Api.heading(:email_field_value)
19
- optional :file_field_value, type: String, allow_blank: true, desc: Api.heading(:file_field_value)
20
- optional :password_field_value, type: String, allow_blank: true, desc: Api.heading(:password_field_value)
21
- optional :phone_field_value, type: String, allow_blank: true, desc: Api.heading(:phone_field_value)
22
- optional :option_value, type: String, allow_blank: true, desc: Api.heading(:option_value)
23
- optional :super_select_value, type: String, allow_blank: true, desc: Api.heading(:super_select_value)
24
- optional :text_area_value, type: String, allow_blank: true, desc: Api.heading(:text_area_value)
25
- optional :action_text_value, type: String, allow_blank: true, desc: Api.heading(:action_text_value)
26
- # 🚅 stop any skipping we're doing now.
27
- # 🚅 super scaffolding will insert new fields above this line.
28
- # 🚅 skip this section when scaffolding.
29
- optional :multiple_button_values, type: Array, default: [], desc: Api.heading(:multiple_button_values)
30
- optional :multiple_option_values, type: Array, default: [], desc: Api.heading(:multiple_option_values)
31
- optional :multiple_super_select_values, type: Array, default: [], desc: Api.heading(:multiple_super_select_values)
32
- # 🚅 stop any skipping we're doing now.
33
- # 🚅 super scaffolding will insert new arrays above this line.
34
-
35
- # 🚅 super scaffolding will insert processing for new fields above this line.
36
- end
37
- end
38
-
39
- resource "scaffolding/absolutely_abstract/creative_concepts", desc: Api.title(:collection_actions) do
40
- after_validation do
41
- load_and_authorize_api_resource Scaffolding::CompletelyConcrete::TangibleThing
42
- end
43
-
44
- #
45
- # INDEX
46
- #
47
-
48
- desc Api.title(:index), &Api.index_desc
49
- params do
50
- use :absolutely_abstract_creative_concept_id
51
- end
52
- oauth2
53
- paginate per_page: 100
54
- get "/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things" do
55
- @paginated_tangible_things = paginate @tangible_things
56
- render @paginated_tangible_things, serializer: Api.serializer
57
- end
58
-
59
- #
60
- # CREATE
61
- #
62
-
63
- desc Api.title(:create), &Api.create_desc
64
- params do
65
- use :absolutely_abstract_creative_concept_id
66
- use :tangible_thing
67
- end
68
- route_setting :api_resource_options, permission: :create
69
- oauth2 "write"
70
- post "/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things" do
71
- if @tangible_thing.save
72
- render @tangible_thing, serializer: Api.serializer
73
- else
74
- record_not_saved @tangible_thing
75
- end
76
- end
77
- end
78
-
79
- resource "scaffolding/completely_concrete/tangible_things", desc: Api.title(:member_actions) do
80
- after_validation do
81
- load_and_authorize_api_resource Scaffolding::CompletelyConcrete::TangibleThing
82
- end
83
-
84
- #
85
- # SHOW
86
- #
87
-
88
- desc Api.title(:show), &Api.show_desc
89
- params do
90
- use :id
91
- end
92
- oauth2
93
- route_param :id do
94
- get do
95
- render @tangible_thing, serializer: Api.serializer
96
- end
97
- end
98
-
99
- #
100
- # UPDATE
101
- #
102
-
103
- desc Api.title(:update), &Api.update_desc
104
- params do
105
- use :id
106
- use :tangible_thing
107
- end
108
- route_setting :api_resource_options, permission: :update
109
- oauth2 "write"
110
- route_param :id do
111
- put do
112
- if @tangible_thing.update(declared(params, include_missing: false))
113
- render @tangible_thing, serializer: Api.serializer
114
- else
115
- record_not_saved @tangible_thing
116
- end
117
- end
118
- end
119
-
120
- #
121
- # DESTROY
122
- #
123
-
124
- desc Api.title(:destroy), &Api.destroy_desc
125
- params do
126
- use :id
127
- end
128
- route_setting :api_resource_options, permission: :destroy
129
- oauth2 "delete"
130
- route_param :id do
131
- delete do
132
- render @tangible_thing.destroy, serializer: Api.serializer
133
- end
134
- end
135
- end
136
- end
@@ -1,14 +0,0 @@
1
- class Api::V1::Scaffolding::AbsolutelyAbstract::CreativeConceptSerializer < Api::V1::ApplicationSerializer
2
- set_type "scaffolding/absolutely_abstract/creative_concept"
3
-
4
- attributes :id,
5
- :team_id,
6
- :name,
7
- :description,
8
- # 🚅 super scaffolding will insert new fields above this line.
9
- :created_at,
10
- :updated_at
11
-
12
- belongs_to :team, serializer: Api::V1::TeamSerializer
13
- has_many :completely_concrete_tangible_things, serializer: Api::V1::Scaffolding::CompletelyConcrete::TangibleThingSerializer
14
- end
@@ -1,37 +0,0 @@
1
- class Api::V1::Scaffolding::CompletelyConcrete::TangibleThingSerializer < Api::V1::ApplicationSerializer
2
- set_type "scaffolding/completely_concrete/tangible_thing"
3
- singleton_class.include Rails.application.routes.url_helpers
4
-
5
- attributes :id,
6
- :absolutely_abstract_creative_concept_id,
7
- # 🚅 skip this section when scaffolding.
8
- :text_field_value,
9
- :button_value,
10
- :multiple_button_values,
11
- :color_picker_value,
12
- :cloudinary_image_value,
13
- :date_field_value,
14
- :date_and_time_field_value,
15
- :email_field_value,
16
- :password_field_value,
17
- :phone_field_value,
18
- :option_value,
19
- # :multiple_option_values,
20
- :super_select_value,
21
- # :multiple_super_select_values,
22
- # :text_area_value,
23
- # :action_text_value,
24
- # 🚅 stop any skipping we're doing now.
25
- # 🚅 super scaffolding will insert new fields above this line.
26
- :created_at,
27
- :updated_at
28
-
29
- # 🚅 skip this section when scaffolding.
30
- attribute :file_field_value do |object|
31
- rails_blob_path(object.file_field_value, disposition: "attachment", only_path: true) if object.file_field_value.attached?
32
- end
33
- # 🚅 stop any skipping we're doing now.
34
- # 🚅 super scaffolding will insert file-related logic above this line.
35
-
36
- belongs_to :absolutely_abstract_creative_concept, serializer: Api::V1::Scaffolding::AbsolutelyAbstract::CreativeConceptSerializer
37
- end
@@ -1 +0,0 @@
1
- json.array! @tangible_things, partial: "scaffolding/completely_concrete/tangible_things/tangible_thing", as: :tangible_thing
@@ -1 +0,0 @@
1
- json.partial! "scaffolding/completely_concrete/tangible_things/tangible_thing", tangible_thing: @tangible_thing