cm-admin 0.2.0 → 0.4.2

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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +7 -1
  6. data/Gemfile.lock +121 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +8 -19
  9. data/app/assets/images/logo.png +0 -0
  10. data/{lib/generators/cm_admin/templates/assets/stylesheets → app/assets/stylesheets/cm_admin}/base/auth.scss +4 -6
  11. data/app/assets/stylesheets/cm_admin/base/common.scss +237 -0
  12. data/app/assets/stylesheets/cm_admin/base/filters.scss +200 -0
  13. data/{lib/generators/cm_admin/templates/assets/stylesheets → app/assets/stylesheets/cm_admin}/base/form.scss +83 -11
  14. data/app/assets/stylesheets/cm_admin/base/main-nav.scss +47 -0
  15. data/app/assets/stylesheets/cm_admin/base/navbar.scss +65 -0
  16. data/app/assets/stylesheets/cm_admin/base/quicksearch.scss +76 -0
  17. data/app/assets/stylesheets/cm_admin/base/scaffold.scss +96 -0
  18. data/app/assets/stylesheets/cm_admin/base/show.scss +76 -0
  19. data/app/assets/stylesheets/cm_admin/base/sidebar.scss +225 -0
  20. data/app/assets/stylesheets/cm_admin/base/table.scss +320 -0
  21. data/app/assets/stylesheets/cm_admin/base/tabs.scss +26 -0
  22. data/app/assets/stylesheets/cm_admin/cm_admin.css.scss +26 -0
  23. data/app/assets/stylesheets/cm_admin/components/_alerts.scss +101 -0
  24. data/app/assets/stylesheets/cm_admin/components/_buttons.scss +135 -0
  25. data/app/assets/stylesheets/cm_admin/components/_dropdown-popup.scss +153 -0
  26. data/app/assets/stylesheets/cm_admin/components/_input.scss +274 -0
  27. data/app/assets/stylesheets/cm_admin/components/_modal.scss +34 -0
  28. data/app/assets/stylesheets/cm_admin/components/_range.scss +31 -0
  29. data/app/assets/stylesheets/cm_admin/components/_status-tag.scss +68 -0
  30. data/app/assets/stylesheets/cm_admin/components/index.scss +7 -0
  31. data/app/assets/stylesheets/cm_admin/dependency/bootstrap.min.css +7 -0
  32. data/app/assets/stylesheets/cm_admin/helpers/_mixins.scss +20 -0
  33. data/app/assets/stylesheets/cm_admin/helpers/_variable.scss +87 -0
  34. data/app/assets/stylesheets/cm_admin/helpers/index.scss +2 -0
  35. data/app/controllers/cm_admin/application_controller.rb +11 -0
  36. data/app/controllers/cm_admin/exports_controller.rb +16 -0
  37. data/app/controllers/cm_admin/static_controller.rb +12 -0
  38. data/app/helpers/cm_admin/application_helper.rb +11 -0
  39. data/app/helpers/cm_admin/custom_helper.rb +4 -0
  40. data/app/javascript/packs/cm_admin/application.js +22 -0
  41. data/app/javascript/packs/cm_admin/filters.js +347 -0
  42. data/app/javascript/packs/cm_admin/quick_search.js +67 -0
  43. data/app/javascript/packs/cm_admin/scaffolds.js +43 -0
  44. data/app/javascript/stylesheets/cm_admin/application.scss +3 -0
  45. data/app/views/cm_admin/main/_associated_table.html.slim +60 -0
  46. data/app/views/cm_admin/main/_cm_pagy_nav.html.slim +23 -0
  47. data/app/views/cm_admin/main/_filters.html.slim +1 -0
  48. data/app/views/cm_admin/main/_nested_fields.html.slim +7 -0
  49. data/app/views/cm_admin/main/_nested_table_form.html.slim +6 -0
  50. data/app/views/cm_admin/main/_table.html.slim +60 -0
  51. data/app/views/cm_admin/main/_tabs.html.slim +5 -0
  52. data/app/views/cm_admin/main/_top_navbar.html.slim +25 -0
  53. data/app/views/cm_admin/main/associated_index.html.slim +6 -0
  54. data/app/views/cm_admin/main/associated_show.html.slim +6 -0
  55. data/app/views/cm_admin/main/dashboard.html.slim +1 -0
  56. data/app/views/cm_admin/main/edit.html.slim +19 -0
  57. data/app/views/cm_admin/main/index.html.slim +12 -0
  58. data/app/views/cm_admin/main/new.html.slim +22 -0
  59. data/app/views/cm_admin/main/show.html.slim +12 -0
  60. data/app/views/cm_admin/static/error_401.html.slim +4 -0
  61. data/app/views/layouts/_left_sidebar_nav.html.slim +34 -0
  62. data/app/views/layouts/_quick_links.html.slim +25 -0
  63. data/app/views/layouts/cm_admin.html.slim +41 -0
  64. data/app/views/layouts/static.html.slim +18 -0
  65. data/bin/webpack +18 -0
  66. data/bin/webpack-dev-server +18 -0
  67. data/cm_admin.gemspec +21 -31
  68. data/config/.DS_Store +0 -0
  69. data/config/initializers/active_record_extension.rb +9 -0
  70. data/config/routes.rb +19 -0
  71. data/config/webpack/development.js +5 -0
  72. data/config/webpack/environment.js +13 -0
  73. data/config/webpack/production.js +5 -0
  74. data/config/webpack/test.js +5 -0
  75. data/config/webpacker.yml +92 -0
  76. data/lib/cm_admin/constants.rb +33 -0
  77. data/lib/cm_admin/engine.rb +38 -0
  78. data/lib/cm_admin/model.rb +152 -0
  79. data/lib/cm_admin/models/action.rb +36 -0
  80. data/lib/cm_admin/models/actions/blocks.rb +25 -0
  81. data/lib/cm_admin/models/blocks.rb +19 -0
  82. data/lib/cm_admin/models/cm_show_section.rb +20 -0
  83. data/lib/cm_admin/models/column.rb +61 -0
  84. data/lib/cm_admin/models/controller_method.rb +75 -0
  85. data/lib/cm_admin/models/dsl_method.rb +122 -0
  86. data/lib/cm_admin/models/export.rb +54 -0
  87. data/lib/cm_admin/models/field.rb +15 -0
  88. data/lib/cm_admin/models/filter.rb +95 -0
  89. data/lib/cm_admin/models/form_field.rb +21 -0
  90. data/lib/cm_admin/models/tab.rb +13 -0
  91. data/lib/cm_admin/utils.rb +67 -0
  92. data/lib/cm_admin/version.rb +1 -1
  93. data/lib/cm_admin/view_helpers/column_field_helper.rb +29 -0
  94. data/lib/cm_admin/view_helpers/field_display_helper.rb +65 -0
  95. data/lib/cm_admin/view_helpers/filter_helper.rb +190 -0
  96. data/lib/cm_admin/view_helpers/form_field_helper.rb +33 -0
  97. data/lib/cm_admin/view_helpers/form_helper.rb +65 -0
  98. data/lib/cm_admin/view_helpers/manage_column_popup_helper.rb +75 -0
  99. data/lib/cm_admin/view_helpers/navigation_helper.rb +34 -0
  100. data/lib/cm_admin/view_helpers/page_info_helper.rb +57 -0
  101. data/lib/cm_admin/view_helpers.rb +74 -0
  102. data/lib/cm_admin.rb +33 -2
  103. data/lib/generators/cm_admin/install_generator.rb +3 -13
  104. data/lib/tasks/webpack_install.rake +63 -0
  105. data/package.json +23 -0
  106. data/postcss.config.js +12 -0
  107. data/tmp/cache/webpacker/last-compilation-digest-development +1 -0
  108. data/yarn.lock +6933 -0
  109. metadata +155 -46
  110. data/lib/generators/cm_admin/USAGE +0 -8
  111. data/lib/generators/cm_admin/templates/assets/images/cm.png +0 -0
  112. data/lib/generators/cm_admin/templates/assets/stylesheets/application.css.scss +0 -33
  113. data/lib/generators/cm_admin/templates/assets/stylesheets/base/_variable.scss +0 -14
  114. data/lib/generators/cm_admin/templates/assets/stylesheets/base/input-styles.scss +0 -72
  115. data/lib/generators/cm_admin/templates/assets/stylesheets/base/main-nav.scss +0 -79
  116. data/lib/generators/cm_admin/templates/assets/stylesheets/base/scaffold.scss +0 -95
  117. data/lib/generators/cm_admin/templates/assets/stylesheets/base/show.scss +0 -88
  118. data/lib/generators/cm_admin/templates/assets/stylesheets/base/sidebar.scss +0 -69
  119. data/lib/generators/cm_admin/templates/assets/stylesheets/base/table.scss +0 -246
  120. data/lib/generators/cm_admin/templates/layouts/_navbar.html.slim +0 -8
  121. data/lib/generators/cm_admin/templates/layouts/_side_navbar.html.slim +0 -12
  122. data/lib/generators/cm_admin/templates/layouts/application.html.slim +0 -20
  123. data/lib/generators/cm_admin/templates/layouts/initializer.rb +0 -2
  124. data/lib/generators/cm_admin/templates/views/_form.erb +0 -67
  125. data/lib/generators/cm_admin/templates/views/_table.erb +0 -22
  126. data/lib/generators/cm_admin/templates/views/edit.erb +0 -10
  127. data/lib/generators/cm_admin/templates/views/index.erb +0 -11
  128. data/lib/generators/cm_admin/templates/views/new.erb +0 -10
  129. data/lib/generators/cm_admin/templates/views/reset_password.erb +0 -12
  130. data/lib/generators/cm_admin/templates/views/show.erb +0 -18
  131. data/lib/generators/cm_admin/templates/views/sign_in.erb +0 -18
  132. data/lib/generators/cm_admin/view_generator.rb +0 -78
@@ -0,0 +1,19 @@
1
+ == render 'cm_admin/main/top_navbar'
2
+ .form-page
3
+ .form-page__inner
4
+ .form-wrapper
5
+ .flag-alert.mb-4
6
+ p.alert-header
7
+ span
8
+ i.fa.fa-exclamation-triangle
9
+ | Attention
10
+ .alert-body
11
+ p.body-title
12
+ | Error heading
13
+ p.body-info
14
+ | The details of the error would be explained in this line. It could also be listed out as points on below the other if there are multiple reasons.
15
+ .form-container
16
+ p.form-title
17
+ | Section heading
18
+ .form-container__inner
19
+ = generate_form(@ar_object, @model)
@@ -0,0 +1,12 @@
1
+ .cm-index-page
2
+ .index-page.page-container
3
+ .sticky-container
4
+ == render 'cm_admin/main/top_navbar'
5
+ - if @model.filters.present?
6
+ .index-page__filters
7
+ == render partial: 'cm_admin/main/filters', locals: { filters: @model.filters }
8
+ .index-page__table-container
9
+ == render 'cm_admin/main/table'
10
+
11
+ = column_pop_up(@model)
12
+ = manage_column_pop_up(@model)
@@ -0,0 +1,22 @@
1
+ == render 'cm_admin/main/top_navbar'
2
+ .form-page
3
+ .form-page__inner
4
+ .form-wrapper
5
+ - if @ar_object.errors.present?
6
+ .flag-alert.mb-4
7
+ p.alert-header
8
+ span
9
+ i.fa.fa-exclamation-triangle
10
+ | Attention
11
+ .alert-body
12
+ p.body-title
13
+ | Error saving #{@ar_object.class}
14
+ p.body-info
15
+ ul
16
+ - @ar_object.errors.full_messages.each do |error_message|
17
+ li = error_message
18
+ .form-container
19
+ p.form-title
20
+ | Section heading
21
+ .form-container__inner
22
+ = generate_form(@ar_object, @model)
@@ -0,0 +1,12 @@
1
+ .show-page.page-container
2
+ .show-page__tabs.sticky-container
3
+ .cm-tabs-bar
4
+ == render 'cm_admin/main/top_navbar'
5
+ == render 'cm_admin/main/tabs'
6
+ .show-page__inner.scrollable
7
+ - @model.available_fields[:show].each do |section|
8
+ .info-section
9
+ p.section-heading = section.section_name
10
+ .paper
11
+ - section.available_section_fields.each do |field|
12
+ = show_field(@ar_object, field)
@@ -0,0 +1,4 @@
1
+ main.flex-shrink-0
2
+ .container
3
+ h1.mt-5 401
4
+ p.lead You do not authorized to access this page.
@@ -0,0 +1,34 @@
1
+ .cm-sidebar
2
+ .cm-sidebar__logo-header
3
+ = image_tag('/assets/logo.png', alt: 'logo image')
4
+
5
+ .cm-sidebar__quick-search
6
+ span
7
+ i.fa.fa-search
8
+ input data-bs-target="#quickSearchModal" data-bs-toggle="modal" type="text" placeholder="Quick Links"
9
+
10
+ .cm-sidebar__menu-wrapper
11
+ = navigation_links('sidebar')
12
+
13
+ .sidebar-menu__tabs-wrapper
14
+
15
+
16
+ .sidebar__footer
17
+ .profile-name
18
+ span.profile-avatar J
19
+ | John Doe
20
+ .profile-popup.hidden
21
+ .profile-info
22
+ .profile-info__left
23
+ p.name-text John Doe
24
+ p.email-text johndoe@commutatus.com
25
+ .profile-info__right J
26
+ .page-options
27
+ = link_to '/', class: 'page-link'
28
+ | Profile
29
+ = link_to '', class: 'page-link'
30
+ | Settings
31
+ .auth-option
32
+ = link_to '/sign-out', method: :delete, class: 'auth-link'
33
+ | Logout
34
+ = render 'layouts/quick_links'
@@ -0,0 +1,25 @@
1
+ #quickSearchModal.modal.fade.quick-search-modal aria-hidden="true" aria-labelledby="exampleModalLabel" role="dialog" tabindex="-1"
2
+ .modal-dialog role="document"
3
+ .modal-content
4
+ .modal-body
5
+ .quick-search-field
6
+ .form-field
7
+ .field-input-wrapper
8
+ input#quick-search-input.search-input placeholder="Search" data-behaviour="quick-input-search" autocomplete="off"
9
+ span.search-input-icon
10
+ i.fa.fa-search
11
+ span.clear-search.hidden
12
+ i.fa.fa-times
13
+ .search-results-container.list-area
14
+ = navigation_links('quick_links')
15
+ .results-action
16
+ .select
17
+ span.move-arrow
18
+ i.fa.fa-long-arrow-up
19
+ span.move-arrow
20
+ i.fa.fa-long-arrow-down
21
+ span Select
22
+ button.text-btn.enter-btn
23
+ | ENTER
24
+ button.text-btn.open-btn
25
+ | open
@@ -0,0 +1,41 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title
5
+ | Admin
6
+ meta[name="viewport" content="width=device-width,initial-scale=1"]
7
+ = csrf_meta_tags
8
+ = csp_meta_tag
9
+ = stylesheet_link_tag 'cm_admin/cm_admin', media: 'all', 'data-turbolinks-track': 'reload'
10
+ = stylesheet_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
11
+ link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" /
12
+ = javascript_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
13
+ script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"
14
+ script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"
15
+ body
16
+ - flash.each do |type, msg|
17
+ .alert class="alert-#{type}"
18
+ = msg
19
+ .cm-admin
20
+ = render 'layouts/left_sidebar_nav'
21
+ .panel-area
22
+ - if defined?(@action) && @action&.layout_type.to_s == 'cm_association_show'
23
+ .show-page.page-container
24
+ .show-page__tabs.sticky-container
25
+ .cm-tabs-bar
26
+ == render 'cm_admin/main/top_navbar'
27
+ == render 'cm_admin/main/tabs'
28
+ .show-page__inner.scrollable
29
+ = yield
30
+ - elsif defined?(@action) && @action&.layout_type.to_s == 'cm_association_index'
31
+ .show-page.page-container
32
+ .show-page__tabs.sticky-container
33
+ .cm-tabs-bar
34
+ == render 'cm_admin/main/top_navbar'
35
+ == render 'cm_admin/main/tabs'
36
+ - if @associated_model.filters.present?
37
+ .index-page__filters
38
+ == render partial: 'cm_admin/main/filters', locals: { filters: @associated_model.filters }
39
+ = yield
40
+ - else
41
+ = yield
@@ -0,0 +1,18 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title
5
+ | Admin
6
+ meta[name="viewport" content="width=device-width,initial-scale=1"]
7
+ = csrf_meta_tags
8
+ = csp_meta_tag
9
+ = stylesheet_link_tag 'cm_admin/cm_admin', media: 'all', 'data-turbolinks-track': 'reload'
10
+ = stylesheet_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
11
+ = javascript_pack_tag 'cm_admin/application', 'data-turbolinks-track': 'reload'
12
+ body
13
+ - flash.each do |type, msg|
14
+ .alert class="alert-#{type}"
15
+ = msg
16
+ .cm-admin-static
17
+ .d-flex.flex-column.h-100
18
+ = yield
data/bin/webpack ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/webpack_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::WebpackRunner.run(ARGV)
18
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= "development"
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "bundler/setup"
11
+
12
+ require "webpacker"
13
+ require "webpacker/dev_server_runner"
14
+
15
+ APP_ROOT = File.expand_path("..", __dir__)
16
+ Dir.chdir(APP_ROOT) do
17
+ Webpacker::DevServerRunner.run(ARGV)
18
+ end
data/cm_admin.gemspec CHANGED
@@ -1,44 +1,34 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "cm_admin/version"
1
+ require_relative 'lib/cm_admin/version'
5
2
 
6
3
  Gem::Specification.new do |spec|
7
4
  spec.name = "cm-admin"
8
5
  spec.version = CmAdmin::VERSION
9
- spec.date = '2020-05-08'
10
- spec.authors = ["Anbazhagan Palani"]
11
- spec.email = ["anbu@commutatus.com"]
6
+ spec.authors = ["sajinmp", "anbublacky", "manikandan0603"]
7
+ spec.email = ["sajinprasadkm@gmail.com", "anbublacky@gmail.com"]
12
8
 
13
- spec.summary = "Setup basic requied components for admin management."
9
+ spec.summary = %q{This is an admin panel gem}
10
+ spec.description = %q{This is an admin panel gem}
14
11
  spec.homepage = "https://github.com/commutatus/cm-admin"
15
12
  spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
16
14
 
17
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- end
15
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
16
 
21
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
22
- # to allow pushing to a single host or delete this section to allow pushing to any host.
23
- # if spec.respond_to?(:metadata)
24
- # spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
25
- #
26
- # spec.metadata["homepage_uri"] = spec.homepage
27
- # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
28
- # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
29
- # else
30
- # raise "RubyGems 2.0 or newer is required to protect against " \
31
- # "public gem pushes."
32
- # end
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/commutatus/cm-admin"
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
33
20
 
34
21
  # Specify which files should be added to the gem when it is released.
35
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
36
-
37
- # spec.bindir = "exe"
38
- # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
39
- # spec.require_paths = ["lib"]
40
-
41
- spec.add_development_dependency "bundler", "~> 2.0"
42
- spec.add_development_dependency "rake", "~> 10.0"
43
- spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+ spec.add_runtime_dependency 'pagy', '~> 4.11.0'
30
+ spec.add_runtime_dependency 'slim', '~> 4.1.0'
31
+ spec.add_runtime_dependency 'webpacker', '~> 5.2.1'
32
+ spec.add_runtime_dependency 'axlsx_rails', '~> 0.6.1'
33
+ spec.add_runtime_dependency 'cocoon', '~> 1.2.15'
44
34
  end
data/config/.DS_Store ADDED
Binary file
@@ -0,0 +1,9 @@
1
+ ActiveSupport.on_load(:active_record) do
2
+ module ActiveRecord
3
+ class Base
4
+ def self.cm_admin(&block)
5
+ CmAdmin.config(self, &block)
6
+ end
7
+ end
8
+ end
9
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,19 @@
1
+ CmAdmin::Engine.routes.draw do
2
+ controller 'static' do
3
+ get '/', action: 'dashboard'
4
+ get '/access-denied', action: 'error_403'
5
+ end
6
+
7
+ controller 'exports' do
8
+ post '/export_to_file', action: 'export'
9
+ end
10
+
11
+ # Defining action routes for each model
12
+ CmAdmin.cm_admin_models.each do |model|
13
+ model.available_actions.each do |act|
14
+ scope model.name.tableize do
15
+ send(act.verb, act.path.present? ? act.path : act.name, to: "#{model.name.underscore}##{act.name}")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,13 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ const webpack = require('webpack')
4
+ environment.plugins.prepend('Provide',
5
+ new webpack.ProvidePlugin({
6
+ $: 'jquery',
7
+ jQuery: 'jquery',
8
+ moment: 'moment',
9
+ Popper: ['popper.js', 'default']
10
+ })
11
+ )
12
+
13
+ module.exports = environment
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,5 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+
3
+ const environment = require('./environment')
4
+
5
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,92 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_root_path: public
7
+ public_output_path: cm-admin-packs
8
+ cache_path: tmp/cache/webpacker
9
+ webpack_compile_output: true
10
+
11
+ # Additional paths webpack should lookup modules
12
+ # ['app/assets', 'engine/foo/app/assets']
13
+ additional_paths: []
14
+
15
+ # Reload manifest.json on all requests so we reload latest compiled packs
16
+ cache_manifest: false
17
+
18
+ # Extract and emit a css file
19
+ extract_css: false
20
+
21
+ static_assets_extensions:
22
+ - .jpg
23
+ - .jpeg
24
+ - .png
25
+ - .gif
26
+ - .tiff
27
+ - .ico
28
+ - .svg
29
+ - .eot
30
+ - .otf
31
+ - .ttf
32
+ - .woff
33
+ - .woff2
34
+
35
+ extensions:
36
+ - .mjs
37
+ - .js
38
+ - .sass
39
+ - .scss
40
+ - .css
41
+ - .module.sass
42
+ - .module.scss
43
+ - .module.css
44
+ - .png
45
+ - .svg
46
+ - .gif
47
+ - .jpeg
48
+ - .jpg
49
+
50
+ development:
51
+ <<: *default
52
+ compile: true
53
+
54
+ # Reference: https://webpack.js.org/configuration/dev-server/
55
+ dev_server:
56
+ https: false
57
+ host: localhost
58
+ port: 3035
59
+ public: localhost:3035
60
+ hmr: false
61
+ # Inline should be set to true if using HMR
62
+ inline: true
63
+ overlay: true
64
+ compress: true
65
+ disable_host_check: true
66
+ use_local_ip: false
67
+ quiet: false
68
+ pretty: false
69
+ headers:
70
+ 'Access-Control-Allow-Origin': '*'
71
+ watch_options:
72
+ ignored: '**/node_modules/**'
73
+
74
+
75
+ test:
76
+ <<: *default
77
+ compile: true
78
+
79
+ # Compile test packs to a separate directory
80
+ public_output_path: packs-test
81
+
82
+ production:
83
+ <<: *default
84
+
85
+ # Production depends on precompilation of packs prior to booting for performance.
86
+ compile: false
87
+
88
+ # Extract and emit a css file
89
+ extract_css: true
90
+
91
+ # Cache manifest.json for performance
92
+ cache_manifest: true
@@ -0,0 +1,33 @@
1
+ module CmAdmin
2
+ DEFAULT_ACTIONS = {
3
+ index: {
4
+ verb: :get,
5
+ path: '/'
6
+ },
7
+ new: {
8
+ verb: :get,
9
+ path: 'new'
10
+ },
11
+ show: {
12
+ verb: :get,
13
+ path: ':id'
14
+ },
15
+ create: {
16
+ verb: :post,
17
+ path: '/'
18
+ },
19
+ edit: {
20
+ verb: :get,
21
+ path: ':id/edit'
22
+ },
23
+ update: {
24
+ verb: :patch,
25
+ path: ':id'
26
+ },
27
+ destroy: {
28
+ verb: :delete,
29
+ path: ':id'
30
+ }
31
+ }
32
+ REJECTABLE_FIELDS = %w(id created_at updated_at)
33
+ end
@@ -0,0 +1,38 @@
1
+ require 'rails'
2
+ module CmAdmin
3
+ class Engine < Rails::Engine
4
+ isolate_namespace CmAdmin
5
+
6
+ config.app_middleware.use(
7
+ Rack::Static,
8
+ # note! this varies from the webpacker/engine documentation
9
+ urls: ["/cm-admin-packs"], root: CmAdmin::Engine.root.join("public")
10
+ )
11
+
12
+ initializer 'RailsAdmin precompile hook', group: :all do |app|
13
+ app.config.assets.precompile += %w(
14
+ cm_admin/cm_admin.css
15
+ )
16
+ end
17
+
18
+ initializer "webpacker.proxy" do |app|
19
+ insert_middleware = begin
20
+ CmAdmin.webpacker.config.dev_server.present?
21
+ rescue
22
+ nil
23
+ end
24
+ next unless insert_middleware
25
+
26
+ app.middleware.insert_before(
27
+ 0, Webpacker::DevServerProxy, # "Webpacker::DevServerProxy" if Rails version < 5
28
+ ssl_verify_none: true,
29
+ webpacker: CmAdmin.webpacker
30
+ )
31
+ end
32
+
33
+ def mount_path
34
+ CmAdmin::Engine.routes.find_script_name({})
35
+ end
36
+
37
+ end
38
+ end