Sha256: e20068864b05e1d7faaea6d1d2e8a1e431ede5d43d41dedfa0eb2ebcb578f706

Contents?: true

Size: 1.23 KB

Versions: 87

Compression:

Stored size: 1.23 KB

Contents

# Used on the Event Registrations Addons step

class EffectiveEventAddonsDatatable < Effective::Datatable
  datatable do

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

    col :event_product, search: :string, label: 'Add-on' do |er|
      [
        er.event_product.to_s,
        (content_tag(:span, 'Archived', class: 'badge badge-warning') if er.event_product&.archived?)
      ].compact.join('<br>').html_safe
    end

    col :price, as: :price

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

    col :archived, visible: false

    # no actions_col
  end

  collection do
    scope = Effective::EventAddon.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_by_id(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

87 entries across 87 versions & 1 rubygems

Version Path
effective_events-2.31.4 app/datatables/effective_event_addons_datatable.rb
effective_events-2.31.3 app/datatables/effective_event_addons_datatable.rb
effective_events-2.31.2 app/datatables/effective_event_addons_datatable.rb
effective_events-2.31.1 app/datatables/effective_event_addons_datatable.rb
effective_events-2.31.0 app/datatables/effective_event_addons_datatable.rb
effective_events-2.30.3 app/datatables/effective_event_addons_datatable.rb
effective_events-2.30.2 app/datatables/effective_event_addons_datatable.rb
effective_events-2.30.1 app/datatables/effective_event_addons_datatable.rb
effective_events-2.30.0 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.6 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.5 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.4 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.3 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.2 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.1 app/datatables/effective_event_addons_datatable.rb
effective_events-2.29.0 app/datatables/effective_event_addons_datatable.rb
effective_events-2.28.3 app/datatables/effective_event_addons_datatable.rb
effective_events-2.28.2 app/datatables/effective_event_addons_datatable.rb
effective_events-2.28.1 app/datatables/effective_event_addons_datatable.rb
effective_events-2.28.0 app/datatables/effective_event_addons_datatable.rb