add some columns to datagrid
This commit is contained in:
parent
b4695d623f
commit
3a7472dcd0
3 changed files with 28 additions and 7 deletions
|
@ -6,7 +6,13 @@ class TransactionsController < ApplicationController
|
||||||
before_action :authenticate_user_or_client!, only: :create
|
before_action :authenticate_user_or_client!, only: :create
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@grid = TransactionsGrid.new(params[:transactions_grid]) do |scope|
|
gridparams = params[:transactions_grid] || Hash.new
|
||||||
|
gridparams = gridparams.merge(
|
||||||
|
order: :created_at,
|
||||||
|
descending: true,
|
||||||
|
current_user: current_user
|
||||||
|
)
|
||||||
|
@grid = TransactionsGrid.new(gridparams) do |scope|
|
||||||
scope.page(params[:page])
|
scope.page(params[:page])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,31 @@ class TransactionsGrid
|
||||||
|
|
||||||
include Datagrid
|
include Datagrid
|
||||||
|
|
||||||
|
attr_accessor :current_user
|
||||||
|
|
||||||
scope do
|
scope do
|
||||||
Transaction
|
Transaction
|
||||||
|
#@current_user.transactions
|
||||||
|
# TODO current user should not be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
filter(:id, :integer)
|
self.default_column_options = { order: false }
|
||||||
|
|
||||||
|
column(:created_at, order: true) { |model| model.created_at.to_date }
|
||||||
filter(:created_at, :date, range: true)
|
filter(:created_at, :date, range: true)
|
||||||
|
|
||||||
column(:id)
|
|
||||||
column(:amount)
|
column(:amount)
|
||||||
column(:created_at) do |model|
|
filter(:amount, :integer, range: true)
|
||||||
model.created_at.to_date
|
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
= datagrid_form_for @grid, :method => :get, :url => transactions_path
|
= datagrid_form_for @grid, method: :get, url: transactions_path
|
||||||
= paginate(@grid.assets)
|
= paginate(@grid.assets)
|
||||||
= datagrid_table @grid
|
= datagrid_table @grid
|
||||||
= paginate(@grid.assets)
|
= paginate(@grid.assets)
|
||||||
|
|
Loading…
Reference in a new issue