Sha256: 751f0b96d18f9a04dc6056895ebeee8a6c5ba0028baf70fb2794422dc7593158

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

class EffectiveLogChangesDatatable < Effective::Datatable
  datatable do
    order :id, :desc

    col :updated_at, label: 'Date'
    col :id, visible: false

    col :user, search: :string, sort: false

    col :associated_type, visible: false
    col :associated_id, visible: false, label: 'Associated Id'
    col :associated_to_s, visible: false, label: 'Associated'

    col :message, sort: false do |log|
      message = (log.message || '').gsub("\n", '<br>')

      if log.associated_id == attributes[:changes_to_id] && log.associated_type == attributes[:changes_to_type]
        message
      else
        "#{log.associated_type} #{log.associated_to_s} - #{message}"
      end

    end.search do |collection, term, column, sql_column|
      ilike = effective_resource.ilike
      collection.where("associated_type #{ilike} ? OR associated_to_s #{ilike} ? OR message #{ilike} ?", "%#{term}%", "%#{term}%", "%#{term}%")
    end

    col :details, visible: false, sort: false do |log|
      tableize_hash(log.details)
    end

    actions_col
  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
  collection do
    EffectiveLogging.Log.logged_changes.deep
      .where(changes_to_type: attributes[:changes_to_type], changes_to_id: attributes[:changes_to_id])
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
effective_logging-4.3.1 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.3.0 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.2.0 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.1.3 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.1.2 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.1.1 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.1.0 app/datatables/effective_log_changes_datatable.rb
effective_logging-4.0.0 app/datatables/effective_log_changes_datatable.rb