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.
@@ -3,33 +3,34 @@
3
3
  module TinyAdmin
4
4
  module Views
5
5
  module Components
6
- class Navbar < Phlex::HTML
7
- attr_reader :current_slug, :items, :root_path, :root_title
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(class: 'navbar-toggler', type: 'button', 'data-bs-toggle' => 'collapse', 'data-bs-target' => '#navbarNav', 'aria-controls' => 'navbarNav', 'aria-expanded' => 'false', 'aria-label' => 'Toggle navigation') {
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, (name, path, options)|
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 < Phlex::HTML
7
- attr_reader :current, :pages, :query_string
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
- flash_component&.update(messages: messages)
10
- head_component&.update(title, style_links: style_links, extra_styles: settings.extra_styles)
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
@@ -18,7 +18,7 @@ module TinyAdmin
18
18
  def configure_from_file(file)
19
19
  config = YAML.load_file(file, symbolize_names: true)
20
20
  config.each do |key, value|
21
- TinyAdmin::Settings.instance.send("#{key}=", value)
21
+ TinyAdmin::Settings.instance[key] = value
22
22
  end
23
23
  end
24
24
 
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.3.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-14 00:00:00.000000000 Z
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