Sha256: 8de4401a3afdb50b7965bee1e007c98c9820c5f8c2022f46639fd2ddcbf94319

Contents?: true

Size: 1.61 KB

Versions: 2

Compression:

Stored size: 1.61 KB

Contents

if defined?(EffectiveDatatables)
  module Effective
    module Datatables
      class Logs < Effective::Datatable
        include EffectiveLoggingHelper

        default_order :created_at, :desc

        table_column :created_at
        table_column :user

        table_column :status, :filter => {:type => :select, :values => EffectiveLogging.statuses }
        table_column :message, :width => '50%'

        table_column :details, :visible => false do |log|
          log.details.delete(:email)
          tableize_hash(log.details, :th => true, :sub_th => false, :width => '100%')
        end

        table_column :actions, :sortable => false, :filter => false do |log|
          show_path =
            if datatables_active_admin_path?
              admin_effective_log_path(log)
            elsif datatables_admin_path?
              effective_logging.admin_log_path(log)
            else
              effective_logging.log_path(log)
            end

          if log.logs_count.to_i > 0
            link_to "View&nbsp;(#{log.logs_count}&nbsp;more)".html_safe, show_path
          else
            link_to 'View', show_path
          end
        end

        # A nil attributes[:log_id] means give me all the top level log entries
        # If we set a log_id then it's for sub logs
        def collection
          if attributes[:user_id].present?
            Effective::Log.unscoped.where(:parent_id => attributes[:log_id]).where(:user_id => attributes[:user_id]).includes(:user)
          else
            Effective::Log.unscoped.where(:parent_id => attributes[:log_id]).includes(:user)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_logging-1.1.0 app/models/effective/datatables/logs.rb
effective_logging-1.0.0 app/models/effective/datatables/logs.rb