Module: Para::Admin::PageHelper
- Defined in:
- app/helpers/para/admin/page_helper.rb
Instance Method Summary collapse
- #actions_for(type) ⇒ Object
- #build_action(action) ⇒ Object
- #component_navigation ⇒ Object
- #page_top_bar(options = {}) ⇒ Object
Instance Method Details
#actions_for(type) ⇒ Object
31 32 33 34 35 |
# File 'app/helpers/para/admin/page_helper.rb', line 31 def actions_for(type) Para.config.page_actions_for(type).map do |action| instance_eval(&action) end.compact end |
#build_action(action) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/para/admin/page_helper.rb', line 17 def build_action(action) = action.fetch(:link_options, {}) [:class] ||= 'btn btn-default btn-shadow btn-sm' content_tag(:div, class: 'actions-control pull-right') do link_to(action[:url], ) do ( (fa_icon(action[:icon], class: 'fa-fw') if action[:icon]) + action[:label] ).html_safe end end end |
#component_navigation ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/para/admin/page_helper.rb', line 37 def parent_component = @component && ( @component.parent_component || @component.child_components.any? && @component ) return unless parent_component # If the component has a `model_type` option, therefore, an associated model, # we try to render the partial from the relative path of the model, else we # use the component class as the base target path partial_target = parent_component.try(:model_type) || parent_component render partial: find_partial_for(partial_target, :navigation), locals: { parent_component: parent_component, active_component: @component } end |
#page_top_bar(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/para/admin/page_helper.rb', line 4 def ( = {}) = content_tag(:div, class: 'page-title row') do content_tag(:h1, [:title]) + if (actions = actions_for([:type])) actions.map(&method(:build_action)).join('').html_safe end end # Return both top bar and component navigation to be displayed at the top of the # page. + end |