Sha256: b0a02348d781ad0c6b2da9b5b5dcda0c81a851f3480101964ff55b4dc729ca18

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

class EffectiveQbSyncDatatable < Effective::Datatable
  datatable do
    order :created_at, :desc

    col :created_at
    col :state

    val :num_orders, visible: false do |qb_ticket|
      qb_ticket.qb_requests.length
    end

    val :orders, sort: false, as: :obfuscated_id do |qb_ticket|
      qb_ticket.qb_requests.select { |qb_request| qb_request.order.present? }
    end.format do |requests|
      requests.map { |qb_request| link_to "##{qb_request.order.to_param}", effective_orders.admin_order_path(qb_request.order) }
      .join('<br>').html_safe
    end.search do |collection, term, column, sql_column|
      order = Effective::Order.where(id: search_term).first

      if order.present?
        collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
      else
        collection.none
      end
    end

    actions_col do |qb_ticket|
      dropdown_link_to 'Show', effective_qb_sync.admin_qb_sync_path(qb_ticket)
    end

  end

  collection do
    Effective::QbTicket.deep.all
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_qb_sync-1.3.3 app/datatables/effective_qb_sync_datatable.rb
effective_qb_sync-1.3.2 app/datatables/effective_qb_sync_datatable.rb
effective_qb_sync-1.3.1 app/datatables/effective_qb_sync_datatable.rb
effective_qb_sync-1.3.0 app/datatables/effective_qb_sync_datatable.rb