Sha256: 7b26770be02acb6b3a4274d14029a878013c3bd954a2587536fbce0f52e2a0c8

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

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

      col :purchased_event_registrants, label: 'Registrants' do |ticket|
        ticket.purchased_event_registrants.sort_by(&:last_name).map do |registrant|
          content_tag(:div, registrant.last_first_name, class: 'col-resource_item')
        end.join.html_safe
      end

      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

6 entries across 6 versions & 1 rubygems

Version Path
effective_events-0.2.0 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.1.10 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.1.9 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.1.8 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.1.7 app/datatables/admin/effective_event_tickets_datatable.rb
effective_events-0.1.6 app/datatables/admin/effective_event_tickets_datatable.rb