Module: Para::Admin::ComponentsHelper
- Defined in:
- app/helpers/para/admin/components_helper.rb
Instance Method Summary collapse
-
#admin_component_sections ⇒ Object
Return the sections / components structure, with components properly decorated.
- #ordered_components ⇒ Object
- #show_component?(component) ⇒ Boolean
Instance Method Details
#admin_component_sections ⇒ Object
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_components ⇒ Object
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 |
#show_component?(component) ⇒ Boolean
22 23 24 25 |
# File 'app/helpers/para/admin/components_helper.rb', line 22 def show_component?(component) config = Para.components.component_configuration_for(component.identifier) !config.shown_if || instance_exec(&config.shown_if) end |