Sha256: a423bc03ae1b8cc6257e85c57f471ff6b001d618262d9a2d075c4e522a8512b9

Contents?: true

Size: 980 Bytes

Versions: 8

Compression:

Stored size: 980 Bytes

Contents

module Admin
  class EffectiveEventTicketsDatatable < Effective::Datatable
    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 :archived

      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

8 entries across 8 versions & 1 rubygems

Version Path
effective_events-0.2.8 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.7 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.6 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.5 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.4 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.3 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.2 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.2.1 app/datatables/admin/effective_event_tickets_datatable.rb