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
@@ -207,7 +207,7 @@ module Rails
|
|
207
207
|
|
208
208
|
# References to add nest button in father_module's listing
|
209
209
|
def str_last_button(father)
|
210
|
-
" - if
|
210
|
+
" - if can?(#{father.camelcase}).show?"
|
211
211
|
end
|
212
212
|
|
213
213
|
#String of the button to add in father_module's listing
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/rails/resource/resource_generator'
|
2
4
|
require 'rails/generators/resource_helpers'
|
3
5
|
module Rails
|
@@ -11,7 +13,7 @@ module Rails
|
|
11
13
|
class_option :stylesheet_engine, desc: 'Engine for Stylesheets'
|
12
14
|
remove_class_option :resource_route, type: :boolean
|
13
15
|
|
14
|
-
source_root File.expand_path('
|
16
|
+
source_root File.expand_path('templates', __dir__)
|
15
17
|
|
16
18
|
check_class_collision suffix: 'Controller'
|
17
19
|
|
@@ -31,13 +33,12 @@ module Rails
|
|
31
33
|
)
|
32
34
|
|
33
35
|
def add_route
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
36
|
+
return if options[:skip_routes]
|
37
|
+
inject_into_file(
|
38
|
+
'config/routes.rb',
|
39
|
+
"\n #{indent(str_route)}",
|
40
|
+
after: "root to: 'admin#root'"
|
41
|
+
)
|
41
42
|
end
|
42
43
|
|
43
44
|
def add_option_menu
|
@@ -48,6 +49,13 @@ module Rails
|
|
48
49
|
)
|
49
50
|
end
|
50
51
|
|
52
|
+
def add_option_permissions
|
53
|
+
inject_into_file(
|
54
|
+
'config/permissions.yml',
|
55
|
+
str_permissions,
|
56
|
+
before: 'scripts:'
|
57
|
+
)
|
58
|
+
end
|
51
59
|
# def add_access_ability
|
52
60
|
# inject_into_file(
|
53
61
|
# 'app/models/ability.rb',
|
@@ -67,7 +75,7 @@ module Rails
|
|
67
75
|
# end
|
68
76
|
|
69
77
|
def add_locales
|
70
|
-
%w
|
78
|
+
%w[en es].each do |locale|
|
71
79
|
add_str_locales(locale, 'singularize')
|
72
80
|
add_str_locales(locale, 'pluralize')
|
73
81
|
add_str_locales(locale, 'modules')
|
@@ -76,7 +84,7 @@ module Rails
|
|
76
84
|
end
|
77
85
|
end
|
78
86
|
|
79
|
-
# Se usa para configurar la
|
87
|
+
# Se usa para configurar la exportacion del ActiveRecords a .xls,
|
80
88
|
# pero da problemas al borrar el KepplerScaffold
|
81
89
|
|
82
90
|
# def add_config_xls
|
@@ -114,7 +122,8 @@ module Rails
|
|
114
122
|
'policies/policy.rb',
|
115
123
|
File.join(
|
116
124
|
'app/policies',
|
117
|
-
controller_class_path,
|
125
|
+
controller_class_path,
|
126
|
+
"#{controller_file_name.singularize}_policy.rb"
|
118
127
|
)
|
119
128
|
)
|
120
129
|
end
|
@@ -122,16 +131,22 @@ module Rails
|
|
122
131
|
def create_views_files
|
123
132
|
names
|
124
133
|
attachments
|
125
|
-
template_keppler_views('_description.html.haml')
|
126
|
-
template_keppler_views('_index_show.html.haml')
|
127
|
-
template_keppler_views('_listing.html.haml')
|
128
|
-
template_keppler_views('_form.html.haml')
|
129
|
-
template_keppler_views('show.js.haml')
|
130
|
-
template_keppler_views('edit.html.haml')
|
131
|
-
template_keppler_views('new.html.haml')
|
132
|
-
template_keppler_views('show.html.haml')
|
133
|
-
template_keppler_views('index.html.haml')
|
134
|
-
template_keppler_views('reload.js.haml')
|
134
|
+
# template_keppler_views('_description.html.haml')
|
135
|
+
# template_keppler_views('_index_show.html.haml')
|
136
|
+
# template_keppler_views('_listing.html.haml')
|
137
|
+
# template_keppler_views('_form.html.haml')
|
138
|
+
# template_keppler_views('show.js.haml')
|
139
|
+
# template_keppler_views('edit.html.haml')
|
140
|
+
# template_keppler_views('new.html.haml')
|
141
|
+
# template_keppler_views('show.html.haml')
|
142
|
+
# template_keppler_views('index.html.haml')
|
143
|
+
# template_keppler_views('reload.js.haml')
|
144
|
+
%w[
|
145
|
+
_description.html _index_show.html _listing.html _form.html edit.html
|
146
|
+
new.html show.html index.html show.js reload.js
|
147
|
+
].each do |file_name|
|
148
|
+
template_keppler_views("#{file_name}.haml")
|
149
|
+
end
|
135
150
|
end
|
136
151
|
|
137
152
|
hook_for :test_framework, as: :scaffold
|
@@ -141,24 +156,24 @@ module Rails
|
|
141
156
|
invoke invoked, [controller_name]
|
142
157
|
end
|
143
158
|
|
144
|
-
def add_position_field
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
159
|
+
# def add_position_field
|
160
|
+
# file = Dir::entries('db/migrate').max
|
161
|
+
# # system 'sudo apt-get update'
|
162
|
+
# inject_into_file(
|
163
|
+
# "db/migrate/#{file}",
|
164
|
+
# "t.integer :position\n ",
|
165
|
+
# before: 't.timestamps'
|
166
|
+
# )
|
167
|
+
# end
|
153
168
|
|
154
169
|
private
|
155
170
|
|
156
171
|
def names
|
157
|
-
@names = [
|
172
|
+
@names = %w[name title first_name full_name]
|
158
173
|
end
|
159
174
|
|
160
175
|
def attachments
|
161
|
-
@attachments = [
|
176
|
+
@attachments = %w[logo brand photo avatar cover image picture banner attachment pic file]
|
162
177
|
end
|
163
178
|
|
164
179
|
def add_str_locales(locale, switch)
|
@@ -170,14 +185,16 @@ module Rails
|
|
170
185
|
end
|
171
186
|
|
172
187
|
def str_route
|
173
|
-
"\n resources :#{controller_file_name} do\n get '(page/:page)', action: :index, on: :collection, as: ''\n get '/clone', action: 'clone'\n post '/
|
174
|
-
end"
|
188
|
+
"\n resources :#{controller_file_name} do\n post '/sort', action: :sort, on: :collection\n get '(page/:page)', action: :index, on: :collection, as: ''\n get '/clone', action: 'clone'\n post '/upload', action: 'upload', as: :upload\n get(\n '/reload',\n action: :reload,\n on: :collection,\n )\n delete(\n '/destroy_multiple',\n action: :destroy_multiple,\n on: :collection,\n as: :destroy_multiple\n )\n end"
|
175
189
|
end
|
176
190
|
|
177
191
|
def str_menu
|
178
192
|
" #{controller_file_name.singularize}:\n name: #{controller_file_name.humanize.downcase}\n url_path: /admin/#{controller_file_name}\n icon: layers\n current: ['admin/#{controller_file_name}']\n model: #{controller_file_name.singularize.camelize}\n"
|
179
193
|
end
|
180
194
|
|
195
|
+
def str_permissions
|
196
|
+
"#{controller_file_name.pluralize}:\n name: #{controller_file_name.singularize.camelize}\n actions: [\n 'index', 'create', 'update',\n 'destroy', 'download', 'upload',\n 'clone'\n ]\n "
|
197
|
+
end
|
181
198
|
# def str_ability_admin
|
182
199
|
# "\n\n # - #{controller_file_name.singularize.camelcase} authorize -\n can :manage, #{controller_file_name.singularize.camelcase}"
|
183
200
|
# end
|
@@ -186,9 +203,9 @@ module Rails
|
|
186
203
|
# "\n\n # - #{controller_file_name.singularize.camelcase} authorize -\n can [:index, :show], #{controller_file_name.singularize.camelcase}"
|
187
204
|
# end
|
188
205
|
|
189
|
-
def str_xls
|
190
|
-
|
191
|
-
end
|
206
|
+
# def str_xls
|
207
|
+
# "\nif #{controller_file_name.singularize.camelcase}.table_exists?\n @#{controller_file_name.pluralize} = #{controller_file_name.singularize.camelcase}.all\n @#{controller_file_name.pluralize}.to_xls(\n only: %i[#{attributes_names.map { |name| name }.join(' ')}],\n except: [:id],\n header: false,\n prepend: [['Col 0, Row 0', 'Col 1, Row 0'], ['Col 0, Row 1']],\n column_width: [17, 15, 15, 40, 25, 37]\n )\n @#{controller_file_name.pluralize}.to_xls do |column, value|\n column == :salutation ? t(value) : value\n end\nend\n"
|
208
|
+
# end
|
192
209
|
|
193
210
|
def str_locales(switch)
|
194
211
|
case switch
|
@@ -197,9 +214,9 @@ module Rails
|
|
197
214
|
when 'pluralize'
|
198
215
|
"\n #{controller_file_name}: #{controller_file_name.humanize.downcase}"
|
199
216
|
when 'modules'
|
200
|
-
"\n admin/#{controller_file_name}: #{controller_file_name.humanize}"
|
217
|
+
"\n admin/#{controller_file_name.dasherize}: #{controller_file_name.humanize}"
|
201
218
|
when 'sidebar-menu'
|
202
|
-
"\n #{controller_file_name}: #{controller_file_name.humanize}"
|
219
|
+
"\n #{controller_file_name.dasherize}: #{controller_file_name.humanize}"
|
203
220
|
# when 'attributes'
|
204
221
|
# array = ["\n #{controller_file_name.singularize}:"]
|
205
222
|
# attributes_names.each do |attribute|
|
@@ -212,7 +229,7 @@ module Rails
|
|
212
229
|
def template_keppler_views(name_file)
|
213
230
|
template(
|
214
231
|
"views/#{name_file}",
|
215
|
-
File.join("app/views/admin/#{controller_file_name}",
|
232
|
+
File.join("app/views/admin/#{controller_file_name}", name_file)
|
216
233
|
)
|
217
234
|
end
|
218
235
|
|
@@ -5,36 +5,34 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
|
|
5
5
|
module Admin
|
6
6
|
# <%= controller_class_name %>Controller
|
7
7
|
class <%= controller_class_name %>Controller < AdminController
|
8
|
-
before_action :set_<%= singular_table_name %>, only: [
|
9
|
-
before_action :show_history, only: [
|
8
|
+
before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy]
|
9
|
+
before_action :show_history, only: %i[index]
|
10
10
|
before_action :set_attachments
|
11
|
+
before_action :authorization, except: %i[reload]
|
11
12
|
|
12
13
|
# GET <%= route_url %>
|
13
14
|
def index
|
14
15
|
@q = <%= class_name %>.ransack(params[:q])
|
15
16
|
<%= plural_table_name %> = @q.result(distinct: true)
|
16
|
-
@objects = <%= plural_table_name %>.page(@current_page).order(position: :
|
17
|
+
@objects = <%= plural_table_name %>.page(@current_page).order(position: :asc)
|
17
18
|
@total = <%= plural_table_name %>.size
|
18
|
-
@<%= plural_table_name %> =
|
19
|
+
@<%= plural_table_name %> = <%= class_name %>.all
|
19
20
|
if !@objects.first_page? && @objects.size.zero?
|
20
21
|
redirect_to <%= plural_table_name %>_path(page: @current_page.to_i.pred, search: @query)
|
21
22
|
end
|
23
|
+
format
|
22
24
|
end
|
23
25
|
|
24
26
|
# GET <%= route_url %>/1
|
25
|
-
def show
|
26
|
-
end
|
27
|
+
def show; end
|
27
28
|
|
28
29
|
# GET <%= route_url %>/new
|
29
30
|
def new
|
30
31
|
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
31
|
-
authorize @<%= singular_table_name %>
|
32
32
|
end
|
33
33
|
|
34
34
|
# GET <%= route_url %>/1/edit
|
35
|
-
def edit
|
36
|
-
authorize @<%= singular_table_name %>
|
37
|
-
end
|
35
|
+
def edit; end
|
38
36
|
|
39
37
|
# POST <%= route_url %>
|
40
38
|
def create
|
@@ -54,7 +52,6 @@ module Admin
|
|
54
52
|
else
|
55
53
|
render :edit
|
56
54
|
end
|
57
|
-
authorize @<%= singular_table_name %>
|
58
55
|
end
|
59
56
|
|
60
57
|
def clone
|
@@ -65,14 +62,12 @@ module Admin
|
|
65
62
|
else
|
66
63
|
render :new
|
67
64
|
end
|
68
|
-
authorize @<%= singular_table_name %>
|
69
65
|
end
|
70
66
|
|
71
67
|
# DELETE <%= route_url %>/1
|
72
68
|
def destroy
|
73
69
|
@<%= orm_instance.destroy %>
|
74
70
|
redirect_to admin_<%= index_helper %>_path, notice: actions_messages(@<%= singular_table_name %>)
|
75
|
-
authorize @<%= singular_table_name %>
|
76
71
|
end
|
77
72
|
|
78
73
|
def destroy_multiple
|
@@ -81,26 +76,14 @@ module Admin
|
|
81
76
|
admin_<%= index_helper %>_path(page: @current_page, search: @query),
|
82
77
|
notice: actions_messages(<%= orm_class.build(class_name) %>)
|
83
78
|
)
|
84
|
-
authorize @<%= singular_table_name %>
|
85
79
|
end
|
86
80
|
|
87
|
-
def
|
88
|
-
<%= class_name %>.
|
81
|
+
def upload
|
82
|
+
<%= class_name %>.upload(params[:file])
|
89
83
|
redirect_to(
|
90
84
|
admin_<%= index_helper %>_path(page: @current_page, search: @query),
|
91
85
|
notice: actions_messages(<%= orm_class.build(class_name) %>)
|
92
86
|
)
|
93
|
-
authorize @<%= singular_table_name %>
|
94
|
-
end
|
95
|
-
|
96
|
-
def download
|
97
|
-
@<%= plural_table_name %> = <%= class_name %>.all
|
98
|
-
respond_to do |format|
|
99
|
-
format.html
|
100
|
-
format.xls { send_data(@<%= plural_table_name %>.to_xls) }
|
101
|
-
format.json { render :json => @<%= plural_table_name %> }
|
102
|
-
end
|
103
|
-
authorize @<%= plural_table_name %>
|
104
87
|
end
|
105
88
|
|
106
89
|
def reload
|
@@ -111,14 +94,30 @@ module Admin
|
|
111
94
|
|
112
95
|
def sort
|
113
96
|
<%= class_name %>.sorter(params[:row])
|
114
|
-
|
97
|
+
@q = <%= class_name %>.ransack(params[:q])
|
98
|
+
<%= plural_table_name %> = @q.result(distinct: true)
|
99
|
+
@objects = <%= plural_table_name %>.page(@current_page)
|
115
100
|
end
|
116
101
|
|
117
102
|
private
|
118
103
|
|
104
|
+
def format
|
105
|
+
respond_to do |format|
|
106
|
+
format.html
|
107
|
+
format.csv { send_data @<%= plural_table_name %>.to_csv }
|
108
|
+
format.xls # { send_data @<%= plural_table_name %>.to_xls }
|
109
|
+
format.json { render json: @<%= plural_table_name %> }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def authorization
|
114
|
+
authorize <%= class_name %>
|
115
|
+
end
|
116
|
+
|
119
117
|
def set_attachments
|
120
|
-
@attachments = [
|
121
|
-
|
118
|
+
@attachments = %w[
|
119
|
+
logo brand photo avatar cover image picture banner attachment pic file
|
120
|
+
]
|
122
121
|
end
|
123
122
|
|
124
123
|
# Use callbacks to share common setup or constraints between actions.
|
@@ -1,36 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# <%= class_name %> Model
|
2
4
|
<% module_namespacing do -%>
|
3
5
|
class <%= class_name %> < ApplicationRecord
|
4
6
|
include ActivityHistory
|
5
7
|
include CloneRecord
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
include Uploadable
|
9
|
+
include Downloadable
|
10
|
+
include Sortable
|
11
|
+
<%- attributes.each do |attribute| -%>
|
12
|
+
<%- if @attachments.include?(attribute.name) -%>
|
13
|
+
mount_uploader :<%=attribute.name%>, AttachmentUploader
|
14
|
+
<%- end -%>
|
15
|
+
<%- if attribute.reference? -%>
|
16
|
+
belongs_to :<%= attribute.name %>
|
10
17
|
<%- end -%>
|
11
18
|
<%- end -%>
|
12
19
|
acts_as_list
|
20
|
+
acts_as_paranoid
|
21
|
+
|
13
22
|
# Fields for the search form in the navbar
|
14
23
|
def self.search_field
|
15
|
-
fields = <%= attributes_names.map { |name| name } %>
|
24
|
+
fields = %i[<%= attributes_names.map { |name| name }.join(' ') %>]
|
16
25
|
build_query(fields, :or, :cont)
|
17
26
|
end
|
18
27
|
|
19
|
-
def self.import(file)
|
20
|
-
CSV.foreach(file.path, headers: true) do |row|
|
21
|
-
begin
|
22
|
-
self.create! row.to_hash
|
23
|
-
rescue => err
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.sorter(params)
|
29
|
-
params.each_with_index do |id, idx|
|
30
|
-
self.find(id).update(position: idx.to_i+1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
28
|
# Funcion para armar el query de ransack
|
35
29
|
def self.build_query(fields, operator, conf)
|
36
30
|
query = fields.join("_#{operator}_")
|
@@ -2,7 +2,7 @@
|
|
2
2
|
.container
|
3
3
|
.row
|
4
4
|
.col-lg-2
|
5
|
-
= link_to admin_<%= plural_table_name %>_path, class:
|
5
|
+
= link_to admin_<%= plural_table_name %>_path, class: '', 'data-position' => 'bottom', 'data-tooltip' => t('keppler.actions.back') do
|
6
6
|
.arrow-back.btn.btn-default
|
7
7
|
%i.fa.fa-angle-left
|
8
8
|
= t('keppler.actions.back')
|
@@ -13,48 +13,37 @@
|
|
13
13
|
.box-header.with-border
|
14
14
|
%h3.box-title= t("keppler.modules.#{action_name.underscore}")
|
15
15
|
.box-tools.pull-right
|
16
|
-
%a.btn.btn-box-tool{
|
16
|
+
%a.btn.btn-box-tool{ 'data-widget' => 'collapse', type: 'button' }
|
17
17
|
%i.fa.fa-minus
|
18
18
|
.box-body
|
19
19
|
%table.table.table-bordered
|
20
20
|
%tbody
|
21
21
|
.form-padding
|
22
|
-
<%- attributes.
|
23
|
-
<%- if @attachments.include?(attribute.name) -%>
|
24
|
-
.col-xs-12
|
25
|
-
.upload-image
|
26
|
-
= f.label :<%= attribute.name %>
|
27
|
-
.files.form-group.trigger{ class: "#{'files-absolute' unless @<%= singular_table_name %>.<%= attribute.name %>.blank?}" }
|
28
|
-
#icon-file
|
29
|
-
+
|
30
|
-
= f.file_field :<%= attribute.name %>, class: 'photo_upload'
|
31
|
-
%center#image
|
32
|
-
= image_tag "#{@<%= singular_table_name %>.<%= attribute.name %>.blank? ? '<%= attribute.name %>.png' : @<%= singular_table_name %>.<%= attribute.name %>}", class: "#{'hidden' if @<%= singular_table_name %>.<%= attribute.name %>.blank?} image_to_upload"
|
33
|
-
<%- end -%>
|
34
|
-
<%- end -%>
|
35
|
-
<%- attributes.each do |attribute| -%>
|
22
|
+
<%- attributes.each_with_index do |attribute, index| -%>
|
36
23
|
.col-xs-12
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
24
|
+
<%- if @attachments.include?(attribute.name) -%>
|
25
|
+
= f.input :<%= attribute.name %>, as: :keppler_file, label: false
|
26
|
+
<%- elsif attribute.reference? -%>
|
27
|
+
= f.association :<%= attribute.name %>, include_blank: false
|
28
|
+
<%- elsif attribute.type.to_s == 'text' -%>
|
29
|
+
= f.input :<%= attribute.name %>, input_html: { ckeditor: { toolbar: 'mini' } }
|
30
|
+
<%- elsif %[position deleted_at].include?(attribute.name.to_s) || attribute.type.to_s == 'timestamp' -%>
|
31
|
+
= f.input :<%= attribute.name %>, as: :hidden
|
32
|
+
<%- elsif attribute.type.to_s == 'date' -%>
|
33
|
+
= f.input :<%= attribute.name %>, as: :string, input_html: { class: 'datepicker' }
|
34
|
+
<%- elsif attribute.type.to_s == 'boolean' -%>
|
35
|
+
= f.input :<%= attribute.name %>, as: :keppler_boolean
|
36
|
+
<%- elsif %w[integer float decimal].include?(attribute.type.to_s) -%>
|
37
|
+
= f.input :<%= attribute.name %>, input_html: { min: 0 }
|
38
|
+
<%- elsif attribute.type.to_s == 'binary' -%>
|
39
|
+
= f.input :<%= attribute.name %>, as: :string
|
40
|
+
<%- elsif attribute.name.to_s == "position" || attribute.name.to_s == "deleted_at" -%>
|
41
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>, as: :hidden
|
52
42
|
<%- else -%>
|
53
|
-
= f
|
43
|
+
= f.input :<%= attribute.name %>
|
54
44
|
<%- end -%>
|
55
45
|
<%- end -%>
|
56
|
-
<%- end -%>
|
57
46
|
.col-xs-12
|
58
47
|
.pull-right
|
59
|
-
= f.button :submit, t(
|
60
|
-
= f.button :submit, t(
|
48
|
+
= f.button :submit, t('keppler.actions.save'), name: '_save', class: 'btn-primary'
|
49
|
+
= f.button :submit, t('keppler.actions.save_and_add_another'), name: '_add_other'
|