madmin 1.0.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -1
  3. data/app/controllers/madmin/base_controller.rb +0 -5
  4. data/app/controllers/madmin/resource_controller.rb +23 -2
  5. data/app/helpers/madmin/application_helper.rb +4 -0
  6. data/app/helpers/madmin/nav_helper.rb +30 -0
  7. data/app/helpers/madmin/sort_helper.rb +32 -0
  8. data/app/views/layouts/madmin/application.html.erb +5 -5
  9. data/app/views/madmin/application/_form.html.erb +6 -8
  10. data/app/views/madmin/application/_javascript.html.erb +73 -7
  11. data/app/views/madmin/application/_navigation.html.erb +31 -5
  12. data/app/views/madmin/application/edit.html.erb +5 -1
  13. data/app/views/madmin/application/index.html.erb +34 -22
  14. data/app/views/madmin/application/new.html.erb +5 -1
  15. data/app/views/madmin/application/show.html.erb +24 -17
  16. data/app/views/madmin/fields/attachment/_form.html.erb +3 -1
  17. data/app/views/madmin/fields/attachment/_show.html.erb +7 -1
  18. data/app/views/madmin/fields/attachments/_form.html.erb +3 -1
  19. data/app/views/madmin/fields/attachments/_show.html.erb +7 -3
  20. data/app/views/madmin/fields/belongs_to/_form.html.erb +4 -2
  21. data/app/views/madmin/fields/belongs_to/_show.html.erb +1 -1
  22. data/app/views/madmin/fields/boolean/_form.html.erb +3 -1
  23. data/app/views/madmin/fields/date/_form.html.erb +3 -1
  24. data/app/views/madmin/fields/date_time/_form.html.erb +3 -1
  25. data/app/views/madmin/fields/decimal/_form.html.erb +3 -1
  26. data/app/views/madmin/fields/enum/_form.html.erb +4 -2
  27. data/app/views/madmin/fields/float/_form.html.erb +3 -1
  28. data/app/views/madmin/fields/has_many/_form.html.erb +4 -2
  29. data/app/views/madmin/fields/has_many/_show.html.erb +1 -1
  30. data/app/views/madmin/fields/has_one/_form.html.erb +3 -2
  31. data/app/views/madmin/fields/integer/_form.html.erb +3 -1
  32. data/app/views/madmin/fields/json/_form.html.erb +3 -1
  33. data/app/views/madmin/fields/nested_has_many/_fields.html.erb +18 -0
  34. data/app/views/madmin/fields/nested_has_many/_form.html.erb +32 -0
  35. data/app/views/madmin/fields/nested_has_many/_index.html.erb +1 -0
  36. data/app/views/madmin/fields/nested_has_many/_show.html.erb +5 -0
  37. data/app/views/madmin/fields/password/_form.html.erb +4 -0
  38. data/app/views/madmin/fields/password/_index.html.erb +1 -0
  39. data/app/views/madmin/fields/password/_show.html.erb +1 -0
  40. data/app/views/madmin/fields/polymorphic/_form.html.erb +3 -1
  41. data/app/views/madmin/fields/polymorphic/_show.html.erb +1 -1
  42. data/app/views/madmin/fields/rich_text/_form.html.erb +3 -1
  43. data/app/views/madmin/fields/string/_form.html.erb +3 -1
  44. data/app/views/madmin/fields/text/_form.html.erb +3 -1
  45. data/app/views/madmin/fields/time/_form.html.erb +3 -1
  46. data/app/views/madmin/shared/_label.html.erb +4 -0
  47. data/lib/generators/madmin/field/field_generator.rb +31 -0
  48. data/lib/generators/madmin/field/templates/_form.html.erb +2 -0
  49. data/lib/generators/madmin/field/templates/_index.html.erb +1 -0
  50. data/lib/generators/madmin/field/templates/_show.html.erb +1 -0
  51. data/lib/generators/madmin/field/templates/field.rb.tt +26 -0
  52. data/lib/generators/madmin/install/install_generator.rb +6 -1
  53. data/lib/generators/madmin/install/templates/routes.rb.tt +3 -0
  54. data/lib/generators/madmin/resource/resource_generator.rb +15 -4
  55. data/lib/generators/madmin/resource/templates/controller.rb.tt +6 -0
  56. data/lib/generators/madmin/resource/templates/resource.rb.tt +14 -0
  57. data/lib/generators/madmin/views/javascript_generator.rb +15 -0
  58. data/lib/generators/madmin/views/views_generator.rb +6 -5
  59. data/lib/madmin/engine.rb +1 -1
  60. data/lib/madmin/field.rb +4 -0
  61. data/lib/madmin/fields/belongs_to.rb +9 -5
  62. data/lib/madmin/fields/has_many.rb +10 -5
  63. data/lib/madmin/fields/nested_has_many.rb +40 -0
  64. data/lib/madmin/fields/password.rb +6 -0
  65. data/lib/madmin/fields/string.rb +3 -0
  66. data/lib/madmin/fields/text.rb +3 -0
  67. data/lib/madmin/generator_helpers.rb +22 -4
  68. data/lib/madmin/resource.rb +53 -19
  69. data/lib/madmin/search.rb +60 -0
  70. data/lib/madmin/version.rb +1 -1
  71. data/lib/madmin.rb +30 -14
  72. metadata +25 -5
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "1.0.1"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/madmin.rb CHANGED
@@ -6,36 +6,52 @@ module Madmin
6
6
  autoload :Field, "madmin/field"
7
7
  autoload :GeneratorHelpers, "madmin/generator_helpers"
8
8
  autoload :Resource, "madmin/resource"
9
+ autoload :Search, "madmin/search"
9
10
 
10
11
  module Fields
12
+ autoload :Attachment, "madmin/fields/attachment"
13
+ autoload :Attachments, "madmin/fields/attachments"
14
+ autoload :BelongsTo, "madmin/fields/belongs_to"
11
15
  autoload :Boolean, "madmin/fields/boolean"
12
- autoload :Integer, "madmin/fields/integer"
13
- autoload :String, "madmin/fields/string"
14
- autoload :Text, "madmin/fields/text"
15
16
  autoload :Date, "madmin/fields/date"
16
17
  autoload :DateTime, "madmin/fields/date_time"
17
18
  autoload :Decimal, "madmin/fields/decimal"
18
- autoload :Json, "madmin/fields/json"
19
19
  autoload :Enum, "madmin/fields/enum"
20
20
  autoload :Float, "madmin/fields/float"
21
- autoload :Time, "madmin/fields/time"
22
- autoload :BelongsTo, "madmin/fields/belongs_to"
23
- autoload :Polymorphic, "madmin/fields/polymorphic"
24
21
  autoload :HasMany, "madmin/fields/has_many"
25
22
  autoload :HasOne, "madmin/fields/has_one"
23
+ autoload :Integer, "madmin/fields/integer"
24
+ autoload :Json, "madmin/fields/json"
25
+ autoload :NestedHasMany, "madmin/fields/nested_has_many"
26
+ autoload :Password, "madmin/fields/password"
27
+ autoload :Polymorphic, "madmin/fields/polymorphic"
26
28
  autoload :RichText, "madmin/fields/rich_text"
27
- autoload :Attachment, "madmin/fields/attachment"
28
- autoload :Attachments, "madmin/fields/attachments"
29
+ autoload :String, "madmin/fields/string"
30
+ autoload :Text, "madmin/fields/text"
31
+ autoload :Time, "madmin/fields/time"
29
32
  end
30
33
 
31
- mattr_accessor :resources, default: []
32
-
33
34
  class << self
34
35
  def resource_for(object)
35
- Rails.application.eager_load!
36
+ "#{object.class.name}Resource".constantize
37
+ end
38
+
39
+ def resource_by_name(name)
40
+ "#{name}Resource".constantize
41
+ end
42
+
43
+ def resources
44
+ @resources ||= resource_names.map(&:constantize)
45
+ end
46
+
47
+ def reset_resources!
48
+ @resources = nil
49
+ end
36
50
 
37
- klass_name = object.class.name
38
- Madmin.resources.find { |r| r.model_name == klass_name }
51
+ def resource_names
52
+ root = Rails.root.join("app/madmin/resources/")
53
+ files = Dir.glob(root.join("**/*.rb"))
54
+ files.sort!.map! { |f| f.split(root.to_s).last.delete_suffix(".rb").classify }
39
55
  end
40
56
  end
41
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: madmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-04 00:00:00.000000000 Z
12
+ date: 2021-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: '3.5'
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '4.0'
37
+ version: '5.0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.5'
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.0'
47
+ version: '5.0'
48
48
  description: It's an admin, obviously.
49
49
  email:
50
50
  - excid3@gmail.com
@@ -63,6 +63,8 @@ files:
63
63
  - app/controllers/madmin/dashboard_controller.rb
64
64
  - app/controllers/madmin/resource_controller.rb
65
65
  - app/helpers/madmin/application_helper.rb
66
+ - app/helpers/madmin/nav_helper.rb
67
+ - app/helpers/madmin/sort_helper.rb
66
68
  - app/views/layouts/madmin/application.html.erb
67
69
  - app/views/madmin/application/_form.html.erb
68
70
  - app/views/madmin/application/_javascript.html.erb
@@ -111,6 +113,13 @@ files:
111
113
  - app/views/madmin/fields/json/_form.html.erb
112
114
  - app/views/madmin/fields/json/_index.html.erb
113
115
  - app/views/madmin/fields/json/_show.html.erb
116
+ - app/views/madmin/fields/nested_has_many/_fields.html.erb
117
+ - app/views/madmin/fields/nested_has_many/_form.html.erb
118
+ - app/views/madmin/fields/nested_has_many/_index.html.erb
119
+ - app/views/madmin/fields/nested_has_many/_show.html.erb
120
+ - app/views/madmin/fields/password/_form.html.erb
121
+ - app/views/madmin/fields/password/_index.html.erb
122
+ - app/views/madmin/fields/password/_show.html.erb
114
123
  - app/views/madmin/fields/polymorphic/_form.html.erb
115
124
  - app/views/madmin/fields/polymorphic/_index.html.erb
116
125
  - app/views/madmin/fields/polymorphic/_show.html.erb
@@ -126,14 +135,22 @@ files:
126
135
  - app/views/madmin/fields/time/_form.html.erb
127
136
  - app/views/madmin/fields/time/_index.html.erb
128
137
  - app/views/madmin/fields/time/_show.html.erb
138
+ - app/views/madmin/shared/_label.html.erb
139
+ - lib/generators/madmin/field/field_generator.rb
140
+ - lib/generators/madmin/field/templates/_form.html.erb
141
+ - lib/generators/madmin/field/templates/_index.html.erb
142
+ - lib/generators/madmin/field/templates/_show.html.erb
143
+ - lib/generators/madmin/field/templates/field.rb.tt
129
144
  - lib/generators/madmin/install/install_generator.rb
130
145
  - lib/generators/madmin/install/templates/controller.rb.tt
146
+ - lib/generators/madmin/install/templates/routes.rb.tt
131
147
  - lib/generators/madmin/resource/resource_generator.rb
132
148
  - lib/generators/madmin/resource/templates/controller.rb.tt
133
149
  - lib/generators/madmin/resource/templates/resource.rb.tt
134
150
  - lib/generators/madmin/views/edit_generator.rb
135
151
  - lib/generators/madmin/views/form_generator.rb
136
152
  - lib/generators/madmin/views/index_generator.rb
153
+ - lib/generators/madmin/views/javascript_generator.rb
137
154
  - lib/generators/madmin/views/layout_generator.rb
138
155
  - lib/generators/madmin/views/navigation_generator.rb
139
156
  - lib/generators/madmin/views/new_generator.rb
@@ -155,6 +172,8 @@ files:
155
172
  - lib/madmin/fields/has_one.rb
156
173
  - lib/madmin/fields/integer.rb
157
174
  - lib/madmin/fields/json.rb
175
+ - lib/madmin/fields/nested_has_many.rb
176
+ - lib/madmin/fields/password.rb
158
177
  - lib/madmin/fields/polymorphic.rb
159
178
  - lib/madmin/fields/rich_text.rb
160
179
  - lib/madmin/fields/string.rb
@@ -163,6 +182,7 @@ files:
163
182
  - lib/madmin/generator_helpers.rb
164
183
  - lib/madmin/namespace.rb
165
184
  - lib/madmin/resource.rb
185
+ - lib/madmin/search.rb
166
186
  - lib/madmin/version.rb
167
187
  - lib/madmin/view_generator.rb
168
188
  - lib/tasks/madmin_tasks.rake
@@ -185,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
205
  - !ruby/object:Gem::Version
186
206
  version: '0'
187
207
  requirements: []
188
- rubygems_version: 3.2.3
208
+ rubygems_version: 3.2.22
189
209
  signing_key:
190
210
  specification_version: 4
191
211
  summary: A modern admin for Ruby on Rails apps