-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Zilola-Nazarova/views
Views
- Loading branch information
Showing
14 changed files
with
3,389 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,5 @@ | |
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key | ||
|
||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,9 @@ | |
*= require_tree . | ||
*= require_self | ||
*/ | ||
|
||
.chevron { | ||
width: 2rem; | ||
height: 2rem; | ||
color: black; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
class PurchasesController < ApplicationController | ||
def index; end | ||
def index | ||
@group = Group.find(params[:group_id]) | ||
@purchases = @group.purchases.order(id: :desc) | ||
end | ||
|
||
def show; end | ||
def show | ||
@purchase = Purchase.find(params[:id]) | ||
end | ||
|
||
def new; end | ||
|
||
def edit; end | ||
|
||
def update; end | ||
|
||
def delete; end | ||
def destroy | ||
@purchase = Purchase.find(params[:id]) | ||
@purchase.destroy! | ||
flash[:success] = 'Transaction was deleted successfully!' | ||
redirect_to group_purchases_url(params[:group_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module GroupHelper | ||
def total_amount(group) | ||
group.purchases.sum(:amount) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
<h1>List groups</h1> | ||
<section> | ||
<h1>categories</h1> | ||
</section> | ||
|
||
<section> | ||
<ul> | ||
<% @groups.each do |group| %> | ||
<% total_amount = total_amount(group) %> | ||
<li> | ||
<%= link_to group_purchases_url(group) do %> | ||
<%= image_tag(group.icon, height: '32', width: '32', class: 'icon', alt: 'group_icon') %> | ||
<span><%= group.name %></span> | ||
<br> | ||
<span>Transactions: <%= total_amount %></span> | ||
<% end %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</section> | ||
|
||
<section> | ||
<%= link_to "add category", new_group_path %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
<h1>List purchases</h1> | ||
<section> | ||
<%= link_to groups_path do %> | ||
<%= inline_svg_tag "chevron_left.svg", class: "chevron" %> | ||
<% end %> | ||
<h1>transactions</h1> | ||
</section> | ||
|
||
<section> | ||
<div> | ||
<span><%= @group.name %></span> | ||
<span>Total amount: <%= total_amount(@group) %> </span> | ||
</div> | ||
|
||
<% if @purchases.empty? %> | ||
<%= button_to "delete", {:controller => :groups, :action => 'destroy', :id => @group.id }, :method => :delete %> | ||
<% end %> | ||
|
||
<ul> | ||
<% @purchases.each do |purchase| %> | ||
<li> | ||
<%= link_to group_purchase_url(@group, purchase) do %> | ||
<span><%= purchase.name %></span> | ||
<span><%= purchase.amount %></span> | ||
<% end %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</section> | ||
|
||
<section> | ||
<%= link_to "add transaction", new_group_purchase_path %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
<h1>Show purchase details</h1> | ||
<section> | ||
<%= link_to group_purchases_path(params[:group_id]) do %> | ||
<%= inline_svg_tag "chevron_left.svg", class: "chevron" %> | ||
<% end %> | ||
<h1>details</h1> | ||
</section> | ||
|
||
<section> | ||
<span><%= @purchase.name %></span> | ||
<span><%= @purchase.amount %></span> | ||
|
||
<section> | ||
<%= link_to "edit", edit_group_purchase_path(params[:group_id], @purchase) %> | ||
<%= button_to "delete", {:controller => :purchases, :action => 'destroy'}, method: :delete %> | ||
</section> |
Oops, something went wrong.