Module: PageHelper

Defined in:
app/helpers/page_helper.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#card(title: nil, css_class: '', without_block: false, id: nil, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/page_helper.rb', line 35

def card(title: nil, css_class: '', without_block: false, id: nil, &block)
  tag.div(class: "card #{css_class}", id: id) do
    concat tag.h3(title, class: 'card-header') if title
    if without_block
      yield
    else
      concat tag.div(class: 'card-body', &block)
    end
  end
end

#content(&block) ⇒ Object

Main body of the page, provides information about what you HAVE



26
27
28
# File 'app/helpers/page_helper.rb', line 26

def content(&block)
  grouping(:content, class: 'content-main', &block)
end

#count_badge(count, badge_id = nil) ⇒ Object

eg. count_badge(0) <span class=“badge badge-secondary”>0</span> eg. count_badge(10) <span class=“badge badge-primary”>10</span>



63
64
65
66
67
68
69
70
71
72
# File 'app/helpers/page_helper.rb', line 63

def count_badge(count, badge_id = nil)
  state =
    case count
    when nil, 0
      'secondary'
    else
      'primary'
    end
  tag.span(count || '...', class: "badge badge-pill badge-#{state}", id: badge_id)
end

#flash_messagesObject



4
5
6
# File 'app/helpers/page_helper.rb', line 4

def flash_messages
  render(partial: 'application/flash_messages')
end

#jumbotron(jumbotron_id = nil, options = {}, &block) ⇒ Object



46
47
48
49
50
51
# File 'app/helpers/page_helper.rb', line 46

def jumbotron(jumbotron_id = nil, options = {}, &block)
  options[:class] ||= +''
  options[:class] << ' jumbotron'
  options[:id] = jumbotron_id
  tag.div(**options, &block)
end

#page(id, css_class = nil, prevent_row: false, &block) ⇒ Object

Renders the content in the block in the standard page template, including heading flash and sidebar



15
16
17
18
19
20
21
22
23
# File 'app/helpers/page_helper.rb', line 15

def page(id, css_class = nil, prevent_row: false, &block)
  grouping(:page, id: id, class: "container-fluid #{css_class}") do
    if prevent_row
      concat yield
    else
      concat tag.div(class: 'row', &block)
    end
  end
end

Provides information about what you can DO



31
32
33
# File 'app/helpers/page_helper.rb', line 31

def sidebar(&block)
  grouping(:sidebar, class: 'sidebar content-secondary', &block)
end

#state_badge(state) ⇒ Object

eg. state_badge(‘pending’) <span class=“state-badge-pending”>Pending</span>



55
56
57
# File 'app/helpers/page_helper.rb', line 55

def state_badge(state)
  tag.span(state.titleize, class: "state-badge #{state}", title: 'Labware State', data: { toggle: 'tooltip' })
end