bullet_train-super_scaffolding 1.0.6 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/account/scaffolding/absolutely_abstract/creative_concepts/collaborators_controller.rb +81 -0
  3. data/app/controllers/account/scaffolding/absolutely_abstract/creative_concepts_controller.rb +82 -0
  4. data/app/controllers/account/scaffolding/completely_concrete/tangible_things_controller.rb +107 -0
  5. data/app/controllers/api/v1/scaffolding/absolutely_abstract/creative_concepts_endpoint.rb +103 -0
  6. data/app/controllers/api/v1/scaffolding/absolutely_abstract.rb +2 -0
  7. data/app/controllers/api/v1/scaffolding/completely_concrete/tangible_things_endpoint.rb +136 -0
  8. data/app/controllers/api/v1/scaffolding/completely_concrete.rb +2 -0
  9. data/app/controllers/api/v1/scaffolding.rb +2 -0
  10. data/app/controllers/api/v1.rb +2 -0
  11. data/app/controllers/api.rb +2 -0
  12. data/app/controllers/concerns/scaffolding/absolutely_abstract/creative_concepts/controller_support.rb +11 -0
  13. data/app/models/scaffolding/absolutely_abstract/creative_concept.rb +42 -0
  14. data/app/models/scaffolding/absolutely_abstract/creative_concepts/collaborator.rb +39 -0
  15. data/app/models/scaffolding/absolutely_abstract/creative_concepts.rb +5 -0
  16. data/app/models/scaffolding/absolutely_abstract.rb +5 -0
  17. data/app/models/scaffolding/completely_concrete/tangible_thing.rb +42 -0
  18. data/app/models/scaffolding/completely_concrete/tangible_things/assignment.rb +22 -0
  19. data/app/models/scaffolding/completely_concrete/tangible_things.rb +5 -0
  20. data/app/models/scaffolding/completely_concrete.rb +5 -0
  21. data/app/models/scaffolding.rb +5 -0
  22. data/app/serializers/api/v1/scaffolding/absolutely_abstract/creative_concept_serializer.rb +14 -0
  23. data/app/serializers/api/v1/scaffolding/completely_concrete/tangible_thing_serializer.rb +30 -0
  24. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/_breadcrumbs.html.erb +8 -0
  25. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/_creative_concept.json.jbuilder +8 -0
  26. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/_form.html.erb +18 -0
  27. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/_index.html.erb +56 -0
  28. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/_menu_item.html.erb +10 -0
  29. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/_breadcrumbs.html.erb +8 -0
  30. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/_collaborator.json.jbuilder +9 -0
  31. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/_form.html.erb +19 -0
  32. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/_index.html.erb +69 -0
  33. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/_menu_item.html.erb +10 -0
  34. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/edit.html.erb +12 -0
  35. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/index.html.erb +6 -0
  36. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/index.json.jbuilder +1 -0
  37. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/new.html.erb +12 -0
  38. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/show.html.erb +31 -0
  39. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/collaborators/show.json.jbuilder +1 -0
  40. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/edit.html.erb +12 -0
  41. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/index.html.erb +6 -0
  42. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/index.json.jbuilder +1 -0
  43. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/new.html.erb +12 -0
  44. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/show.html.erb +65 -0
  45. data/app/views/account/scaffolding/absolutely_abstract/creative_concepts/show.json.jbuilder +1 -0
  46. data/app/views/account/scaffolding/completely_concrete/tangible_things/_breadcrumbs.html.erb +8 -0
  47. data/app/views/account/scaffolding/completely_concrete/tangible_things/_form.html.erb +66 -0
  48. data/app/views/account/scaffolding/completely_concrete/tangible_things/_index.html.erb +72 -0
  49. data/app/views/account/scaffolding/completely_concrete/tangible_things/_menu_item.html.erb +10 -0
  50. data/app/views/account/scaffolding/completely_concrete/tangible_things/_tangible_thing.json.jbuilder +23 -0
  51. data/app/views/account/scaffolding/completely_concrete/tangible_things/edit.html.erb +12 -0
  52. data/app/views/account/scaffolding/completely_concrete/tangible_things/index.html.erb +6 -0
  53. data/app/views/account/scaffolding/completely_concrete/tangible_things/index.json.jbuilder +1 -0
  54. data/app/views/account/scaffolding/completely_concrete/tangible_things/new.html.erb +12 -0
  55. data/app/views/account/scaffolding/completely_concrete/tangible_things/show.html.erb +45 -0
  56. data/app/views/account/scaffolding/completely_concrete/tangible_things/show.json.jbuilder +1 -0
  57. data/config/locales/en/scaffolding/absolutely_abstract/creative_concepts/collaborators.en.yml +98 -0
  58. data/config/locales/en/scaffolding/absolutely_abstract/creative_concepts.en.yml +111 -0
  59. data/config/locales/en/scaffolding/completely_concrete/tangible_things.en.yml +229 -0
  60. data/config/routes.rb +28 -0
  61. data/db/migrate/20190124040656_add_csv_import_to_scaffolding_things.rb +5 -0
  62. data/db/migrate/20191021215724_add_example_fields_to_scaffolding_things.rb +14 -0
  63. data/db/migrate/20191021233425_add_ckeditor_value_to_scaffolding_things.rb +5 -0
  64. data/db/migrate/20191204020251_create_scaffolding_absolutely_abstract_creative_concepts.rb +11 -0
  65. data/db/migrate/20191204020913_create_scaffolding_completely_concrete_tangible_things.rb +21 -0
  66. data/db/migrate/20191225224034_add_sort_order_to_scaffolding_completely_concrete_tangible_things.rb +5 -0
  67. data/db/migrate/20200101203645_drop_scaffolding_things.rb +9 -0
  68. data/db/migrate/20210101210524_create_scaffolding_absolutely_abstract_creative_concepts_collaborators.rb +10 -0
  69. data/db/migrate/20210101231429_add_roles_to_scaffolding_absolutely_abstract_creative_concepts_collaborators.rb +5 -0
  70. data/db/migrate/20210224234445_remove_select_value_from_scaffolding_completely_concrete_tangible_things.rb +5 -0
  71. data/db/migrate/20210513013030_add_color_value_to_scaffolding_completely_concrete_tangible_things.rb +5 -0
  72. data/db/migrate/20210602230736_add_option_fields_to_scaffolding_completely_concrete_tangible_things.rb +6 -0
  73. data/lib/bullet_train/super_scaffolding/engine.rb +15 -0
  74. data/lib/bullet_train/super_scaffolding/scaffolders/crud_field_scaffolder.rb +1 -1
  75. data/lib/bullet_train/super_scaffolding/scaffolders/crud_scaffolder.rb +1 -3
  76. data/lib/bullet_train/super_scaffolding/version.rb +1 -1
  77. data/lib/bullet_train/super_scaffolding.rb +1 -1
  78. data/lib/scaffolding/transformer.rb +13 -12
  79. metadata +72 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce5d6f3d2cb0ff2a0ed85aa5928e2a9e390b17709b41889c0fb6c25b9d7c4293
4
- data.tar.gz: af398b0b3cbc631f42e38d8643899678399bf1d7e819a1261f0142980029ec97
3
+ metadata.gz: befdf948a83be89983605eebe89d8d50cb5195de572f972f53a4a678af07fce8
4
+ data.tar.gz: 6391715f9efeb97738a9912987a0d4984676721c4b6db3a9708e556cae6031b8
5
5
  SHA512:
6
- metadata.gz: 6a1450d9449295670cd943ad637da3405b6b509c09905520c93bfdbab32eb471d93eedd3df5915db3cf325d77a5bd2d0ea8b4add6cf29b9811aba12b4242d74b
7
- data.tar.gz: f5c3879c59b9ed29c0982856e206e569756f6861f5f80784ef6ae04cdc5cd315771adfebdb18bcf3b7ae0a7aa32482ddf7c9f025f90befc7f7632b7c38f18cda
6
+ metadata.gz: 803dd84fea9c1bae1ddc957059394482bdf7b2789048609625aa89056122e6ebe982f622785eaf0ca448fd46f6328bd3e0053ab6d8d7d03511e521886b128844
7
+ data.tar.gz: fea78d2105111e9ee26e8657fab3ed881fc22fbf635c01a03db9e4af210ef7f6f8d8d1d319f6e569b1197c297b83d744ba0d134137942336fd18ec3cd1866bf4
@@ -0,0 +1,81 @@
1
+ class Account::Scaffolding::AbsolutelyAbstract::CreativeConcepts::CollaboratorsController < Account::ApplicationController
2
+ account_load_and_authorize_resource :collaborator, through: :creative_concept, through_association: :collaborators
3
+
4
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:creative_concept_id/collaborators
5
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:creative_concept_id/collaborators.json
6
+ def index
7
+ redirect_to [:account, @creative_concept]
8
+ end
9
+
10
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id
11
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id.json
12
+ def show
13
+ redirect_to [:account, @creative_concept]
14
+ end
15
+
16
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:creative_concept_id/collaborators/new
17
+ def new
18
+ end
19
+
20
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id/edit
21
+ def edit
22
+ end
23
+
24
+ # POST /account/scaffolding/absolutely_abstract/creative_concepts/:creative_concept_id/collaborators
25
+ # POST /account/scaffolding/absolutely_abstract/creative_concepts/:creative_concept_id/collaborators.json
26
+ def create
27
+ respond_to do |format|
28
+ if @collaborator.save
29
+ format.html { redirect_to [:account, @creative_concept, :collaborators], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts/collaborators.notifications.created") }
30
+ format.json { render :show, status: :created, location: [:account, @collaborator] }
31
+ else
32
+ format.html { render :new, status: :unprocessable_entity }
33
+ format.json { render json: @collaborator.errors, status: :unprocessable_entity }
34
+ end
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id
39
+ # PATCH/PUT /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id.json
40
+ def update
41
+ respond_to do |format|
42
+ if @collaborator.update(collaborator_params)
43
+ format.html { redirect_to [:account, @collaborator], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts/collaborators.notifications.updated") }
44
+ format.json { render :show, status: :ok, location: [:account, @collaborator] }
45
+ else
46
+ format.html { render :edit, status: :unprocessable_entity }
47
+ format.json { render json: @collaborator.errors, status: :unprocessable_entity }
48
+ end
49
+ end
50
+ end
51
+
52
+ # DELETE /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id
53
+ # DELETE /account/scaffolding/absolutely_abstract/creative_concepts/collaborators/:id.json
54
+ def destroy
55
+ @collaborator.destroy
56
+ respond_to do |format|
57
+ format.html { redirect_to [:account, @creative_concept, :collaborators], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts/collaborators.notifications.destroyed") }
58
+ format.json { head :no_content }
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ # Never trust parameters from the scary internet, only allow the white list through.
65
+ def collaborator_params
66
+ role_ids = params.dig(:scaffolding_absolutely_abstract_creative_concepts_collaborator, :role_ids)
67
+ role_ids = [role_ids] unless role_ids.is_a?(Array)
68
+ params[:scaffolding_absolutely_abstract_creative_concepts_collaborator][:role_ids] = role_ids
69
+ strong_params = params.require(:scaffolding_absolutely_abstract_creative_concepts_collaborator).permit(
70
+ :membership_id,
71
+ # 🚅 super scaffolding will insert new fields above this line.
72
+ role_ids: []
73
+ # 🚅 super scaffolding will insert new arrays above this line.
74
+ )
75
+
76
+ assign_checkboxes(strong_params, :roles)
77
+ # 🚅 super scaffolding will insert processing for new fields above this line.
78
+
79
+ strong_params
80
+ end
81
+ end
@@ -0,0 +1,82 @@
1
+ class Account::Scaffolding::AbsolutelyAbstract::CreativeConceptsController < Account::ApplicationController
2
+ include Scaffolding::AbsolutelyAbstract::CreativeConcepts::ControllerSupport
3
+
4
+ account_load_and_authorize_resource :creative_concept, through: :team, through_association: :scaffolding_absolutely_abstract_creative_concepts
5
+
6
+ # GET /account/teams/:team_id/scaffolding/absolutely_abstract/creative_concepts
7
+ # GET /account/teams/:team_id/scaffolding/absolutely_abstract/creative_concepts.json
8
+ def index
9
+ # since we're showing creative_concepts on the team show page by default,
10
+ # we might as well just go there.
11
+ # redirect_to [:account, @team]
12
+ end
13
+
14
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:id
15
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:id.json
16
+ def show
17
+ end
18
+
19
+ # GET /account/teams/:team_id/scaffolding/absolutely_abstract/creative_concepts/new
20
+ def new
21
+ end
22
+
23
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:id/edit
24
+ def edit
25
+ end
26
+
27
+ # POST /account/teams/:team_id/scaffolding/absolutely_abstract/creative_concepts
28
+ # POST /account/teams/:team_id/scaffolding/absolutely_abstract/creative_concepts.json
29
+ def create
30
+ respond_to do |format|
31
+ if @creative_concept.save
32
+
33
+ # any user adding a creative concept should be able to manage it.
34
+ ensure_current_user_can_manage_creative_concept @creative_concept
35
+
36
+ format.html { redirect_to [:account, @creative_concept], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts.notifications.created") }
37
+ format.json { render :show, status: :created, location: [:account, @team, @creative_concept] }
38
+ else
39
+ format.html { render :new, status: :unprocessable_entity }
40
+ format.json { render json: @creative_concept.errors, status: :unprocessable_entity }
41
+ end
42
+ end
43
+ end
44
+
45
+ # PATCH/PUT /account/scaffolding/absolutely_abstract/creative_concepts/:id
46
+ # PATCH/PUT /account/scaffolding/absolutely_abstract/creative_concepts/:id.json
47
+ def update
48
+ respond_to do |format|
49
+ if @creative_concept.update(creative_concept_params)
50
+ format.html { redirect_to [:account, @creative_concept], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts.notifications.updated") }
51
+ format.json { render :show, status: :ok, location: [:account, @creative_concept] }
52
+ else
53
+ format.html { render :edit, status: :unprocessable_entity }
54
+ format.json { render json: @creative_concept.errors, status: :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # DELETE /account/scaffolding/absolutely_abstract/creative_concepts/:id
60
+ # DELETE /account/scaffolding/absolutely_abstract/creative_concepts/:id.json
61
+ def destroy
62
+ @creative_concept.destroy
63
+ respond_to do |format|
64
+ format.html { redirect_to [:account, @team, :scaffolding, :absolutely_abstract, :creative_concepts], notice: I18n.t("scaffolding/absolutely_abstract/creative_concepts.notifications.destroyed") }
65
+ format.json { head :no_content }
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ # Never trust parameters from the scary internet, only allow the white list through.
72
+ def creative_concept_params
73
+ params.require(:scaffolding_absolutely_abstract_creative_concept).permit(
74
+ :name,
75
+ :description
76
+ # 🚅 super scaffolding will insert new fields above this line.
77
+ # 🚅 super scaffolding will insert new arrays above this line.
78
+ )
79
+
80
+ # 🚅 super scaffolding will insert processing for new fields above this line.
81
+ end
82
+ end
@@ -0,0 +1,107 @@
1
+ class Account::Scaffolding::CompletelyConcrete::TangibleThingsController < Account::ApplicationController
2
+ account_load_and_authorize_resource :tangible_thing, through: :absolutely_abstract_creative_concept, through_association: :completely_concrete_tangible_things
3
+
4
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things
5
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things.json
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]
9
+ end
10
+
11
+ # GET /account/scaffolding/completely_concrete/tangible_things/:id
12
+ # GET /account/scaffolding/completely_concrete/tangible_things/:id.json
13
+ def show
14
+ end
15
+
16
+ # GET /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things/new
17
+ def new
18
+ end
19
+
20
+ # GET /account/scaffolding/completely_concrete/tangible_things/:id/edit
21
+ def edit
22
+ end
23
+
24
+ # POST /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things
25
+ # POST /account/scaffolding/absolutely_abstract/creative_concepts/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things.json
26
+ def create
27
+ respond_to do |format|
28
+ if @tangible_thing.save
29
+ format.html { redirect_to [:account, @absolutely_abstract_creative_concept, :completely_concrete_tangible_things], notice: I18n.t("scaffolding/completely_concrete/tangible_things.notifications.created") }
30
+ format.json { render :show, status: :created, location: [:account, @tangible_thing] }
31
+ else
32
+ format.html { render :new, status: :unprocessable_entity }
33
+ format.json { render json: @tangible_thing.errors, status: :unprocessable_entity }
34
+ end
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT /account/scaffolding/completely_concrete/tangible_things/:id
39
+ # PATCH/PUT /account/scaffolding/completely_concrete/tangible_things/:id.json
40
+ def update
41
+ respond_to do |format|
42
+ if @tangible_thing.update(tangible_thing_params)
43
+ format.html { redirect_to [:account, @tangible_thing], notice: I18n.t("scaffolding/completely_concrete/tangible_things.notifications.updated") }
44
+ format.json { render :show, status: :ok, location: [:account, @tangible_thing] }
45
+ else
46
+ format.html { render :edit, status: :unprocessable_entity }
47
+ format.json { render json: @tangible_thing.errors, status: :unprocessable_entity }
48
+ end
49
+ end
50
+ end
51
+
52
+ # DELETE /account/scaffolding/completely_concrete/tangible_things/:id
53
+ # DELETE /account/scaffolding/completely_concrete/tangible_things/:id.json
54
+ def destroy
55
+ @tangible_thing.destroy
56
+ respond_to do |format|
57
+ format.html { redirect_to [:account, @absolutely_abstract_creative_concept, :completely_concrete_tangible_things], notice: I18n.t("scaffolding/completely_concrete/tangible_things.notifications.destroyed") }
58
+ format.json { head :no_content }
59
+ end
60
+ end
61
+
62
+ private
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
+ :ckeditor_value,
74
+ :cloudinary_image_value,
75
+ :date_field_value,
76
+ :date_and_time_field_value,
77
+ :date_and_time_field_value_time_zone,
78
+ :email_field_value,
79
+ :file_field_value,
80
+ :file_field_value_removal,
81
+ :option_value,
82
+ :password_field_value,
83
+ :phone_field_value,
84
+ :super_select_value,
85
+ :text_area_value,
86
+ # 🚅 stop any skipping we're doing now.
87
+ # 🚅 super scaffolding will insert new fields above this line.
88
+ # 🚅 skip this section when scaffolding.
89
+ multiple_button_values: [],
90
+ multiple_option_values: [],
91
+ multiple_super_select_values: []
92
+ # 🚅 stop any skipping we're doing now.
93
+ # 🚅 super scaffolding will insert new arrays above this line.
94
+ )
95
+
96
+ # 🚅 skip this section when scaffolding.
97
+ assign_boolean(strong_params, :boolean_button_value)
98
+ assign_date_and_time(strong_params, :date_and_time_field_value)
99
+ assign_checkboxes(strong_params, :multiple_button_values)
100
+ assign_checkboxes(strong_params, :multiple_option_values)
101
+ assign_select_options(strong_params, :multiple_super_select_values)
102
+ # 🚅 stop any skipping we're doing now.
103
+ # 🚅 super scaffolding will insert processing for new fields above this line.
104
+
105
+ strong_params
106
+ end
107
+ end
@@ -0,0 +1,103 @@
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
@@ -0,0 +1,2 @@
1
+ module Api::V1::Scaffolding::AbsolutelyAbstract
2
+ end
@@ -0,0 +1,136 @@
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 :password_field_value, type: String, allow_blank: true, desc: Api.heading(:password_field_value)
20
+ optional :phone_field_value, type: String, allow_blank: true, desc: Api.heading(:phone_field_value)
21
+ optional :option_value, type: String, allow_blank: true, desc: Api.heading(:option_value)
22
+ optional :super_select_value, type: String, allow_blank: true, desc: Api.heading(:super_select_value)
23
+ optional :text_area_value, type: String, allow_blank: true, desc: Api.heading(:text_area_value)
24
+ optional :action_text_value, type: String, allow_blank: true, desc: Api.heading(:action_text_value)
25
+ optional :ckeditor_value, type: String, allow_blank: true, desc: Api.heading(:ckeditor_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
@@ -0,0 +1,2 @@
1
+ module Api::V1::Scaffolding::CompletelyConcrete
2
+ end
@@ -0,0 +1,2 @@
1
+ module Api::V1::Scaffolding
2
+ end
@@ -0,0 +1,2 @@
1
+ module Api::V1
2
+ end
@@ -0,0 +1,2 @@
1
+ module Api
2
+ end
@@ -0,0 +1,11 @@
1
+ module Scaffolding::AbsolutelyAbstract::CreativeConcepts::ControllerSupport
2
+ extend ActiveSupport::Concern
3
+
4
+ def ensure_current_user_can_manage_creative_concept(creative_concept)
5
+ unless can? :manage, creative_concept
6
+ collaborator = creative_concept.collaborators.find_or_create_by(membership: current_membership)
7
+ collaborator.roles << :admin
8
+ collaborator.save
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,42 @@
1
+ class Scaffolding::AbsolutelyAbstract::CreativeConcept < ApplicationRecord
2
+ # 🚅 add concerns above.
3
+
4
+ belongs_to :team
5
+ # 🚅 add belongs_to associations above.
6
+
7
+ has_many :completely_concrete_tangible_things, class_name: "Scaffolding::CompletelyConcrete::TangibleThing", foreign_key: :absolutely_abstract_creative_concept_id, dependent: :destroy
8
+ has_many :collaborators, class_name: "Scaffolding::AbsolutelyAbstract::CreativeConcepts::Collaborator", dependent: :destroy, foreign_key: :creative_concept_id
9
+ has_many :memberships, through: :collaborators
10
+ # 🚅 add has_many associations above.
11
+
12
+ # 🚅 add oauth providers above.
13
+
14
+ # 🚅 add has_one associations above.
15
+
16
+ # 🚅 add scopes above.
17
+
18
+ validates :name, presence: true
19
+ # 🚅 add validations above.
20
+
21
+ # 🚅 add callbacks above.
22
+
23
+ # 🚅 add delegations above.
24
+
25
+ def admins
26
+ collaborators.admins.map(&:membership)
27
+ end
28
+
29
+ def editors
30
+ collaborators.editors.map(&:membership)
31
+ end
32
+
33
+ def viewers
34
+ collaborators.viewers.map(&:membership)
35
+ end
36
+
37
+ def all_collaborators
38
+ team.admins.or(Membership.where(id: memberships.pluck(:id)))
39
+ end
40
+
41
+ # 🚅 add methods above.
42
+ end
@@ -0,0 +1,39 @@
1
+ class Scaffolding::AbsolutelyAbstract::CreativeConcepts::Collaborator < ApplicationRecord
2
+ include Roles::Support
3
+ # 🚅 add concerns above.
4
+
5
+ belongs_to :creative_concept
6
+ belongs_to :membership
7
+ # 🚅 add belongs_to associations above.
8
+
9
+ # 🚅 add has_many associations above.
10
+
11
+ has_one :team, through: :creative_concept
12
+ has_one :user, through: :membership
13
+ # 🚅 add has_one associations above.
14
+
15
+ # 🚅 add scopes above.
16
+
17
+ validates :membership_id, presence: true
18
+ validate :validate_membership
19
+ # 🚅 add validations above.
20
+
21
+ # 🚅 add callbacks above.
22
+
23
+ # 🚅 add delegations above.
24
+
25
+ def valid_memberships
26
+ team.memberships.current_and_invited
27
+ end
28
+
29
+ def validate_membership
30
+ if membership_id.present?
31
+ # don't allow users to assign the ids of other teams' or users' resources to this attribute.
32
+ unless valid_memberships.ids.include?(membership_id)
33
+ errors.add(:membership_id, :invalid)
34
+ end
35
+ end
36
+ end
37
+
38
+ # 🚅 add methods above.
39
+ end
@@ -0,0 +1,5 @@
1
+ module Scaffolding::AbsolutelyAbstract::CreativeConcepts
2
+ def self.table_name_prefix
3
+ "scaffolding_absolutely_abstract_creative_concepts_"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Scaffolding::AbsolutelyAbstract
2
+ def self.table_name_prefix
3
+ "scaffolding_absolutely_abstract_"
4
+ end
5
+ end