Sha256: ca55d7e4dcb45b5391d4a801c90a973b5e36969465888ce85d7f7443d48aaa31

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# Used on the Event Registrations registrants step

class EffectiveEventRegistrantsDatatable < Effective::Datatable
  datatable do

    col :event_ticket, search: :string, label: 'Ticket'

    col :name do |er|
      "#{er.first_name} #{er.last_name}<br><small>#{mail_to(er.email)}</small>"
    end

    col :first_name, visible: false
    col :last_name, visible: false
    col :email, visible: false
    col :company, visible: false
    col :number, visible: false

    col :price, as: :price
    col :notes

    # no actions_col
  end

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

    if event.present?
      scope = scope.where(event: event)
    end

    if event_registration.present?
      scope = scope.where(event_registration_id: event_registration)
    end

    scope
  end

  def event
    @event ||= if attributes[:event_id]
      Effective::Event.find(attributes[:event_id])
    end
  end

  def event_registration
    @event_registration ||= if attributes[:event_registration_id]
      EffectiveEvents.EventRegistration.find_by_id(attributes[:event_registration_id])
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_events-0.2.0 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.1.10 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.1.9 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.1.8 app/datatables/effective_event_registrants_datatable.rb