Sha256: 8521c5e95ceb1080ae9d95c1a192712d4884522799d3599449c7011a2e252413

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

module Admin
  class EffectiveEventAddonsDatatable < Effective::Datatable
    filters do
      scope :unarchived, label: "All"
      scope :archived
    end

    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 :first_name
      col :last_name
      col :email
      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_by_id(attributes[:event_id])
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
effective_events-0.6.9 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.8 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.7 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.6 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.5 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.4 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.3 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.2 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.1 app/datatables/admin/effective_event_addons_datatable.rb
effective_events-0.6.0 app/datatables/admin/effective_event_addons_datatable.rb