Sha256: 67f7611fb06f297d4d66ecb22c3756669b934808f113a456307915e179d09b5f

Contents?: true

Size: 1.66 KB

Versions: 14

Compression:

Stored size: 1.66 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 :archived, 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 :registered_event_addons_count, label: 'Registered'
      col :purchased_event_addons_count, label: 'Purchased', visible: false

      col :capacity, visible: false
      col :capacity_available, visible: false

      # col :registered_event_addons, label: 'Registered Names' do |product|
      #   product.registered_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
      #     content_tag(:div, addon.name.to_s, class: 'col-resource_item')
      #   end.join.html_safe
      # end

      # col :purchased_event_addons, label: 'Purchased Names', visible: false do |product|
      #   product.purchased_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
      #     content_tag(:div, addon.name.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

14 entries across 14 versions & 1 rubygems

Version Path
effective_events-2.29.2 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.29.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.29.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.28.3 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.28.2 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.28.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.28.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.27.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.26.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.25.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-2.25.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.24.0 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.23.1 app/datatables/admin/effective_event_products_datatable.rb
effective_events-0.23.0 app/datatables/admin/effective_event_products_datatable.rb