Updated order display again
[depot.git] / app / views / products / index.html.erb
index 6bb547aa96d8023ebc9d510494ba5354c34bb5c2..ca7fb6a809cd53c83ec2491a40f59f13fcb21e19 100644 (file)
@@ -1,39 +1,41 @@
-<div id="product-list">
+<div id="pretty-list">
   <h1>Listing products</h1>
 
   <table>
-  <% for product in @products %>
-     <tr class="<%= cycle('list-line-odd', 'list-line-even')%>">
+    <% 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 %>
+          <% if not product.date_available_until.nil? %> 
+            <% if product.date_available_until.future? %>
+              <dd>Available until <%= product.date_available_until %></dd>
+            <% else %>
+              <dd class="unavailable">Unavailable since <%= product.date_available_until %></dd>
+            <% end %>
+          <% end %>
+        </dl>
+      </td>
 
-        <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>
-              <% 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 %>
-        </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 %>
+    <% end %>
   </table>
 </div>
-
-<br/>
-
+<br />
 <%= link_to 'New product', new_product_path %>