-
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.
Update app to show and hide reviews on mainpage with book detail.
- Loading branch information
Kelsey Langlois and LDevinMacKrell
committed
Dec 6, 2017
1 parent
db1ed79
commit d60d33b
Showing
3 changed files
with
23 additions
and
15 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
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,14 +1,16 @@ | ||
<h2>Reviews</h2> | ||
<% if @product.reviews.any? %> | ||
<div id="reviews"> | ||
<% @product.reviews.each do |review| %> | ||
<%= render "reviews/review", review: review %> | ||
<% end %> | ||
</div> | ||
<% else %> | ||
<h3>There are no saved reviews for this book!</h3> | ||
<p>Be the first to voyage where no man has gone before!</p> | ||
<% end %> | ||
<% if current_user && current_user.account.has_purchased?(@product) %> | ||
<%= link_to "Add a Review", new_product_review_path(@product), id: "new_link", remote: true %> | ||
<% end %> | ||
<div id="reviews-<%= @product.id %>"> | ||
<h2>Reviews</h2> | ||
<% if @product.reviews.any? %> | ||
<div id="reviews"> | ||
<% @product.reviews.each do |review| %> | ||
<%= render "reviews/review", review: review %> | ||
<% end %> | ||
</div> | ||
<% else %> | ||
<h3>There are no saved reviews for this book!</h3> | ||
<p>Be the first to voyage where no man has gone before!</p> | ||
<% end %> | ||
<% if current_user && current_user.account.has_purchased?(@product) %> | ||
<%= link_to "Add a Review", new_product_review_path(@product), id: "new_link", remote: true %> | ||
<% end %> | ||
</div> |
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,7 @@ | ||
$('#show_reviews_<%= @product.id %>').hide().after("<%= j render('reviews/index') %>"); | ||
$('#hide_reviews_<%= @product.id %>').show().click(function(event) { | ||
event.preventDefault(); | ||
$('#show_reviews_<%= @product.id %>').show(); | ||
$('#hide_reviews_<%= @product.id %>').hide(); | ||
$('#reviews-<%= @product.id %>').remove(); | ||
}); |