Sha256: 2edc89cdc3da2bbf0043611456f269b666995e9ce80edac83894f1382a9c7389

Contents?: true

Size: 1 KB

Versions: 17

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  class BaseController < ::InheritedResources::Base
    module Menu
      extend ActiveSupport::Concern

      included do
        before_action :set_current_tab
        helper_method :current_menu
      end

      protected

      def current_menu
        active_admin_config.navigation_menu
      end

      # Set's @current_tab to be name of the tab to mark as current
      # Get's called through a before filter
      def set_current_tab
        @current_tab = if current_menu && active_admin_config.belongs_to? && parent?
                         parent_item = active_admin_config.belongs_to_config.target.menu_item
                         if current_menu.include? parent_item
                           parent_item
                         else
                           active_admin_config.menu_item
                         end
                       else
                         active_admin_config.menu_item
                       end
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/base_controller/menu.rb
activeadmin-3.2.4 lib/active_admin/base_controller/menu.rb
activeadmin-3.2.3 lib/active_admin/base_controller/menu.rb
activeadmin-3.2.2 lib/active_admin/base_controller/menu.rb
activeadmin-3.2.1 lib/active_admin/base_controller/menu.rb
activeadmin-3.2.0 lib/active_admin/base_controller/menu.rb
activeadmin-3.1.0 lib/active_admin/base_controller/menu.rb
activeadmin-3.0.0 lib/active_admin/base_controller/menu.rb
activeadmin-2.14.0 lib/active_admin/base_controller/menu.rb
activeadmin-2.13.1 lib/active_admin/base_controller/menu.rb
activeadmin-2.13.0 lib/active_admin/base_controller/menu.rb
activeadmin-2.12.0 lib/active_admin/base_controller/menu.rb
activeadmin-2.11.2 lib/active_admin/base_controller/menu.rb
activeadmin-2.11.1 lib/active_admin/base_controller/menu.rb
activeadmin-2.11.0 lib/active_admin/base_controller/menu.rb
activeadmin-2.10.1 lib/active_admin/base_controller/menu.rb
activeadmin-2.10.0 lib/active_admin/base_controller/menu.rb