bullet_train-super_scaffolding 1.0.9 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) 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 +106 -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 +135 -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 +29 -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 +65 -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 +22 -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 +44 -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 +224 -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 +11 -0
  74. data/lib/bullet_train/super_scaffolding/version.rb +1 -1
  75. metadata +72 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2cb314ed84525cc6dafce8c9c1ddeec7b51486c8e759b1ab32b176791730e4f
4
- data.tar.gz: 3d72bc268faeb84f61bec331bc5fda61e2d298e539ed184ce273d614d18303eb
3
+ metadata.gz: 4383583527b6e82c8c4a2c3b3377b70febe3aac37d81fb87e0bb8c03a740b8f4
4
+ data.tar.gz: b805ee23858fdb68dcb5c42809a6bfa8a8b5476457a3a4c7186066cf6ba21ed2
5
5
  SHA512:
6
- metadata.gz: 12fc83283e2bd199994e47457e09ad18f097cc61c80d10ec67b55e72971e198f76616fad859539ad2be547683a77b3a7abcbd725bb69cdc005566c679cb80324
7
- data.tar.gz: 4e3ae7e9b86a6ae8341384081ca05b87aa71e0c0de4d4af9277c554a05d6ac5765064e840fa274ae428c9e016ada8d1e3e180f3f048f363c0d5eb2d06cbc17cb
6
+ metadata.gz: a566c140c290fe44daf385d5b34d288d15335d3bcbad7cacad976e42f688c7eab844bea717f75b70dd75e484c0fedd96e87d6c39de0bbe5bd87703339679d9ea
7
+ data.tar.gz: '000539d956b409f05f7cb365278d3ef3953e5d8466fe407de7a0503b476f99cac25d7eb785ac2b262cf65e9ac759f2c1c31354422d31a9b04eff42d301300c51'
@@ -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,106 @@
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
+ :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
+ )
94
+
95
+ # 🚅 skip this section when scaffolding.
96
+ assign_boolean(strong_params, :boolean_button_value)
97
+ assign_date_and_time(strong_params, :date_and_time_field_value)
98
+ assign_checkboxes(strong_params, :multiple_button_values)
99
+ assign_checkboxes(strong_params, :multiple_option_values)
100
+ assign_select_options(strong_params, :multiple_super_select_values)
101
+ # 🚅 stop any skipping we're doing now.
102
+ # 🚅 super scaffolding will insert processing for new fields above this line.
103
+
104
+ strong_params
105
+ end
106
+ 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,135 @@
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
+ # 🚅 stop any skipping we're doing now.
26
+ # 🚅 super scaffolding will insert new fields above this line.
27
+ # 🚅 skip this section when scaffolding.
28
+ optional :multiple_button_values, type: Array, default: [], desc: Api.heading(:multiple_button_values)
29
+ optional :multiple_option_values, type: Array, default: [], desc: Api.heading(:multiple_option_values)
30
+ optional :multiple_super_select_values, type: Array, default: [], desc: Api.heading(:multiple_super_select_values)
31
+ # 🚅 stop any skipping we're doing now.
32
+ # 🚅 super scaffolding will insert new arrays above this line.
33
+
34
+ # 🚅 super scaffolding will insert processing for new fields above this line.
35
+ end
36
+ end
37
+
38
+ resource "scaffolding/absolutely_abstract/creative_concepts", desc: Api.title(:collection_actions) do
39
+ after_validation do
40
+ load_and_authorize_api_resource Scaffolding::CompletelyConcrete::TangibleThing
41
+ end
42
+
43
+ #
44
+ # INDEX
45
+ #
46
+
47
+ desc Api.title(:index), &Api.index_desc
48
+ params do
49
+ use :absolutely_abstract_creative_concept_id
50
+ end
51
+ oauth2
52
+ paginate per_page: 100
53
+ get "/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things" do
54
+ @paginated_tangible_things = paginate @tangible_things
55
+ render @paginated_tangible_things, serializer: Api.serializer
56
+ end
57
+
58
+ #
59
+ # CREATE
60
+ #
61
+
62
+ desc Api.title(:create), &Api.create_desc
63
+ params do
64
+ use :absolutely_abstract_creative_concept_id
65
+ use :tangible_thing
66
+ end
67
+ route_setting :api_resource_options, permission: :create
68
+ oauth2 "write"
69
+ post "/:absolutely_abstract_creative_concept_id/completely_concrete/tangible_things" do
70
+ if @tangible_thing.save
71
+ render @tangible_thing, serializer: Api.serializer
72
+ else
73
+ record_not_saved @tangible_thing
74
+ end
75
+ end
76
+ end
77
+
78
+ resource "scaffolding/completely_concrete/tangible_things", desc: Api.title(:member_actions) do
79
+ after_validation do
80
+ load_and_authorize_api_resource Scaffolding::CompletelyConcrete::TangibleThing
81
+ end
82
+
83
+ #
84
+ # SHOW
85
+ #
86
+
87
+ desc Api.title(:show), &Api.show_desc
88
+ params do
89
+ use :id
90
+ end
91
+ oauth2
92
+ route_param :id do
93
+ get do
94
+ render @tangible_thing, serializer: Api.serializer
95
+ end
96
+ end
97
+
98
+ #
99
+ # UPDATE
100
+ #
101
+
102
+ desc Api.title(:update), &Api.update_desc
103
+ params do
104
+ use :id
105
+ use :tangible_thing
106
+ end
107
+ route_setting :api_resource_options, permission: :update
108
+ oauth2 "write"
109
+ route_param :id do
110
+ put do
111
+ if @tangible_thing.update(declared(params, include_missing: false))
112
+ render @tangible_thing, serializer: Api.serializer
113
+ else
114
+ record_not_saved @tangible_thing
115
+ end
116
+ end
117
+ end
118
+
119
+ #
120
+ # DESTROY
121
+ #
122
+
123
+ desc Api.title(:destroy), &Api.destroy_desc
124
+ params do
125
+ use :id
126
+ end
127
+ route_setting :api_resource_options, permission: :destroy
128
+ oauth2 "delete"
129
+ route_param :id do
130
+ delete do
131
+ render @tangible_thing.destroy, serializer: Api.serializer
132
+ end
133
+ end
134
+ end
135
+ 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