Sha256: 3c6037bf76172571f785d2c0fe79b56fc47ab79720b720f14a48bb0d557d789e

Contents?: true

Size: 730 Bytes

Versions: 46

Compression:

Stored size: 730 Bytes

Contents

require 'active_support/concern'

module ExportConcern
  extend ActiveSupport::Concern
  included do
    # Should the action be visible
    # Edit By taris, it shows the button only if there are records displayed
    register_instance_option :visible? do
      # If not in index, then return true,
      # otherwise it wont' be added to the list
      # of all Actions during rails initialization
      # In index, instead, I show it only if there are records in the current view
      bindings[:controller].action_name == "index" ? (authorized? && !bindings[:controller].instance_variable_get("@objects").blank?) : true
    end
  end
end

# include the extension
RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
thecore-1.5.10 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.9 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.8 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.7 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.6 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.5 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.4 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.3 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.2 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.1 lib/thecore_rails_admin_export_concern.rb
thecore-1.5.0 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.10 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.8 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.7 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.6 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.5 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.4 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.3 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.2 lib/thecore_rails_admin_export_concern.rb
thecore-1.4.1 lib/thecore_rails_admin_export_concern.rb