Module: Releaf::Builders::View

Includes:
Base, Template
Included in:
IndexBuilder, ResourceDialog, ResourceView
Defined in:
app/builders/releaf/builders/view.rb

Instance Attribute Summary

Attributes included from Template

#template

Instance Method Summary collapse

Methods included from Template

#initialize

Methods included from Base

#default_translation_scope, #html_escape, #icon, #layout_settings, #locale_options, #resource_title, #safe_join, #t, #tag, #template_variable, #translate_locale, #wrapper

Instance Method Details



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/builders/releaf/builders/view.rb', line 55

def breadcrumb_item(item, last)
  content = []
  if item[:url].present?
    content << tag(:a, item[:name], href: item[:url])
  else
    content << item[:name]
  end

  content << icon("chevron-right") unless last

  tag(:li) do
    safe_join{ content }
  end
end


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/builders/releaf/builders/view.rb', line 39

def breadcrumbs
  breadcrumb_items = template_variable("breadcrumbs")
  return unless breadcrumb_items.present?

  tag(:nav) do
    tag(:ul, class: "breadcrumbs") do
      safe_join do
        last_item = breadcrumb_items.last
        breadcrumb_items.each.collect do |item, _index|
          breadcrumb_item(item, item == last_item)
        end
      end
    end
  end
end

#dialog?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/builders/releaf/builders/view.rb', line 13

def dialog?
  controller.ajax?
end

#dialog_nameObject



17
18
19
# File 'app/builders/releaf/builders/view.rb', line 17

def dialog_name
  self.class.name.split("::").last.gsub(/(Dialog)?Builder$/, "").underscore.dasherize
end

#flash_item(name, item) ⇒ Object



76
77
78
79
80
81
82
83
# File 'app/builders/releaf/builders/view.rb', line 76

def flash_item(name, item)
  item_data = {type: name}
  item_data[:id] = item["id"] if item.is_a?(Hash)

  tag(:div, class: "flash", data: item_data) do
    item.is_a?(Hash) ? item["message"] : item
  end
end

#flash_noticesObject



70
71
72
73
74
# File 'app/builders/releaf/builders/view.rb', line 70

def flash_notices
  safe_join do
    flash.collect{|name, item| flash_item(name, item) }
  end
end


117
118
119
# File 'app/builders/releaf/builders/view.rb', line 117

def footer_blocks
  [footer_primary_block, footer_secondary_block]
end


121
122
123
124
125
# File 'app/builders/releaf/builders/view.rb', line 121

def footer_primary_block
  tag(:div, class: "primary") do
    footer_primary_tools
  end
end


133
# File 'app/builders/releaf/builders/view.rb', line 133

def footer_primary_tools; end


127
128
129
130
131
# File 'app/builders/releaf/builders/view.rb', line 127

def footer_secondary_block
  tag(:div, class: "secondary") do
    footer_secondary_tools
  end
end


134
# File 'app/builders/releaf/builders/view.rb', line 134

def footer_secondary_tools; end


111
112
113
114
115
# File 'app/builders/releaf/builders/view.rb', line 111

def footer_tools
  tag(:div, class: "tools") do
    footer_blocks
  end
end

#headerObject



21
22
23
24
25
# File 'app/builders/releaf/builders/view.rb', line 21

def header
  tag(:header) do
    [breadcrumbs, flash_notices, header_extras]
  end
end

#header_extrasObject



85
# File 'app/builders/releaf/builders/view.rb', line 85

def header_extras; end

#outputObject



5
6
7
8
9
10
11
# File 'app/builders/releaf/builders/view.rb', line 5

def output
  safe_join do
    list = []
    list << header unless dialog?
    list << section
  end
end

#sectionObject



27
28
29
30
31
# File 'app/builders/releaf/builders/view.rb', line 27

def section
  tag(:section, section_attributes) do
    section_blocks
  end
end

#section_attributesObject



33
34
35
36
37
# File 'app/builders/releaf/builders/view.rb', line 33

def section_attributes
  attributes = {}
  attributes[:class] = ["dialog", dialog_name] if dialog?
  attributes
end

#section_blocksObject



87
88
89
# File 'app/builders/releaf/builders/view.rb', line 87

def section_blocks
  [section_header, section_body, ]
end

#section_bodyObject



99
# File 'app/builders/releaf/builders/view.rb', line 99

def section_body; end


101
102
103
104
105
# File 'app/builders/releaf/builders/view.rb', line 101

def 
  tag(:footer, class: ) do
    footer_tools
  end
end


107
108
109
# File 'app/builders/releaf/builders/view.rb', line 107

def 
  :main unless dialog?
end

#section_headerObject



91
92
93
94
95
# File 'app/builders/releaf/builders/view.rb', line 91

def section_header
  tag(:header) do
    [tag(:h1, section_header_text), section_header_extras]
  end
end

#section_header_extrasObject



98
# File 'app/builders/releaf/builders/view.rb', line 98

def section_header_extras; end

#section_header_textObject



97
# File 'app/builders/releaf/builders/view.rb', line 97

def section_header_text; end