Module: Releaf::Builders::View
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
#breadcrumb_item(item, last) ⇒ Object
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
|
#breadcrumbs ⇒ Object
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
13
14
15
|
# File 'app/builders/releaf/builders/view.rb', line 13
def dialog?
controller.ajax?
end
|
#dialog_name ⇒ Object
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_notices ⇒ Object
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
[, ]
end
|
121
122
123
124
125
|
# File 'app/builders/releaf/builders/view.rb', line 121
def
tag(:div, class: "primary") do
end
end
|
133
|
# File 'app/builders/releaf/builders/view.rb', line 133
def ; end
|
127
128
129
130
131
|
# File 'app/builders/releaf/builders/view.rb', line 127
def
tag(:div, class: "secondary") do
end
end
|
134
|
# File 'app/builders/releaf/builders/view.rb', line 134
def ; end
|
111
112
113
114
115
|
# File 'app/builders/releaf/builders/view.rb', line 111
def
tag(:div, class: "tools") do
end
end
|
21
22
23
24
25
|
# File 'app/builders/releaf/builders/view.rb', line 21
def
tag(:header) do
[breadcrumbs, flash_notices, ]
end
end
|
85
|
# File 'app/builders/releaf/builders/view.rb', line 85
def ; end
|
#output ⇒ Object
5
6
7
8
9
10
11
|
# File 'app/builders/releaf/builders/view.rb', line 5
def output
safe_join do
list = []
list << unless dialog?
list << section
end
end
|
#section ⇒ Object
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_attributes ⇒ Object
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_blocks ⇒ Object
87
88
89
|
# File 'app/builders/releaf/builders/view.rb', line 87
def section_blocks
[, section_body, ]
end
|
#section_body ⇒ Object
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
end
end
|
107
108
109
|
# File 'app/builders/releaf/builders/view.rb', line 107
def
:main unless dialog?
end
|
91
92
93
94
95
|
# File 'app/builders/releaf/builders/view.rb', line 91
def
tag(:header) do
[tag(:h1, ), ]
end
end
|
98
|
# File 'app/builders/releaf/builders/view.rb', line 98
def ; end
|
97
|
# File 'app/builders/releaf/builders/view.rb', line 97
def ; end
|