Sha256: 98fa4fb26673410a6636a90aac5ff75f8f561353ae56986e11ac27688c47e028

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

module Admin
  class EffectiveEventAddonsDatatable < Effective::Datatable
    datatable do
      col :updated_at, visible: false
      col :created_at, visible: false
      col :id, 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
      col :owner
      col :notes, label: 'Notes'

      actions_col
    end

    collection do
      scope = Effective::EventAddon.deep.purchased.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(attributes[:event_id])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_events-0.2.8 app/datatables/admin/effective_event_addons_datatable.rb