Sha256: e90bde4d438d194c6772860bc738ade263d04284d9b3fbeff599ba54f75f56a6

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module ActiveAdmin
  module Dashboards
    class DashboardController < ResourceController

      actions :index

      def index
        @dashboard_sections = find_sections
        render 'active_admin/dashboard/index.html.arb'
      end

      private

      def set_current_tab
        @current_tab = I18n.t("active_admin.dashboard")
      end

      def find_sections
        sections = ActiveAdmin::Dashboards.sections_for_namespace(namespace)        
        sections.select do |section|
          if section.options.has_key?(:if)
            symbol_or_proc = section.options[:if]
            case symbol_or_proc
            when Symbol, String then self.send(symbol_or_proc)
            when Proc           then instance_exec(&symbol_or_proc)
            else symbol_or_proc
            end
          else
            true
          end
        end
      end
      
      def namespace
        class_name = self.class.name
        if class_name.include?('::')
          self.class.name.split('::').first.underscore.to_sym
        else
          :root
        end
      end

      # Return the current menu for the view. This is a helper method
      def current_menu
        active_admin_namespace.menu
      end

      def active_admin_namespace
        ActiveAdmin.application.namespace(namespace)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
andrewroth_activeadmin-0.3.4.4 lib/active_admin/dashboards/dashboard_controller.rb
andrewroth_activeadmin-0.3.4.3 lib/active_admin/dashboards/dashboard_controller.rb
andrewroth_activeadmin-0.3.4.2 lib/active_admin/dashboards/dashboard_controller.rb
andrewroth_activeadmin-0.3.4.1 lib/active_admin/dashboards/dashboard_controller.rb