From a7f091ab8335d5f7ef101301bc4c3ec840e7dcd7 Mon Sep 17 00:00:00 2001
From: Meutel
Date: Mon, 29 Jun 2015 19:51:55 +0200
Subject: [PATCH] tables
---
app/views/authors/_index.html.erb | 17 ++++++++++----
app/views/books/_index.html.erb | 33 +++++++++++++++++++--------
app/views/series/_index.html.erb | 34 ++++++++++++++++++++++++----
app/views/series/show.html.erb | 6 +++--
app/views/static_pages/home.html.erb | 2 +-
5 files changed, 70 insertions(+), 22 deletions(-)
diff --git a/app/views/authors/_index.html.erb b/app/views/authors/_index.html.erb
index 7e36c98..e1da93b 100644
--- a/app/views/authors/_index.html.erb
+++ b/app/views/authors/_index.html.erb
@@ -1,9 +1,16 @@
-<%= will_paginate %>
+<%= will_paginate class: "center" %>
-
+
+
+ Name |
+ Books |
+
<% @authors.each do |author| %>
- - <%= link_to author.name, author %>
+
+ <%= link_to author.name, author %> |
+ <%= author.books.count %> |
+
<% end %>
-
+
-<%= will_paginate %>
+<%= will_paginate class: "center" %>
diff --git a/app/views/books/_index.html.erb b/app/views/books/_index.html.erb
index 03b71a5..e1ce4f2 100644
--- a/app/views/books/_index.html.erb
+++ b/app/views/books/_index.html.erb
@@ -1,12 +1,27 @@
-<%= will_paginate %>
+<%= will_paginate class: "center" %>
-
- <% @books.each do |book| %>
- -
- <%= link_to book.title, book %>
-
+
+
+ Name |
+ Authors |
+ Serie |
+
+<% @books.each do |book| %>
+
+ <%= link_to book.title, book %> |
+
+ <% book.authors.each do |author| %>
+ <%= link_to author.name, author %>
<% end %>
-
-
-<%= will_paginate %>
+ |
+
+ <% if book.serie %>
+ <%= link_to book.serie.name, book.serie %>
+ <%= book.series_index.to_i %>
+ <% end %>
+ |
+
+<% end %>
+
+<%= will_paginate class: "center" %>
diff --git a/app/views/series/_index.html.erb b/app/views/series/_index.html.erb
index 45f0a89..f5d8e5d 100644
--- a/app/views/series/_index.html.erb
+++ b/app/views/series/_index.html.erb
@@ -1,9 +1,33 @@
-<%= will_paginate %>
+<%= will_paginate class: "center" %>
-
+
+
+ Name |
+ Authors |
+ Books |
+
<% @series.each do |serie| %>
- - <%= link_to serie.name, serie %>
+
+ <%= link_to serie.name, serie %> |
+
+ <%
+ authors = Array.new
+ serie.books.each do |book|
+ authors.concat book.authors
+ end
+ unless authors.nil?
+ #authors.uniq!.sort! { |x,y| x.sort <=> y.sort }
+ authors.uniq!
+ authors.sort! { |x,y| x.sort <=> y.sort }
+ authors.each do |author|
+ %>
+ <%= link_to author.name, author %>
+ <% end
+ end %>
+ |
+ <%= serie.books.count %> |
+
<% end %>
-
+
-<%= will_paginate %>
+<%= will_paginate class: "center" %>
diff --git a/app/views/series/show.html.erb b/app/views/series/show.html.erb
index e07316b..ebdf856 100644
--- a/app/views/series/show.html.erb
+++ b/app/views/series/show.html.erb
@@ -18,8 +18,10 @@ authors = Array.new
@serie.books.each do |book|
authors.concat book.authors
end
-authors.uniq!.sort! { |x,y| x.sort <=> y.sort }
-if authors %>
+if authors
+ authors.uniq!
+ authors.sort! { |x,y| x.sort <=> y.sort }
+%>
<%= "Author".pluralize(authors.count) %>
diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb
index e7efe64..00df61b 100644
--- a/app/views/static_pages/home.html.erb
+++ b/app/views/static_pages/home.html.erb
@@ -8,5 +8,5 @@
<%= link_to "Series", series_path, class: "btn btn-lg btn-primary", remote: true %>
-