madmin 2.1.0 → 2.1.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.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/app/assets/stylesheets/madmin/buttons.css +8 -1
- data/app/assets/stylesheets/madmin/sidebar.css +3 -1
- data/app/views/layouts/madmin/application.html.erb +2 -2
- data/lib/madmin/fields/belongs_to.rb +2 -6
- data/lib/madmin/fields/has_many.rb +2 -1
- data/lib/madmin/resource.rb +3 -1
- data/lib/madmin/search.rb +1 -1
- data/lib/madmin/version.rb +1 -1
- data/lib/madmin/view_generator.rb +1 -0
- data/lib/madmin.rb +22 -15
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 67db829bf99130d9746ef0d3bd416f0c38e9ecaf70530db4c4066a60032e934d
|
|
4
|
+
data.tar.gz: 91694aac3e2db7fad14918af8be8ab97029ca542848e6ccc1f36d493d2bd4f1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bfa374d40d58292a97885e238681bd6bfb91dbe2618f501bda0e25ada1b5490fa8a69b5e80b86cf7262fce44a501a1e1935b672bb6b46a5456e322b11939f93d
|
|
7
|
+
data.tar.gz: 2cf03a691fcda333691547743b7879495bb2de3ed8fc992761a505c154d92d81cb47d994209cca501bcf7b91f26343ccc9b9f007441f641a71440164864b80e4
|
data/Rakefile
CHANGED
|
@@ -11,10 +11,17 @@
|
|
|
11
11
|
padding-left: 0.75rem;
|
|
12
12
|
padding-right: 0.75rem;
|
|
13
13
|
|
|
14
|
-
&:hover
|
|
14
|
+
&:hover,
|
|
15
|
+
&:focus {
|
|
16
|
+
cursor: pointer;
|
|
15
17
|
text-decoration: none !important;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
&:disabled {
|
|
21
|
+
opacity: 60%;
|
|
22
|
+
cursor: not-allowed;
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
&.btn-primary {
|
|
19
26
|
background-color: var(--primary-color);
|
|
20
27
|
color: white;
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
main {
|
|
42
|
+
overflow: auto;
|
|
42
43
|
padding-right: 1rem;
|
|
43
44
|
padding-bottom: 1rem;
|
|
44
45
|
padding-left: calc(1rem + var(--sidebar-width));
|
|
@@ -48,7 +49,8 @@ main {
|
|
|
48
49
|
#sidebar {
|
|
49
50
|
position: absolute;
|
|
50
51
|
inset: 0;
|
|
51
|
-
|
|
52
|
+
/* Ensure sidebar is above main content */
|
|
53
|
+
z-index: 10;
|
|
52
54
|
|
|
53
55
|
border-right: 1px solid var(--border-color);
|
|
54
56
|
height: 100%;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<button id="hamburger-menu" type="button" data-action="click->mobile-nav#toggle" aria-label="Open menu" aria-expanded="false" aria-controls="sidebar">
|
|
23
23
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" class="size-5"> <path fill-rule="evenodd" d="M2 4.75A.75.75 0 0 1 2.75 4h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 4.75ZM2 10a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75A.75.75 0 0 1 2 10Zm0 5.25a.75.75 0 0 1 .75-.75h14.5a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1-.75-.75Z" clip-rule="evenodd" /> </svg>
|
|
24
24
|
</button>
|
|
25
|
-
<%=
|
|
25
|
+
<%= link_to Madmin.site_name, try(:root_url) || madmin_root_url, data: {turbo: false} %>
|
|
26
26
|
</div>
|
|
27
27
|
</header>
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
<div>
|
|
35
35
|
<%= yield %>
|
|
36
|
-
</div
|
|
36
|
+
</div>
|
|
37
37
|
</main>
|
|
38
38
|
|
|
39
39
|
<div data-mobile-nav-target="overlay" data-action="click->mobile-nav#close" class="mobile-nav-overlay"></div>
|
|
@@ -2,12 +2,8 @@ module Madmin
|
|
|
2
2
|
module Fields
|
|
3
3
|
class BelongsTo < Field
|
|
4
4
|
def options_for_select(record)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
else
|
|
8
|
-
associated_resource.model.first(25)
|
|
9
|
-
end
|
|
10
|
-
|
|
5
|
+
current_value = record.send(attribute_name)
|
|
6
|
+
records = [current_value].compact + associated_resource.model.excluding(current_value).limit(25)
|
|
11
7
|
records.map { [Madmin.resource_for(_1).display_name(_1), _1.id] }
|
|
12
8
|
end
|
|
13
9
|
|
data/lib/madmin/resource.rb
CHANGED
|
@@ -71,8 +71,10 @@ module Madmin
|
|
|
71
71
|
)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
# Returns singular name
|
|
75
|
+
# For example: "Forum::Post" -> "Forum / Post"
|
|
74
76
|
def friendly_name
|
|
75
|
-
model_name.split("::").map { |part| part.underscore.humanize }.join(" / ").titlecase
|
|
77
|
+
model_name.split("::").map { |part| part.underscore.humanize }.join(" / ").titlecase
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
# Support for isolated namespaces
|
data/lib/madmin/search.rb
CHANGED
data/lib/madmin/version.rb
CHANGED
data/lib/madmin.rb
CHANGED
|
@@ -45,30 +45,37 @@ module Madmin
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
class << self
|
|
48
|
+
# Returns a Madmin::Resource class for the given object
|
|
48
49
|
def resource_for(object)
|
|
49
|
-
if (resource_name = resource_name_for(object))
|
|
50
|
+
if (resource_name = resource_name_for(object)) && Object.const_defined?(resource_name)
|
|
50
51
|
resource_name.constantize
|
|
51
|
-
end
|
|
52
|
-
rescue NameError
|
|
53
|
-
raise MissingResource, <<~MESSAGE
|
|
54
|
-
#{resource_name} is missing. Create it by running:
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
# STI models should look at the parent
|
|
54
|
+
elsif (resource_name = sti_resource_name_for(object)) && Object.const_defined?(resource_name)
|
|
55
|
+
resource_name.constantize
|
|
56
|
+
|
|
57
|
+
else
|
|
58
|
+
raise MissingResource, <<~MESSAGE
|
|
59
|
+
`#{object.class.name}Resource` is missing.
|
|
60
|
+
|
|
61
|
+
Create the Madmin resource by running:
|
|
62
|
+
|
|
63
|
+
bin/rails generate madmin:resource #{object.class.name}
|
|
64
|
+
MESSAGE
|
|
65
|
+
end
|
|
58
66
|
end
|
|
59
67
|
|
|
60
68
|
def resource_name_for(object)
|
|
61
69
|
if object.is_a? ::ActiveStorage::Attached
|
|
62
70
|
"ActiveStorage::AttachmentResource"
|
|
63
71
|
else
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
+
"#{object.class.name}Resource"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def sti_resource_name_for(object)
|
|
77
|
+
if (column = object.class.inheritance_column) && object.class.column_names.include?(column)
|
|
78
|
+
"#{object.class.superclass.base_class.name}Resource"
|
|
72
79
|
end
|
|
73
80
|
end
|
|
74
81
|
|
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: 2.1.
|
|
4
|
+
version: 2.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Oliver
|
|
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
257
257
|
- !ruby/object:Gem::Version
|
|
258
258
|
version: '0'
|
|
259
259
|
requirements: []
|
|
260
|
-
rubygems_version: 3.7.
|
|
260
|
+
rubygems_version: 3.7.2
|
|
261
261
|
specification_version: 4
|
|
262
262
|
summary: A modern admin for Ruby on Rails apps
|
|
263
263
|
test_files: []
|