tiny_admin 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/lib/tiny_admin/actions/index.rb +2 -1
- data/lib/tiny_admin/router.rb +3 -2
- data/lib/tiny_admin/utils.rb +3 -1
- data/lib/tiny_admin/version.rb +1 -1
- data/lib/tiny_admin/views/actions/index.rb +2 -2
- data/lib/tiny_admin/views/basic_layout.rb +1 -1
- data/lib/tiny_admin/views/components/pagination.rb +22 -14
- 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: de3ed265839998db96c8e220f1b66576a8a37325e0726f3597e0b1ef315087a4
|
4
|
+
data.tar.gz: 828309ff8139a11c3e73fcbeb82ffea7f752191e5c4e99e9dc19fbaa29a2180e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3648b175fd028a82bc7c3ae35fc51d3380a4d22fc6dd38dfd5da5ed375d94b4b45358b36c17c955482574756700bd2889ba57348e4ed3453491e2112c9d1471f
|
7
|
+
data.tar.gz: 4ea2a1301b70a3b88e07829e5755976482d22b2f18c1752ab7b7626e93b19b20527a7944c9da634fdf92a4bed53cf20d56c1e7e6738bc8c3b519de4147cd810b
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Please ⭐ if you like it.
|
|
19
19
|
|
20
20
|
## Install
|
21
21
|
|
22
|
-
- Add to your Gemfile: `gem 'tiny_admin', '~> 0.
|
22
|
+
- Add to your Gemfile: `gem 'tiny_admin', '~> 0.9'`
|
23
23
|
- Mount the app in a route (check some examples with: Hanami, Rails, Roda and standalone in [extra](extra))
|
24
24
|
+ in Rails, update _config/routes.rb_: `mount TinyAdmin::Router => '/admin'`
|
25
25
|
- Configure the dashboard using `TinyAdmin.configure` and/or `TinyAdmin.configure_from_file` with a YAML config file (see [configuration](#configuration) below):
|
@@ -218,6 +218,8 @@ model: Post
|
|
218
218
|
|
219
219
|
#### Resource index options
|
220
220
|
|
221
|
+
> 📚 [Wiki Resource index page](https://github.com/blocknotes/tiny_admin/wiki/Resource-index) available
|
222
|
+
|
221
223
|
The Index hash supports the following options:
|
222
224
|
|
223
225
|
- `attributes` (Array): fields to expose in the resource list page;
|
@@ -257,6 +259,8 @@ Example:
|
|
257
259
|
|
258
260
|
#### Resource show options
|
259
261
|
|
262
|
+
> 📚 [Wiki Resource show page](https://github.com/blocknotes/tiny_admin/wiki/Resource-show) available
|
263
|
+
|
260
264
|
The Show hash supports the following options:
|
261
265
|
|
262
266
|
- `attributes` (Array): fields to expose in the resource details page.
|
@@ -62,8 +62,9 @@ module TinyAdmin
|
|
62
62
|
@pages = (total_count / pagination.to_f).ceil
|
63
63
|
return if pages <= 1 || !pagination_component_class
|
64
64
|
|
65
|
+
attributes = { current: current_page, pages: pages, query_string: query_string, total_count: total_count }
|
65
66
|
page.pagination_component = pagination_component_class.new
|
66
|
-
page.pagination_component.update_attributes(
|
67
|
+
page.pagination_component.update_attributes(attributes)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
data/lib/tiny_admin/router.rb
CHANGED
@@ -58,14 +58,15 @@ module TinyAdmin
|
|
58
58
|
router.redirect route_for(TinyAdmin.settings.root[:redirect])
|
59
59
|
else
|
60
60
|
page_class = to_class(TinyAdmin.settings.root[:page])
|
61
|
-
|
61
|
+
attributes = TinyAdmin.settings.root.slice(:content, :title, :widgets)
|
62
|
+
render_page prepare_page(page_class, attributes: attributes, params: request.params)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
def setup_page_route(router, slug, page_data)
|
66
67
|
router.get slug do
|
67
68
|
attributes = page_data.slice(:content, :title, :widgets)
|
68
|
-
render_page prepare_page(page_data[:class], slug: slug, attributes: attributes)
|
69
|
+
render_page prepare_page(page_data[:class], slug: slug, attributes: attributes, params: request.params)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
data/lib/tiny_admin/utils.rb
CHANGED
@@ -14,7 +14,7 @@ module TinyAdmin
|
|
14
14
|
list.join('&')
|
15
15
|
end
|
16
16
|
|
17
|
-
def prepare_page(page_class, slug: nil, attributes: nil, options: nil)
|
17
|
+
def prepare_page(page_class, slug: nil, attributes: nil, options: nil, params: nil)
|
18
18
|
page_class.new.tap do |page|
|
19
19
|
page.options = options
|
20
20
|
page.head_component = TinyAdmin.settings.components[:head]&.new
|
@@ -27,9 +27,11 @@ module TinyAdmin
|
|
27
27
|
items: options&.include?(:no_menu) ? [] : TinyAdmin.settings.store&.navbar
|
28
28
|
)
|
29
29
|
attrs = attributes || {}
|
30
|
+
attrs[:params] = params if params
|
30
31
|
attrs[:widgets] = attrs[:widgets].map { to_class(_1) } if attrs[:widgets]
|
31
32
|
page.update_attributes(attrs) unless attrs.empty?
|
32
33
|
yield(page) if block_given?
|
34
|
+
page.setup if page.respond_to?(:setup)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
data/lib/tiny_admin/version.rb
CHANGED
@@ -28,6 +28,8 @@ module TinyAdmin
|
|
28
28
|
|
29
29
|
table_body
|
30
30
|
}
|
31
|
+
|
32
|
+
render pagination_component if pagination_component
|
31
33
|
}
|
32
34
|
|
33
35
|
if filters&.any?
|
@@ -39,8 +41,6 @@ module TinyAdmin
|
|
39
41
|
end
|
40
42
|
}
|
41
43
|
|
42
|
-
render pagination_component if pagination_component
|
43
|
-
|
44
44
|
render TinyAdmin::Views::Components::Widgets.new(widgets)
|
45
45
|
}
|
46
46
|
end
|
@@ -4,23 +4,31 @@ module TinyAdmin
|
|
4
4
|
module Views
|
5
5
|
module Components
|
6
6
|
class Pagination < BasicComponent
|
7
|
-
attr_accessor :current, :pages, :query_string
|
7
|
+
attr_accessor :current, :pages, :query_string, :total_count
|
8
8
|
|
9
9
|
def template
|
10
|
-
div(class: '
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
pages_range(1..pages)
|
15
|
-
elsif current <= 4 || current >= pages - 3
|
16
|
-
pages_range(1..(current <= 4 ? current + 2 : 4), with_dots: true)
|
17
|
-
pages_range((current > pages - 4 ? current - 2 : pages - 2)..pages)
|
18
|
-
else
|
19
|
-
pages_range(1..1, with_dots: true)
|
20
|
-
pages_range(current - 2..current + 2, with_dots: true)
|
21
|
-
pages_range(pages..pages)
|
22
|
-
end
|
10
|
+
div(class: 'container') {
|
11
|
+
div(class: 'row') {
|
12
|
+
div(class: 'col total-count') {
|
13
|
+
"#{total_count} items"
|
23
14
|
}
|
15
|
+
div(class: 'col col-6 text-center pagination-div') {
|
16
|
+
nav(class: 'd-inline-block', 'aria-label': 'Pagination') {
|
17
|
+
ul(class: 'pagination') {
|
18
|
+
if pages <= 10
|
19
|
+
pages_range(1..pages)
|
20
|
+
elsif current <= 4 || current >= pages - 3
|
21
|
+
pages_range(1..(current <= 4 ? current + 2 : 4), with_dots: true)
|
22
|
+
pages_range((current > pages - 4 ? current - 2 : pages - 2)..pages)
|
23
|
+
else
|
24
|
+
pages_range(1..1, with_dots: true)
|
25
|
+
pages_range(current - 2..current + 2, with_dots: true)
|
26
|
+
pages_range(pages..pages)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
div(class: 'col')
|
24
32
|
}
|
25
33
|
}
|
26
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|