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
|
||||
|
||||
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])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,16 +2,31 @@ class TransactionsGrid
|
|||
|
||||
include Datagrid
|
||||
|
||||
attr_accessor :current_user
|
||||
|
||||
scope do
|
||||
Transaction
|
||||
#@current_user.transactions
|
||||
# TODO current user should not be nil
|
||||
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)
|
||||
|
||||
column(:id)
|
||||
column(:amount)
|
||||
column(:created_at) do |model|
|
||||
model.created_at.to_date
|
||||
end
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
= datagrid_table @grid
|
||||
= paginate(@grid.assets)
|
||||
|
|
Loading…
Reference in a new issue