Sha256: 674673e83b711b4a87971bf7d446eb71ccf264e316f5154ac8bdaa1947847b15

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  module IndexHelper
    def scope_name(scope)
      case scope.name
      when Proc then
        self.instance_exec(&scope.name).to_s
      else
        scope.name.to_s
      end
    end

    def batch_actions_to_display
      @batch_actions_to_display ||= begin
        if active_admin_config && active_admin_config.batch_actions.any?
          active_admin_config.batch_actions.select do |batch_action|
            call_method_or_proc_on(self, batch_action.display_if_block)
          end
        else
          []
        end
      end
    end

    # 1. removes `select` and `order` to prevent invalid SQL
    # 2. correctly handles the Hash returned when `group by` is used
    def collection_size(c = collection)
      return c.count if c.is_a?(Array)
      return c.length if c.limit_value

      c = c.except :select, :order

      c.group_values.present? ? c.count.count : c.count
    end

    def collection_empty?(c = collection)
      collection_size(c) == 0
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
activeadmin-4.0.0.beta14 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta13 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta12 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta11 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta10 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta9 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta8 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta7 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta6 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta5 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta4 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta3 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta2 app/helpers/active_admin/index_helper.rb
activeadmin-4.0.0.beta1 app/helpers/active_admin/index_helper.rb