Skip to content

Commit

Permalink
removed the delete buttons for none members
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrobert committed Jun 23, 2020
1 parent f04a8bc commit 103647e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,8 @@ form textarea {
font-size: 20px;
font-weight: bold;
color: grey;
}

.hidden{
display: none;
}
14 changes: 13 additions & 1 deletion app/helpers/groups_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module GroupsHelper

def edit_delete_btn(user, group)

if group.user_id == user.id
links = [link_to("edit", edit_group_path(group), class: "btn btn-primary edit_btn"), link_to("delete", group_path(group), class: "btn btn-danger delete_grp_btn", data: {confirm: "Are you sure?"}, method: :delete)]

content_tag (:span) do
links.collect{
|l| concat content_tag(:span, l)
}
end
end

end
end
7 changes: 3 additions & 4 deletions app/views/groups/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ Groups
<h5 class="card-title"> <%= g.name %> </h5>

<p class="card-text"><small class="text-muted"><%= g.created_at %></small></p>

<%= link_to "edit", edit_group_path(g), :class => "btn btn-primary edit_btn" %>

<%= link_to "delete", group_path(g), :class => "btn btn-danger delete_grp_btn", data: {confirm: "Are you sure?"}, :method => :delete %>
<%= edit_delete_btn(current_user, g) %>




</div>
Expand Down
10 changes: 6 additions & 4 deletions app/views/groups/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<section class="transaction_header">
<div class="container t-d">
<div class="button">
<i class="fa fa-bars" aria-hidden="true"></i>
<%= link_to root_path do %>
<i class="fa fa-bars" aria-hidden="true"></i>
<% end %>
</div>
<div class="title">
Transactions
Transactions for a specific group
</div>

<div class="search">
Expand Down Expand Up @@ -38,8 +40,8 @@ Transactions
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title"> <%= t.name %> </h5>
<p class="card-text"> <span>$</span> <%= t.amount %></p>
<h5 class="card-title trns"> <%= t.name %> </h5>
<p class="card-text style-up"> <span>$</span> <%= t.amount %></p>
<p class="card-text"> <span>created by</span> <%= t.user.name %></p>
<p class="card-text"><small class="text-muted"><%= t.created_at %></small></p>

Expand Down

0 comments on commit 103647e

Please sign in to comment.