Sha256: f10406334c43f1402e86aad86a5d8743b8ef2833fb93002837b02af398c59269

Contents?: true

Size: 975 Bytes

Versions: 7

Compression:

Stored size: 975 Bytes

Contents

class MessageDatatable < AjaxDatatablesRails::Base
  def_delegators :@view, :link_to, :manage_message_path

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

  private

  def data
    records.map do |record|
      {
        link: link_to('<i class="fa fa-search"></i>'.html_safe, manage_message_path(record)),
        id: record.id,
        name: record.name,
        subject: record.subject,
        trigger: Message::POSSIBLE_TRIGGERS[record.trigger],
        status: record.status.titleize,
        delivered_at: record.delivered_at.present? ? record.delivered_at.strftime("%B %d, %Y at %I:%M %p") : ''
      }
    end
  end

  # rubocop:disable Style/AccessorMethodName
  def get_raw_records
    Message.unscoped
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hackathon_manager-0.6.6 app/datatables/message_datatable.rb
hackathon_manager-0.6.5 app/datatables/message_datatable.rb
hackathon_manager-0.6.4 app/datatables/message_datatable.rb
hackathon_manager-0.6.3 app/datatables/message_datatable.rb
hackathon_manager-0.6.2 app/datatables/message_datatable.rb
hackathon_manager-0.6.1 app/datatables/message_datatable.rb
hackathon_manager-0.6.0 app/datatables/message_datatable.rb