Sha256: feed4ef1ad878e9ec84e790c42dbf4efac03ba0624f5552a197635b476b6ab65

Contents?: true

Size: 1.23 KB

Versions: 20

Compression:

Stored size: 1.23 KB

Contents

module Admin
  class EffectiveEventProductsDatatable < 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 :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_addons_count, label: 'Purchased'
      col :capacity, visible: false
      col :capacity_available, visible: false

      col :purchased_event_addons, label: 'Purchased by' do |product|
        product.purchased_event_addons.sort_by(&:to_s).map do |purchase|
          content_tag(:div, purchase.owner.to_s, class: 'col-resource_item')
        end.join.html_safe
      end

      actions_col
    end

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

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

      scope
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
effective_events-0.7.3 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.7.2 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.7.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.7.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.13 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.12 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.11 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.10 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.9 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.8 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.7 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.6 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.5 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.4 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.3 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.2 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.6.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.5.6 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.5.5 app/datatables/admin/effective_event_products_datatable.rb