Class: MegaBar::LayablesController
Instance Method Summary
collapse
#add_form_path_to_mega_displays, #administer_block, #administer_page, #collect_filters, #column_sorting, #conditions, #constant_from_controller, #create, #destroy, #edit, #form_path, #is_displayable?, #might_filter?, #might_paginate?, #move, #new, #num_per_page, #process_filters, #redo_setup, #set_vars_for_all, #set_vars_for_displays, #show, #sort_column, #sort_direction, #test_create, #unpack_nested_classes, #update
#_params, #env
#can_create?, #can_destroy?, #can_edit?, #can_index?, #can_perform_action?, #can_show?, #can_update?, #has_mega_role?, #link_if_can, #link_if_can_create, #link_if_can_destroy, #link_if_can_edit, #link_if_can_index, #link_if_can_show, #link_if_can_update, #link_if_can_with_wrapper
Instance Method Details
#display_layout ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/mega_bar/layables_controller.rb', line 16
def display_layout
final_layout_sections = {}
@layout.template.template_sections.each do |section|
@layable = @layables.find_by(template_section_id: section.id)
final_layout_sections[section.code_name] = []
final_layout_sections[section.code_name][0] = generate_section(section)
end
html = []
m_template = TemplatesController.new
m_template.request = request
m_template.response = response
m_template.instance_variable_set("@mega_layout_sections", final_layout_sections)
m_template.instance_variable_set("@mega_layout", @layout)
html << m_template.render_template_with_layout_sections
"<div class='admin-layout-template'>" + html[0] + "</div>"
end
|
#generate_section(template_section) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/mega_bar/layables_controller.rb', line 62
def generate_section(template_section)
m_layout_section = MegaBar::MasterLayoutSectionsController.new
m_layout_section.request = request
m_layout_section.response = response
m_layout_section.instance_variable_set("@layable", @layable)
m_layout_section.instance_variable_set("@mega_layout_section", template_section)
m_layout_section.instance_variable_set("@mega_layout", @layout)
blocks = MegaBar::Block.by_layout_section(template_section.id).order(position: :asc)
m_layout_section.instance_variable_set("@blocks", blocks.map do |blck|
{
id: blck.id,
header: blck.model_displays.where(action: "index").first&.,
actions: blck.actions,
html: blck.html || "",
}
end)
m_layout_section.render_to_string("render_layout_section_admin")
end
|
#index ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'app/controllers/mega_bar/layables_controller.rb', line 6
def index
if @layout
@layables = Layable.where(layout_id: @layout.id)
@bob = display_layout
render plain: @bob
else
super
end
end
|