madmin 2.0.2 → 2.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b751bd0646e9d0cf013c394c5724e0873ba7c1d7f6e209ebb415eccb1468fa9
4
- data.tar.gz: 8e6a92c242c2a9937391e403dad3fe6d664f334cd36c5c686d611ca09fa5a02e
3
+ metadata.gz: 5738233eebbda8b8b68dd7a00e0bb4006d77a80cea0b75b1466b5f67dfe67e5c
4
+ data.tar.gz: d28a9f663c5fbd612a1b1ad7593414ad3ee8125d3d194d9c1efbc4d2f88b2a49
5
5
  SHA512:
6
- metadata.gz: b6c32d6e92da3f973086c18edf4b9f2d870d3391a32748587e6097ce34973b1416e532da904bc452cd943aa5f6438493b62ae6627d375a6d7fcfa51f4998fdb4
7
- data.tar.gz: 30d59f92c948e6bc6621accbd17ec4d0ae8701a349c4561ba3a9072010a655c0e1db9edfca785fa1cfdc2ffb5f8356ed8fe0e7b31c10a24aca176fec7c61a5b5
6
+ metadata.gz: 91f19c83273374d2eafc04873fec3e06575ecd2525745ae3237aa13485ef1d682872cc21996602c67f7b7ee8d3c01f54bcdf8163124360ca0c6020200ab8d962
7
+ data.tar.gz: 2cf083d97e766b6e8a43662caa217dd6dbbf8df913a6339f6ca88db57bf579cfb7b32ff443ff7d4dc185f73f0708c56f3766b0d02508963d446882fd8445e865
data/README.md CHANGED
@@ -103,9 +103,9 @@ The `attribute` method in model_resource.rb gives you that flexibility.
103
103
  ```
104
104
 
105
105
  ```ruby
106
- class UserResource < Madmin::Resource
106
+ class BookResource < Madmin::Resource
107
107
  attribute :id, form: false
108
- attribute :tile
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:
@@ -4,7 +4,7 @@ module Madmin
4
4
  matching_column = (column.to_s == sort_column)
5
5
  direction = (sort_direction == "asc") ? "desc" : "asc"
6
6
 
7
- link_to resource.index_path(sort: column, direction: direction), options do
7
+ link_to resource.index_path(sort: column, direction: direction, scope: params[:scope], q: params[:q]), options do
8
8
  concat title
9
9
  if matching_column
10
10
  concat " "
@@ -25,7 +25,7 @@
25
25
  <% end %>
26
26
 
27
27
  <% resource.scopes.each do |scope| %>
28
- <%= link_to scope.to_s.humanize, resource.index_path(scope: scope), class: class_names("btn btn-secondary", {"active" => params[:scope] == scope.to_s}) %>
28
+ <%= link_to scope.to_s.humanize, resource.index_path(scope: scope, q: params[:q], sort: params[:sort], direction: params[:direction]), class: class_names("btn btn-secondary", {"active" => params[:scope] == scope.to_s}) %>
29
29
  <% end %>
30
30
  </nav>
31
31
 
@@ -45,10 +45,8 @@ module Madmin
45
45
 
46
46
  if field.nil?
47
47
  Rails.logger.warn <<~MESSAGE
48
- WARNING: Madmin could not infer a field type for `#{name}` attribute. Defaulting to a String type.
49
- You can set the type by specifying the type on the attribute:
50
-
51
- 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 }}
52
50
  MESSAGE
53
51
  field = Fields::String
54
52
  end
@@ -1,3 +1,3 @@
1
1
  module Madmin
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.4"
3
3
  end
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.2
4
+ version: 2.0.4
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: 2025-05-06 00:00:00.000000000 Z
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.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: []