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

Inherits:
App
  • Object
show all
Defined in:
app/concepts/matestack/ui/bootstrap/apps/admin_template.rb

Instance Method Summary collapse

Instance Method Details

#content_background_classObject



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

def content_background_class
  "bg-light"
end

#loading_state_slotObject



60
61
62
63
64
65
66
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 60

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


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

def navbar_brand_config

end


68
69
70
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 68

def navbar_items
  []
end

#responseObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 3

def response
  div class: "d-flex flex-row" do
    if should_show_sidebar?
      bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: 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_page slots: { loading_state: loading_state_slot }
      end
    end
  end
  toasts_partial
end

#should_show_navbar?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 34

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)


26
27
28
29
30
31
32
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 26

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


72
73
74
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 72

def sidebar_navigation_items
  []
end


42
43
44
45
46
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 42

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

#toasts_partialObject



48
49
50
51
52
53
54
55
56
57
58
# File 'app/concepts/matestack/ui/bootstrap/apps/admin_template.rb', line 48

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