binda 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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,114 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class FieldGroupsController < ApplicationController
5
+ before_action :set_structure
6
+ before_action :set_field_group, only: [:show, :edit, :update, :destroy]
7
+
8
+ def index
9
+ @field_groups = @structure.field_groups.order('position').all
10
+ end
11
+
12
+ def show
13
+ redirect_to action: :edit
14
+ end
15
+
16
+ def new
17
+ @field_group = @structure.field_groups.build()
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def create
24
+ @field_group = @structure.field_groups.build(field_group_params)
25
+
26
+ if @field_group.save
27
+ reset_field_settings_cache
28
+ redirect_to structure_field_group_path( @structure.slug, @field_group.slug ), notice: 'Field group was successfully created.'
29
+ else
30
+ redirect_to new_structure_field_group_path( @structure.slug ), flash: { alert: @field_group.errors }
31
+ end
32
+ end
33
+
34
+ def update
35
+ # Create new fields if any
36
+ new_params[:new_field_settings].each do |field_setting|
37
+ unless field_setting[:name].blank?
38
+ new_field_setting = @field_group.field_settings.create( field_setting )
39
+ unless new_field_setting
40
+ return redirect_to edit_structure_field_group_path( @structure.slug, @field_group.slug ), flash: { error: new_field_setting.errors }
41
+ end
42
+ end
43
+ end
44
+
45
+ # Update the other ones
46
+ if @field_group.update(field_group_params)
47
+ reset_field_settings_cache
48
+ redirect_to structure_field_group_path( @structure.slug, @field_group.slug ), notice: 'Field group was successfully updated.'
49
+ else
50
+ redirect_to edit_structure_field_group_path( @structure.slug, @field_group.slug ), flash: { alert: @field_group.errors }
51
+ end
52
+ end
53
+
54
+ def destroy
55
+ @field_group.destroy
56
+ reset_field_settings_cache
57
+ redirect_to structure_path( @structure.slug ), notice: 'Field group was successfully destroyed.'
58
+ end
59
+
60
+ private
61
+ # Use callbacks to share common setup or constraints between actions.
62
+ def set_structure
63
+ @structure = Structure.friendly.find( params[:structure_id] )
64
+ end
65
+
66
+ def set_field_group
67
+ @field_group = FieldGroup.friendly.find(params[:id])
68
+ end
69
+
70
+ # Only allow a trusted parameter "white list" through.
71
+ def field_group_params
72
+ params.require(:field_group).permit(
73
+ :name,
74
+ :slug,
75
+ :description,
76
+ :position,
77
+ :layout,
78
+ :structure_id,
79
+ field_settings_attributes: [
80
+ :id,
81
+ :field_group_id,
82
+ :field_setting_id,
83
+ :name,
84
+ :slug,
85
+ :description,
86
+ :field_type,
87
+ :position,
88
+ :required,
89
+ :default_text,
90
+ :ancestry
91
+ ])
92
+ end
93
+
94
+ def new_params
95
+ params.require(:field_group).permit(
96
+ new_field_settings:[
97
+ :field_group_id,
98
+ :field_setting_id,
99
+ :name,
100
+ :slug,
101
+ :description,
102
+ :field_type,
103
+ :position,
104
+ :required,
105
+ :ancestry
106
+ ])
107
+ end
108
+
109
+ def reset_field_settings_cache
110
+ Binda::FieldSetting.reset_field_settings_array
111
+ end
112
+
113
+ end
114
+ end
@@ -0,0 +1,66 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class FieldSettingsController < ApplicationController
5
+ before_action :set_structure
6
+ before_action :set_field_group
7
+ before_action :set_field_setting, only: [:show, :edit, :update, :destroy]
8
+
9
+ def index
10
+ @field_settings = @field_group.field_settings.order('position').all
11
+ end
12
+
13
+ def show
14
+ redirect_to action: :edit
15
+ end
16
+
17
+ def new
18
+ @field_setting = @field_group.field_settings.build()
19
+ end
20
+
21
+ def edit
22
+ end
23
+
24
+ def create
25
+ @field_setting = @field_group.field_settings.build(field_setting_params)
26
+
27
+ if @field_setting.save
28
+ redirect_to structure_field_group_field_setting_path( @structure.slug, @field_group.slug, @field_setting.slug ), notice: 'Field setting was successfully created.'
29
+ else
30
+ redirect_to new_structure_field_group_field_setting_path( @structure.slug, @field_group.slug ), flash: { alert: @field_setting.errors }
31
+ end
32
+ end
33
+
34
+ def update
35
+ if @field_setting.update(field_setting_params)
36
+ redirect_to structure_field_group_field_setting_path( @structure.slug, @field_group.slug, @field_setting.slug ), notice: 'Field setting was successfully updated.'
37
+ else
38
+ redirect_to edit_structure_field_group_field_setting_path( @structure.slug, @field_group.slug, @field_setting.slug ), flash: { alert: @field_setting.errors }
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @field_setting.destroy
44
+ redirect_to structure_field_group_path( @structure.slug, @field_group.slug ), notice: 'Field setting and all dependent content were successfully destroyed.'
45
+ end
46
+
47
+ private
48
+ # Use callbacks to share common setup or constraints between actions.
49
+ def set_structure
50
+ @structure = Structure.friendly.find( params[:structure_id] )
51
+ end
52
+
53
+ def set_field_group
54
+ @field_group = FieldGroup.friendly.find( params[:field_group_id] )
55
+ end
56
+
57
+ def set_field_setting
58
+ @field_setting = FieldSetting.friendly.find( params[:id] )
59
+ end
60
+
61
+ # Only allow a trusted parameter "white list" through.
62
+ def field_setting_params
63
+ params.require(:field_setting).permit(:name, :slug, :description, :position, :required, :default_text, :field_group_id, :field_type )
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class GalleriesController < ApplicationController
5
+ before_action :set_gallery, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /galleries
8
+ def index
9
+ @galleries = Gallery.all
10
+ end
11
+
12
+ # GET /galleries/1
13
+ def show
14
+ end
15
+
16
+ # GET /galleries/new
17
+ def new
18
+ @gallery = Gallery.new
19
+ end
20
+
21
+ # GET /galleries/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /galleries
26
+ def create
27
+ @gallery = Gallery.new(gallery_params)
28
+
29
+ if @gallery.save
30
+ redirect_to gallery_path( @gallery.id ), notice: 'Gallery was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /galleries/1
37
+ def update
38
+ if @gallery.update(gallery_params)
39
+ redirect_to gallery_path( @gallery.id ), notice: 'Gallery was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /galleries/1
46
+ def destroy
47
+ @gallery.destroy
48
+ redirect_to galleries_url, notice: 'Gallery was successfully destroyed.'
49
+ end
50
+
51
+ private
52
+ # Use callbacks to share common setup or constraints between actions.
53
+ def set_gallery
54
+ @gallery = Gallery.find(params[:id])
55
+ end
56
+
57
+ # Only allow a trusted parameter "white list" through.
58
+ def gallery_params
59
+ params.require(:gallery).permit( :position )
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,97 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class Manage::UsersController < ApplicationController
5
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
6
+ before_action :check_if_is_superadmin, only: [:update, :destroy]
7
+
8
+ def index
9
+ @users = User.all
10
+ end
11
+
12
+ def show
13
+ redirect_to action: :edit
14
+ end
15
+
16
+ def new
17
+ @user = User.new
18
+ end
19
+
20
+ def edit
21
+ end
22
+
23
+ def create
24
+ @user = User.new( user_params )
25
+
26
+ respond_to do |format|
27
+ if @user.save
28
+ format.html { redirect_to manage_user_path( @user.id ), notice: 'User was successfully created.' }
29
+ format.xml { head :ok }
30
+ format.json { render :show, status: :created, location: @user }
31
+ else
32
+ format.html { redirect_to new_manage_user_path, flash: { alert: @user.errors } }
33
+ format.xml { head :bad_request }
34
+ format.json { render json: @user.errors, status: :unprocessable_entity }
35
+ end
36
+ end
37
+ end
38
+
39
+ def update
40
+ if @user.is_superadmin && !current_user.is_superadmin
41
+ redirect_to manage_users_url, notice: 'Sorry, you cannot edit a administrator.'
42
+ else
43
+ respond_to do |format|
44
+ if @user.update(user_params)
45
+ format.html { redirect_to manage_user_path( @user.id ), notice: 'User was successfully updated.' }
46
+ format.xml { head :ok }
47
+ format.json { render :show, status: :ok, location: @user }
48
+ else
49
+ format.html { redirect_to edit_manage_user_path( @user.id ), flash: { alert: @user.errors } }
50
+ format.xml { head :bad_request }
51
+ format.json { render json: @user.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def destroy
58
+ if current_user.email == @user.email
59
+ redirect_to manage_users_url, flash: { alert: 'Sorry, you cannot delete your own account.' }
60
+ elsif !current_user.is_superadmin
61
+ redirect_to manage_users_url, flash: { alert: 'Sorry, you cannot delete an administrator.' }
62
+ else
63
+ @user.destroy
64
+ respond_to do |format|
65
+ format.html { redirect_to manage_users_url, notice: 'User was successfully destroyed.' }
66
+ format.xml { head :ok }
67
+ format.json { head :no_content }
68
+ end
69
+ end
70
+ end
71
+
72
+ private
73
+ # Use callbacks to share common setup or constraints between actions.
74
+ def set_user
75
+ @user = User.find(params[:id])
76
+ end
77
+
78
+ # Never trust parameters from the scary internet, only allow the white list through.
79
+ def user_params
80
+ params.fetch(:user, {}).permit( :email, :password, :password_confirmation, :is_superadmin )
81
+ end
82
+
83
+ # https://github.com/plataformatec/devise/wiki/How-To%3a-Manage-users-through-a-CRUD-interface
84
+ def devise_fix
85
+ if params[:user][:password].blank?
86
+ params[:user].delete(:password)
87
+ params[:user].delete(:password_confirmation)
88
+ end
89
+ end
90
+
91
+ def check_if_is_superadmin
92
+ if current_user.is_superadmin
93
+ redirect_to manage_users_url, alert: 'Sorry, it\'s forbidden to modify this account.'
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,67 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class RepeatersController < ApplicationController
5
+ before_action :set_repeater, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /repeaters
8
+ def index
9
+ @repeaters = Repeater.all
10
+ end
11
+
12
+ # GET /repeaters/1
13
+ def show
14
+ end
15
+
16
+ # GET /repeaters/new
17
+ def new
18
+ @repeater = Repeater.new
19
+ end
20
+
21
+ # GET /repeaters/1/edit
22
+ def edit
23
+ end
24
+
25
+ # POST /repeaters
26
+ def create
27
+ @repeater = Repeater.new(repeater_params)
28
+
29
+ if @repeater.save
30
+ redirect_to @repeater, notice: 'Repeater was successfully created.'
31
+ else
32
+ render :new
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /repeaters/1
37
+ def update
38
+ if @repeater.update(repeater_params)
39
+ redirect_to @repeater, notice: 'Repeater was successfully updated.'
40
+ else
41
+ render :edit
42
+ end
43
+ end
44
+
45
+ # DELETE /repeaters/1
46
+ def destroy
47
+ @repeater.destroy
48
+ # redirect_to repeaters_url, notice: 'Repeater was successfully destroyed.'
49
+ if params['isAjax']
50
+ head :ok
51
+ else
52
+ redirect_to :back, notice: 'Field group was successfully destroyed.'
53
+ end
54
+ end
55
+
56
+ private
57
+ # Use callbacks to share common setup or constraints between actions.
58
+ def set_repeater
59
+ @repeater = Repeater.find(params[:id])
60
+ end
61
+
62
+ # Only allow a trusted parameter "white list" through.
63
+ def repeater_params
64
+ params.require(:repeater).permit(:name, :slug)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,75 @@
1
+ require_dependency "binda/application_controller"
2
+
3
+ module Binda
4
+ class SettingsController < ApplicationController
5
+ before_action :set_setting, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @settings = Setting.all
9
+ end
10
+
11
+ def show
12
+ redirect_to action: :edit
13
+ end
14
+
15
+ def new
16
+ @setting = Setting.new
17
+ end
18
+
19
+ def edit
20
+ end
21
+
22
+ def create
23
+ @setting = Setting.new(setting_params)
24
+
25
+ if @setting.save
26
+ redirect_to setting_path( @setting.slug ), notice: 'Setting was successfully created.'
27
+ else
28
+ render :new
29
+ end
30
+ end
31
+
32
+ def update
33
+ if @setting.update(setting_params)
34
+ redirect_to setting_path( @setting.slug ), notice: 'Setting was successfully updated.'
35
+ else
36
+ render :edit
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @setting.destroy
42
+ redirect_to settings_url, notice: 'Setting was successfully destroyed.'
43
+ end
44
+
45
+ def dashboard
46
+ @settings = Setting.all
47
+ @dashboard = Setting
48
+ end
49
+
50
+ def update_dashboard
51
+ dashboard_params[:settings].each do |id|
52
+ setting = Setting.find(id)
53
+ unless setting.update( dashboard_params[:settings][id.to_s] )
54
+ return redirect_to dashboard_path, flash: { error: setting.errors }
55
+ end
56
+ end
57
+ redirect_to dashboard_path, flash: { notice: 'Dashboard was successfully updated.' }
58
+ end
59
+
60
+ private
61
+ # Use callbacks to share common setup or constraints between actions.
62
+ def set_setting
63
+ @setting = Setting.friendly.find(params[:id])
64
+ end
65
+
66
+ def dashboard_params
67
+ params.require(:dashboard).permit( settings: [ :id, :name, :content, :slug, :position, :is_true ] )
68
+ end
69
+
70
+ # Only allow a trusted parameter "white list" through.
71
+ def setting_params
72
+ params.require(:setting).permit(:name, :content, :slug, :position, :dashboard )
73
+ end
74
+ end
75
+ end