/
index.html.erb
57 lines (53 loc) · 1.7 KB
/
index.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<% title @user.name if @user %>
<% content_for :sidebar do %>
<div class="span1"> </div>
<div class="span4">
<div class="well sidebar-nav">
<% if @book %>
<%= render :template => 'books/show' %>
<% else %>
<%= render :partial => "adv_search" %>
<% end %>
</div>
</div>
</div>
<% end %>
<table class="table table-striped">
<thead>
<tr>
<th>Título</th>
<th>Autores</th>
<% if current_user %><th>Ações</th><% end %>
<% if @user.nil? %><th>Acervo</th><% end %>
</tr>
</thead>
<tbody>
<% @books.each do |book| %>
<% if book %>
<tr>
<td>
<%= link_to "#{book.title} #{book.volume}", params.merge({:book => book.tombo, :user => book.user.username}), :class => 'book-title' %>
</td>
<td><a href="#" rel="tooltip" title="<%= book.authors.map(&:name).join(', ') %>"><%= truncate(book.authors.map(&:name).join(', ')) %></a></td>
<% restricted_to([book.user, admin]) do %>
<td>
<%= link_to 'Editar', edit_user_book_path(book.user, book), :class => 'btn btn-mini' %>
<%= link_to 'Deletar', user_book_path(book.user, book), :method => :delete, :confirm => 'Tem certeza?', :class => 'btn btn-mini btn-danger' %>
</td>
<% end %>
<% if @user.nil? %>
<td><%= link_to book.user.name, user_books_path(book.user) %></td>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<div class="pagination">
<%= paginate @books %>
</div>
<% restricted_to([@user, admin]) do %>
<% if @user %>
<%= link_to 'Novo livro', new_user_book_path(@user), :class => 'btn btn-primary' %>
<% end %>
<% end %>