keppler 2.0.2 → 2.0.3
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.
- checksums.yaml +5 -5
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile.lock +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -22
- data/Rakefile +6 -0
- data/bin/keppler +6 -2
- data/bin/setup +2 -1
- data/exe/keppler +6 -0
- data/installer/core/.gitignore +87 -0
- data/installer/core/.ruby-version +1 -0
- data/installer/core/Gemfile +6 -4
- data/installer/core/README.md +86 -50
- data/installer/core/app/assets/images/.keep +0 -0
- data/installer/core/app/assets/images/admin/astronauta_keppler.svg +123 -0
- data/installer/core/app/assets/images/admin/avatar_keppler.svg +100 -0
- data/installer/core/app/assets/images/admin/image_default.png +0 -0
- data/installer/core/app/assets/images/app/fondo.svg +19 -0
- data/installer/core/app/assets/javascripts/admin/file_upload.coffee +11 -0
- data/installer/core/app/assets/javascripts/admin/main.coffee +23 -12
- data/installer/core/app/assets/javascripts/admin/preview_template.js +2 -2
- data/installer/core/app/assets/javascripts/admin/sidebar.js +8 -7
- data/installer/core/app/assets/javascripts/admin/swal.js +37 -0
- data/installer/core/app/assets/javascripts/admin/switch.js +6 -0
- data/installer/core/app/assets/javascripts/admin/tooltips.coffee +3 -0
- data/installer/core/app/assets/javascripts/errors/application.js.coffee +1 -0
- data/installer/core/app/assets/javascripts/errors/errors.js +113 -0
- data/installer/core/app/assets/javascripts/keppler_ga_dashboard/view-selector2.js +1 -1
- data/installer/core/app/assets/javascripts/vue_admin/index.js +34 -9
- data/installer/core/app/assets/stylesheets/admin/application.scss +4 -14
- data/installer/core/app/assets/stylesheets/admin/components/navigation/_navbar.scss +4 -5
- data/installer/core/app/assets/stylesheets/admin/components/navigation/_sidebar.scss +26 -17
- data/installer/core/app/assets/stylesheets/admin/pages/_appearance.scss +5 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_customize.scss +21 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_datepicker.scss +1088 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_files.scss +26 -9
- data/installer/core/app/assets/stylesheets/admin/pages/_form.scss +19 -6
- data/installer/core/app/assets/stylesheets/admin/pages/_index.scss +4 -8
- data/installer/core/app/assets/stylesheets/admin/pages/_listing.scss +5 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_navbar.scss +9 -2
- data/installer/core/app/assets/stylesheets/admin/pages/_roles.scss +6 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_search.scss +24 -28
- data/installer/core/app/assets/stylesheets/admin/pages/_sidebar.scss +1 -1
- data/installer/core/app/assets/stylesheets/admin/pages/_switchs.scss +135 -39
- data/installer/core/app/assets/stylesheets/admin/pages/_timepicker.scss +16 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_user.scss +6 -0
- data/installer/core/app/assets/stylesheets/admin/utils/_base.scss +6 -1
- data/installer/core/app/assets/stylesheets/admin/utils/_theme.scss +24 -11
- data/installer/core/app/assets/stylesheets/admin/utils/_variables.scss +1 -1
- data/installer/core/app/assets/stylesheets/app/pages/_front.sass +70 -56
- data/installer/core/app/assets/stylesheets/errors/errors.scss +161 -120
- data/installer/core/app/assets/stylesheets/vendor/admin-lte/_skin-blue.scss +1 -1
- data/installer/core/app/controllers/admin/admin_controller.rb +1 -1
- data/installer/core/app/controllers/admin/customizes_controller.rb +6 -8
- data/installer/core/app/controllers/admin/meta_tags_controller.rb +14 -18
- data/installer/core/app/controllers/admin/roles_controller.rb +176 -0
- data/installer/core/app/controllers/admin/scripts_controller.rb +14 -33
- data/installer/core/app/controllers/admin/settings_controller.rb +26 -27
- data/installer/core/app/controllers/admin/users_controller.rb +35 -29
- data/installer/core/app/controllers/app/app_controller.rb +27 -4
- data/installer/core/app/controllers/application_controller.rb +39 -1
- data/installer/core/app/controllers/concerns/.keep +0 -0
- data/installer/core/app/helpers/admin_helper.rb +5 -0
- data/installer/core/app/helpers/application_helper.rb +9 -0
- data/installer/core/app/helpers/roles_helper.rb +2 -0
- data/installer/core/app/inputs/file_material_input.rb +4 -2
- data/installer/core/app/inputs/keppler_boolean_input.rb +74 -0
- data/installer/core/app/inputs/keppler_file_input.rb +70 -0
- data/installer/core/app/mailers/.keep +0 -0
- data/installer/core/app/mailers/application_mailer.rb +13 -13
- data/installer/core/app/models/.keep +0 -0
- data/installer/core/app/models/appearance.rb +2 -0
- data/installer/core/app/models/application_record.rb +3 -0
- data/installer/core/app/models/concerns/.keep +0 -0
- data/installer/core/app/models/concerns/downloadable.rb +13 -0
- data/installer/core/app/models/concerns/sortable.rb +9 -0
- data/installer/core/app/models/concerns/uploadable.rb +10 -0
- data/installer/core/app/models/customize.rb +8 -6
- data/installer/core/app/models/front.rb +3 -0
- data/installer/core/app/models/google_analytics_setting.rb +2 -0
- data/installer/core/app/models/meta_tag.rb +27 -14
- data/installer/core/app/models/permission.rb +3 -0
- data/installer/core/app/models/role.rb +62 -5
- data/installer/core/app/models/script.rb +6 -15
- data/installer/core/app/models/setting.rb +2 -0
- data/installer/core/app/models/smtp_setting.rb +2 -0
- data/installer/core/app/models/social_account.rb +2 -0
- data/installer/core/app/models/user.rb +17 -1
- data/installer/core/app/policies/application_policy.rb +4 -4
- data/installer/core/app/policies/controller_policy.rb +15 -11
- data/installer/core/app/policies/role_policy.rb +25 -0
- data/installer/core/app/policies/user_policy.rb +1 -1
- data/installer/core/app/uploaders/attachment_uploader.rb +18 -1
- data/installer/core/app/views/admin/customizes/_description.html.haml +4 -4
- data/installer/core/app/views/admin/customizes/_form.html.haml +4 -4
- data/installer/core/app/views/admin/customizes/_listing.html.haml +1 -1
- data/installer/core/app/views/admin/customizes/_switch_default_template.html.haml +8 -13
- data/installer/core/app/views/admin/customizes/_switch_template.html.haml +8 -11
- data/installer/core/app/views/admin/customizes/index.html.haml +9 -9
- data/installer/core/app/views/admin/layouts/_head.html.haml +3 -3
- data/installer/core/app/views/admin/layouts/_keppler_boolean_script.haml +12 -0
- data/installer/core/app/views/admin/layouts/_navigation.html.haml +17 -16
- data/installer/core/app/views/admin/layouts/_sidebar.html.haml +27 -36
- data/installer/core/app/views/admin/layouts/application.html.haml +1 -0
- data/installer/core/app/views/admin/layouts/index/remote_messages.js.haml +6 -6
- data/installer/core/app/views/admin/meta_tags/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/meta_tags/_listing.html.haml +6 -6
- data/installer/core/app/views/admin/meta_tags/index.html.haml +15 -29
- data/installer/core/app/views/admin/meta_tags/show.html.haml +7 -8
- data/installer/core/app/views/admin/roles/_description.html.haml +13 -0
- data/installer/core/app/views/admin/roles/_form.html.haml +27 -0
- data/installer/core/app/views/admin/roles/_index_show.html.haml +24 -0
- data/installer/core/app/views/admin/roles/_listing.html.haml +46 -0
- data/installer/core/app/views/admin/roles/_switch.html.haml +20 -0
- data/installer/core/app/views/admin/roles/add_permissions.html.haml +60 -0
- data/installer/core/app/views/admin/roles/create_permissions.html.haml +0 -0
- data/installer/core/app/views/admin/roles/create_permissions.js.erb +1 -0
- data/installer/core/app/views/admin/roles/edit.html.haml +1 -0
- data/installer/core/app/views/admin/roles/index.html.haml +80 -0
- data/installer/core/app/views/admin/roles/new.html.haml +1 -0
- data/installer/core/app/views/admin/roles/reload.js.haml +5 -0
- data/installer/core/app/views/admin/roles/show.html.haml +32 -0
- data/installer/core/app/views/admin/roles/show.js.haml +4 -0
- data/installer/core/app/views/admin/roles/show_description.js.erb +2 -0
- data/installer/core/app/views/admin/scripts/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/scripts/_listing.html.haml +13 -13
- data/installer/core/app/views/admin/scripts/index.html.haml +12 -26
- data/installer/core/app/views/admin/scripts/show.html.haml +4 -4
- data/installer/core/app/views/admin/settings/components/_preview.html.haml +1 -1
- data/installer/core/app/views/admin/settings/fields/_appearance.html.haml +25 -17
- data/installer/core/app/views/admin/settings/fields/_basic_information.html.haml +13 -7
- data/installer/core/app/views/admin/settings/fields/_email_setting.html.haml +16 -16
- data/installer/core/app/views/admin/settings/fields/_google_analytics_setting.html.haml +1 -1
- data/installer/core/app/views/admin/settings/fields/_social_accounts.html.haml +39 -39
- data/installer/core/app/views/admin/users/_form.html.haml +18 -25
- data/installer/core/app/views/admin/users/_index_show.html.haml +2 -2
- data/installer/core/app/views/admin/users/_listing.html.haml +6 -6
- data/installer/core/app/views/admin/users/delete_avatar.js.haml +3 -0
- data/installer/core/app/views/admin/users/filter_by_role.js.erb +9 -0
- data/installer/core/app/views/admin/users/index.html.haml +22 -22
- data/installer/core/app/views/admin/users/show.html.haml +10 -12
- data/installer/core/app/views/app/front/index.html.haml +137 -87
- data/installer/core/app/views/app/layouts/_footer.html.haml +2 -2
- data/installer/core/app/views/app/layouts/_head.html.haml +4 -12
- data/installer/core/app/views/app/layouts/_meta_tags.html.haml +38 -6
- data/installer/core/app/views/app/layouts/application.html.haml +8 -8
- data/installer/core/app/views/devise/sessions/new.html.haml +32 -28
- data/installer/core/app/views/errors/internal_server_error.html.haml +50 -7
- data/installer/core/app/views/errors/not_authorized.html.haml +75 -6
- data/installer/core/app/views/errors/not_found.html.haml +101 -7
- data/installer/core/app/views/errors/unprocessable.html.haml +50 -7
- data/installer/core/bin/update +31 -0
- data/installer/core/bin/yarn +11 -0
- data/installer/core/config/application.rb +1 -1
- data/installer/core/config/environments/production.rb +1 -1
- data/installer/core/config/initializers/carrierwave.rb +12 -0
- data/installer/core/config/initializers/mime_types.rb +2 -2
- data/installer/core/config/initializers/simple_form_bootstrap.rb +20 -1
- data/installer/core/config/initializers/simple_form_components.rb +61 -0
- data/installer/core/config/locales/en.yml +29 -6
- data/installer/core/config/locales/es.yml +32 -5
- data/installer/core/config/locales/simple_form.en.yml +1 -0
- data/installer/core/config/locales/simple_form.es.yml +3 -2
- data/installer/core/config/menu.yml +34 -8
- data/installer/core/config/permissions.yml +21 -0
- data/installer/core/config/routes.rb +56 -14
- data/installer/core/db/migrate/20140812210925_rolify_create_roles.rb +2 -0
- data/installer/core/db/migrate/20160128131802_create_scripts.rb +1 -0
- data/installer/core/db/migrate/20180503174351_create_permissions.rb +11 -0
- data/installer/core/db/seeds.rb +12 -6
- data/installer/core/lib/generators/keppler_front/templates/views/template.html.haml +222 -177
- data/installer/core/lib/generators/keppler_relation/keppler_relation_generator.rb +1 -1
- data/installer/core/lib/generators/keppler_scaffold/keppler_scaffold_generator.rb +57 -40
- data/installer/core/lib/generators/keppler_scaffold/templates/controllers/controller.rb +29 -30
- data/installer/core/lib/generators/keppler_scaffold/templates/models/model.rb +14 -20
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_form.html.haml +24 -35
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_index_show.html.haml +12 -11
- data/installer/core/lib/generators/keppler_scaffold/templates/views/_listing.html.haml +7 -7
- data/installer/core/lib/generators/keppler_scaffold/templates/views/index.html.haml +17 -33
- data/installer/core/lib/generators/keppler_scaffold/templates/views/show.html.haml +23 -24
- data/installer/core/plugins/keppler_ga_dashboard/app/assets/images/keppler_ga_dashboard/.keep +0 -0
- data/installer/core/plugins/keppler_ga_dashboard/config/permissions.yml +4 -0
- data/installer/core/plugins/keppler_ga_dashboard/keppler_ga_dashboard.gemspec +1 -1
- data/installer/core/test/controllers/.keep +0 -0
- data/installer/core/test/controllers/roles_controller_test.rb +48 -0
- data/installer/core/test/fixtures/.keep +0 -0
- data/installer/core/test/fixtures/permissions.yml +9 -0
- data/installer/core/test/helpers/.keep +0 -0
- data/installer/core/test/integration/.keep +0 -0
- data/installer/core/test/mailers/.keep +0 -0
- data/installer/core/test/models/.keep +0 -0
- data/installer/core/test/models/permission_test.rb +7 -0
- data/installer/core/test/system/roles_test.rb +43 -0
- data/installer/core/vendor/assets/javascripts/.keep +0 -0
- data/installer/core/vendor/assets/stylesheets/.keep +0 -0
- data/installer/plugins/concerns/commons.rb +47 -0
- data/installer/plugins/concerns/destroy_multiple.rb +33 -0
- data/installer/plugins/concerns/history.rb +24 -0
- data/installer/plugins/config/locales/en.yml +104 -0
- data/installer/plugins/config/locales/es.yml +139 -0
- data/installer/plugins/config/menu.yml +12 -0
- data/installer/plugins/config/permissions.yml +1 -0
- data/installer/plugins/generators/keppler_scaffold/keppler_scaffold_generator.rb +203 -0
- data/installer/plugins/generators/keppler_scaffold/templates/controllers/controller.rb +171 -0
- data/installer/plugins/generators/keppler_scaffold/templates/models/model.rb +41 -0
- data/installer/plugins/generators/keppler_scaffold/templates/policies/policy.rb +11 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_description.html.haml +13 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_form.html.haml +49 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_index_show.html.haml +26 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/_listing.html.haml +65 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/edit.html.haml +1 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/index.html.haml +97 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/new.html.haml +1 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/reload.js.haml +5 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/show.html.haml +66 -0
- data/installer/plugins/generators/keppler_scaffold/templates/views/show.js.haml +4 -0
- data/installer/plugins/install.rb +156 -0
- data/installer/plugins/layouts/_navigation.html.haml +47 -0
- data/installer/plugins/layouts/application.html.haml +24 -0
- data/keppler.gemspec +35 -0
- data/lib/keppler.rb +0 -1
- data/lib/keppler/add.rb +13 -0
- data/lib/keppler/cli.rb +134 -5
- data/lib/keppler/delete.rb +13 -0
- data/lib/keppler/version.rb +1 -1
- metadata +117 -23
- data/installer/core/app/assets/images/admin/space.png +0 -0
- data/installer/core/app/assets/stylesheets/admin/pages/_header.scss +0 -34
- data/installer/core/app/assets/stylesheets/admin/pages/_pageslide.scss +0 -125
- data/installer/core/db/schema.rb +0 -172
- data/installer/lib/conf.rb +0 -31
- data/installer/lib/scaffold.rb +0 -10
- data/installer/run.sh +0 -17
- data/installer/scripts/bin.sh +0 -61
- data/lib/keppler/cli/generate.rb +0 -19
@@ -1,12 +1,10 @@
|
|
1
1
|
module Admin
|
2
2
|
# CustomizesController
|
3
3
|
class CustomizesController < AdminController
|
4
|
-
before_action :set_customize, only: %i[show edit update destroy]
|
4
|
+
before_action :set_customize, only: %i[show edit update destroy authorization]
|
5
5
|
before_action :set_customizes, only: %i[update install_default]
|
6
6
|
before_action :show_history, only: %i[index]
|
7
|
-
before_action :authorization,
|
8
|
-
new create edit update destroy destroy_multiple
|
9
|
-
]
|
7
|
+
before_action :authorization, except: %i[reload install_default]
|
10
8
|
|
11
9
|
# GET /customizes
|
12
10
|
def index
|
@@ -43,7 +41,7 @@ module Admin
|
|
43
41
|
@customizes.each { |customize| customize.update(installed: false) }
|
44
42
|
if @customize.update(customize_params)
|
45
43
|
@customize.installed? ? @customize.install : @customize.uninstall
|
46
|
-
redirect_to
|
44
|
+
redirect_to admin_customizes_path
|
47
45
|
else
|
48
46
|
render :edit
|
49
47
|
end
|
@@ -52,12 +50,12 @@ module Admin
|
|
52
50
|
def install_default
|
53
51
|
@customize = Customize.find(params[:customize_id])
|
54
52
|
if @customize.installed?
|
55
|
-
redirect_to
|
53
|
+
redirect_to admin_customizes_path
|
56
54
|
else
|
57
55
|
@customizes.each { |customize| customize.update(installed: false) }
|
58
56
|
if @customize.update(customize_params)
|
59
57
|
@customize.install_keppler_template
|
60
|
-
redirect_to
|
58
|
+
redirect_to admin_customizes_path
|
61
59
|
else
|
62
60
|
render :edit
|
63
61
|
end
|
@@ -93,7 +91,7 @@ module Admin
|
|
93
91
|
end
|
94
92
|
|
95
93
|
def authorization
|
96
|
-
authorize
|
94
|
+
authorize Customize
|
97
95
|
end
|
98
96
|
|
99
97
|
# Only allow a trusted parameter "white list" through.
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Admin
|
2
2
|
# MetaTagController
|
3
3
|
class MetaTagsController < AdminController
|
4
|
-
before_action :set_meta_tag, only: [
|
5
|
-
before_action :show_history, only: [
|
4
|
+
before_action :set_meta_tag, only: %i[show edit update destroy]
|
5
|
+
before_action :show_history, only: %i[index]
|
6
|
+
before_action :authorization, except: %i[reload]
|
6
7
|
|
7
8
|
# GET /meta_tags
|
8
9
|
def index
|
9
10
|
@q = MetaTag.ransack(params[:q])
|
10
|
-
meta_tags = @q.result(distinct: true).order(:position)
|
11
|
-
@objects = meta_tags.page(@current_page)
|
12
|
-
@total = meta_tags.size
|
13
|
-
if
|
14
|
-
|
15
|
-
end
|
11
|
+
@meta_tags = @q.result(distinct: true).order(:position)
|
12
|
+
@objects = @meta_tags.page(@current_page)
|
13
|
+
@total = @meta_tags.size
|
14
|
+
redirect_to_index(meta_tags_path) if nothing_in_first_page?(@objects)
|
15
|
+
respond_to_formats(@meta_tags)
|
16
16
|
end
|
17
17
|
|
18
18
|
# GET /meta_tags/1
|
@@ -22,12 +22,10 @@ module Admin
|
|
22
22
|
# GET /meta_tags/new
|
23
23
|
def new
|
24
24
|
@meta_tag = MetaTag.new
|
25
|
-
authorize @meta_tag
|
26
25
|
end
|
27
26
|
|
28
27
|
# GET /meta_tags/1/edit
|
29
28
|
def edit
|
30
|
-
authorize @meta_tag
|
31
29
|
end
|
32
30
|
|
33
31
|
# POST /meta_tags
|
@@ -47,7 +45,6 @@ module Admin
|
|
47
45
|
else
|
48
46
|
render :edit
|
49
47
|
end
|
50
|
-
authorize @meta_tag
|
51
48
|
end
|
52
49
|
|
53
50
|
def clone
|
@@ -58,14 +55,12 @@ module Admin
|
|
58
55
|
else
|
59
56
|
render :new
|
60
57
|
end
|
61
|
-
authorize @meta_tag
|
62
58
|
end
|
63
59
|
|
64
60
|
# DELETE /meta_tags/1
|
65
61
|
def destroy
|
66
62
|
@meta_tag.destroy
|
67
63
|
redirect_to admin_meta_tags_path, notice: actions_messages(@meta_tag)
|
68
|
-
authorize @meta_tag
|
69
64
|
end
|
70
65
|
|
71
66
|
def destroy_multiple
|
@@ -74,16 +69,14 @@ module Admin
|
|
74
69
|
admin_meta_tags_path(page: @current_page, search: @query),
|
75
70
|
notice: actions_messages(MetaTag.new)
|
76
71
|
)
|
77
|
-
authorize @meta_tag
|
78
72
|
end
|
79
73
|
|
80
|
-
def
|
81
|
-
MetaTag.
|
74
|
+
def upload
|
75
|
+
MetaTag.upload(params[:file])
|
82
76
|
redirect_to(
|
83
77
|
admin_meta_tags_path(page: @current_page, search: @query),
|
84
78
|
notice: actions_messages(MetaTag.new)
|
85
79
|
)
|
86
|
-
authorize @meta_tag
|
87
80
|
end
|
88
81
|
|
89
82
|
def download
|
@@ -93,7 +86,6 @@ module Admin
|
|
93
86
|
format.xls { send_data(@meta_tags.to_xls) }
|
94
87
|
format.json { render :json => @meta_tags }
|
95
88
|
end
|
96
|
-
authorize @meta_tags
|
97
89
|
end
|
98
90
|
|
99
91
|
def reload
|
@@ -107,6 +99,10 @@ module Admin
|
|
107
99
|
|
108
100
|
private
|
109
101
|
|
102
|
+
def authorization
|
103
|
+
authorize MetaTag
|
104
|
+
end
|
105
|
+
|
110
106
|
# Use callbacks to share common setup or constraints between actions.
|
111
107
|
def set_meta_tag
|
112
108
|
@meta_tag = MetaTag.find(params[:id])
|
@@ -0,0 +1,176 @@
|
|
1
|
+
module Admin
|
2
|
+
# RolesController
|
3
|
+
class RolesController < AdminController
|
4
|
+
before_action :set_role, only: %i[show edit update destroy toggle_actions create_first_permission]
|
5
|
+
before_action :set_role_id, only: %i[create_permissions add_permissions]
|
6
|
+
before_action :show_history, only: [:index]
|
7
|
+
before_action :set_attachments
|
8
|
+
before_action :authorization, except: %i[reload]
|
9
|
+
|
10
|
+
# GET /roles
|
11
|
+
def index
|
12
|
+
@q = Role.ransack(params[:q])
|
13
|
+
roles = @q.result(distinct: true)
|
14
|
+
@objects = roles.page(@current_page).order(position: :desc)
|
15
|
+
@total = roles.size
|
16
|
+
@roles = @objects.order(:position)
|
17
|
+
if !@objects.first_page? && @objects.size.zero?
|
18
|
+
redirect_to roles_path(page: @current_page.to_i.pred, search: @query)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET /roles/1
|
23
|
+
def show
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /roles/new
|
27
|
+
def new
|
28
|
+
@role = Role.new
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /roles/1/edit
|
32
|
+
def edit
|
33
|
+
end
|
34
|
+
|
35
|
+
# POST /roles
|
36
|
+
def create
|
37
|
+
@role = Role.new(role_params)
|
38
|
+
|
39
|
+
if @role.save
|
40
|
+
redirect_to admin_role_add_permissions_path(@role)
|
41
|
+
else
|
42
|
+
render :new
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# PATCH/PUT /roles/1
|
47
|
+
def update
|
48
|
+
if @role.update(role_params)
|
49
|
+
redirect(@role, params)
|
50
|
+
else
|
51
|
+
render :edit
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def clone
|
56
|
+
@role = Role.clone_record params[:role_id]
|
57
|
+
if @role.save
|
58
|
+
redirect_to admin_roles_path
|
59
|
+
else
|
60
|
+
render :new
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# DELETE /roles/1
|
65
|
+
def destroy
|
66
|
+
@role.destroy
|
67
|
+
redirect_to admin_roles_path, notice: actions_messages(@role)
|
68
|
+
end
|
69
|
+
|
70
|
+
def destroy_multiple
|
71
|
+
Role.destroy redefine_ids(params[:multiple_ids])
|
72
|
+
redirect_to(
|
73
|
+
admin_roles_path(page: @current_page, search: @query),
|
74
|
+
notice: actions_messages(Role.new)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def upload
|
79
|
+
Role.upload(params[:file])
|
80
|
+
redirect_to(
|
81
|
+
admin_roles_path(page: @current_page, search: @query),
|
82
|
+
notice: actions_messages(Role.new)
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def download
|
87
|
+
@roles = Role.all
|
88
|
+
respond_to do |format|
|
89
|
+
format.html
|
90
|
+
format.xls { send_data(@roles.to_xls) }
|
91
|
+
format.json { render :json => @roles }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def reload
|
96
|
+
@q = Role.ransack(params[:q])
|
97
|
+
roles = @q.result(distinct: true)
|
98
|
+
@objects = roles.page(@current_page).order(position: :desc)
|
99
|
+
end
|
100
|
+
|
101
|
+
def sort
|
102
|
+
Role.sorter(params[:row])
|
103
|
+
render :index
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_permissions
|
107
|
+
@role = Role.find(params[:role_id])
|
108
|
+
end
|
109
|
+
|
110
|
+
def create_permissions
|
111
|
+
@module = params[:role][:module]
|
112
|
+
@action = params[:role][:action]
|
113
|
+
|
114
|
+
if @role.have_permissions?
|
115
|
+
toggle_actions(params[:role][:module], params[:role][:action])
|
116
|
+
else
|
117
|
+
create_first_permission
|
118
|
+
end
|
119
|
+
# redirect_to admin_role_add_permissions_path(params[:role_id])
|
120
|
+
end
|
121
|
+
|
122
|
+
def show_description
|
123
|
+
@module = params[:module]
|
124
|
+
@action = params[:action_name]
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
|
130
|
+
def toggle_actions(module_name, action)
|
131
|
+
if @role.have_permission_to(module_name)
|
132
|
+
@role.toggle_action(module_name, action)
|
133
|
+
else
|
134
|
+
@role.add_module(module_name, action)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def create_first_permission
|
139
|
+
Permission.create(
|
140
|
+
role_id: @role.id,
|
141
|
+
modules: create_hash(params[:role][:module], params[:role][:action])
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
def create_hash(module_name, actions)
|
146
|
+
Hash[module_name, Hash["actions", Array(actions)]]
|
147
|
+
end
|
148
|
+
|
149
|
+
def set_attachments
|
150
|
+
@attachments = ['logo', 'brand', 'photo', 'avatar', 'cover', 'image',
|
151
|
+
'picture', 'banner', 'attachment', 'pic', 'file']
|
152
|
+
end
|
153
|
+
|
154
|
+
# Use callbacks to share common setup or constraints between actions.
|
155
|
+
def set_role
|
156
|
+
@role = Role.find(params[:id])
|
157
|
+
end
|
158
|
+
|
159
|
+
def set_role_id
|
160
|
+
@role = Role.find(params[:role_id])
|
161
|
+
end
|
162
|
+
|
163
|
+
# Only allow a trusted parameter "white list" through.
|
164
|
+
def role_params
|
165
|
+
params.require(:role).permit(:name, :role_id)
|
166
|
+
end
|
167
|
+
|
168
|
+
def authorization
|
169
|
+
authorize Role
|
170
|
+
end
|
171
|
+
|
172
|
+
def show_history
|
173
|
+
get_history(Role)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -1,35 +1,30 @@
|
|
1
1
|
module Admin
|
2
2
|
# ScriptsController
|
3
3
|
class ScriptsController < AdminController
|
4
|
-
before_action :set_ga_track, only: [
|
5
|
-
before_action :show_history, only: [
|
4
|
+
before_action :set_ga_track, only: %i[show edit update destroy]
|
5
|
+
before_action :show_history, only: %i[index]
|
6
|
+
before_action :authorization, except: %i[reload]
|
6
7
|
|
7
8
|
# GET /scripts
|
8
9
|
def index
|
9
10
|
@q = Script.ransack(params[:q])
|
10
|
-
scripts = @q.result(distinct: true)
|
11
|
-
@objects = scripts.page(@current_page)
|
12
|
-
@total = scripts.size
|
13
|
-
|
14
|
-
|
15
|
-
redirect_to scripts_path(page: @current_page.to_i.pred,search: @query)
|
16
|
-
end
|
11
|
+
@scripts = @q.result(distinct: true)
|
12
|
+
@objects = @scripts.page(@current_page)
|
13
|
+
@total = @scripts.size
|
14
|
+
redirect_to_index(scripts_path) if nothing_in_first_page?(@objects)
|
15
|
+
respond_to_formats(@scripts)
|
17
16
|
end
|
18
17
|
|
19
18
|
# GET /scripts/1
|
20
|
-
def show
|
21
|
-
end
|
19
|
+
def show; end
|
22
20
|
|
23
21
|
# GET /scripts/new
|
24
22
|
def new
|
25
23
|
@script = Script.new
|
26
|
-
authorize @script
|
27
24
|
end
|
28
25
|
|
29
26
|
# GET /scripts/1/edit
|
30
|
-
def edit
|
31
|
-
authorize @script
|
32
|
-
end
|
27
|
+
def edit; end
|
33
28
|
|
34
29
|
# POST /scripts
|
35
30
|
def create
|
@@ -49,7 +44,6 @@ module Admin
|
|
49
44
|
else
|
50
45
|
render :edit
|
51
46
|
end
|
52
|
-
authorize @script
|
53
47
|
end
|
54
48
|
|
55
49
|
def clone
|
@@ -60,7 +54,6 @@ module Admin
|
|
60
54
|
else
|
61
55
|
render :new
|
62
56
|
end
|
63
|
-
authorize @script
|
64
57
|
end
|
65
58
|
|
66
59
|
# DELETE /scripts/1
|
@@ -71,12 +64,10 @@ module Admin
|
|
71
64
|
admin_scripts_path,
|
72
65
|
notice: actions_messages(@script)
|
73
66
|
)
|
74
|
-
authorize @script
|
75
67
|
end
|
76
68
|
|
77
69
|
def destroy_multiple
|
78
70
|
Script.destroy redefine_ids(params[:multiple_ids])
|
79
|
-
|
80
71
|
redirect_to(
|
81
72
|
admin_scripts_path(page: @current_page, search: @query),
|
82
73
|
notice: actions_messages(Script.new)
|
@@ -84,23 +75,12 @@ module Admin
|
|
84
75
|
authorize @script
|
85
76
|
end
|
86
77
|
|
87
|
-
def
|
88
|
-
Script.
|
78
|
+
def upload
|
79
|
+
Script.upload(params[:file])
|
89
80
|
redirect_to(
|
90
81
|
admin_scripts_path(page: @current_page, search: @query),
|
91
82
|
notice: actions_messages(Script.new)
|
92
83
|
)
|
93
|
-
authorize @script
|
94
|
-
end
|
95
|
-
|
96
|
-
def download
|
97
|
-
@scripts = Script.all
|
98
|
-
respond_to do |format|
|
99
|
-
format.html
|
100
|
-
format.xls { send_data(@scripts.to_xls) }
|
101
|
-
format.json { render :json => @scripts }
|
102
|
-
end
|
103
|
-
authorize @scripts
|
104
84
|
end
|
105
85
|
|
106
86
|
def reload
|
@@ -110,13 +90,14 @@ module Admin
|
|
110
90
|
end
|
111
91
|
|
112
92
|
private
|
93
|
+
|
113
94
|
# Use callbacks to share common setup or constraints between actions.
|
114
95
|
def set_ga_track
|
115
96
|
@script = Script.find(params[:id])
|
116
97
|
end
|
117
98
|
|
118
99
|
def authorization
|
119
|
-
authorize
|
100
|
+
authorize Script
|
120
101
|
end
|
121
102
|
|
122
103
|
# Only allow a trusted parameter "white list" through.
|