Sha256: cf3fa13c5157f460e17e7c2bc8e23518bb21cc91bbf275dc2af4ae8f8eaa7a68

Contents?: true

Size: 1.19 KB

Versions: 12

Compression:

Stored size: 1.19 KB

Contents

class Admin::EffectivePollNotificationsDatatable < Effective::Datatable
  filters do
    scope :all
    scope :started
    scope :completed
  end

  datatable do
    col :updated_at, visible: false
    col :created_at, visible: false
    col :id, visible: false

    col :poll
    col :category

    col :reminder do |poll_notification|
      case poll_notification.category
      when 'When poll starts'
        poll_notification.poll.start_at&.strftime('%F %H:%M')
      when 'When poll ends'
        poll_notification.poll.end_at&.strftime('%F %H:%M')
      when 'Upcoming reminder'
        Effective::PollNotification::UPCOMING_REMINDERS.invert[poll_notification.reminder]
      when 'Reminder'
        Effective::PollNotification::REMINDERS.invert[poll_notification.reminder]
      when 'Before poll ends'
        Effective::PollNotification::UPCOMING_REMINDERS.invert[poll_notification.reminder]
      else
        raise('unexpected category')
      end
    end

    col :subject

    col :body do |notification|
      simple_format(notification.body.to_s)
    end

    col :started_at, visible: false
    col :completed_at

    actions_col
  end

  collection do
    Effective::PollNotification.all.deep
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
effective_polls-0.6.2 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.6.1 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.6.0 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.6 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.5 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.4 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.3 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.2 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.1 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.5.0 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.4.1 app/datatables/admin/effective_poll_notifications_datatable.rb
effective_polls-0.4.0 app/datatables/admin/effective_poll_notifications_datatable.rb