Sha256: 716d69df0b21646a045ca601a51fae83d628b61cf8b65a6c2b13296f27c4a7dc

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

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

        datatable do
          default_order :created_at, :desc

          table_column :created_at
          table_column :id, visible: false

          table_column :parent_id, visible: false
          table_column :user, :if => proc { attributes[:user_id].blank? }

          table_column :status, filter: { type: :select, values: EffectiveLogging.statuses }

          table_column :message, width: '50%', sortable: false
          table_column :logs_count, visible: false

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

          table_column :updated_at, visible: false

          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
        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

6 entries across 6 versions & 1 rubygems

Version Path
effective_logging-1.3.1 app/models/effective/datatables/logs.rb
effective_logging-1.3.0 app/models/effective/datatables/logs.rb
effective_logging-1.2.6 app/models/effective/datatables/logs.rb
effective_logging-1.2.5 app/models/effective/datatables/logs.rb
effective_logging-1.2.4 app/models/effective/datatables/logs.rb
effective_logging-1.2.3 app/models/effective/datatables/logs.rb