binda 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +63 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/binda_manifest.js +2 -0
  6. data/app/assets/javascripts/binda/application.js +18 -0
  7. data/app/assets/javascripts/binda/components/form_item.js +54 -0
  8. data/app/assets/javascripts/binda/components/form_item_asset.js +24 -0
  9. data/app/assets/javascripts/binda/components/form_item_repeater.js +66 -0
  10. data/app/assets/javascripts/binda/components/sortable.js +44 -0
  11. data/app/assets/javascripts/binda/dist/binda.bundle.js +336 -0
  12. data/app/assets/javascripts/binda/index.js +16 -0
  13. data/app/assets/stylesheets/binda/application.css +6 -0
  14. data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -0
  15. data/app/assets/stylesheets/binda/components/button.scss +7 -0
  16. data/app/assets/stylesheets/binda/components/form_body.scss +2 -0
  17. data/app/assets/stylesheets/binda/components/form_item.scss +169 -0
  18. data/app/assets/stylesheets/binda/components/form_item_asset.scss +20 -0
  19. data/app/assets/stylesheets/binda/components/form_section.scss +40 -0
  20. data/app/assets/stylesheets/binda/components/login.scss +6 -0
  21. data/app/assets/stylesheets/binda/components/main_container.scss +0 -0
  22. data/app/assets/stylesheets/binda/components/main_content.scss +5 -0
  23. data/app/assets/stylesheets/binda/components/main_header.scss +25 -0
  24. data/app/assets/stylesheets/binda/components/main_table.scss +28 -0
  25. data/app/assets/stylesheets/binda/components/sidebar.scss +131 -0
  26. data/app/assets/stylesheets/binda/components/sortable.scss +98 -0
  27. data/app/assets/stylesheets/binda/index.scss +24 -0
  28. data/app/assets/stylesheets/binda/layout/components_index.scss +9 -0
  29. data/app/assets/stylesheets/binda/layout/dashboard.scss +7 -0
  30. data/app/assets/stylesheets/binda/layout/users_sign_in.scss +29 -0
  31. data/app/assets/stylesheets/binda/settings/common.scss +93 -0
  32. data/app/assets/stylesheets/binda/settings/fonts.scss +90 -0
  33. data/app/assets/stylesheets/binda/settings/variables.scss +83 -0
  34. data/app/assets/stylesheets/scaffolds.scss +89 -0
  35. data/app/controllers/binda/application_controller.rb +29 -0
  36. data/app/controllers/binda/assets_controller.rb +62 -0
  37. data/app/controllers/binda/bindings_controller.rb +62 -0
  38. data/app/controllers/binda/categories_controller.rb +60 -0
  39. data/app/controllers/binda/components_controller.rb +223 -0
  40. data/app/controllers/binda/dates_controller.rb +62 -0
  41. data/app/controllers/binda/field_groups_controller.rb +114 -0
  42. data/app/controllers/binda/field_settings_controller.rb +66 -0
  43. data/app/controllers/binda/galleries_controller.rb +62 -0
  44. data/app/controllers/binda/manage/users_controller.rb +97 -0
  45. data/app/controllers/binda/repeaters_controller.rb +67 -0
  46. data/app/controllers/binda/settings_controller.rb +75 -0
  47. data/app/controllers/binda/structures_controller.rb +89 -0
  48. data/app/controllers/binda/texts_controller.rb +62 -0
  49. data/app/controllers/binda/users/confirmations_controller.rb +33 -0
  50. data/app/controllers/binda/users/omniauth_callbacks_controller.rb +33 -0
  51. data/app/controllers/binda/users/passwords_controller.rb +37 -0
  52. data/app/controllers/binda/users/registrations_controller.rb +89 -0
  53. data/app/controllers/binda/users/sessions_controller.rb +30 -0
  54. data/app/controllers/binda/users/unlocks_controller.rb +33 -0
  55. data/app/helpers/binda/application_helper.rb +25 -0
  56. data/app/helpers/binda/assets_helper.rb +4 -0
  57. data/app/helpers/binda/bindings_helper.rb +4 -0
  58. data/app/helpers/binda/categories_helper.rb +10 -0
  59. data/app/helpers/binda/components_helper.rb +10 -0
  60. data/app/helpers/binda/dates_helper.rb +4 -0
  61. data/app/helpers/binda/field_groups_helper.rb +10 -0
  62. data/app/helpers/binda/field_settings_helper.rb +14 -0
  63. data/app/helpers/binda/galleries_helper.rb +4 -0
  64. data/app/helpers/binda/repeaters_helper.rb +4 -0
  65. data/app/helpers/binda/settings_helper.rb +13 -0
  66. data/app/helpers/binda/structures_helper.rb +4 -0
  67. data/app/helpers/binda/texts_helper.rb +4 -0
  68. data/app/jobs/binda/application_job.rb +4 -0
  69. data/app/mailers/binda/application_mailer.rb +6 -0
  70. data/app/models/binda/application_record.rb +5 -0
  71. data/app/models/binda/asset.rb +21 -0
  72. data/app/models/binda/binding.rb +24 -0
  73. data/app/models/binda/category.rb +31 -0
  74. data/app/models/binda/component.rb +186 -0
  75. data/app/models/binda/date.rb +9 -0
  76. data/app/models/binda/field_group.rb +40 -0
  77. data/app/models/binda/field_setting.rb +95 -0
  78. data/app/models/binda/gallery.rb +18 -0
  79. data/app/models/binda/repeater.rb +108 -0
  80. data/app/models/binda/setting.rb +42 -0
  81. data/app/models/binda/structure.rb +31 -0
  82. data/app/models/binda/text.rb +9 -0
  83. data/app/models/binda/user.rb +8 -0
  84. data/app/uploaders/binda/asset/image_uploader.rb +76 -0
  85. data/app/views/binda/assets/_form.html.erb +22 -0
  86. data/app/views/binda/assets/edit.html.erb +6 -0
  87. data/app/views/binda/assets/index.html.erb +29 -0
  88. data/app/views/binda/assets/new.html.erb +5 -0
  89. data/app/views/binda/assets/show.html.erb +19 -0
  90. data/app/views/binda/bindings/_form.html.erb +32 -0
  91. data/app/views/binda/bindings/edit.html.erb +6 -0
  92. data/app/views/binda/bindings/index.html.erb +31 -0
  93. data/app/views/binda/bindings/new.html.erb +5 -0
  94. data/app/views/binda/bindings/show.html.erb +19 -0
  95. data/app/views/binda/categories/_form.html.erb +58 -0
  96. data/app/views/binda/categories/edit.html.erb +8 -0
  97. data/app/views/binda/categories/index.html.erb +34 -0
  98. data/app/views/binda/categories/new.html.erb +8 -0
  99. data/app/views/binda/components/_form_body.html.erb +86 -0
  100. data/app/views/binda/components/_form_item_asset.html.erb +20 -0
  101. data/app/views/binda/components/_form_item_date.html.erb +16 -0
  102. data/app/views/binda/components/_form_item_gallery.html.erb +0 -0
  103. data/app/views/binda/components/_form_item_new_repeater.html.erb +33 -0
  104. data/app/views/binda/components/_form_item_repeater.html.erb +81 -0
  105. data/app/views/binda/components/_form_item_text.html.erb +28 -0
  106. data/app/views/binda/components/_form_section.html.erb +37 -0
  107. data/app/views/binda/components/_form_section_repeater.html.erb +31 -0
  108. data/app/views/binda/components/_form_sidebar.html.erb +34 -0
  109. data/app/views/binda/components/edit.html.erb +8 -0
  110. data/app/views/binda/components/index.html.erb +43 -0
  111. data/app/views/binda/components/new.html.erb +8 -0
  112. data/app/views/binda/dates/_form.html.erb +22 -0
  113. data/app/views/binda/dates/edit.html.erb +6 -0
  114. data/app/views/binda/dates/index.html.erb +27 -0
  115. data/app/views/binda/dates/new.html.erb +5 -0
  116. data/app/views/binda/dates/show.html.erb +9 -0
  117. data/app/views/binda/field_groups/_form_body.html.erb +71 -0
  118. data/app/views/binda/field_groups/_form_item.html.erb +62 -0
  119. data/app/views/binda/field_groups/_form_section.html.erb +37 -0
  120. data/app/views/binda/field_groups/_form_section_repeater.html.erb +25 -0
  121. data/app/views/binda/field_groups/edit.html.erb +8 -0
  122. data/app/views/binda/field_groups/index.html.erb +34 -0
  123. data/app/views/binda/field_groups/new.html.erb +8 -0
  124. data/app/views/binda/field_settings/_form_body.html.erb +60 -0
  125. data/app/views/binda/field_settings/edit.html.erb +8 -0
  126. data/app/views/binda/field_settings/index.html.erb +31 -0
  127. data/app/views/binda/field_settings/new.html.erb +8 -0
  128. data/app/views/binda/galleries/_form.html.erb +27 -0
  129. data/app/views/binda/galleries/edit.html.erb +6 -0
  130. data/app/views/binda/galleries/index.html.erb +29 -0
  131. data/app/views/binda/galleries/new.html.erb +5 -0
  132. data/app/views/binda/galleries/show.html.erb +14 -0
  133. data/app/views/binda/manage/users/_admin_manage_user.json.jbuilder +2 -0
  134. data/app/views/binda/manage/users/_form_body.html.erb +58 -0
  135. data/app/views/binda/manage/users/edit.html.erb +8 -0
  136. data/app/views/binda/manage/users/index.html.erb +38 -0
  137. data/app/views/binda/manage/users/index.json.jbuilder +1 -0
  138. data/app/views/binda/manage/users/new.html.erb +8 -0
  139. data/app/views/binda/manage/users/show.json.jbuilder +1 -0
  140. data/app/views/binda/repeaters/_form.html.erb +27 -0
  141. data/app/views/binda/repeaters/edit.html.erb +6 -0
  142. data/app/views/binda/repeaters/index.html.erb +29 -0
  143. data/app/views/binda/repeaters/new.html.erb +5 -0
  144. data/app/views/binda/repeaters/show.html.erb +14 -0
  145. data/app/views/binda/settings/_dashboard_form.html.erb +51 -0
  146. data/app/views/binda/settings/_form.html.erb +52 -0
  147. data/app/views/binda/settings/dashboard.html.erb +9 -0
  148. data/app/views/binda/settings/edit.html.erb +8 -0
  149. data/app/views/binda/settings/index.html.erb +34 -0
  150. data/app/views/binda/settings/new.html.erb +8 -0
  151. data/app/views/binda/structures/_form_body.html.erb +56 -0
  152. data/app/views/binda/structures/_form_section.html.erb +64 -0
  153. data/app/views/binda/structures/add_child.html.erb +0 -0
  154. data/app/views/binda/structures/edit.html.erb +8 -0
  155. data/app/views/binda/structures/index.html.erb +34 -0
  156. data/app/views/binda/structures/new.html.erb +8 -0
  157. data/app/views/binda/texts/_form.html.erb +22 -0
  158. data/app/views/binda/texts/edit.html.erb +6 -0
  159. data/app/views/binda/texts/index.html.erb +27 -0
  160. data/app/views/binda/texts/new.html.erb +5 -0
  161. data/app/views/binda/texts/show.html.erb +9 -0
  162. data/app/views/layouts/binda/_flash.html.erb +26 -0
  163. data/app/views/layouts/binda/_header.html.erb +9 -0
  164. data/app/views/layouts/binda/_sidebar.html.erb +50 -0
  165. data/app/views/layouts/binda/application.html.erb +29 -0
  166. data/app/views/users/confirmations/new.html.erb +16 -0
  167. data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
  168. data/app/views/users/mailer/password_change.html.erb +3 -0
  169. data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
  170. data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
  171. data/app/views/users/passwords/edit.html.erb +31 -0
  172. data/app/views/users/passwords/new.html.erb +28 -0
  173. data/app/views/users/registrations/edit.html.erb +27 -0
  174. data/app/views/users/registrations/new.html.erb +17 -0
  175. data/app/views/users/sessions/new.html.erb +27 -0
  176. data/app/views/users/shared/_links.html.erb +25 -0
  177. data/app/views/users/unlocks/new.html.erb +16 -0
  178. data/config/initializers/assets.rb +3 -0
  179. data/config/initializers/devise.rb +278 -0
  180. data/config/initializers/devise_patch.rb +50 -0
  181. data/config/initializers/friendly_id.rb +88 -0
  182. data/config/initializers/simple_form.rb +165 -0
  183. data/config/initializers/simple_form_bootstrap.rb +149 -0
  184. data/config/locales/devise.en.yml +62 -0
  185. data/config/locales/en.yml +37 -0
  186. data/config/locales/simple_form.en.yml +31 -0
  187. data/config/routes.rb +67 -0
  188. data/config/tinymce.yml +15 -0
  189. data/db/migrate/1_create_binda_tables.rb +172 -0
  190. data/lib/binda.rb +5 -0
  191. data/lib/binda/engine.rb +30 -0
  192. data/lib/binda/version.rb +3 -0
  193. data/lib/generators/binda/install/USAGE +9 -0
  194. data/lib/generators/binda/install/install_generator.rb +107 -0
  195. data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +32 -0
  196. data/lib/generators/binda/install/templates/config/initializers/devise.rb +280 -0
  197. data/lib/generators/binda/setup/USAGE +8 -0
  198. data/lib/generators/binda/setup/setup_generator.rb +43 -0
  199. data/lib/tasks/binda.rake +25 -0
  200. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  201. metadata +637 -0
@@ -0,0 +1,29 @@
1
+ module Binda
2
+ class ApplicationController < ActionController::Base
3
+
4
+ protect_from_forgery with: :exception
5
+
6
+ before_action :authenticate_user!
7
+
8
+ # _ indicates that we are not using the argument in the method
9
+ def after_sign_in_path_for(_)
10
+ binda.dashboard_path
11
+ end
12
+
13
+ # _ indicates that we are not using the argument in the method
14
+ def after_sign_out_path_for(_)
15
+ root_path
16
+ end
17
+
18
+ def get_components( slug, ask_for_published = true, custom_order = '' )
19
+ if ask_for_published && custom_order.blank?
20
+ Binda::Structure.friendly.find( slug ).components.published.order('position')
21
+ elsif custom_order.blank?
22
+ Binda::Structure.friendly.find( slug ).components.order('position')
23
+ else
24
+ Binda::Structure.friendly.find( slug ).components.order( custom_order )
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class AssetsController < ApplicationController
5
+ before_action :set_asset, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /assets
8
+ def index
9
+ @assets = Asset.all
10
+ end
11
+
12
+ # GET /assets/1
13
+ def show
14
+ end
15
+
16
+ # GET /assets/new
17
+ def new
18
+ @asset = Asset.new
19
+ end
20
+
21
+ # GET /assets/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /assets
26
+ def create
27
+ @asset = Asset.new(asset_params)
28
+
29
+ if @asset.save
30
+ redirect_to asset_path( @asset.id ), notice: 'Asset was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /assets/1
37
+ def update
38
+ if @asset.update(asset_params)
39
+ redirect_to asset_path( @asset.id ), notice: 'Asset was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /assets/1
46
+ def destroy
47
+ @asset.destroy
48
+ redirect_to assets_url, notice: 'Asset was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_asset
54
+ @asset = Asset.find(params[:id])
55
+ end
56
+
57
+ # Only allow a trusted parameter "white list" through.
58
+ def asset_params
59
+ params.require(:asset).permit( :image, :name )
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class BindingsController < ApplicationController
5
+ before_action :set_binding, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /bindings
8
+ def index
9
+ @bindings = Binding.all
10
+ end
11
+
12
+ # GET /bindings/1
13
+ def show
14
+ end
15
+
16
+ # GET /bindings/new
17
+ def new
18
+ @binding = Binding.new
19
+ end
20
+
21
+ # GET /bindings/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /bindings
26
+ def create
27
+ @binding = Binding.new(binding_params)
28
+
29
+ if @binding.save
30
+ redirect_to binding_path( @binding.id ), notice: 'Binding was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /bindings/1
37
+ def update
38
+ if @binding.update(binding_params)
39
+ redirect_to binding_path( @binding.id ), notice: 'Binding was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /bindings/1
46
+ def destroy
47
+ @binding.destroy
48
+ redirect_to bindings_url, notice: 'Binding was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_binding
54
+ @binding = Binding.find(params[:id])
55
+ end
56
+
57
+ # Only allow a trusted parameter "white list" through.
58
+ def binding_params
59
+ params.require(:binding).permit(:title, :description, :position)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class CategoriesController < ApplicationController
5
+ before_action :set_structure
6
+ before_action :set_category, only: [:show, :edit, :update, :destroy]
7
+
8
+ def index
9
+ @categories = @structure.categories.order(:name).all
10
+ end
11
+
12
+ def show
13
+ redirect_to action: :edit
14
+ end
15
+
16
+ def new
17
+ @category = @structure.categories.build()
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def create
24
+ @category = @structure.categories.build(category_params)
25
+ if @category.save
26
+ redirect_to structure_category_path( @structure.slug, @category.slug ), notice: 'Category was successfully created.'
27
+ else
28
+ redirect_to structure_category_path( @structure.slug, @category.slug )
29
+ end
30
+ end
31
+
32
+ def update
33
+ if @category.update(category_params)
34
+ redirect_to structure_category_path( @structure.slug, @category.slug ), notice: 'Category was successfully updated.'
35
+ else
36
+ redirect_to structure_category_path( @structure.slug, @category.slug )
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @category.destroy
42
+ redirect_to structure_categories_url( @structure.slug ), notice: 'Category was successfully destroyed.'
43
+ end
44
+
45
+ private
46
+ # Use callbacks to share common setup or constraints between actions.
47
+ def set_category
48
+ @category = Category.friendly.find(params[:id])
49
+ end
50
+
51
+ # Only allow a trusted parameter "white list" through.
52
+ def category_params
53
+ params.require(:category).permit(:name, :slug, :structure_id, :description, :position)
54
+ end
55
+
56
+ def set_structure
57
+ @structure = Structure.friendly.find(params[:structure_id])
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,223 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class ComponentsController < ApplicationController
5
+ before_action :set_structure
6
+ before_action :set_component, only: [:show, :edit, :update, :destroy, :new_repeater]
7
+ before_action :set_position, only: [:create]
8
+
9
+ def index
10
+ @components = @structure.components.order('position').all
11
+ end
12
+
13
+ def show
14
+ redirect_to action: :edit
15
+ end
16
+
17
+ def new
18
+ @component = @structure.components.build()
19
+ end
20
+
21
+ def edit
22
+ end
23
+
24
+ def create
25
+ @component = @structure.components.build(component_params)
26
+ @component.position = @position
27
+ if @component.save
28
+ redirect_to structure_component_path( @structure.slug, @component.slug ), notice: 'Component was successfully created.'
29
+ else
30
+ redirect_to new_structure_component_path( @structure.slug ), flash: { alert: @component.errors }
31
+ end
32
+ end
33
+
34
+ def update
35
+ if @component.update(component_params)
36
+ redirect_to structure_component_path( @structure.slug, @component.slug ), notice: 'Component was successfully updated.'
37
+ else
38
+ redirect_to edit_structure_component_path( @structure.slug, @component.slug ), flash: { alert: @component.errors }
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @component.destroy
44
+ redirect_to structure_components_url( @structure.slug ), notice: 'Component was successfully destroyed.'
45
+ end
46
+
47
+ def new_repeater
48
+ # @repeater_setting = Binda::FieldSetting.find( '3' )
49
+ @repeater_setting = Binda::FieldSetting.find( params[:repeater_setting_id] )
50
+ render 'binda/components/_form_item_new_repeater', layout: false
51
+ end
52
+
53
+ def sort_repeaters
54
+ params[:repeater].each_with_index do |id, i|
55
+ Binda::Repeater.find( id ).update({ position: i + 1 })
56
+ end
57
+ head :ok
58
+ end
59
+
60
+ def sort
61
+ params[:component].each_with_index do |id, i|
62
+ Binda::Component.find( id ).update({ position: i + 1 })
63
+ end
64
+ head :ok
65
+ end
66
+
67
+ private
68
+ # Use callbacks to share common setup or constraints between actions.
69
+ def set_structure
70
+ @structure = Structure.friendly.find( params[:structure_id] )
71
+ end
72
+
73
+ def set_component
74
+ if params[:component_id].nil?
75
+ return @component = Component.friendly.find(params[:id])
76
+ else
77
+ return @component = Component.friendly.find(params[:component_id])
78
+ end
79
+ end
80
+
81
+ # Only allow a trusted parameter "white list" through.
82
+ def component_params
83
+ params.require(:component).permit(
84
+ :name,
85
+ :slug,
86
+ :position,
87
+ :publish_state,
88
+ :structure_id,
89
+ :category_ids,
90
+ structure_attributes: [
91
+ :id
92
+ ],
93
+ categories_attributes: [
94
+ :id,
95
+ :category_id
96
+ ],
97
+ texts_attributes: [
98
+ :id,
99
+ :field_setting_id,
100
+ :fieldable_type,
101
+ :fieldable_id,
102
+ :content
103
+ ],
104
+ assets_attributes: [
105
+ :id,
106
+ :field_setting_id,
107
+ :fieldable_type,
108
+ :fieldable_id,
109
+ :image
110
+ ],
111
+ dates_attributes: [
112
+ :id,
113
+ :field_setting_id,
114
+ :fieldable_type,
115
+ :fieldable_id,
116
+ :date
117
+ ],
118
+ galleries_attributes: [
119
+ :id,
120
+ :field_setting_id,
121
+ :fieldable_type,
122
+ :fieldable_id
123
+ ],
124
+ repeaters_attributes: [
125
+ :id,
126
+ :field_setting_id,
127
+ :field_group_id,
128
+ :fieldable_type,
129
+ :fieldable_id,
130
+ texts_attributes: [
131
+ :id,
132
+ :repeater_id,
133
+ :field_setting_id,
134
+ :fieldable_type,
135
+ :fieldable_id,
136
+ :content
137
+ ],
138
+ assets_attributes: [
139
+ :id,
140
+ :repeater_id,
141
+ :field_setting_id,
142
+ :fieldable_type,
143
+ :fieldable_id,
144
+ :image
145
+ ],
146
+ dates_attributes: [
147
+ :id,
148
+ :repeater_id,
149
+ :field_setting_id,
150
+ :fieldable_type,
151
+ :fieldable_id,
152
+ :date
153
+ ],
154
+ galleries_attributes: [
155
+ :id,
156
+ :repeater_id,
157
+ :field_setting_id,
158
+ :fieldable_type,
159
+ :fieldable_id
160
+ ],
161
+ repeaters_attributes: [
162
+ :id,
163
+ :repeater_id,
164
+ :field_setting_id,
165
+ :field_group_id,
166
+ :fieldable_type,
167
+ :fieldable_id
168
+ ]
169
+ ])
170
+ end
171
+
172
+ def repeater_params
173
+ params.require(:repeater).permit(
174
+ new_repeaters_attributes: [
175
+ :id,
176
+ :field_setting_id,
177
+ :field_group_id,
178
+ :fieldable_type,
179
+ :fieldable_id,
180
+ texts_attributes: [
181
+ :id,
182
+ :field_setting_id,
183
+ :fieldable_type,
184
+ :fieldable_id,
185
+ :content
186
+ ],
187
+ assets_attributes: [
188
+ :id,
189
+ :field_setting_id,
190
+ :fieldable_type,
191
+ :fieldable_id,
192
+ :image
193
+ ],
194
+ dates_attributes: [
195
+ :id,
196
+ :field_setting_id,
197
+ :fieldable_type,
198
+ :fieldable_id,
199
+ :date
200
+ ],
201
+ galleries_attributes: [
202
+ :id,
203
+ :field_setting_id,
204
+ :fieldable_type,
205
+ :fieldable_id
206
+ ],
207
+ repeaters_attributes: [
208
+ :id,
209
+ :field_setting_id,
210
+ :field_group_id,
211
+ :fieldable_type,
212
+ :fieldable_id
213
+ ]
214
+ ])
215
+ end
216
+
217
+ def set_position
218
+ @position = @structure.components.order(:position).pluck(:position).last.to_i + 1 unless @position.to_i > 0
219
+ end
220
+
221
+ end
222
+ end
223
+
@@ -0,0 +1,62 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class DatesController < ApplicationController
5
+ before_action :set_date, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /dates
8
+ def index
9
+ @dates = Date.all
10
+ end
11
+
12
+ # GET /dates/1
13
+ def show
14
+ end
15
+
16
+ # GET /dates/new
17
+ def new
18
+ @date = Date.new
19
+ end
20
+
21
+ # GET /dates/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /dates
26
+ def create
27
+ @date = Date.new(date_params)
28
+
29
+ if @date.save
30
+ redirect_to @date, notice: 'Date was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /dates/1
37
+ def update
38
+ if @date.update(date_params)
39
+ redirect_to @date, notice: 'Date was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /dates/1
46
+ def destroy
47
+ @date.destroy
48
+ redirect_to dates_url, notice: 'Date was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_date
54
+ @date = Date.find(params[:id])
55
+ end
56
+
57
+ # Only allow a trusted parameter "white list" through.
58
+ def date_params
59
+ params.require(:date).permit(:date)
60
+ end
61
+ end
62
+ end