tiny_admin 0.3.0 → 0.5.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 +157 -71
- data/lib/tiny_admin/actions/basic_action.rb +15 -6
- data/lib/tiny_admin/actions/index.rb +21 -10
- data/lib/tiny_admin/actions/show.rb +10 -7
- data/lib/tiny_admin/context.rb +10 -1
- data/lib/tiny_admin/field.rb +11 -4
- data/lib/tiny_admin/plugins/active_record_repository.rb +17 -29
- data/lib/tiny_admin/plugins/base_repository.rb +14 -0
- data/lib/tiny_admin/router.rb +26 -19
- data/lib/tiny_admin/settings.rb +88 -42
- data/lib/tiny_admin/support.rb +35 -0
- data/lib/tiny_admin/utils.rb +13 -5
- data/lib/tiny_admin/version.rb +1 -1
- data/lib/tiny_admin/views/actions/index.rb +45 -21
- data/lib/tiny_admin/views/actions/show.rb +24 -22
- data/lib/tiny_admin/views/components/basic_component.rb +15 -0
- data/lib/tiny_admin/views/components/filters_form.rb +2 -7
- data/lib/tiny_admin/views/components/flash.rb +7 -10
- data/lib/tiny_admin/views/components/head.rb +2 -8
- data/lib/tiny_admin/views/components/navbar.rb +15 -14
- data/lib/tiny_admin/views/components/pagination.rb +2 -8
- data/lib/tiny_admin/views/default_layout.rb +3 -2
- data/lib/tiny_admin.rb +1 -1
- metadata +4 -2
@@ -3,33 +3,34 @@
|
|
3
3
|
module TinyAdmin
|
4
4
|
module Views
|
5
5
|
module Components
|
6
|
-
class Navbar <
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(root_path:, root_title:, items: [], current_slug: nil)
|
10
|
-
@root_path = root_path
|
11
|
-
@root_title = root_title
|
12
|
-
@items = items || []
|
13
|
-
@current_slug = current_slug
|
14
|
-
end
|
6
|
+
class Navbar < BasicComponent
|
7
|
+
attr_accessor :current_slug, :items, :root_path, :root_title
|
15
8
|
|
16
9
|
def template
|
17
10
|
nav(class: 'navbar navbar-expand-lg') {
|
18
11
|
div(class: 'container') {
|
19
12
|
a(class: 'navbar-brand', href: root_path) { root_title }
|
20
|
-
button(
|
13
|
+
button(
|
14
|
+
class: 'navbar-toggler',
|
15
|
+
type: 'button',
|
16
|
+
'data-bs-toggle' => 'collapse',
|
17
|
+
'data-bs-target' => '#navbarNav',
|
18
|
+
'aria-controls' => 'navbarNav',
|
19
|
+
'aria-expanded' => 'false',
|
20
|
+
'aria-label' => 'Toggle navigation'
|
21
|
+
) {
|
21
22
|
span(class: 'navbar-toggler-icon')
|
22
23
|
}
|
23
24
|
div(class: 'collapse navbar-collapse', id: 'navbarNav') {
|
24
25
|
ul(class: 'navbar-nav') {
|
25
|
-
items.each do |slug,
|
26
|
+
items.each do |slug, item|
|
26
27
|
classes = %w[nav-link]
|
27
28
|
classes << 'active' if slug == current_slug
|
28
|
-
link_attributes = { class: classes.join(' '), href: path, 'aria-current' => 'page' }
|
29
|
-
link_attributes.merge!(options) if options
|
29
|
+
link_attributes = { class: classes.join(' '), href: item[:path], 'aria-current' => 'page' }
|
30
|
+
link_attributes.merge!(item[:options]) if item[:options]
|
30
31
|
|
31
32
|
li(class: 'nav-item') {
|
32
|
-
a(**link_attributes) { name }
|
33
|
+
a(**link_attributes) { item[:name] }
|
33
34
|
}
|
34
35
|
end
|
35
36
|
}
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module TinyAdmin
|
4
4
|
module Views
|
5
5
|
module Components
|
6
|
-
class Pagination <
|
7
|
-
|
6
|
+
class Pagination < BasicComponent
|
7
|
+
attr_accessor :current, :pages, :query_string
|
8
8
|
|
9
9
|
def template
|
10
10
|
div(class: 'pagination-div') {
|
@@ -25,12 +25,6 @@ module TinyAdmin
|
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
28
|
-
def update(current:, pages:, query_string:)
|
29
|
-
@current = current
|
30
|
-
@pages = pages
|
31
|
-
@query_string = query_string
|
32
|
-
end
|
33
|
-
|
34
28
|
private
|
35
29
|
|
36
30
|
def pages_range(range, with_dots: false)
|
@@ -6,8 +6,9 @@ module TinyAdmin
|
|
6
6
|
attr_accessor :flash_component, :head_component, :messages, :navbar_component, :options, :title
|
7
7
|
|
8
8
|
def template(&block)
|
9
|
-
|
10
|
-
|
9
|
+
extra_styles = settings.extra_styles
|
10
|
+
flash_component&.messages = messages
|
11
|
+
head_component&.update_attributes(page_title: title, style_links: style_links, extra_styles: extra_styles)
|
11
12
|
|
12
13
|
doctype
|
13
14
|
html {
|
data/lib/tiny_admin.rb
CHANGED
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.5.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-04-
|
11
|
+
date: 2023-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|
@@ -88,11 +88,13 @@ files:
|
|
88
88
|
- lib/tiny_admin/plugins/simple_auth.rb
|
89
89
|
- lib/tiny_admin/router.rb
|
90
90
|
- lib/tiny_admin/settings.rb
|
91
|
+
- lib/tiny_admin/support.rb
|
91
92
|
- lib/tiny_admin/utils.rb
|
92
93
|
- lib/tiny_admin/version.rb
|
93
94
|
- lib/tiny_admin/views/actions/index.rb
|
94
95
|
- lib/tiny_admin/views/actions/show.rb
|
95
96
|
- lib/tiny_admin/views/basic_layout.rb
|
97
|
+
- lib/tiny_admin/views/components/basic_component.rb
|
96
98
|
- lib/tiny_admin/views/components/filters_form.rb
|
97
99
|
- lib/tiny_admin/views/components/flash.rb
|
98
100
|
- lib/tiny_admin/views/components/head.rb
|