madmin 2.0.5 → 2.1.0
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/app/assets/stylesheets/madmin/pagination.css +1 -1
- data/app/controllers/madmin/base_controller.rb +6 -1
- data/app/controllers/madmin/resource_controller.rb +0 -3
- data/app/helpers/madmin/application_helper.rb +1 -1
- data/app/views/madmin/application/index.html.erb +7 -2
- data/app/views/madmin/fields/has_many/_show.html.erb +7 -2
- data/app/views/madmin/fields/nested_has_many/_show.html.erb +7 -2
- data/lib/madmin/fields/has_many.rb +23 -7
- data/lib/madmin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de0ee3515b8f8689bbd5c7b6b99675c2724f0be4cf7774e97d71da99076f3b68
|
4
|
+
data.tar.gz: 4224940c11670cfbc2a481cc0001ad64d846595929993f5971490c1f53e0343c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaf9f28c5e3dac557dceaff92f823b3372d9c927a2c429d296da83bee28c3f14cd78b31bf198bde7d43bfc8025aaa01d96e1586edc42ebef5c49e3f827929cfc
|
7
|
+
data.tar.gz: e0b561bb2c7d0367238ba4c9af7794161480396ccf2bc625ffad2a3adfbeb1b6919490f59a8fc24c1eac89eec4f0162e202186dc47913f41351b893972c2fb13
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Madmin
|
2
2
|
class BaseController < ActionController::Base
|
3
3
|
include ::ActiveStorage::SetCurrent if defined?(::ActiveStorage)
|
4
|
-
|
4
|
+
|
5
|
+
if Gem::Version.new(Pagy::VERSION) >= Gem::Version.new("43.0.0.rc")
|
6
|
+
include Pagy::Method
|
7
|
+
else
|
8
|
+
include Pagy::Backend
|
9
|
+
end
|
5
10
|
|
6
11
|
protect_from_forgery with: :exception
|
7
12
|
end
|
@@ -65,6 +65,11 @@
|
|
65
65
|
</div>
|
66
66
|
|
67
67
|
<div class="pagination">
|
68
|
-
|
69
|
-
|
68
|
+
<% if @pagy.respond_to?(:series_nav) %>
|
69
|
+
<%== @pagy.series_nav if @pagy.last > 1 %>
|
70
|
+
<%== @pagy.info_tag %>
|
71
|
+
<% else %>
|
72
|
+
<%== pagy_nav @pagy if @pagy.last > 1 %>
|
73
|
+
<%== pagy_info @pagy %>
|
74
|
+
<% end %>
|
70
75
|
</div>
|
@@ -8,6 +8,11 @@
|
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
<div class="pagination">
|
11
|
-
|
12
|
-
|
11
|
+
<% if pagy.respond_to?(:series_nav) %>
|
12
|
+
<%== pagy.series_nav if pagy.last > 1 %>
|
13
|
+
<%== pagy.info_tag %>
|
14
|
+
<% else %>
|
15
|
+
<%== pagy_nav pagy if pagy.last > 1 %>
|
16
|
+
<%== pagy_info pagy %>
|
17
|
+
<% end %>
|
13
18
|
</div>
|
@@ -8,6 +8,11 @@
|
|
8
8
|
<% end %>
|
9
9
|
|
10
10
|
<div class="pagination">
|
11
|
-
|
12
|
-
|
11
|
+
<% if pagy.respond_to?(:series_nav) %>
|
12
|
+
<%== pagy.series_nav if pagy.last > 1 %>
|
13
|
+
<%== pagy.info_tag %>
|
14
|
+
<% else %>
|
15
|
+
<%== pagy_nav pagy if pagy.last > 1 %>
|
16
|
+
<%== pagy_info pagy %>
|
17
|
+
<% end %>
|
13
18
|
</div>
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Madmin
|
2
2
|
module Fields
|
3
3
|
class HasMany < Field
|
4
|
-
include Pagy::Backend
|
5
|
-
|
6
4
|
def options_for_select(record)
|
7
5
|
if (records = record.send(attribute_name))
|
8
6
|
return [] unless records.first
|
@@ -35,11 +33,29 @@ module Madmin
|
|
35
33
|
true
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
if Gem::Version.new(Pagy::VERSION) >= Gem::Version.new("43.0.0.rc")
|
37
|
+
include Pagy::Method
|
38
|
+
|
39
|
+
def paginated_value(record, params)
|
40
|
+
page_key = "#{attribute_name}_page"
|
41
|
+
request = {
|
42
|
+
query: {
|
43
|
+
"#{attribute_name}_page" => [params[page_key].to_i, 1].max
|
44
|
+
}
|
45
|
+
}
|
46
|
+
pagy value(record), page_key: page_key, request: request
|
47
|
+
rescue Pagy::OptionError
|
48
|
+
end
|
49
|
+
else
|
50
|
+
include Pagy::Backend
|
51
|
+
|
52
|
+
def paginated_value(record, params)
|
53
|
+
page_key = "#{attribute_name}_page"
|
54
|
+
page = [params[page_key].to_i, 1].max
|
55
|
+
pagy value(record), page: page, page_param: page_key
|
56
|
+
rescue Pagy::OverflowError, Pagy::VariableError
|
57
|
+
pagy value, page: 1, page_param: page_key
|
58
|
+
end
|
43
59
|
end
|
44
60
|
end
|
45
61
|
end
|
data/lib/madmin/version.rb
CHANGED