Sha256: e1aa3027ccdf0a3a20c85b3f8f6a332a826bf72328c369e58b21309035da5c4e

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 KB

Contents

module ThinkFeelDoDashboard
  # Ensure font awesome icon helpers are available.
  module ApplicationHelper
    TOP_LEVEL_CONTROLLERS = %w( arms groups participants users reports ).freeze

    # Render navigational information in the form of breadcrumbs
    def breadcrumbs
      return unless show_breadcrumbs?

      content_for(
        :breadcrumbs,
        content_tag(:ol, class: "breadcrumb") do
          concat(content_tag(:li, link_to("Home", root_path)))

          if can_view_resource_index?
            concat(content_tag(:li,
                               link_to(controller_name.capitalize,
                                       url_for(controller: controller_name))
                              )
                  )
          end
        end
      )
    end

    def social_features?
      if Rails.application.config.respond_to?(:include_social_features)
        Rails.application.config.include_social_features
      end
    end

    private

    def show_breadcrumbs?
      TOP_LEVEL_CONTROLLERS.include?(controller_name)
    end

    def can_view_resource_index?
      begin
        klass = controller_name.singularize.capitalize.constantize
      rescue NameError
        klass = nil
      end

      !klass.is_a?(Class) || can?(:index, klass)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
think_feel_do_dashboard-1.1.19 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.18 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.17 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.16 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.15 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.14 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.13 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.12 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.11 app/helpers/think_feel_do_dashboard/application_helper.rb
think_feel_do_dashboard-1.1.10 app/helpers/think_feel_do_dashboard/application_helper.rb