madmin 2.0.1 → 2.0.3
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/README.md +15 -3
- data/lib/madmin/field.rb +1 -1
- data/lib/madmin/fields/has_many.rb +4 -8
- data/lib/madmin/resource.rb +3 -6
- data/lib/madmin/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e151654e85ee04e468708ebcb264633db5647e24964ea20a8b94f29850059fc
|
4
|
+
data.tar.gz: b709f0e2c7cae8461fc4ff7fc7470fc720b7c84bd4eecea9b647e61c2a647d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8de42f8febe633ac7398b4e69be0acca9c20cd0b1ea1025079a81508b233c75e2ec3aa14969acf6685fdbef6ff7d9461818b753734731c97549e3f8973410c
|
7
|
+
data.tar.gz: ec7843b7ec7e89a521d39150bdde71b9359369b2de988711aa50b75399a70252947516e15387dced3f0161ecb04d0ca4094b0914f7a836e3f13197ae9fefdbd7
|
data/README.md
CHANGED
@@ -9,9 +9,9 @@ Why another Ruby on Rails admin? We wanted an admin that was:
|
|
9
9
|
- Familiar and customizable like Rails scaffolds (less DSL)
|
10
10
|
- Supports all the Rails features out of the box (ActionText, ActionMailbox, has_secure_password, etc)
|
11
11
|
- Stimulus / Turbolinks / Hotwire ready
|
12
|
+
- Works with Import maps and Sprockets
|
12
13
|
|
13
14
|

|
14
|
-
_We're still working on the design!_
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -103,9 +103,9 @@ The `attribute` method in model_resource.rb gives you that flexibility.
|
|
103
103
|
```
|
104
104
|
|
105
105
|
```ruby
|
106
|
-
class
|
106
|
+
class BookResource < Madmin::Resource
|
107
107
|
attribute :id, form: false
|
108
|
-
attribute :
|
108
|
+
attribute :title
|
109
109
|
attribute :subtitle, index: false
|
110
110
|
attribute :author
|
111
111
|
attribute :genre
|
@@ -120,6 +120,18 @@ rails generate madmin:views:index Book
|
|
120
120
|
# -> app/views/madmin/books/index.html.erb
|
121
121
|
```
|
122
122
|
|
123
|
+
### Specifying Field Types
|
124
|
+
|
125
|
+
You can set a field type as the second argument. Field types may have additional options to render the field UI.
|
126
|
+
|
127
|
+
|
128
|
+
For example, we can use a select for the genre attribute and specify the collection of options to choose from.
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
class BookResource < Madmin::Resource
|
132
|
+
attribute :genre, :select, collection: ["Fiction", "Mystery", "Thriller"]
|
133
|
+
end
|
134
|
+
|
123
135
|
## Custom Fields
|
124
136
|
|
125
137
|
You can generate a custom field with:
|
data/lib/madmin/field.rb
CHANGED
@@ -26,14 +26,10 @@ module Madmin
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def paginated_value(record, params)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def pagy_get_page(vars, force_integer: true)
|
34
|
-
params = vars[:params]
|
35
|
-
page = params[vars[:page_param] || DEFAULT[:page_param]]
|
36
|
-
force_integer ? (page || 1).to_i : page
|
29
|
+
param_name = "#{attribute_name}_page"
|
30
|
+
pagy value(record), page: params[param_name].to_i, page_param: param_name
|
31
|
+
rescue Pagy::OverflowError, Pagy::VariableError
|
32
|
+
pagy value(record), page: 1, page_param: param_name
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
data/lib/madmin/resource.rb
CHANGED
@@ -24,8 +24,7 @@ module Madmin
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def model_find(id)
|
27
|
-
|
28
|
-
becomes(record)
|
27
|
+
friendly_model? ? model.friendly.find(id) : model.find(id)
|
29
28
|
end
|
30
29
|
|
31
30
|
def model_name
|
@@ -46,10 +45,8 @@ module Madmin
|
|
46
45
|
|
47
46
|
if field.nil?
|
48
47
|
Rails.logger.warn <<~MESSAGE
|
49
|
-
WARNING: Madmin could not infer a field type for `#{name}` attribute. Defaulting to a String type.
|
50
|
-
|
51
|
-
|
52
|
-
attribute :#{name}, :boolean
|
48
|
+
WARNING: Madmin could not infer a field type for `#{name}` attribute in `#{self.name}`. Defaulting to a String type.
|
49
|
+
#{caller.find { _1.start_with? Rails.root.to_s }}
|
53
50
|
MESSAGE
|
54
51
|
field = Fields::String
|
55
52
|
end
|
data/lib/madmin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: madmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
8
8
|
- Andrea Fomera
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0'
|
257
257
|
requirements: []
|
258
|
-
rubygems_version: 3.6.
|
258
|
+
rubygems_version: 3.6.9
|
259
259
|
specification_version: 4
|
260
260
|
summary: A modern admin for Ruby on Rails apps
|
261
261
|
test_files: []
|