Sha256: fb3089e99936c91e3cd60e0877b09574c7d5fec109e59db2ef876ca5cc13b5f5

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

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

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

5 entries across 5 versions & 1 rubygems

Version Path
hackathon_manager-0.10.1 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.10.0 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.9.2 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.9.1 app/datatables/bulk_message_datatable.rb
hackathon_manager-0.9.0 app/datatables/bulk_message_datatable.rb