tabulatr2 – index tables for lazy people
DESCRIPTION
a brief wrapup about the ruby gem tabulatr2TRANSCRIPT
tabulatr2Index Pages for Lazy People…
Florian Thomas [email protected]
@crunch09
Peter Horn [email protected]
@n0dashes
Lightning Talk Oct 3rd 2014
tr th Firstname th Lastname th Balance @customers.each do |customer| tr td= customer.firstname td= customer.lastname td= customer.balance
index.html.slim
simple ‘nuf
def index @customers = Customer.all end
Classic Index Page
customer_controller.rb
tr th Firstname th Lastname th Balance @customers.each do |customer| tr td= customer.firstname td= customer.lastname td= customer.balance
index.html.slim
simple ‘nuf
def index @customers = Customer.all end
Classic Index Page
customer_controller.rbLovely!
Just quickly add
• Pagination
• Filtering
• Sorting
• Searching
• Batch Actions
…and we’re done.
tr th Firstname th Lastname th Balance @customers.each do |customer| tr td= customer.firstname td= customer.lastname td= customer.balance
index.html.slim
simple ‘nuf
def index @customers = Customer.all end
Classic Index Page
customer_controller.rbLovely!
Just quickly add
• Pagination
• Filtering
• Sorting
• Searching
• Batch Actions
…and we’re done.
That can’t be!
• ActiveRecord is so simple (and even adequate)
• SimpleForm is so simple!
Why need tables to be such a hazzle?
That can’t be!
• ActiveRecord is so simple (and even adequate)
• SimpleForm is so simple!
Why need tables to be such a hazzle?
Because a friggin’ lot of stuff
is involved.
…but now …there’s tabulatr2!
= table_for Customer
index.html.slim
def index tabulatr_for Customer end
Tabulatr Index Page
customer_controller.rb
class CustomerTabulatrData < Tabulatr::Data ! search :firstname, :lastname column :firstname column :lastname column :balance, format: :currency, align: :right end
customer_tabulatr_data.rb
= table_for Customer
index.html.slim
def index tabulatr_for Customer end
Tabulatr Index Page
customer_controller.rb
class CustomerTabulatrData < Tabulatr::Data ! search :firstname, :lastname column :firstname column :lastname column :balance, format: :currency, align: :right end
customer_tabulatr_data.rb
There’s so much more• All data is fetched via ajax
• Custom SQL for sorting, filtering, sorting, no N + 1
• Tables are (by default) stateful
• Infinite scrolling, if you so wish
• Shortcuts to create ‘action’ buttons
• Support for static tables (non-ajax)
• Batch actions
• …
How Does That Work?
(rough concept only)
Controller
Renderer
DSL
Javascript
View
TabulatrData
122.54% Cooler!*
✴ Based on a study with 4 developers that took place between October 1st and October 2rd 2014 in some pubs in Ghent. There definitely was too much alcohol involved, and the number is made up anyway, but things look so much more professional with a footnote.
github.com/provideal/tabulatr2
Sparklelord demands: Give it a try!
Talk to us!@n0dashes / no-dashes!@crunch09 / Crunch09