Module: Para::Admin::ComponentsHelper

Defined in:
app/helpers/para/admin/components_helper.rb

Instance Method Summary collapse

Instance Method Details

#admin_component_sectionsObject

Return the sections / components structure, with components properly decorated



6
7
8
9
10
11
12
# File 'app/helpers/para/admin/components_helper.rb', line 6

def admin_component_sections
  @admin_component_sections ||= begin
    Para::ComponentSection.ordered.includes(:components).tap do |sections|
      sections.flat_map(&:components).each(&method(:decorate))
    end
  end
end

#ordered_componentsObject



14
15
16
17
18
19
20
# File 'app/helpers/para/admin/components_helper.rb', line 14

def ordered_components
  admin_component_sections.each_with_object([]) do |section, components|
    section.components.each do |component|
      components << component if can?(:read, component)
    end
  end.sort_by(&:name)
end