madmin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -2,3 +2,10 @@
2
2
  # task :madmin do
3
3
  # # Task goes here
4
4
  # end
5
+
6
+ namespace :madmin do
7
+ desc "Installs madmin into your app"
8
+ task :install do
9
+ system("#{RbConfig.ruby} ./bin/rails generate madmin:install")
10
+ end
11
+ end
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Jason Charnes
8
7
  - Chris Oliver
9
- - Andrew Fomera
8
+ - Andrea Fomera
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2019-10-18 00:00:00.000000000 Z
12
+ date: 2021-01-15 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rails
@@ -18,44 +17,36 @@ dependencies:
18
17
  requirements:
19
18
  - - ">="
20
19
  - !ruby/object:Gem::Version
21
- version: '5.2'
20
+ version: 6.0.3
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
25
  - - ">="
27
26
  - !ruby/object:Gem::Version
28
- version: '5.2'
27
+ version: 6.0.3
29
28
  - !ruby/object:Gem::Dependency
30
- name: pry-rails
29
+ name: pagy
31
30
  requirement: !ruby/object:Gem::Requirement
32
31
  requirements:
33
32
  - - ">="
34
33
  - !ruby/object:Gem::Version
35
- version: '0'
36
- type: :development
34
+ version: '3.5'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '4.0'
38
+ type: :runtime
37
39
  prerelease: false
38
40
  version_requirements: !ruby/object:Gem::Requirement
39
41
  requirements:
40
42
  - - ">="
41
43
  - !ruby/object:Gem::Version
42
- version: '0'
43
- - !ruby/object:Gem::Dependency
44
- name: sqlite3
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: 1.3.6
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
44
+ version: '3.5'
45
+ - - "<"
55
46
  - !ruby/object:Gem::Version
56
- version: 1.3.6
47
+ version: '4.0'
57
48
  - !ruby/object:Gem::Dependency
58
- name: standardrb
49
+ name: sqlite3
59
50
  requirement: !ruby/object:Gem::Requirement
60
51
  requirements:
61
52
  - - ">="
@@ -68,11 +59,10 @@ dependencies:
68
59
  - - ">="
69
60
  - !ruby/object:Gem::Version
70
61
  version: '0'
71
- description: Administration for Rails
62
+ description: It's an admin, obviously.
72
63
  email:
73
- - jason@thecharnes.com
74
64
  - excid3@gmail.com
75
- - andrew@zerlex.net
65
+ - afomera@hey.com
76
66
  executables: []
77
67
  extensions: []
78
68
  extra_rdoc_files: []
@@ -80,98 +70,101 @@ files:
80
70
  - MIT-LICENSE
81
71
  - README.md
82
72
  - Rakefile
83
- - app/assets/config/madmin_manifest.js
84
- - app/assets/javascripts/madmin/application.js
85
- - app/assets/javascripts/madmin/dashboard.js
86
- - app/assets/javascripts/madmin/resources.js
87
- - app/assets/stylesheets/madmin/application.css
88
- - app/assets/stylesheets/madmin/dashboard.css
89
- - app/assets/stylesheets/madmin/resources.css
73
+ - app/assets/config/manifest.js
74
+ - app/assets/stylesheets/actiontext.scss
75
+ - app/assets/stylesheets/application.css
90
76
  - app/controllers/madmin/application_controller.rb
91
- - app/controllers/madmin/base_controller.rb
92
77
  - app/controllers/madmin/dashboard_controller.rb
93
- - app/controllers/madmin/resources_controller.rb
94
- - app/decorators/madmin/resource_decorator.rb
78
+ - app/controllers/madmin/resource_controller.rb
95
79
  - app/helpers/madmin/application_helper.rb
96
- - app/helpers/madmin/fields/polymorphic_helper.rb
97
- - app/jobs/madmin/application_job.rb
98
- - app/mailers/madmin/application_mailer.rb
99
- - app/models/madmin/application_record.rb
100
- - app/views/application/_navigation.html.erb
101
80
  - app/views/layouts/madmin/application.html.erb
102
- - app/views/madmin/dashboard/index.html.erb
81
+ - app/views/madmin/application/_form.html.erb
82
+ - app/views/madmin/application/_navigation.html.erb
83
+ - app/views/madmin/application/edit.html.erb
84
+ - app/views/madmin/application/index.html.erb
85
+ - app/views/madmin/application/new.html.erb
86
+ - app/views/madmin/application/show.html.erb
87
+ - app/views/madmin/dashboard/show.html.erb
88
+ - app/views/madmin/fields/attachment/_form.html.erb
89
+ - app/views/madmin/fields/attachment/_index.html.erb
90
+ - app/views/madmin/fields/attachment/_show.html.erb
91
+ - app/views/madmin/fields/attachments/_form.html.erb
92
+ - app/views/madmin/fields/attachments/_index.html.erb
93
+ - app/views/madmin/fields/attachments/_show.html.erb
103
94
  - app/views/madmin/fields/belongs_to/_form.html.erb
104
95
  - app/views/madmin/fields/belongs_to/_index.html.erb
105
96
  - app/views/madmin/fields/belongs_to/_show.html.erb
106
- - app/views/madmin/fields/check_box/_form.html.erb
107
- - app/views/madmin/fields/check_box/_index.html.erb
108
- - app/views/madmin/fields/check_box/_show.html.erb
109
- - app/views/madmin/fields/email/_form.html.erb
110
- - app/views/madmin/fields/email/_index.html.erb
111
- - app/views/madmin/fields/email/_show.html.erb
97
+ - app/views/madmin/fields/boolean/_form.html.erb
98
+ - app/views/madmin/fields/boolean/_index.html.erb
99
+ - app/views/madmin/fields/boolean/_show.html.erb
100
+ - app/views/madmin/fields/date/_form.html.erb
101
+ - app/views/madmin/fields/date/_index.html.erb
102
+ - app/views/madmin/fields/date/_show.html.erb
103
+ - app/views/madmin/fields/date_time/_form.html.erb
104
+ - app/views/madmin/fields/date_time/_index.html.erb
105
+ - app/views/madmin/fields/date_time/_show.html.erb
106
+ - app/views/madmin/fields/enum/_form.html.erb
107
+ - app/views/madmin/fields/enum/_index.html.erb
108
+ - app/views/madmin/fields/enum/_show.html.erb
109
+ - app/views/madmin/fields/float/_form.html.erb
110
+ - app/views/madmin/fields/float/_index.html.erb
111
+ - app/views/madmin/fields/float/_show.html.erb
112
112
  - app/views/madmin/fields/has_many/_form.html.erb
113
+ - app/views/madmin/fields/has_many/_index.html.erb
113
114
  - app/views/madmin/fields/has_many/_show.html.erb
114
115
  - app/views/madmin/fields/has_one/_form.html.erb
116
+ - app/views/madmin/fields/has_one/_index.html.erb
115
117
  - app/views/madmin/fields/has_one/_show.html.erb
116
- - app/views/madmin/fields/number/_form.html.erb
117
- - app/views/madmin/fields/number/_index.html.erb
118
- - app/views/madmin/fields/number/_show.html.erb
119
- - app/views/madmin/fields/password/_form.html.erb
120
- - app/views/madmin/fields/password/_index.html.erb
121
- - app/views/madmin/fields/password/_show.html.erb
118
+ - app/views/madmin/fields/integer/_form.html.erb
119
+ - app/views/madmin/fields/integer/_index.html.erb
120
+ - app/views/madmin/fields/integer/_show.html.erb
121
+ - app/views/madmin/fields/json/_form.html.erb
122
+ - app/views/madmin/fields/json/_index.html.erb
123
+ - app/views/madmin/fields/json/_show.html.erb
122
124
  - app/views/madmin/fields/polymorphic/_form.html.erb
123
125
  - app/views/madmin/fields/polymorphic/_index.html.erb
124
126
  - app/views/madmin/fields/polymorphic/_show.html.erb
125
- - app/views/madmin/fields/select/_form.html.erb
126
- - app/views/madmin/fields/select/_index.html.erb
127
- - app/views/madmin/fields/select/_show.html.erb
127
+ - app/views/madmin/fields/rich_text/_form.html.erb
128
+ - app/views/madmin/fields/rich_text/_index.html.erb
129
+ - app/views/madmin/fields/rich_text/_show.html.erb
130
+ - app/views/madmin/fields/string/_form.html.erb
131
+ - app/views/madmin/fields/string/_index.html.erb
132
+ - app/views/madmin/fields/string/_show.html.erb
128
133
  - app/views/madmin/fields/text/_form.html.erb
129
134
  - app/views/madmin/fields/text/_index.html.erb
130
135
  - app/views/madmin/fields/text/_show.html.erb
131
- - app/views/madmin/fields/text_area/_form.html.erb
132
- - app/views/madmin/fields/text_area/_index.html.erb
133
- - app/views/madmin/fields/text_area/_show.html.erb
134
- - app/views/madmin/resources/_form.html.erb
135
- - app/views/madmin/resources/_scopes.html.erb
136
- - app/views/madmin/resources/edit.html.erb
137
- - app/views/madmin/resources/index.html.erb
138
- - app/views/madmin/resources/index/_content.html.erb
139
- - app/views/madmin/resources/new.html.erb
140
- - app/views/madmin/resources/show.html.erb
141
- - config/routes.rb
142
- - lib/generators/madmin/controller/USAGE
143
- - lib/generators/madmin/controller/controller_generator.rb
136
+ - app/views/madmin/fields/time/_form.html.erb
137
+ - app/views/madmin/fields/time/_index.html.erb
138
+ - app/views/madmin/fields/time/_show.html.erb
144
139
  - lib/generators/madmin/install/install_generator.rb
145
- - lib/generators/madmin/page/USAGE
146
- - lib/generators/madmin/page/page_generator.rb
147
- - lib/generators/madmin/page/templates/template.html.erb
148
- - lib/generators/madmin/page/templates/template.rb.erb
149
140
  - lib/generators/madmin/resource/resource_generator.rb
150
- - lib/generators/madmin/resource/templates/resource.rb.erb
151
- - lib/generators/madmin/views/views_generator.rb
141
+ - lib/generators/madmin/resource/templates/controller.rb.tt
142
+ - lib/generators/madmin/resource/templates/resource.rb.tt
152
143
  - lib/madmin.rb
153
144
  - lib/madmin/engine.rb
154
145
  - lib/madmin/field.rb
155
- - lib/madmin/field/associatable.rb
156
- - lib/madmin/field/belongs_to.rb
157
- - lib/madmin/field/check_box.rb
158
- - lib/madmin/field/date_time.rb
159
- - lib/madmin/field/email.rb
160
- - lib/madmin/field/has_many.rb
161
- - lib/madmin/field/has_one.rb
162
- - lib/madmin/field/number.rb
163
- - lib/madmin/field/password.rb
164
- - lib/madmin/field/polymorphic.rb
165
- - lib/madmin/field/select.rb
166
- - lib/madmin/field/text.rb
167
- - lib/madmin/field/text_area.rb
146
+ - lib/madmin/fields/attachment.rb
147
+ - lib/madmin/fields/attachments.rb
148
+ - lib/madmin/fields/belongs_to.rb
149
+ - lib/madmin/fields/boolean.rb
150
+ - lib/madmin/fields/date.rb
151
+ - lib/madmin/fields/date_time.rb
152
+ - lib/madmin/fields/enum.rb
153
+ - lib/madmin/fields/float.rb
154
+ - lib/madmin/fields/has_many.rb
155
+ - lib/madmin/fields/has_one.rb
156
+ - lib/madmin/fields/integer.rb
157
+ - lib/madmin/fields/json.rb
158
+ - lib/madmin/fields/polymorphic.rb
159
+ - lib/madmin/fields/rich_text.rb
160
+ - lib/madmin/fields/string.rb
161
+ - lib/madmin/fields/text.rb
162
+ - lib/madmin/fields/time.rb
168
163
  - lib/madmin/generator_helpers.rb
169
- - lib/madmin/resourceable.rb
170
- - lib/madmin/resourceable/class_methods.rb
171
- - lib/madmin/resources.rb
164
+ - lib/madmin/resource.rb
172
165
  - lib/madmin/version.rb
173
166
  - lib/tasks/madmin_tasks.rake
174
- homepage: https://madmin.jasoncharnes.com
167
+ homepage: https://github.com/excid3/madmin
175
168
  licenses:
176
169
  - MIT
177
170
  metadata: {}
@@ -183,15 +176,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
176
  requirements:
184
177
  - - ">="
185
178
  - !ruby/object:Gem::Version
186
- version: '0'
179
+ version: 2.5.0
187
180
  required_rubygems_version: !ruby/object:Gem::Requirement
188
181
  requirements:
189
182
  - - ">="
190
183
  - !ruby/object:Gem::Version
191
184
  version: '0'
192
185
  requirements: []
193
- rubygems_version: 3.0.6
186
+ rubygems_version: 3.1.4
194
187
  signing_key:
195
188
  specification_version: 4
196
- summary: Administration for Rails
189
+ summary: A modern admin for Ruby on Rails apps
197
190
  test_files: []
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts/madmin .js
2
- //= link_directory ../stylesheets/madmin .css
@@ -1,15 +0,0 @@
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_tree .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,36 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
3
-
4
- var updateResourceOptions = function(polymorphicField) {
5
- var idField = document.getElementById("commentable_id");
6
- var slug =
7
- polymorphicField.options[polymorphicField.selectedIndex].dataset.slug;
8
-
9
- idField.options.length = 0;
10
-
11
- if (!slug) {
12
- idField.classList.add("d-none");
13
- return;
14
- }
15
-
16
- axios.get("/madmin/" + slug + ".json").then(function(response) {
17
- response.data.forEach(function(resource) {
18
- var option = document.createElement("option");
19
- option.text = resource.display_value;
20
- option.value = resource.id;
21
- idField.add(option);
22
- });
23
-
24
- idField.classList.remove("d-none");
25
- });
26
- };
27
-
28
- if (window.polymorphicFields) {
29
- window.polymorphicFields.forEach(function(field) {
30
- var polymorphicField = document.getElementById(field + "_type");
31
-
32
- polymorphicField.addEventListener("change", function() {
33
- updateResourceOptions(polymorphicField);
34
- });
35
- });
36
- }
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,16 +0,0 @@
1
- require_dependency "madmin/resources"
2
-
3
- module Madmin
4
- class BaseController < ActionController::Base
5
- before_action :validate_resources
6
-
7
- private
8
-
9
- # Taking a peek at all the resources will raise an error if one isn't found.
10
- # Let's inform the user if we can't find a resource no matter what page
11
- # they're on. This should fail to prevent surprises at run time.
12
- def validate_resources
13
- Madmin::Resources.all
14
- end
15
- end
16
- end
@@ -1,97 +0,0 @@
1
- require_dependency "madmin/application_controller"
2
-
3
- module Madmin
4
- class ResourcesController < ApplicationController
5
- include ActiveSupport::Inflector
6
-
7
- before_action :find_resource, only: [:show, :edit, :update, :destroy]
8
-
9
- helper_method :madmin_resource
10
-
11
- def index
12
- @scopes = madmin_resource.scopes
13
- @headers = madmin_resource.index_headers
14
-
15
- if params[:scope]&.to_sym&.in?(@scopes)
16
- begin
17
- @collection = resource.send(params[:scope])
18
- rescue ArgumentError
19
- raise ScopeWithArgumentsError, "The scope #{params[:scope.to_sym]} on #{resource.name} takes arguments, which are currently unsupported."
20
- end
21
- else
22
- @collection = resource.all
23
- end
24
-
25
- respond_to do |format|
26
- format.html
27
- format.json { render json: @collection.map { |c| {id: c.id, display_value: c.title} } }
28
- end
29
- end
30
-
31
- def show
32
- end
33
-
34
- def new
35
- @resource = ResourceDecorator.new(resource.new(resource_params))
36
- end
37
-
38
- def create
39
- @resource = ResourceDecorator.new(resource.new(resource_params))
40
-
41
- if @resource.save
42
- redirect_to resource_path(id: @resource.id)
43
- else
44
- render :new
45
- end
46
- end
47
-
48
- def edit
49
- end
50
-
51
- def update
52
- if @resource.update(resource_params)
53
- redirect_to resource_path(id: @resource.id)
54
- else
55
- render :edit
56
- end
57
- end
58
-
59
- def destroy
60
- if @resource.destroy
61
- redirect_to resources_path(params[:resource])
62
- else
63
- flash[:error] = "There was an issue deleting the record."
64
- redirect_to :back
65
- end
66
- end
67
-
68
- private
69
-
70
- def find_resource
71
- @resource ||= Madmin::ResourceDecorator.new(resource.find(params[:id]))
72
- end
73
-
74
- def form_keys
75
- madmin_resource.form_fields.map { |field| field.strong_params_keys }.flatten
76
- end
77
-
78
- def madmin_resource
79
- Object.const_get("::Madmin::Resources::#{resource_name}").new
80
- end
81
-
82
- def resource
83
- Object.const_get(resource_name)
84
- end
85
-
86
- def resource_name
87
- camelize(params[:resource].singularize)
88
- end
89
-
90
- def resource_params
91
- param_key = resource_name.downcase.to_sym
92
- return unless params.dig(param_key)
93
-
94
- params.require(param_key).permit(form_keys)
95
- end
96
- end
97
- end