Sha256: 33b9d53ebc6f5f001afef5783736d5fd2707cc518e32f952d67b55ac4f8b8814

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

class BulkMessageDatatable < AjaxDatatablesRails::Base
  def_delegators :@view, :link_to, :manage_message_path, :display_datetime

  def view_columns
    @view_columns ||= {
      id: { source: "Message.id" },
      name: { source: "Message.name" },
      subject: { source: "Message.subject" },
      created_at: { source: "Message.created_at", searchable: false },
      updated_at: { source: "Message.updated_at", searchable: false },
      delivered_at: { source: "Message.delivered_at", searchable: false }
    }
  end

  private

  def data
    records.map do |record|
      {
        id: record.id,
        name: link_to(record.name, manage_message_path(record)),
        subject: record.subject,
        status: record.status.titleize,
        created_at: display_datetime(record.created_at),
        updated_at: record.updated_at.present? ? display_datetime(record.updated_at) : '',
        delivered_at: record.delivered_at.present? ? display_datetime(record.delivered_at) : ''
      }
    end
  end

  # rubocop:disable Naming/AccessorMethodName
  def get_raw_records
    Message.where(type: 'bulk')
  end
  # rubocop:enable Naming/AccessorMethodName
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hackathon_manager-0.8.2 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.8.1 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.8.0 app/datatables/bulk_message_datatable.rb