Class: Matestack::Ui::Bootstrap::Apps::AdminTemplate

Inherits:
App
  • Object
show all
Includes:
Registry
Defined in:
lib/matestack/ui/bootstrap/apps/admin_template.rb

Instance Method Summary collapse

Methods included from Registry

#bs_accordion, #bs_alert, #bs_avatar, #bs_badge, #bs_breadcrumb, #bs_btn, #bs_btn_group, #bs_card, #bs_carousel, #bs_close, #bs_col, #bs_collapse, #bs_container, #bs_dropdown, #bs_figure, #bs_form_checkbox, #bs_form_input, #bs_form_radio, #bs_form_select, #bs_form_submit, #bs_form_switch, #bs_icon, #bs_list_group, #bs_modal, #bs_navbar, #bs_page_heading, #bs_pagination, #bs_popover, #bs_progress, #bs_row, #bs_scrollspy, #bs_section_card, #bs_sidebar, #bs_smart_collection, #bs_spinner, #bs_tab_nav, #bs_tab_nav_content, #bs_toast, #bs_tooltip

Instance Method Details

#body_response(&block) ⇒ Object



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

def body_response(&block)
  div class: "d-flex flex-row" do
    if should_show_sidebar?
      bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: method(:sidebar_top_slot) }
    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" do
            # div class: "d-flex" do
            #   navbar_end_partial if self.respond_to?(:navbar_end_partial)
            # end
          end
        end
      end
      bs_container class: "my-5 px-4 pt-5" do
        yield if block_given?
      end
    end
  end
  toasts_partial
end

#content_background_classObject



88
89
90
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 88

def content_background_class
  "bg-light"
end

#loading_state_slotObject



68
69
70
71
72
73
74
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 68

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


84
85
86
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 84

def navbar_brand_config

end


76
77
78
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 76

def navbar_items
  []
end

#response(&block) ⇒ Object



7
8
9
10
11
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 7

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

#should_show_navbar?Boolean



44
45
46
47
48
49
50
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 44

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



36
37
38
39
40
41
42
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 36

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


80
81
82
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 80

def sidebar_navigation_items
  []
end


52
53
54
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 52

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

#toasts_partialObject



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/matestack/ui/bootstrap/apps/admin_template.rb', line 56

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