bookstore/app/views/books/index.html.erb

43 lines
1 KiB
Text
Raw Normal View History

2021-03-19 17:31:38 +02:00
<div class='container'>
2021-03-22 01:24:13 +01:00
<div class='row'>
2021-03-22 02:49:05 +01:00
<h6 class='col s2'>Title</h6>
<h6 class='col s3'>Authors</h6>
<h6 class='col s1'>Price</h6>
<h6 class='col s3'>Quantity</h6>
2021-03-22 01:24:13 +01:00
</div>
2021-03-19 17:31:38 +02:00
<% @books.each do |book| %>
<div class='row'>
2021-03-22 01:24:13 +01:00
<div class='col s2'>
<%= link_to book.title, book %>
2021-03-19 17:31:38 +02:00
</div>
2021-03-22 01:24:13 +01:00
2021-03-21 20:30:25 +01:00
<div class='col s3'>
2021-03-22 01:24:13 +01:00
<%= book.authors %>
2021-03-19 17:31:38 +02:00
</div>
2021-03-22 01:24:13 +01:00
<div class='col s1'>
<%= book.price_with_currency %>
</div>
2021-03-21 20:30:25 +01:00
2021-03-22 01:24:13 +01:00
<div class='col s1'>
<%= book.quantity %>
</div>
<div class='col s2'>
2021-03-22 02:49:05 +01:00
<% if can_book_be_added?(book) %>
2021-03-22 02:25:17 +01:00
<%= link_to 'Add', "book/#{book.id}/add_to_cart", method: :post, class: "btn" %>
2021-03-22 01:24:13 +01:00
<% end %>
2021-03-19 17:31:38 +02:00
</div>
2021-03-21 20:30:25 +01:00
2021-03-22 01:24:13 +01:00
<% if current_user&.admin? %>
2021-03-21 20:30:25 +01:00
<div class='col s2'>
<%= book.published ? 'published' : 'unpublished' %>
</div>
<div class='col s1'>
<%= link_to 'Edit', edit_book_path(book), class: "btn" %>
</div>
<% end %>
2021-03-19 17:31:38 +02:00
</div>
<% end %>
</div>