X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=app%2Fviews%2Fproducts%2Findex.html.erb;h=3e068e6697479b9aa50cf8223096c4bb23567a05;hb=f9d45398338f9e5b2dabd768fcd793c4f81934f2;hp=88120ee7e05a27a417f52f7b280dd760a9ecc1a8;hpb=e580d4626176c8deb6f44fec7e66f980b5923b29;p=depot.git diff --git a/app/views/products/index.html.erb b/app/views/products/index.html.erb index 88120ee..3e068e6 100644 --- a/app/views/products/index.html.erb +++ b/app/views/products/index.html.erb @@ -1,24 +1,34 @@ -<h1>Listing products</h1> +<div id="product-list"> + <h1>Listing products</h1> -<table> - <tr> - <th>Title</th> - <th>Description</th> - <th>Image url</th> - </tr> - -<% for product in @products %> - <tr> - <td><%=h product.title %></td> - <td><%=h product.description %></td> - <td><%=h product.image_url %></td> - <td><%= link_to 'Show', product %></td> - <td><%= link_to 'Edit', edit_product_path(product) %></td> - <td><%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %></td> - </tr> -<% end %> -</table> + <table> + <% for product in @products %> + <tr class="<%= cycle('list-line-odd', 'list-line-even') %>"> + <td> + <%= image_tag product.image_url, :class => 'list-image' %> + </td> + <td class="list-description"> + <dl> + <dt><%=h product.title %></dt> + <dd><%=h truncate(product.description.gsub(/<.*?>/, '|'), + :length => 80) %></dd> + <dd><%=number_to_currency product.price, :unit => "£" %> + <% if product.date_available.past? %> + <dd>Available since <%= product.date_available %></dd> + <% else %> + <dd class="unavailable">Available from <%= product.date_available %></dd> + <% end %> + </dl> + </td> + <td class="list-actions"> + <%= link_to 'Show', product %><br/> + <%= link_to 'Edit', edit_product_path(product) %><br/> + <%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %><br/> + </td> + </tr> + <% end %> + </table> +</div> <br /> - <%= link_to 'New product', new_product_path %>