2015-09-10 00:35:59 +02:00
|
|
|
class TransactionsGrid
|
|
|
|
|
|
|
|
include Datagrid
|
|
|
|
|
2015-09-10 01:31:47 +02:00
|
|
|
attr_accessor :current_user
|
|
|
|
|
2015-09-10 00:35:59 +02:00
|
|
|
scope do
|
|
|
|
Transaction
|
2015-09-10 01:31:47 +02:00
|
|
|
#@current_user.transactions
|
|
|
|
# TODO current user should not be nil
|
2015-09-10 00:35:59 +02:00
|
|
|
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 }
|
2015-09-10 00:35:59 +02:00
|
|
|
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}%") }
|
|
|
|
|
2015-09-10 00:35:59 +02:00
|
|
|
end
|