Second Commit

This commit is contained in:
2021-04-15 13:06:31 +05:30
parent 7f1d1f54e7
commit 129cd9cbcc
169 changed files with 11137 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<%= form_with model: [:admin, @book] do |f| %>
<div class="form-group">
<label for="title">Title</label>
<%= f.text_field :title, class: 'form-control', id: 'title' %>
</div>
<div class="form-group">
<label for="author">Author</label>
<%= f.text_field :author, class: 'form-control', id: 'author' %>
</div>
<div class="form-group">
<label for="genre">Genre</label>
<%= f.select :genre, Book.genres.keys.map {|genre| [genre.titleize,genre]},{}, class: 'form-control', id: 'genre' %>
</div>
<div class="form-group">
<label for="sub_genre">Sub Genre</label>
<%= f.select :sub_genre, Book.sub_genres.keys.map {|sub_genre| [sub_genre.titleize,sub_genre]},{}, class: 'form-control', id: 'sub_genre' %>
</div>
<div class="form-group">
<label for="pages">Pages</label>
<%= f.number_field :pages, class: 'form-control', id: 'pages' %>
</div>
<div class="form-group">
<label for="copies">Copies</label>
<%= f.number_field :copies, class: 'form-control', id: 'copies' %>
</div>
<div class="form-group">
<%= f.submit 'Save', class: 'btn btn-primary'%>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
<h1 class="my-4">Edit Book details</h1>
<%= render 'form' %>

View File

@@ -0,0 +1,39 @@
<div class="row">
<div class="col-sm-12 ">
<h1 class="my-4">Manage Books</h1>
<%= link_to 'Add New Book', new_admin_book_path, class: 'btn btn-sm btn-primary mb-2'%>
</div>
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Title</th>
<th scope="col">Genre</th>
<th scope="col">SubGenre</th>
<th scope="col">Author</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<% @books.each_with_index do |book, index| %>
<tr>
<th scope="row"><%= index + 1 %></th>
<td><%= book.title %></td>
<td><%= book.genre %></td>
<td><%= book.sub_genre %></td>
<td><%= book.author %></td>
<td>
<%= link_to 'Edit', edit_admin_book_path(book), class: 'btn btn-sm btn-primary' %>
<%= link_to 'Delete', admin_book_path(book), method: :delete, class: 'btn btn-sm btn-danger', data: { confirm: 'Are you sure?'} %>
<%= link_to 'View', admin_book_path(book), class: 'btn btn-sm btn-secondary' %></td>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @books, theme: 'twitter-bootstrap-4' %>
</div>
</div>

View File

@@ -0,0 +1,2 @@
<h1 class="my-4">New Book details</h1>
<%= render 'form' %>

View File

@@ -0,0 +1,64 @@
<h1 class="my-4">Book Details</h1>
<div class="row">
<div class="col-sm-6">
<table class="table table-bordered">
<tr>
<th scope="col">Title</th>
<td><%= @book.title %></td>
</tr>
<tr>
<th scope="col">Genre</th>
<td><%= @book.genre %></td>
</tr>
<tr>
<th scope="col">Sub Genre</th>
<td><%= @book.sub_genre %></td>
</tr>
<tr>
<th scope="col">Author</th>
<td><%= @book.author %></td>
</tr>
<tr>
<th scope="col">Pages</th>
<td><%= @book.pages %></td>
</tr>
<tr>
<th scope="col">Total Copies</th>
<td><%= @book.copies %></td>
</tr>
<tr>
<th scope="col">Available Copies</th>
<td><%= @book.available_copies %></td>
</tr>
</table>
</div>
</div>
<h3 class="my-4">Check out Status</h3>
<div class="row">
<div class="col-sm-12">
<table class="table table-bordered">
<thead>
<th>#</th>
<th>Book copy code</th>
<th>Status</th>
<th>Email</th>
<th>Borrow date</th>
<th>Expected Return date</th>
<th>Actual Returned Date</th>
</thead>
<tbody>
<% @book.users_books.each_with_index do |user_book, index| %>
<tr>
<td><%= index + 1 %></td>
<td><%= user_book.identifier %></td>
<td><%= user_book.status %></td>
<td><%= user_book.user.email %></td>
<td><%= decorate_date(user_book.created_at) %></td>
<td><%= decorate_date(user_book.due_date) %></td>
<td><%= decorate_date(user_book.returned_at) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>