Add card view for open outgoing requests

This commit is contained in:
benji 2017-01-14 23:12:45 +01:00
parent 696c6aae53
commit c94738123a
4 changed files with 23 additions and 4 deletions

View file

@ -3,9 +3,10 @@ class PagesController < ApplicationController
def landing def landing
query = TransactionsQuery.new(current_user) query = TransactionsQuery.new(current_user)
@transactions = ActiveRecord::Base.connection.exec_query(query.query.order(query.arel_table[:time].desc).take(10).project(Arel.star).to_sql) @transactions = ActiveRecord::Base.connection.exec_query(query.query.order(query.arel_table[:time].desc).take(10).project(Arel.star).to_sql)
@requests = current_user.incoming_requests.open.includes(:creditor).take(10) @requests = current_user.incoming_requests.open.includes(:creditor).take(10)
@notifications = current_user.notifications.unread @outgoing_requests = current_user.outgoing_requests.open.includes(:debtor).take(10)
@notifications = current_user.notifications.unread
end end
def sign_in_page def sign_in_page

View file

@ -21,7 +21,7 @@ class User < ActiveRecord::Base
has_many :incoming_requests, has_many :incoming_requests,
class_name: 'Request', foreign_key: 'debtor_id' class_name: 'Request', foreign_key: 'debtor_id'
has_many :outgoing_requests, has_many :outgoing_requests,
class_name: 'Request', foreign_key: 'debtor_id' class_name: 'Request', foreign_key: 'creditor_id'
has_many :notifications has_many :notifications
has_many :issued_transactions, as: :issuer, class_name: 'Transaction' has_many :issued_transactions, as: :issuer, class_name: 'Transaction'

View file

@ -0,0 +1,17 @@
.card-wrapper
- if @outgoing_requests.any?
.card
.padded
%h3 Outgoing Requests
- @outgoing_requests.each do |r|
.request.pure-g
.pure-u-2-3
%h4= r.message
= r.debtor.name
.pure-u-1-3.actions
= euro_from_cents r.amount
.clear-both
- else
.card.padded
%span.info-message
You have no open outgoing requests at the moment.

View file

@ -5,3 +5,4 @@
= render 'transaction_form' = render 'transaction_form'
= render 'requests' = render 'requests'
= render 'notifications' = render 'notifications'
= render 'outgoing_requests'