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
13
14
# File 'app/helpers/para/admin/components_helper.rb', line 6

def admin_component_sections
  @admin_component_sections ||= begin
    sections = Para::ComponentSection.ordered.includes(:components, :parent_component)

    sections.tap do |loaded_sections|
      loaded_sections.flat_map(&:components).each(&method(:decorate))
    end
  end
end

#current_component_or_parent?(component) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'app/helpers/para/admin/components_helper.rb', line 29

def current_component_or_parent?(component)
  return false unless @component

  @component == component || @component.parent_component == component
end

#ordered_componentsObject



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

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

#show_component?(component) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'app/helpers/para/admin/components_helper.rb', line 24

def show_component?(component)
  config = Para.components.component_configuration_for(component.identifier)
  !config.shown_if || instance_exec(&config.shown_if)
end