Sha256: 5eca021e351165bb5454c137acc6d7367df0b32084f6b160ee06aa5642052bcf

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

module Admin
  class EffectiveEventAddonsDatatable < Effective::Datatable
    filters do
      scope :registered
      scope :purchased_or_created_by_admin, label: 'Purchased'
      scope :deferred
      scope :not_purchased_not_created_by_admin, label: 'Not Purchased'
      scope :archived
      scope :all
    end

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

      col :event

      col :event_registration, visible: false

      if attributes[:event_id]
        col :event_product, search: Effective::EventProduct.where(event: event).all
      else
        col :event_product, search: :string
      end

      col :purchased_order, visible: false
      col :owner, visible: false

      col :first_name
      col :last_name
      col :email
      col :notes, label: 'Notes'

      actions_col
    end

    collection do
      scope = Effective::EventAddon.deep.includes(:purchased_order, :owner)

      if attributes[:event_id].present?
        scope = scope.where(event: event)
      end

      scope
    end

    def event
      @event ||= if attributes[:event_id]
        Effective::Event.find_by_id(attributes[:event_id])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_events-0.23.1 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.23.0 app/datatables/admin/effective_event_addons_datatable.rb