Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update display to agreed look, feel, and functionality
The application will focus on the book list, and book detail pages. Adding a new issue will happen on the book detail page. Editing or deleting an issue will be up to frontend implementors.
- Loading branch information
Showing
8 changed files
with
77 additions
and
54 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,3 +1,5 @@ | ||
class Book < ActiveRecord::Base | ||
has_many :issues | ||
|
||
default_scope { order(:name) } | ||
end |
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,3 +1,5 @@ | ||
class Issue < ActiveRecord::Base | ||
belongs_to :book | ||
|
||
default_scope { order(:number) } | ||
end |
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,31 +1,12 @@ | ||
<h1>All Books</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Cover image url</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @books.each do |book| %> | ||
<tr> | ||
<td><%= book.name %></td> | ||
<td><%= book.cover_image_url %></td> | ||
<td><%= link_to 'Show', book %></td> | ||
<td><%= link_to pluralize(book.issues.count, 'Issue'), book_issues_path(book) %></td> | ||
<td><%= link_to 'Edit', edit_book_path(book) %></td> | ||
<td><%= link_to 'Destroy', book, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% @books.in_groups_of(3, false) do |books| %> | ||
<div class="row"> | ||
<% books.each do |book| %> | ||
<div class="span3"> | ||
<h4><%= book.name %> - <%= pluralize(book.issues.count, 'Issue') %></h4> | ||
<%= link_to book_path(book) do %> | ||
<%= image_tag book.cover_image_url %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Book', new_book_path %> | ||
</div> | ||
<% end %> |
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,15 +1,48 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Name:</strong> | ||
<h1> | ||
<%= @book.name %> | ||
</p> | ||
<div class="btn-group pull-right"> | ||
<%= link_to 'Edit', edit_book_path(@book), class: "btn" %> | ||
<%= link_to 'Destroy', @book, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn" %> | ||
</div> | ||
</h1> | ||
|
||
<p> | ||
<strong>Cover image url:</strong> | ||
<%= @book.cover_image_url %> | ||
</p> | ||
<p><%= pluralize(@book.issues.count, 'Issue') %></p> | ||
|
||
<%= link_to pluralize(@book.issues.count, 'Issue'), book_issues_path(@book) %> | | ||
<%= link_to 'Edit', edit_book_path(@book) %> | | ||
<%= link_to 'Back', books_path %> | ||
<p><%= number_to_currency(@book.issues.sum(:price)) %> Total</p> | ||
|
||
<div id="book_<%= @book.id %>_issues"> | ||
<% @book.issues.in_groups_of(4, false) do |row_issues| %> | ||
<div class="row-fluid"> | ||
<% row_issues.each do |issue| %> | ||
<div class="span3"> | ||
<%= div_for issue do %> | ||
<h4><%= issue.title %></h4> | ||
<%= link_to book_issue_path(issue.book, issue) do %> | ||
<%= image_tag issue.cover_image_url %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<hr> | ||
|
||
<%= simple_form_for([@book, @book.issues.new]) do |f| %> | ||
<fieldset> | ||
<legend><%= controller.action_name.capitalize %> Product</legend> | ||
|
||
<%= f.input :number %> | ||
<%= f.input :title %> | ||
<%= f.input :cover_image_url %> | ||
<%= f.input :price %> | ||
|
||
<div class="form-actions"> | ||
<%= f.submit nil, :class => 'btn btn-primary' %> | ||
<%= link_to 'Cancel', books_path(@book), :class => 'btn' %> | ||
</div> | ||
</fieldset> | ||
<% end %> |
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
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