binda 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +63 -0
- data/Rakefile +37 -0
- data/app/assets/config/binda_manifest.js +2 -0
- data/app/assets/javascripts/binda/application.js +18 -0
- data/app/assets/javascripts/binda/components/form_item.js +54 -0
- data/app/assets/javascripts/binda/components/form_item_asset.js +24 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +66 -0
- data/app/assets/javascripts/binda/components/sortable.js +44 -0
- data/app/assets/javascripts/binda/dist/binda.bundle.js +336 -0
- data/app/assets/javascripts/binda/index.js +16 -0
- data/app/assets/stylesheets/binda/application.css +6 -0
- data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -0
- data/app/assets/stylesheets/binda/components/button.scss +7 -0
- data/app/assets/stylesheets/binda/components/form_body.scss +2 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +169 -0
- data/app/assets/stylesheets/binda/components/form_item_asset.scss +20 -0
- data/app/assets/stylesheets/binda/components/form_section.scss +40 -0
- data/app/assets/stylesheets/binda/components/login.scss +6 -0
- data/app/assets/stylesheets/binda/components/main_container.scss +0 -0
- data/app/assets/stylesheets/binda/components/main_content.scss +5 -0
- data/app/assets/stylesheets/binda/components/main_header.scss +25 -0
- data/app/assets/stylesheets/binda/components/main_table.scss +28 -0
- data/app/assets/stylesheets/binda/components/sidebar.scss +131 -0
- data/app/assets/stylesheets/binda/components/sortable.scss +98 -0
- data/app/assets/stylesheets/binda/index.scss +24 -0
- data/app/assets/stylesheets/binda/layout/components_index.scss +9 -0
- data/app/assets/stylesheets/binda/layout/dashboard.scss +7 -0
- data/app/assets/stylesheets/binda/layout/users_sign_in.scss +29 -0
- data/app/assets/stylesheets/binda/settings/common.scss +93 -0
- data/app/assets/stylesheets/binda/settings/fonts.scss +90 -0
- data/app/assets/stylesheets/binda/settings/variables.scss +83 -0
- data/app/assets/stylesheets/scaffolds.scss +89 -0
- data/app/controllers/binda/application_controller.rb +29 -0
- data/app/controllers/binda/assets_controller.rb +62 -0
- data/app/controllers/binda/bindings_controller.rb +62 -0
- data/app/controllers/binda/categories_controller.rb +60 -0
- data/app/controllers/binda/components_controller.rb +223 -0
- data/app/controllers/binda/dates_controller.rb +62 -0
- data/app/controllers/binda/field_groups_controller.rb +114 -0
- data/app/controllers/binda/field_settings_controller.rb +66 -0
- data/app/controllers/binda/galleries_controller.rb +62 -0
- data/app/controllers/binda/manage/users_controller.rb +97 -0
- data/app/controllers/binda/repeaters_controller.rb +67 -0
- data/app/controllers/binda/settings_controller.rb +75 -0
- data/app/controllers/binda/structures_controller.rb +89 -0
- data/app/controllers/binda/texts_controller.rb +62 -0
- data/app/controllers/binda/users/confirmations_controller.rb +33 -0
- data/app/controllers/binda/users/omniauth_callbacks_controller.rb +33 -0
- data/app/controllers/binda/users/passwords_controller.rb +37 -0
- data/app/controllers/binda/users/registrations_controller.rb +89 -0
- data/app/controllers/binda/users/sessions_controller.rb +30 -0
- data/app/controllers/binda/users/unlocks_controller.rb +33 -0
- data/app/helpers/binda/application_helper.rb +25 -0
- data/app/helpers/binda/assets_helper.rb +4 -0
- data/app/helpers/binda/bindings_helper.rb +4 -0
- data/app/helpers/binda/categories_helper.rb +10 -0
- data/app/helpers/binda/components_helper.rb +10 -0
- data/app/helpers/binda/dates_helper.rb +4 -0
- data/app/helpers/binda/field_groups_helper.rb +10 -0
- data/app/helpers/binda/field_settings_helper.rb +14 -0
- data/app/helpers/binda/galleries_helper.rb +4 -0
- data/app/helpers/binda/repeaters_helper.rb +4 -0
- data/app/helpers/binda/settings_helper.rb +13 -0
- data/app/helpers/binda/structures_helper.rb +4 -0
- data/app/helpers/binda/texts_helper.rb +4 -0
- data/app/jobs/binda/application_job.rb +4 -0
- data/app/mailers/binda/application_mailer.rb +6 -0
- data/app/models/binda/application_record.rb +5 -0
- data/app/models/binda/asset.rb +21 -0
- data/app/models/binda/binding.rb +24 -0
- data/app/models/binda/category.rb +31 -0
- data/app/models/binda/component.rb +186 -0
- data/app/models/binda/date.rb +9 -0
- data/app/models/binda/field_group.rb +40 -0
- data/app/models/binda/field_setting.rb +95 -0
- data/app/models/binda/gallery.rb +18 -0
- data/app/models/binda/repeater.rb +108 -0
- data/app/models/binda/setting.rb +42 -0
- data/app/models/binda/structure.rb +31 -0
- data/app/models/binda/text.rb +9 -0
- data/app/models/binda/user.rb +8 -0
- data/app/uploaders/binda/asset/image_uploader.rb +76 -0
- data/app/views/binda/assets/_form.html.erb +22 -0
- data/app/views/binda/assets/edit.html.erb +6 -0
- data/app/views/binda/assets/index.html.erb +29 -0
- data/app/views/binda/assets/new.html.erb +5 -0
- data/app/views/binda/assets/show.html.erb +19 -0
- data/app/views/binda/bindings/_form.html.erb +32 -0
- data/app/views/binda/bindings/edit.html.erb +6 -0
- data/app/views/binda/bindings/index.html.erb +31 -0
- data/app/views/binda/bindings/new.html.erb +5 -0
- data/app/views/binda/bindings/show.html.erb +19 -0
- data/app/views/binda/categories/_form.html.erb +58 -0
- data/app/views/binda/categories/edit.html.erb +8 -0
- data/app/views/binda/categories/index.html.erb +34 -0
- data/app/views/binda/categories/new.html.erb +8 -0
- data/app/views/binda/components/_form_body.html.erb +86 -0
- data/app/views/binda/components/_form_item_asset.html.erb +20 -0
- data/app/views/binda/components/_form_item_date.html.erb +16 -0
- data/app/views/binda/components/_form_item_gallery.html.erb +0 -0
- data/app/views/binda/components/_form_item_new_repeater.html.erb +33 -0
- data/app/views/binda/components/_form_item_repeater.html.erb +81 -0
- data/app/views/binda/components/_form_item_text.html.erb +28 -0
- data/app/views/binda/components/_form_section.html.erb +37 -0
- data/app/views/binda/components/_form_section_repeater.html.erb +31 -0
- data/app/views/binda/components/_form_sidebar.html.erb +34 -0
- data/app/views/binda/components/edit.html.erb +8 -0
- data/app/views/binda/components/index.html.erb +43 -0
- data/app/views/binda/components/new.html.erb +8 -0
- data/app/views/binda/dates/_form.html.erb +22 -0
- data/app/views/binda/dates/edit.html.erb +6 -0
- data/app/views/binda/dates/index.html.erb +27 -0
- data/app/views/binda/dates/new.html.erb +5 -0
- data/app/views/binda/dates/show.html.erb +9 -0
- data/app/views/binda/field_groups/_form_body.html.erb +71 -0
- data/app/views/binda/field_groups/_form_item.html.erb +62 -0
- data/app/views/binda/field_groups/_form_section.html.erb +37 -0
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +25 -0
- data/app/views/binda/field_groups/edit.html.erb +8 -0
- data/app/views/binda/field_groups/index.html.erb +34 -0
- data/app/views/binda/field_groups/new.html.erb +8 -0
- data/app/views/binda/field_settings/_form_body.html.erb +60 -0
- data/app/views/binda/field_settings/edit.html.erb +8 -0
- data/app/views/binda/field_settings/index.html.erb +31 -0
- data/app/views/binda/field_settings/new.html.erb +8 -0
- data/app/views/binda/galleries/_form.html.erb +27 -0
- data/app/views/binda/galleries/edit.html.erb +6 -0
- data/app/views/binda/galleries/index.html.erb +29 -0
- data/app/views/binda/galleries/new.html.erb +5 -0
- data/app/views/binda/galleries/show.html.erb +14 -0
- data/app/views/binda/manage/users/_admin_manage_user.json.jbuilder +2 -0
- data/app/views/binda/manage/users/_form_body.html.erb +58 -0
- data/app/views/binda/manage/users/edit.html.erb +8 -0
- data/app/views/binda/manage/users/index.html.erb +38 -0
- data/app/views/binda/manage/users/index.json.jbuilder +1 -0
- data/app/views/binda/manage/users/new.html.erb +8 -0
- data/app/views/binda/manage/users/show.json.jbuilder +1 -0
- data/app/views/binda/repeaters/_form.html.erb +27 -0
- data/app/views/binda/repeaters/edit.html.erb +6 -0
- data/app/views/binda/repeaters/index.html.erb +29 -0
- data/app/views/binda/repeaters/new.html.erb +5 -0
- data/app/views/binda/repeaters/show.html.erb +14 -0
- data/app/views/binda/settings/_dashboard_form.html.erb +51 -0
- data/app/views/binda/settings/_form.html.erb +52 -0
- data/app/views/binda/settings/dashboard.html.erb +9 -0
- data/app/views/binda/settings/edit.html.erb +8 -0
- data/app/views/binda/settings/index.html.erb +34 -0
- data/app/views/binda/settings/new.html.erb +8 -0
- data/app/views/binda/structures/_form_body.html.erb +56 -0
- data/app/views/binda/structures/_form_section.html.erb +64 -0
- data/app/views/binda/structures/add_child.html.erb +0 -0
- data/app/views/binda/structures/edit.html.erb +8 -0
- data/app/views/binda/structures/index.html.erb +34 -0
- data/app/views/binda/structures/new.html.erb +8 -0
- data/app/views/binda/texts/_form.html.erb +22 -0
- data/app/views/binda/texts/edit.html.erb +6 -0
- data/app/views/binda/texts/index.html.erb +27 -0
- data/app/views/binda/texts/new.html.erb +5 -0
- data/app/views/binda/texts/show.html.erb +9 -0
- data/app/views/layouts/binda/_flash.html.erb +26 -0
- data/app/views/layouts/binda/_header.html.erb +9 -0
- data/app/views/layouts/binda/_sidebar.html.erb +50 -0
- data/app/views/layouts/binda/application.html.erb +29 -0
- data/app/views/users/confirmations/new.html.erb +16 -0
- data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/users/mailer/password_change.html.erb +3 -0
- data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/users/passwords/edit.html.erb +31 -0
- data/app/views/users/passwords/new.html.erb +28 -0
- data/app/views/users/registrations/edit.html.erb +27 -0
- data/app/views/users/registrations/new.html.erb +17 -0
- data/app/views/users/sessions/new.html.erb +27 -0
- data/app/views/users/shared/_links.html.erb +25 -0
- data/app/views/users/unlocks/new.html.erb +16 -0
- data/config/initializers/assets.rb +3 -0
- data/config/initializers/devise.rb +278 -0
- data/config/initializers/devise_patch.rb +50 -0
- data/config/initializers/friendly_id.rb +88 -0
- data/config/initializers/simple_form.rb +165 -0
- data/config/initializers/simple_form_bootstrap.rb +149 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +37 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +67 -0
- data/config/tinymce.yml +15 -0
- data/db/migrate/1_create_binda_tables.rb +172 -0
- data/lib/binda.rb +5 -0
- data/lib/binda/engine.rb +30 -0
- data/lib/binda/version.rb +3 -0
- data/lib/generators/binda/install/USAGE +9 -0
- data/lib/generators/binda/install/install_generator.rb +107 -0
- data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +32 -0
- data/lib/generators/binda/install/templates/config/initializers/devise.rb +280 -0
- data/lib/generators/binda/setup/USAGE +8 -0
- data/lib/generators/binda/setup/setup_generator.rb +43 -0
- data/lib/tasks/binda.rake +25 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- 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
|