tab/app/grids/transactions_grid.rb

33 lines
802 B
Ruby
Raw Normal View History

class TransactionsGrid
include Datagrid
2015-09-10 01:31:47 +02:00
attr_accessor :current_user
scope do
Transaction
2015-09-10 01:31:47 +02:00
#@current_user.transactions
# TODO current user should not be nil
end
2015-09-10 01:31:47 +02:00
self.default_column_options = { order: false }
column(:created_at, order: true) { |model| model.created_at.to_date }
filter(:created_at, :date, range: true)
column(:amount)
2015-09-10 01:31:47 +02:00
filter(:amount, :integer, range: true)
column(:peer) { |model| model.peer_of(@current_user).try(:name) }
#filter(:peer) { |value| where(
# TODO extensive?
column(:issuer) { |model| model.issuer.name }
#filter(:issuer) { |value| where("issuer.name LIKE :value", value: "%#{value}%") }
# TODO issuer.name needs join
column(:message)
filter(:message) { |value| where("message LIKE :value", value: "%#{value}%") }
end