Module: Microservice::BreadcrumbsHelper

Defined in:
app/helpers/microservice/breadcrumbs_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_breadcrumb(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/microservice/breadcrumbs_helper.rb', line 4

def render_breadcrumb(*args)
  flatten_args = args.flatten.compact
   :div, class: 'ui huge breadcrumb' do
    flatten_args.map.with_index do |element, idx|
      if flatten_args.size == idx + 1
        (:span, element.html_safe, class: 'section active')
      else
        (:span, element.html_safe, class: 'section') +
          (:i, '', class: 'right chevron icon divider')
      end
    end.join.html_safe
  end
end

#render_breadcrumb_edit(entity) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/helpers/microservice/breadcrumbs_helper.rb', line 74

def render_breadcrumb_edit(entity)
  links = [home_link(entity.namespace)]

  if @parent_entity
    links << link_to_entity(@parent_entity.class, :index, no_icon: true)
    links << link_to_entity(@parent_entity, :show, no_icon: true)
  end

  links << link_to_entity(entity.class, :index, no_icon: true)
  links << link_to_entity(entity, :edit, no_icon: true)

  render_breadcrumb links
end

#render_breadcrumb_index(entity_class) ⇒ Object



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

def render_breadcrumb_index(entity_class)
  links = [home_link(entity_class.namespace)]

  if @parent_entity
    links << link_to_entity(@parent_entity.class, :index, no_icon: true)
    links << link_to_entity(@parent_entity, :show, no_icon: true)
  end

  links << link_to_entity(entity_class, :index, no_icon: true)

  render_breadcrumb links
end

#render_breadcrumb_new(entity) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/helpers/microservice/breadcrumbs_helper.rb', line 60

def render_breadcrumb_new(entity)
  links = [home_link(entity.namespace)]

  if @parent_entity
    links << link_to_entity(@parent_entity.class, :index, no_icon: true)
    links << link_to_entity(@parent_entity, :show, no_icon: true)
  end

  links << link_to_entity(entity.class, :index, no_icon: true)
  links << link_to_entity(entity.class, :new, no_icon: true)

  render_breadcrumb links
end

#render_breadcrumb_show(entity) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/microservice/breadcrumbs_helper.rb', line 46

def render_breadcrumb_show(entity)
  links = [home_link(entity.namespace)]

  if @parent_entity
    links << link_to_entity(@parent_entity.class, :index, no_icon: true)
    links << link_to_entity(@parent_entity, :show, no_icon: true)
  end

  links << link_to_entity(entity.class, :index, no_icon: true)
  links << link_to_entity(entity, :show, no_icon: true)

  render_breadcrumb links
end

#render_entity_breadcrumbObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/microservice/breadcrumbs_helper.rb', line 18

def render_entity_breadcrumb
  if @entity
    case action_name
    when 'show'
      render_breadcrumb_show @entity
    when 'new', 'create'
      render_breadcrumb_new @entity
    when 'edit', 'update'
      render_breadcrumb_edit @entity
    end
  elsif controller.entity_class
    render_breadcrumb_index controller.entity_class
  end
end