Class: Matestack::Ui::Bootstrap::Layouts::AdminTemplate

Inherits:
Layout
  • Object
show all
Defined in:
lib/matestack/ui/bootstrap/layouts/admin_template.rb

Instance Method Summary collapse

Instance Method Details

#body_response(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 11

def body_response(&block)
  div class: "d-flex flex-row" do
    if should_show_sidebar?
      div id: "sidebar", class: "sidebar-wrapper" do
        bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: method(:sidebar_top_slot) }
      end
    end
    div id: "content", class: "content-wrapper w-100 #{content_background_class}" do
      if should_show_navbar?
        bs_container do
          bs_navbar brand: navbar_brand_config, items: navbar_items, class: "pt-4 #{'ps-5' if should_show_sidebar?}", collapse_class: "text-end text-lg-start pe-3"
        end
      end
      bs_container class: "my-5 px-4 pt-5" do
        page_switch do
          yield if block_given?
        end
      end
    end
  end
  toasts_partial
end

#content_background_classObject



86
87
88
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 86

def content_background_class
  "bg-light"
end

#loading_state_slotObject



66
67
68
69
70
71
72
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 66

def loading_state_slot
  # slot do
  #   div class: "d-flex justify-content-center" do
  #     spinner class: "mt-5"
  #   end
  # end
end


82
83
84
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 82

def navbar_brand_config

end


74
75
76
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 74

def navbar_items
  []
end

#response(&block) ⇒ Object



5
6
7
8
9
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 5

def response(&block)
  matestack_vue_js_app do
    body_response(&block)
  end
end

#should_show_navbar?Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 42

def should_show_navbar?
  if navbar_brand_config.nil? && !self.respond_to?(:navbar_end_partial) && navbar_items.empty?
    false
  else
    true
  end
end

#should_show_sidebar?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 34

def should_show_sidebar?
  if !self.respond_to?(:sidebar_top_partial) && sidebar_navigation_items.empty?
    false
  else
    true
  end
end


78
79
80
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 78

def sidebar_navigation_items
  []
end


50
51
52
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 50

def sidebar_top_slot
  sidebar_top_partial if self.respond_to?(:sidebar_top_partial)
end

#toasts_partialObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/matestack/ui/bootstrap/layouts/admin_template.rb', line 54

def toasts_partial
  toasts.each do |toast|
    bs_toast class: toast[:class],
          body: toast[:body].html_safe,
          placement: {
            position: 'bottom: 15px; right: 15px;',
            height: "200px"
          },
          show_on: toast[:show_on], hide_on: toast[:hide_on], autohide: toast[:autohide] || true
  end
end