administrador 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +73 -0
  4. data/Rakefile +22 -0
  5. data/app/assets/config/administrador_manifest.js +2 -0
  6. data/app/assets/javascripts/administrador/application.js +16 -0
  7. data/app/assets/stylesheets/administrador/application/bootstrap-btn-responsive.css +7 -0
  8. data/app/assets/stylesheets/administrador/application/bootstrap-btn-xs.css +6 -0
  9. data/app/assets/stylesheets/administrador/application/bootstrap-circular-buttons.css +30 -0
  10. data/app/assets/stylesheets/administrador/application/bootstrap-table-xs.css +7 -0
  11. data/app/assets/stylesheets/administrador/application/colors.css +7 -0
  12. data/app/assets/stylesheets/administrador/application/engine-sidebar.css +7 -0
  13. data/app/assets/stylesheets/administrador/application/layout.css +43 -0
  14. data/app/assets/stylesheets/administrador/application/page-actions.css +3 -0
  15. data/app/assets/stylesheets/administrador/application/query_form.css +8 -0
  16. data/app/assets/stylesheets/administrador/application.css +15 -0
  17. data/app/concerns/administrador/controller/application_concern.rb +15 -0
  18. data/app/concerns/administrador/controller/engine_concern.rb +21 -0
  19. data/app/concerns/administrador/controller/resource_concern.rb +50 -0
  20. data/app/concerns/administrador/controller/resources_concern.rb +70 -0
  21. data/app/concerns/administrador/controller/service_concern.rb +17 -0
  22. data/app/concerns/administrador/engine_routable/localized_concern.rb +21 -0
  23. data/app/controllers/administrador/application_controller.rb +5 -0
  24. data/app/controllers/administrador/home_controller/base.rb +7 -0
  25. data/app/controllers/administrador/home_controller.rb +6 -0
  26. data/app/controllers/administrador/resource_controller/base.rb +7 -0
  27. data/app/controllers/administrador/resources_controller/base.rb +7 -0
  28. data/app/controllers/administrador/service_controller/base.rb +7 -0
  29. data/app/controllers/administrador/sidebar_controller/base.rb +17 -0
  30. data/app/jobs/administrador/application_job.rb +4 -0
  31. data/app/mailers/administrador/application_mailer.rb +6 -0
  32. data/app/models/administrador/application_record.rb +5 -0
  33. data/app/view_helpers/administrador/application_view_helper.rb +44 -0
  34. data/app/view_helpers/administrador/breadcrumbs_view_helper.rb +59 -0
  35. data/app/view_helpers/administrador/offcanvas_view_helper.rb +8 -0
  36. data/app/views/administrador/application/_main_sidebar_right.html.haml +1 -0
  37. data/app/views/administrador/application/_navbar.html.haml +14 -0
  38. data/app/views/administrador/application/sidebars/_engine.html.haml +32 -0
  39. data/app/views/administrador/application/sidebars/_i18n.html.haml +8 -0
  40. data/app/views/administrador/application/sidebars/_messages.html.haml +5 -0
  41. data/app/views/administrador/application/sidebars/_notifications.html.haml +5 -0
  42. data/app/views/administrador/application/sidebars/_search.html.haml +5 -0
  43. data/app/views/administrador/application/sidebars/_settings.html.haml +5 -0
  44. data/app/views/administrador/application/sidebars/_user.html.haml +5 -0
  45. data/app/views/administrador/application_view_helper/_flash_messages.html.haml +3 -0
  46. data/app/views/administrador/application_view_helper/_render_engine_sidebars.html.haml +4 -0
  47. data/app/views/administrador/home/_html_head_extras.html.haml +0 -0
  48. data/app/views/administrador/home/index.de.html.haml +6 -0
  49. data/app/views/administrador/home/index.en.html.haml +6 -0
  50. data/app/views/administrador/home_controller/base/_html_head_extras.html.haml +0 -0
  51. data/app/views/administrador/home_controller/base/index.html.haml +3 -0
  52. data/app/views/administrador/resource_controller/base/_after_show_table.html.haml +0 -0
  53. data/app/views/administrador/resource_controller/base/_before_show_table.html.haml +0 -0
  54. data/app/views/administrador/resource_controller/base/_edit_actions.html.haml +7 -0
  55. data/app/views/administrador/resource_controller/base/_form.html.haml +8 -0
  56. data/app/views/administrador/resource_controller/base/_form_buttons.html.haml +1 -0
  57. data/app/views/administrador/resource_controller/base/_form_errors.html.haml +6 -0
  58. data/app/views/administrador/resource_controller/base/_html_head_extras.html.haml +0 -0
  59. data/app/views/administrador/resource_controller/base/_new_actions.html.haml +3 -0
  60. data/app/views/administrador/resource_controller/base/_show_actions.html.haml +6 -0
  61. data/app/views/administrador/resource_controller/base/_show_table.html.haml +2 -0
  62. data/app/views/administrador/resource_controller/base/edit.html.haml +14 -0
  63. data/app/views/administrador/resource_controller/base/new.html.haml +14 -0
  64. data/app/views/administrador/resource_controller/base/show.html.haml +19 -0
  65. data/app/views/administrador/resources_controller/base/_after_index_table.html.haml +0 -0
  66. data/app/views/administrador/resources_controller/base/_after_show_table.html.haml +0 -0
  67. data/app/views/administrador/resources_controller/base/_before_index_table.html.haml +0 -0
  68. data/app/views/administrador/resources_controller/base/_before_show_table.html.haml +0 -0
  69. data/app/views/administrador/resources_controller/base/_edit_actions.html.haml +7 -0
  70. data/app/views/administrador/resources_controller/base/_form.html.haml +10 -0
  71. data/app/views/administrador/resources_controller/base/_form_buttons.html.haml +1 -0
  72. data/app/views/administrador/resources_controller/base/_form_errors.html.haml +6 -0
  73. data/app/views/administrador/resources_controller/base/_html_head_extras.html.haml +0 -0
  74. data/app/views/administrador/resources_controller/base/_index_actions.html.haml +4 -0
  75. data/app/views/administrador/resources_controller/base/_index_table.html.haml +2 -0
  76. data/app/views/administrador/resources_controller/base/_index_table_actions.html.haml +16 -0
  77. data/app/views/administrador/resources_controller/base/_index_table_actions.html.haml~ +16 -0
  78. data/app/views/administrador/resources_controller/base/_new_actions.html.haml +3 -0
  79. data/app/views/administrador/resources_controller/base/_pagination.html.haml +1 -0
  80. data/app/views/administrador/resources_controller/base/_query_form.html.haml +0 -0
  81. data/app/views/administrador/resources_controller/base/_query_form_buttons.html.haml +2 -0
  82. data/app/views/administrador/resources_controller/base/_show_actions.html.haml +10 -0
  83. data/app/views/administrador/resources_controller/base/_show_table.html.haml +5 -0
  84. data/app/views/administrador/resources_controller/base/edit.html.haml +14 -0
  85. data/app/views/administrador/resources_controller/base/index.html.haml +33 -0
  86. data/app/views/administrador/resources_controller/base/new.html.haml +14 -0
  87. data/app/views/administrador/resources_controller/base/show.html.haml +19 -0
  88. data/app/views/administrador/service_controller/base/_create_actions.html.haml +3 -0
  89. data/app/views/administrador/service_controller/base/_create_after_service_output.html.haml +0 -0
  90. data/app/views/administrador/service_controller/base/_create_before_service_output.html.haml +0 -0
  91. data/app/views/administrador/service_controller/base/_form_buttons.haml +1 -0
  92. data/app/views/administrador/service_controller/base/_form_errors.html.haml +6 -0
  93. data/app/views/administrador/service_controller/base/_html_head_extras.html.haml +0 -0
  94. data/app/views/administrador/service_controller/base/_new_actions.html.haml +3 -0
  95. data/app/views/administrador/service_controller/base/create.html.haml +24 -0
  96. data/app/views/administrador/service_controller/base/new.html.haml +14 -0
  97. data/app/views/administrador/sidebar_controller/base/show.html.haml +1 -0
  98. data/app/views/breadcrumbs/_render.html.haml +7 -0
  99. data/app/views/layouts/administrador/application.html.haml +64 -0
  100. data/app/views/offcanvas_view_helper/_offcanvas.html.erb +11 -0
  101. data/config/initializers/localized_engines_fix.rb +3 -0
  102. data/config/locales/de.yml +76 -0
  103. data/config/locales/en.yml +46 -0
  104. data/config/routes.rb +8 -0
  105. data/lib/administrador/configuration.rb +24 -0
  106. data/lib/administrador/engine.rb +5 -0
  107. data/lib/administrador/feature.rb +7 -0
  108. data/lib/administrador/registered_engine.rb +73 -0
  109. data/lib/administrador/version.rb +3 -0
  110. data/lib/administrador.rb +19 -0
  111. data/lib/generators/administrador/install/install_generator.rb +19 -0
  112. data/lib/generators/administrador/install/templates/initializer.rb +11 -0
  113. data/lib/generators/administrador/install/templates/routes.source +4 -0
  114. data/lib/tasks/administrador_tasks.rake +4 -0
  115. metadata +493 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 361baa81c14f79a48e2f8f6779c85b5a21ce05f6a34d2b4e4cccb0f92f5ba8f0
4
+ data.tar.gz: d697b0fe6a177328e22d3754ec141e89669845aadaf4c39e37d9571efc3689b9
5
+ SHA512:
6
+ metadata.gz: 9ce528d1ae3157a7748b582360b2958efa5cfbc2ada15c59c76cae420122d2d57c3823971568a9e272a20a7afc117fb75ebe3e117c551c48008a69aac6cdd9cc
7
+ data.tar.gz: 85447dedab01ce3c5d0c3833eebe531e81f32b883e4cd6bb102fe5083c736befc79bfdf38727ecafe234f605303cc82b3443f9a57a9ebb97b19ed8c70b49f912
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Roberto Vasquez Angel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Administrador
2
+
3
+ Yet another rails admin UI.
4
+
5
+ Why do we need another one?
6
+
7
+ Most admin UIs need to be hacked or bent to support engines. This admin UI thinks
8
+ engines first, main-app second. ;)
9
+
10
+ ## Philosophy
11
+
12
+ Administrador thinks in engines, resources and services.
13
+
14
+ ## Prerequisites
15
+
16
+ If you are using rails <= 4.0 you have to add the responders gem to you Gemfile:
17
+
18
+ ```ruby
19
+ gem 'responders'
20
+ ```
21
+
22
+
23
+ ## Installation
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'administrador'
28
+ ```
29
+
30
+ And then execute:
31
+ ```bash
32
+ $ bundle
33
+ ```
34
+
35
+ Or install it yourself as:
36
+ ```bash
37
+ $ gem install administrador
38
+ ```
39
+
40
+ Run the rails generator:
41
+ ```bash
42
+ $ rails g administrador:install
43
+ ```
44
+
45
+ ## Configuration
46
+
47
+ Look at the initializer at config/initializers/administrador.rb for configuration
48
+ options.
49
+
50
+ ### Adding and engine to administrador
51
+
52
+ ```ruby
53
+ Administrador.configure do |config|
54
+ config.register_engine 'Blorgh::Engine', {}
55
+ end
56
+ ```
57
+ ### Stylesheets and Javascripts
58
+
59
+ Administrador assumes, that you have an application.js and application.css in your engine.
60
+ For example if you have a Blorgh-Engine, you should have following files inside the engine:
61
+
62
+ /app/assets/javascripts/blorgh/application.js
63
+ /app/assets/stylesheets/blorgh/application.css
64
+
65
+ ## Usage
66
+
67
+ Go to /en/backend and enjoy your admin UI.
68
+
69
+ ## Contributing
70
+ Contribution directions go here.
71
+
72
+ ## License
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Administrador'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/administrador .js
2
+ //= link_directory ../stylesheets/administrador .css
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require rao-component/acts_as_list
16
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ @media only screen and (min-width: 0px) and (max-width: 767px) {
2
+ .btn-responsive {
3
+ .btn-text {
4
+ display: none;
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ .btn-xs {
2
+ padding: .125rem .25rem;
3
+ font-size: .75rem;
4
+ line-height: 1.25;
5
+ border-radius: .2rem;
6
+ }
@@ -0,0 +1,30 @@
1
+ .btn-circle.btn-lg {
2
+ width: 50px;
3
+ height: 50px;
4
+ border-radius: 25px;
5
+ font-size: 18px;
6
+ line-height: 1.33;
7
+ }
8
+
9
+ .btn-circle.btn-xl {
10
+ width: 70px;
11
+ height: 70px;
12
+ padding: 10px 16px;
13
+ border-radius: 35px;
14
+ font-size: 24px;
15
+ line-height: 1.33;
16
+ }
17
+
18
+ .btn-circle {
19
+ width: 30px;
20
+ height: 30px;
21
+ padding: 6px 0px;
22
+ border-radius: 15px;
23
+ text-align: center;
24
+ font-size: 12px;
25
+ line-height: 1.42857;
26
+ }
27
+
28
+ .btn-circle.btn-lg i {
29
+ line-height: 2.4rem;
30
+ }
@@ -0,0 +1,7 @@
1
+ table.table-xs {
2
+ font-size: .75rem;
3
+ }
4
+
5
+ table.table-xs th, table.table-xs td {
6
+ padding: 0.25rem;
7
+ }
@@ -0,0 +1,7 @@
1
+ body {
2
+ background-color: #F8F8FB;
3
+ }
4
+
5
+ #main-navbar nav.navbar {
6
+ background-color: #FFFFFF;
7
+ }
@@ -0,0 +1,7 @@
1
+ #engine-sidebar .administrador-object-count {
2
+ margin-right: 1rem;
3
+ }
4
+
5
+ #engine-sidebar .list-group-item {
6
+ padding: 0.2rem 0.3rem;
7
+ }
@@ -0,0 +1,43 @@
1
+ body {
2
+ font-family: 'Poppins', sans-serif;
3
+ }
4
+
5
+ #main-navbar-tools .navbar-nav {
6
+ flex-direction: row;
7
+ flex-wrap: wrap;
8
+ }
9
+
10
+ #main-navbar-tools .navbar-nav li {
11
+ margin-left: 0.75rem;
12
+ }
13
+
14
+ #main-sidebar {
15
+ padding: 0;
16
+ }
17
+
18
+ @media (min-width: 768px) {
19
+ #main-sidebar {
20
+ min-height: 100vh;
21
+ }
22
+
23
+ #main-sidebar > .container-fluid > .row {
24
+ height: 100vh;
25
+ }
26
+ }
27
+
28
+ #main-sidebar-bottom-content {
29
+ width: 100%;
30
+ display: flex;
31
+ justify-content: space-between;
32
+ flex-wrap: wrap;
33
+ }
34
+
35
+ #main-sidebar-bottom-content .btn {
36
+ margin-bottom: 0.75rem;
37
+ }
38
+
39
+ #main-breadcrumbs ol.breadcrumb {
40
+ background-color: inherit !important;
41
+ padding-left: 0;
42
+ padding-right: 0;
43
+ }
@@ -0,0 +1,3 @@
1
+ .edit-actions .btn, .show-actions .btn, .index-actions .btn, .new-actions .btn, .create-actions, .btn {
2
+ margin-left: 0.5rem;
3
+ }
@@ -0,0 +1,8 @@
1
+ .administrador-query-form {
2
+ margin-bottom: 0.75rem;
3
+ }
4
+
5
+ .administrador-query-form input, .administrador-query-form select {
6
+ margin-left: 0.5rem;
7
+ margin-right: 0.5rem;
8
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree ./application
14
+ *= require_self
15
+ */
@@ -0,0 +1,15 @@
1
+ module Administrador
2
+ module Controller
3
+ module ApplicationConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ view_helper Administrador::ApplicationViewHelper, as: :administrador_helper
8
+ view_helper Administrador::OffcanvasViewHelper, as: :offcanvas
9
+ view_helper Administrador::BreadcrumbsViewHelper, as: :breadcrumbs
10
+
11
+ prepend Administrador::EngineRoutable::LocalizedConcern
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ module Administrador
2
+ module Controller
3
+ module EngineConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ helper_method :engine_class
8
+ end
9
+
10
+ class_methods do
11
+ def engine_class
12
+ "#{name.deconstantize}::Engine".constantize
13
+ end
14
+ end
15
+
16
+ def engine_class
17
+ self.class.engine_class
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,50 @@
1
+ module Administrador
2
+ module Controller
3
+ module ResourceConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ include Rao::ResourceController::RestActionsConcern
7
+ include Rao::ResourceController::ResourceConcern
8
+ include Rao::ResourceController::RestResourceUrlsConcern
9
+ include Rao::ResourceController::ResourceInflectionsConcern
10
+ include Rao::ResourceController::LocationHistoryConcern
11
+
12
+ included do
13
+ helper Rao::Component::ApplicationHelper
14
+ end
15
+
16
+ # You can exclude available actions so that buttons to that action are not included
17
+ # in the UI.
18
+ #
19
+ # Example:
20
+ #
21
+ # # app/controllers/posts_controller.rb
22
+ # class PostsController < ApplicationController
23
+ # include Administrador::Controller::ResourcesConcern
24
+ #
25
+ # def self.available_rest_actions
26
+ # super - %i(edit new)
27
+ # end
28
+ # end
29
+ module AvailableRestActionsConcern
30
+ extend ActiveSupport::Concern
31
+
32
+ included do
33
+ helper_method :available_rest_actions
34
+ end
35
+
36
+ module ClassMethods
37
+ def available_rest_actions
38
+ %i(new create show edit update destroy)
39
+ end
40
+ end
41
+
42
+ def available_rest_actions
43
+ self.class.available_rest_actions
44
+ end
45
+ end
46
+
47
+ include AvailableRestActionsConcern
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,70 @@
1
+ module Administrador
2
+ module Controller
3
+ module ResourcesConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ include Rao::ResourcesController::RestActionsConcern
7
+ include Rao::ResourcesController::ResourcesConcern
8
+ include Rao::ResourcesController::RestResourceUrlsConcern
9
+ include Rao::ResourcesController::ResourceInflectionsConcern
10
+ include Rao::ResourcesController::LocationHistoryConcern
11
+ include Rao::ResourcesController::SortingConcern
12
+ include Rao::ResourcesController::BatchActionsConcern
13
+ include Rao::ResourcesController::KaminariConcern if Administrador.features?(:kaminari)
14
+ include Rao::Query::Controller::QueryConcern if Administrador.features?(:rao_query)
15
+
16
+ included do
17
+ helper Rao::Component::ApplicationHelper
18
+ view_helper Rao::Query::ApplicationHelper , as: :query_helper if Administrador.features?(:rao_query)
19
+ end
20
+
21
+ def load_collection_scope
22
+ with_conditions_from_query(super)
23
+ end if Administrador.features?(:rao_query)
24
+
25
+
26
+ module ResourcesCountConcern
27
+ extend ActiveSupport::Concern
28
+ module ClassMethods
29
+ def resource_count
30
+ resource_class.count
31
+ end
32
+ end
33
+ end
34
+ include ResourcesCountConcern
35
+
36
+ # You can exclude available actions so that buttons to that action are not included
37
+ # in the UI.
38
+ #
39
+ # Example:
40
+ #
41
+ # # app/controllers/posts_controller.rb
42
+ # class PostsController < ApplicationController
43
+ # include Administrador::Controller::ResourcesConcern
44
+ #
45
+ # def self.available_rest_actions
46
+ # super - %i(edit new)
47
+ # end
48
+ # end
49
+ module AvailableRestActionsConcern
50
+ extend ActiveSupport::Concern
51
+
52
+ included do
53
+ helper_method :available_rest_actions
54
+ end
55
+
56
+ module ClassMethods
57
+ def available_rest_actions
58
+ %i(index new create show edit update destroy)
59
+ end
60
+ end
61
+
62
+ def available_rest_actions
63
+ self.class.available_rest_actions
64
+ end
65
+ end
66
+
67
+ include AvailableRestActionsConcern
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,17 @@
1
+ module Administrador
2
+ module Controller
3
+ module ServiceConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ include Rao::ServiceController::RestActionsConcern
7
+ include Rao::ServiceController::ServiceConcern
8
+ include Rao::ServiceController::RestServiceUrlsConcern
9
+ include Rao::ServiceController::ServiceInflectionsConcern
10
+ include Rao::ServiceController::LocationHistoryConcern
11
+
12
+ included do
13
+ helper Rao::Component::ApplicationHelper
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Administrador
2
+ module EngineRoutable
3
+ # This prevents missing method error when using localized
4
+ # engines. The localized gem fails to create a default route
5
+ # name for enginges without a locale soffix. For example if you
6
+ # have an engine named blorgh, the router should be named blorgh.
7
+ # With localized you get blorgh_en, blorgh_de and so on. This concern
8
+ # provides the router method without the locale as suffix.
9
+ module LocalizedConcern
10
+ def method_missing(m, *args, &block)
11
+ method_name_with_locale = "#{m}_#{I18n.locale}"
12
+
13
+ if respond_to?(method_name_with_locale)
14
+ send(method_name_with_locale, *args, &block)
15
+ else
16
+ super
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,5 @@
1
+ module Administrador
2
+ class ApplicationController < Administrador::Configuration.base_controller_class_name.constantize
3
+ include Administrador::Controller::ApplicationConcern
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Administrador
2
+ class HomeController::Base < ApplicationController
3
+ include Administrador::Controller::EngineConcern
4
+
5
+ def index; end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Administrador
2
+ class HomeController < Administrador::ApplicationController
3
+ def index
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Administrador
2
+ module ResourceController
3
+ class Base < Administrador::ApplicationController
4
+ include Administrador::Controller::ResourceConcern
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Administrador
2
+ module ResourcesController
3
+ class Base < Administrador::ApplicationController
4
+ include Administrador::Controller::ResourcesConcern
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Administrador
2
+ module ServiceController
3
+ class Base < Administrador::ApplicationController
4
+ include Administrador::Controller::ServiceConcern
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module Administrador
2
+ module SidebarController
3
+ class Base < Administrador::ApplicationController
4
+ layout false
5
+
6
+ def self.icon_name
7
+ :'ellipsis-v'
8
+ end
9
+
10
+ def show
11
+ respond_to do |format|
12
+ format.html
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ module Administrador
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Administrador
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Administrador
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ module Administrador
2
+ class ApplicationViewHelper < Rao::ViewHelper::Base
3
+ def engines
4
+ Administrador::Configuration.engines
5
+ end
6
+
7
+ def filter_attributes_for_form(attribute_names)
8
+ attribute_names.reject { |an| %w(id created_at updated_at).include?(an) }
9
+ end
10
+
11
+ def filter_attributes_for_show(attribute_names)
12
+ attribute_names.reject { |an| %w().include?(an) }
13
+ end
14
+
15
+ def flash_messages
16
+ c.render partial: 'administrador/application_view_helper/flash_messages', locals: { flash: bootstrapify_flash_keys(c.flash) }
17
+ end
18
+
19
+ def label_for(resource)
20
+ Administrador::Configuration.resource_label_methods.each do |method_name|
21
+ next unless resource.respond_to?(method_name)
22
+ return resource.send(method_name)
23
+ end
24
+ end
25
+
26
+ def render_engine_sidebars
27
+ engines.collect do |_, engine|
28
+ c.render partial: 'administrador/application_view_helper/render_engine_sidebars', locals: { engine: engine }
29
+ end.join.html_safe
30
+ end
31
+
32
+ private
33
+
34
+ def bootstrapify_flash_keys(flash)
35
+ flash.each_with_object({}) do |(key, value), memo|
36
+ memo[map_message_type_to_context(key)] = value
37
+ end
38
+ end
39
+
40
+ def map_message_type_to_context(message_type)
41
+ { success: "success", error: "danger", alert: "warning", notice: "info" }[message_type.to_sym] || message_type.to_s
42
+ end
43
+ end
44
+ end