From 2c1c92edb35cc35fd51b120bb60073f2a38521bb Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Thu, 10 Sep 2015 16:35:26 +0200 Subject: [PATCH] show all transactions on index, show user transactions on user show --- app/controllers/transactions_controller.rb | 2 +- app/controllers/users_controller.rb | 11 +++++++++-- app/views/datagrid/_row.html.haml | 5 +++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index b0d58f3..72f6ad3 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -15,7 +15,7 @@ class TransactionsController < ApplicationController current_user: current_user ) @grid = TransactionsGrid.new(gridparams) do |scope| - scope.where('debtor_id = :id OR creditor_id = :id', id: current_user).page(params[:page]) + scope.page(params[:page]) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4c6c362..996d598 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,8 +4,15 @@ class UsersController < ApplicationController def show @user = User.find(params[:id]) @transaction = Transaction.new - respond_to do |format| - format.html + + 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.where('debtor_id = :id OR creditor_id = :id', id: current_user).page(params[:page]) end end diff --git a/app/views/datagrid/_row.html.haml b/app/views/datagrid/_row.html.haml index cc0b25f..82c9918 100644 --- a/app/views/datagrid/_row.html.haml +++ b/app/views/datagrid/_row.html.haml @@ -1,3 +1,4 @@ -%tr{:class => "#{options[:cycle] cycle(*options[:cycle])}"} +%tr{class: "#{options[:cycle] && cycle(*options[:cycle])}"} - grid.html_columns(*options[:columns]).each do |column| - %td{:class => "#{datagrid_column_classes(grid, column)}"}= datagrid_value(grid, column, asset) + %td{:class => "#{datagrid_column_classes(grid, column)}"} + = datagrid_value(grid, column, asset)