Sha256: c38b0df798eaebcfc083070cef2f3ae25a0211fbcef055874b7e060f181a61a9

Contents?: true

Size: 1.42 KB

Versions: 33

Compression:

Stored size: 1.42 KB

Contents

class ProductTabulatrData < Tabulatr::Data

  search :vendor_product_name, :price, :title

  # search do |query|
  #   "products.title LIKE '#{query}'"
  # end

  column :title
  column :id
  column :status
  column :price, filter: :range do "#{record.price} EUR" end
  column :edit_link do link_to "edit #{record.title}", product_path(record) end
  # column :name,
  #   sort: "firstname || ' ' || lastname"
  #   filter: "firstname || ' ' || lastname"
  #   do
  #     "#{firstname} #{lastname}"
  # end
  column :vendor_product_name,
    sort_sql: "products.title || '' || vendors.name",
    filter_sql: "products.title || '' || vendors.name",
    header: 'Product by vendor' do
    "#{record.title} from #{record.vendor.try(:name)}"
  end
  column :active, sortable: false
  column :updated_at, filter: :date do "#{record.updated_at.strftime('%H:%M %d.%m.%Y')}" end
  association :vendor, :name, filter: :exact
  association :tags, :title do |r|
    "'#{r.tags.map(&:title).map(&:upcase).join(', ')}'"
  end
  association :tags, :count

  buttons width: '200px' do |b,r|
    b.button :eye, product_path(r), class: 'btn-success'
    b.button :pencil, edit_product_path(r), class: 'btn-warning'
    b.submenu do |s|
      s.button :star, product_path(r), label: 'Great product!'
      s.divider
      s.button :'trash-o', product_path(r), label: 'Remove', class: 'btn-danger', method: :delete, data: {confirm: 'are you sure?'}
    end
    "test!"
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
tabulatr2-0.10.4 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.10.3 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.10.2 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.10.1 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.10.0 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.48 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.47 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.46 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.45 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.44 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.43 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.42 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.41 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.40 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.39 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.38 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.37 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.36 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.35 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb
tabulatr2-0.9.34 spec/dummy/app/tabulatr_data/product_tabulatr_data.rb