Sha256: f8ec408321f71017d6dace74acca3197df48f0b7969c511380c04fb94073f196

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

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

    datatable do
      reorder :position

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

      col :event

      col :title
      col :regular_price, as: :price
      col :early_bird_price, as: :price

      col :capacity_to_s, label: 'Capacity' do |ticket|
        if ticket.capacity.present?
          "#{ticket.capacity_available} remaining / #{ticket.capacity} total"
        end
      end

      col :purchased_event_registrants_count, label: 'Registered'
      col :capacity, visible: false
      col :capacity_available, visible: false

      actions_col
    end

    collection do
      scope = Effective::EventTicket.deep.all

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

      scope
    end

    def event
      Effective::Event.find(attributes[:event_id])
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
effective_events-0.5.4 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.5.3 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.5.2 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.5.1 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.5.0 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.4.2 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.4.1 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.4.0 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.3.1 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.3.0 app/datatables/admin/effective_event_tickets_datatable.rb