madmin 0.1.0 → 0.1.1

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 (164) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +7 -82
  4. data/Rakefile +1 -6
  5. data/app/assets/config/manifest.js +2 -0
  6. data/app/assets/stylesheets/actiontext.scss +36 -0
  7. data/app/assets/stylesheets/{madmin/application.css → application.css} +2 -9
  8. data/app/controllers/madmin/application_controller.rb +6 -10
  9. data/app/controllers/madmin/dashboard_controller.rb +1 -3
  10. data/app/controllers/madmin/resource_controller.rb +72 -0
  11. data/app/helpers/madmin/application_helper.rb +1 -11
  12. data/app/views/layouts/madmin/application.html.erb +25 -26
  13. data/app/views/madmin/application/_form.html.erb +25 -0
  14. data/app/views/madmin/application/_navigation.html.erb +6 -0
  15. data/app/views/madmin/application/edit.html.erb +3 -0
  16. data/app/views/madmin/application/index.html.erb +35 -0
  17. data/app/views/madmin/application/new.html.erb +3 -0
  18. data/app/views/madmin/application/show.html.erb +24 -0
  19. data/app/views/madmin/dashboard/show.html.erb +1 -0
  20. data/app/views/madmin/fields/attachment/_form.html.erb +2 -0
  21. data/app/views/madmin/fields/attachment/_index.html.erb +3 -0
  22. data/app/views/madmin/fields/attachment/_show.html.erb +3 -0
  23. data/app/views/madmin/fields/attachments/_form.html.erb +2 -0
  24. data/app/views/madmin/fields/attachments/_index.html.erb +1 -0
  25. data/app/views/madmin/fields/attachments/_show.html.erb +7 -0
  26. data/app/views/madmin/fields/belongs_to/_form.html.erb +2 -14
  27. data/app/views/madmin/fields/belongs_to/_index.html.erb +2 -7
  28. data/app/views/madmin/fields/belongs_to/_show.html.erb +2 -8
  29. data/app/views/madmin/fields/boolean/_form.html.erb +2 -0
  30. data/app/views/madmin/fields/boolean/_index.html.erb +1 -0
  31. data/app/views/madmin/fields/boolean/_show.html.erb +1 -0
  32. data/app/views/madmin/fields/date/_form.html.erb +2 -0
  33. data/app/views/madmin/fields/date/_index.html.erb +1 -0
  34. data/app/views/madmin/fields/date/_show.html.erb +1 -0
  35. data/app/views/madmin/fields/date_time/_form.html.erb +2 -0
  36. data/app/views/madmin/fields/date_time/_index.html.erb +1 -0
  37. data/app/views/madmin/fields/date_time/_show.html.erb +1 -0
  38. data/app/views/madmin/fields/enum/_form.html.erb +3 -0
  39. data/app/views/madmin/fields/enum/_index.html.erb +1 -0
  40. data/app/views/madmin/fields/enum/_show.html.erb +1 -0
  41. data/app/views/madmin/fields/float/_form.html.erb +2 -0
  42. data/app/views/madmin/fields/float/_index.html.erb +1 -0
  43. data/app/views/madmin/fields/float/_show.html.erb +1 -0
  44. data/app/views/madmin/fields/has_many/_form.html.erb +2 -0
  45. data/app/views/madmin/fields/has_many/_index.html.erb +1 -0
  46. data/app/views/madmin/fields/has_many/_show.html.erb +4 -14
  47. data/app/views/madmin/fields/has_one/_form.html.erb +3 -0
  48. data/app/views/madmin/fields/has_one/_index.html.erb +3 -0
  49. data/app/views/madmin/fields/has_one/_show.html.erb +3 -12
  50. data/app/views/madmin/fields/integer/_form.html.erb +2 -0
  51. data/app/views/madmin/fields/integer/_index.html.erb +1 -0
  52. data/app/views/madmin/fields/integer/_show.html.erb +1 -0
  53. data/app/views/madmin/fields/json/_form.html.erb +2 -0
  54. data/app/views/madmin/fields/json/_index.html.erb +1 -0
  55. data/app/views/madmin/fields/json/_show.html.erb +1 -0
  56. data/app/views/madmin/fields/polymorphic/_form.html.erb +5 -32
  57. data/app/views/madmin/fields/polymorphic/_index.html.erb +3 -1
  58. data/app/views/madmin/fields/polymorphic/_show.html.erb +3 -14
  59. data/app/views/madmin/fields/rich_text/_form.html.erb +4 -0
  60. data/app/views/madmin/fields/rich_text/_index.html.erb +1 -0
  61. data/app/views/madmin/fields/rich_text/_show.html.erb +3 -0
  62. data/app/views/madmin/fields/string/_form.html.erb +2 -0
  63. data/app/views/madmin/fields/string/_index.html.erb +1 -0
  64. data/app/views/madmin/fields/string/_show.html.erb +1 -0
  65. data/app/views/madmin/fields/text/_form.html.erb +2 -4
  66. data/app/views/madmin/fields/text/_index.html.erb +1 -1
  67. data/app/views/madmin/fields/text/_show.html.erb +1 -8
  68. data/app/views/madmin/fields/time/_form.html.erb +2 -0
  69. data/app/views/madmin/fields/time/_index.html.erb +1 -0
  70. data/app/views/madmin/fields/time/_show.html.erb +1 -0
  71. data/lib/generators/madmin/install/install_generator.rb +24 -12
  72. data/lib/generators/madmin/resource/resource_generator.rb +83 -47
  73. data/lib/generators/madmin/resource/templates/controller.rb.tt +4 -0
  74. data/lib/generators/madmin/resource/templates/resource.rb.tt +11 -0
  75. data/lib/madmin.rb +33 -23
  76. data/lib/madmin/engine.rb +5 -2
  77. data/lib/madmin/field.rb +18 -47
  78. data/lib/madmin/fields/attachment.rb +6 -0
  79. data/lib/madmin/fields/attachments.rb +9 -0
  80. data/lib/madmin/fields/belongs_to.rb +18 -0
  81. data/lib/madmin/fields/boolean.rb +6 -0
  82. data/lib/madmin/fields/date.rb +6 -0
  83. data/lib/madmin/fields/date_time.rb +6 -0
  84. data/lib/madmin/fields/enum.rb +6 -0
  85. data/lib/madmin/fields/float.rb +6 -0
  86. data/lib/madmin/fields/has_many.rb +18 -0
  87. data/lib/madmin/fields/has_one.rb +6 -0
  88. data/lib/madmin/fields/integer.rb +6 -0
  89. data/lib/madmin/fields/json.rb +6 -0
  90. data/lib/madmin/fields/polymorphic.rb +17 -0
  91. data/lib/madmin/fields/rich_text.rb +6 -0
  92. data/lib/madmin/fields/string.rb +6 -0
  93. data/lib/madmin/fields/text.rb +6 -0
  94. data/lib/madmin/fields/time.rb +6 -0
  95. data/lib/madmin/generator_helpers.rb +24 -0
  96. data/lib/madmin/resource.rb +125 -0
  97. data/lib/madmin/version.rb +1 -1
  98. data/lib/tasks/madmin_tasks.rake +7 -0
  99. metadata +90 -97
  100. data/app/assets/config/madmin_manifest.js +0 -2
  101. data/app/assets/javascripts/madmin/application.js +0 -15
  102. data/app/assets/javascripts/madmin/dashboard.js +0 -2
  103. data/app/assets/javascripts/madmin/resources.js +0 -36
  104. data/app/assets/stylesheets/madmin/dashboard.css +0 -4
  105. data/app/assets/stylesheets/madmin/resources.css +0 -4
  106. data/app/controllers/madmin/base_controller.rb +0 -16
  107. data/app/controllers/madmin/resources_controller.rb +0 -97
  108. data/app/decorators/madmin/resource_decorator.rb +0 -16
  109. data/app/helpers/madmin/fields/polymorphic_helper.rb +0 -25
  110. data/app/jobs/madmin/application_job.rb +0 -4
  111. data/app/mailers/madmin/application_mailer.rb +0 -6
  112. data/app/models/madmin/application_record.rb +0 -5
  113. data/app/views/application/_navigation.html.erb +0 -17
  114. data/app/views/madmin/dashboard/index.html.erb +0 -6
  115. data/app/views/madmin/fields/check_box/_form.html.erb +0 -4
  116. data/app/views/madmin/fields/check_box/_index.html.erb +0 -1
  117. data/app/views/madmin/fields/check_box/_show.html.erb +0 -8
  118. data/app/views/madmin/fields/email/_form.html.erb +0 -4
  119. data/app/views/madmin/fields/email/_index.html.erb +0 -1
  120. data/app/views/madmin/fields/email/_show.html.erb +0 -8
  121. data/app/views/madmin/fields/number/_form.html.erb +0 -4
  122. data/app/views/madmin/fields/number/_index.html.erb +0 -1
  123. data/app/views/madmin/fields/number/_show.html.erb +0 -8
  124. data/app/views/madmin/fields/password/_form.html.erb +0 -4
  125. data/app/views/madmin/fields/password/_index.html.erb +0 -1
  126. data/app/views/madmin/fields/password/_show.html.erb +0 -8
  127. data/app/views/madmin/fields/select/_form.html.erb +0 -4
  128. data/app/views/madmin/fields/select/_index.html.erb +0 -1
  129. data/app/views/madmin/fields/select/_show.html.erb +0 -8
  130. data/app/views/madmin/fields/text_area/_form.html.erb +0 -4
  131. data/app/views/madmin/fields/text_area/_index.html.erb +0 -1
  132. data/app/views/madmin/fields/text_area/_show.html.erb +0 -8
  133. data/app/views/madmin/resources/_form.html.erb +0 -15
  134. data/app/views/madmin/resources/_scopes.html.erb +0 -10
  135. data/app/views/madmin/resources/edit.html.erb +0 -2
  136. data/app/views/madmin/resources/index.html.erb +0 -13
  137. data/app/views/madmin/resources/index/_content.html.erb +0 -33
  138. data/app/views/madmin/resources/new.html.erb +0 -2
  139. data/app/views/madmin/resources/show.html.erb +0 -10
  140. data/config/routes.rb +0 -11
  141. data/lib/generators/madmin/controller/USAGE +0 -8
  142. data/lib/generators/madmin/controller/controller_generator.rb +0 -10
  143. data/lib/generators/madmin/page/USAGE +0 -8
  144. data/lib/generators/madmin/page/page_generator.rb +0 -20
  145. data/lib/generators/madmin/page/templates/template.html.erb +0 -2
  146. data/lib/generators/madmin/page/templates/template.rb.erb +0 -10
  147. data/lib/generators/madmin/resource/templates/resource.rb.erb +0 -11
  148. data/lib/generators/madmin/views/views_generator.rb +0 -15
  149. data/lib/madmin/field/associatable.rb +0 -58
  150. data/lib/madmin/field/belongs_to.rb +0 -9
  151. data/lib/madmin/field/check_box.rb +0 -8
  152. data/lib/madmin/field/date_time.rb +0 -8
  153. data/lib/madmin/field/email.rb +0 -8
  154. data/lib/madmin/field/has_many.rb +0 -9
  155. data/lib/madmin/field/has_one.rb +0 -9
  156. data/lib/madmin/field/number.rb +0 -8
  157. data/lib/madmin/field/password.rb +0 -8
  158. data/lib/madmin/field/polymorphic.rb +0 -57
  159. data/lib/madmin/field/select.rb +0 -13
  160. data/lib/madmin/field/text.rb +0 -8
  161. data/lib/madmin/field/text_area.rb +0 -8
  162. data/lib/madmin/resourceable.rb +0 -72
  163. data/lib/madmin/resourceable/class_methods.rb +0 -152
  164. data/lib/madmin/resources.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be4b01320deccbc46e6184ae804f74e278c909ec7b11f74274f09dc4442e78d4
4
- data.tar.gz: cdecb4f3ca23924befe03dc43ec4dda63626adabc24c70cbc892e3e21dd0ca62
3
+ metadata.gz: 3ae907c78952efd333b7151ef50818dc6b171017239a11152c129c17bb45af10
4
+ data.tar.gz: 923a8e6ecb3e84bffd6973a511845cc16cc599e36adc5116525ab01e46bc1c16
5
5
  SHA512:
6
- metadata.gz: 7f8691c029a1f37cf1b515c1ec399481d12ee2a4320c1e564f586e38b2d7e12610796df1c3b391356496dfca4c6b1d156b5459850873dd6bda54940e69a2f951
7
- data.tar.gz: 36e1b5138b977c5a7bb46b7e1a96078c645c204865de2df919fdef9909c4ac9ba6930b18ad905ca6489ff6e8b11656776561aa1c424b38d79ba3e9db3beee204
6
+ metadata.gz: c696a1782666fdcc4a113d7709775c41e245a9f92ef298c93a6fb98a1c1f2db4f5a34f36d59a1c3da476a6db44bfcc864f5b37c8136ef8f8a155415344b74660
7
+ data.tar.gz: d7eef669f0b0366ccaf73f3cd68f85525067172ade70c55397b9cd27e7132c3008a067d68d5bc3d073e94441f1cbf8a9e893a11a2b91fbfd0dbdd6a695487230
@@ -1,4 +1,4 @@
1
- Copyright 2019 Jason Charnes
1
+ Copyright 2020 Chris Oliver
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,102 +1,27 @@
1
1
  # Madmin
2
2
 
3
- Short description and motivation.
3
+ ### A robust admin interface for Ruby on Rails apps
4
4
 
5
- ## Usage
5
+ [![Build Status](https://github.com/excid3/madmin/workflows/Tests/badge.svg)](https://github.com/excid3/madmin/actions) [![Gem Version](https://badge.fury.io/rb/madmin.svg)](https://badge.fury.io/rb/madmin)
6
6
 
7
+ ## Usage
7
8
  How to use my plugin.
8
9
 
9
10
  ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'madmin'
15
- ```
16
-
17
- And then execute:
18
-
19
- ```bash
20
- $ bundle
21
- ```
22
-
23
- Or install it yourself as:
24
-
25
- ```bash
26
- $ gem install madmin
27
- ```
28
-
29
- Then you can run the installer to generate resources for all models in
30
- your app that inherit from `ActiveRecord::Base` by running:
31
-
32
- ```bash
33
- rails generate madmin:install
34
- ```
35
-
36
- ## Generating Resources
37
-
38
- To generate (or re-generate) a Madmin dashboard for a resource, you
39
- can run the following command and pass in the model name
11
+ Add `madmin` to your application's Gemfile:
40
12
 
41
13
  ```bash
42
- rails generate madmin:install User
14
+ bundle add madmin
43
15
  ```
44
16
 
45
- ## Implementing Authentication
46
-
47
- To implement user authentication for your admin dashboard, you can override `authenticate!` in `app/controllers/madmin/application_controller.rb`.
48
-
49
- To access this controller run the following command
17
+ Then run the madmin generator:
50
18
 
51
19
  ```bash
52
- rails generate madmin:controller Application
53
- ```
54
-
55
- If you're using Devise, simply have `authenticate!` authenticate your resource
56
-
57
- ```ruby
58
- class Madmin::ApplicationController < Madmin::BaseController
59
- ...
60
-
61
- private
62
-
63
- def authenticate!
64
- authenticate_user!
65
- end
66
- end
67
- ```
68
-
69
- If you're wanting to use simple HTTP Basic authentication, have `authenticate!` use `authenticate_with_http_basic` like the following
70
-
71
- ```ruby
72
- class Madmin::ApplicationController < Madmin::BaseController
73
- ...
74
-
75
- private
76
-
77
- def authenticate!
78
- authenticated = authenticate_with_http_basic { |user, password|
79
- user == "user" && password == "password"
80
- }
81
-
82
- request_http_basic_authentication unless authenticated
83
- end
84
- end
85
- ```
86
-
87
- ## Autoloading Lib
88
-
89
- If you want to avoid having to restart your Rails application everytime you make an adjustment to a `lib/madmin/resources.rb`, add the following to `config/application.rb`:
90
-
91
- ```ruby
92
- # Autoload Madmin
93
- config.autoload_paths += Dir["#{config.root}/lib/madmin/**/"]
20
+ rails g madmin:install
94
21
  ```
95
22
 
96
23
  ## Contributing
97
-
98
24
  Contribution directions go here.
99
25
 
100
26
  ## License
101
-
102
27
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -8,17 +8,12 @@ require "rdoc/task"
8
8
 
9
9
  RDoc::Task.new(:rdoc) do |rdoc|
10
10
  rdoc.rdoc_dir = "rdoc"
11
- rdoc.title = "Madmin"
11
+ rdoc.title = "Madmin"
12
12
  rdoc.options << "--line-numbers"
13
13
  rdoc.rdoc_files.include("README.md")
14
14
  rdoc.rdoc_files.include("lib/**/*.rb")
15
15
  end
16
16
 
17
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
- load "rails/tasks/engine.rake"
19
-
20
- load "rails/tasks/statistics.rake"
21
-
22
17
  require "bundler/gem_tasks"
23
18
 
24
19
  require "rake/testtask"
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,36 @@
1
+ //
2
+ // Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
3
+ // the trix-editor content (whether displayed or under editing). Feel free to incorporate this
4
+ // inclusion directly in any other asset bundle and remove this file.
5
+ //
6
+ //= require trix/dist/trix
7
+
8
+ // We need to override trix.css’s image gallery styles to accommodate the
9
+ // <action-text-attachment> element we wrap around attachments. Otherwise,
10
+ // images in galleries will be squished by the max-width: 33%; rule.
11
+ .trix-content {
12
+ .attachment-gallery {
13
+ > action-text-attachment,
14
+ > .attachment {
15
+ flex: 1 0 33%;
16
+ padding: 0 0.5em;
17
+ max-width: 33%;
18
+ }
19
+
20
+ &.attachment-gallery--2,
21
+ &.attachment-gallery--4 {
22
+ > action-text-attachment,
23
+ > .attachment {
24
+ flex-basis: 50%;
25
+ max-width: 50%;
26
+ }
27
+ }
28
+ }
29
+
30
+ action-text-attachment {
31
+ .attachment {
32
+ padding: 0 !important;
33
+ max-width: 100% !important;
34
+ }
35
+ }
36
+ }
@@ -2,8 +2,8 @@
2
2
  * This is a manifest file that'll be compiled into application.css, which will include all the files
3
3
  * listed below.
4
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.
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
7
  *
8
8
  * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
9
  * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
@@ -13,10 +13,3 @@
13
13
  *= require_tree .
14
14
  *= require_self
15
15
  */
16
-
17
- .sidebar {
18
- height: 100%;
19
- left: 0;
20
- position: fixed;
21
- top: 0;
22
- }
@@ -1,16 +1,12 @@
1
1
  module Madmin
2
- class ApplicationController < BaseController
3
- protect_from_forgery with: :exception
4
-
5
- before_action :authenticate!
2
+ class ApplicationController < ActionController::Base
3
+ include Pagy::Backend
6
4
 
7
- private
5
+ protect_from_forgery with: :exception
8
6
 
9
- def authenticate!
10
- # redirect_to x_path unless current_user
11
- #
12
- # If using Devise, set this method to call:
13
- # authenticate_user!
7
+ # Loads all the models for the sidebar
8
+ before_action do
9
+ Rails.application.eager_load!
14
10
  end
15
11
  end
16
12
  end
@@ -1,8 +1,6 @@
1
- require_dependency "madmin/application_controller"
2
-
3
1
  module Madmin
4
2
  class DashboardController < ApplicationController
5
- def index
3
+ def show
6
4
  end
7
5
  end
8
6
  end
@@ -0,0 +1,72 @@
1
+ module Madmin
2
+ class ResourceController < ApplicationController
3
+ before_action :set_record, except: [:index, :new, :create]
4
+
5
+ def index
6
+ @pagy, @records = pagy(resource.model.all)
7
+ end
8
+
9
+ def show
10
+ end
11
+
12
+ def new
13
+ @record = resource.model.new
14
+ end
15
+
16
+ def create
17
+ @record = resource.model.new(resource_params)
18
+ if @record.save
19
+ redirect_to resource.show_path(@record)
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def edit
26
+ end
27
+
28
+ def update
29
+ if @record.update(resource_params)
30
+ redirect_to resource.show_path(@record)
31
+ else
32
+ render :edit
33
+ end
34
+ end
35
+
36
+ def destroy
37
+ @record.destroy
38
+ redirect_to resource.index_path
39
+ end
40
+
41
+ private
42
+
43
+ def set_record
44
+ @record = resource.model.find(params[:id])
45
+ end
46
+
47
+ def resource
48
+ @resource ||= resource_name.constantize
49
+ end
50
+ helper_method :resource
51
+
52
+ def resource_name
53
+ "#{controller_path.singularize}_resource".delete_prefix("madmin/").classify
54
+ end
55
+
56
+ def resource_params
57
+ params.require(resource.param_key)
58
+ .permit(*resource.permitted_params)
59
+ .transform_values { |v| change_polymorphic(v) }
60
+ end
61
+
62
+ def change_polymorphic(data)
63
+ return data unless data.is_a?(ActionController::Parameters) && data[:type]
64
+
65
+ if data[:type] == "polymorphic"
66
+ GlobalID::Locator.locate(data[:value])
67
+ else
68
+ raise "Unrecognised param data: #{data.inspect}"
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,15 +1,5 @@
1
1
  module Madmin
2
2
  module ApplicationHelper
3
- def available_resources
4
- @available_resources ||= Madmin::Resources.gather.map { |model| madmin_resource_for(model: model) }
5
- end
6
-
7
- def madmin_resource_for(model:)
8
- Object.const_get("::Madmin::Resources::#{model}").new
9
- end
10
-
11
- def pages
12
- Madmin::Pages.all
13
- end
3
+ include Pagy::Frontend
14
4
  end
15
5
  end
@@ -1,30 +1,29 @@
1
1
  <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Madmin</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
9
-
10
- <%= stylesheet_link_tag "madmin/application", media: "all" %>
11
- </head>
12
- <body>
13
- <div class="container-fluid">
14
- <div class="row">
15
- <%= render 'application/navigation' %>
16
- <div class="col-10 ml-sm-auto mt-4">
17
- <div class="container">
18
- <%= yield %>
19
- </div>
2
+ <html lang="<%= I18n.locale %>">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="ROBOTS" content="NOODP">
6
+ <meta name="viewport" content="initial-scale=1">
7
+ <title>
8
+ Madmin: <%= Rails.application.class %>
9
+ </title>
10
+ <link href="https://unpkg.com/tailwindcss@^2.0/dist/tailwind.min.css" rel="stylesheet" />
11
+ <link href="https://unpkg.com/@tailwindcss/forms/dist/forms.min.css" rel="stylesheet" />
12
+ <link href="https://unpkg.com/@tailwindcss/typography/dist/typography.min.css" rel="stylesheet" />
13
+ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
14
+ <%= javascript_pack_tag "madmin", "data-turbo-track": "reload" %>
15
+ <%= csrf_meta_tags %>
16
+ </head>
17
+ <body class="prose" style="max-width:none">
18
+ <div class="flex w-full p-4">
19
+ <div id="sidebar" class="w-64 flex-shrink-0">
20
+ <%= render "navigation" -%>
20
21
  </div>
22
+ <main class="w-full" role="main">
23
+ <%#= render "flashes" -%>
24
+ <%= yield %>
25
+ </main>
21
26
  </div>
22
- </div>
23
-
24
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
25
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
26
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
27
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
28
- <%= javascript_include_tag "madmin/application" %>
29
- </body>
27
+ <%#= render "javascript" %>
28
+ </body>
30
29
  </html>
@@ -0,0 +1,25 @@
1
+ <%= form_with model: [:madmin, record], url: (record.persisted? ? resource.show_path(record) : resource.index_path), local: true do |form| %>
2
+ <% if form.object.errors.any? %>
3
+ <div class="mb-4 rounded-md text-sm text-red-700 bg-red-100 p-4">
4
+ <div class="mb-2 font-medium leading-5 text-red-800">There was <%= pluralize form.object.errors.full_messages.count, "error" %> with your submission</div>
5
+
6
+ <% form.object.errors.full_messages.each do |message| %>
7
+ <div class="ml-4"><%= message %></div>
8
+ <% end %>
9
+ </div>
10
+ <% end %>
11
+
12
+ <% resource.attributes.each do |attribute| %>
13
+ <% next if attribute[:field].nil? %>
14
+ <% next unless attribute[:field].visible?(action_name) %>
15
+ <% next unless attribute[:field].visible?(:form) %>
16
+
17
+ <% field = attribute[:field] %>
18
+
19
+ <div class="mb-4 flex">
20
+ <%= render partial: field.to_partial_path("form"), locals: { field: field, record: record, form: form, resource: resource } %>
21
+ </div>
22
+ <% end %>
23
+
24
+ <%= form.submit class: "bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 px-4 border border-gray-400 rounded shadow" %>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div class="text-sm">
2
+ <%= link_to "← Back to App", main_app.root_url, class: "block p-1" if main_app.respond_to?(:root_url) %>
3
+ <% Madmin.resources.each do |resource| %>
4
+ <%= link_to resource.friendly_name.pluralize, resource.index_path, class: "block p-1" %>
5
+ <% end %>
6
+ </div>
@@ -0,0 +1,3 @@
1
+ <h1><%= link_to resource.friendly_name.pluralize, resource.index_path %> / Edit <%= resource.friendly_name %> #<%= @record.id %></h1>
2
+
3
+ <%= render partial: "form", locals: { record: @record, resource: resource } %>
@@ -0,0 +1,35 @@
1
+ <h1><%= resource.friendly_name.pluralize %></h1>
2
+ <%= link_to "New #{resource.friendly_name}", resource.new_path %>
3
+
4
+ <table class="table-auto">
5
+ <thead>
6
+ <tr>
7
+ <% resource.attributes.each do |attribute| %>
8
+ <% next if attribute[:field].nil? %>
9
+ <% next unless attribute[:field].visible?(action_name) %>
10
+
11
+ <th><%= attribute[:name].to_s.titleize %></th>
12
+ <% end %>
13
+ <th>Actions</th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @records.each do |record| %>
19
+ <tr>
20
+ <% resource.attributes.each do |attribute| %>
21
+ <% next if attribute[:field].nil? %>
22
+ <% next unless attribute[:field].visible?(action_name) %>
23
+
24
+ <% field = attribute[:field] %>
25
+
26
+ <td><%= render partial: field.to_partial_path("index"), locals: { field: field, record: record } %></td>
27
+ <% end %>
28
+
29
+ <td><%= link_to "View", resource.show_path(record) %></td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+
35
+ <%== pagy_nav(@pagy) if @pagy.pages > 1 %>