Adding calories to several views

This commit is contained in:
David Vandorpe 2015-07-07 20:13:37 +02:00
parent 849d9ce04b
commit a8055d6f09
6 changed files with 22 additions and 0 deletions

View file

@ -5,6 +5,17 @@
<%= image_tag product.avatar %>
</div>
<div class="caption">
<h6>
<% if product.calories != nil %>
<%= content_tag( :small) do
concat( product.calories)
concat ' kcal'
end
%>
<% else %>
&nbsp;
<% end %>
</h6>
<h4 class="text-nowrap">
<%= content_tag :span, product.name %>
<%= content_tag :small, euro(product.price) %>

View file

@ -7,6 +7,7 @@
<%= f.price_field :price %>
<%= f.collection_select :category, Product.categories.keys %>
<%= f.number_field :stock %>
<%= f.number_field :calories %>
<%= f.file_field :avatar %>
<%= f.submit %>

View file

@ -4,6 +4,13 @@
<%= image_tag product.avatar %>
</div>
<div class="caption">
<h6>
<% if product.calories != nil %>
<%= product.calories %> kcal
<% else %>
&nbsp;
<% end %>
</h6>
<h4><%= product.name %></h4>
<h3><%= euro(product.price) %></h3>
<h6>(In stock: <%= product.stock %>)</h6>

View file

@ -4,6 +4,7 @@
<td><%= f.text_field :name, skip_label: true %></td>
<td><%= f.price_field :price, skip_label: true %></td>
<td><%= f.number_field :stock, skip_label: true %></td>
<td><%= f.number_field :calories, skip_label: true %></td>
<td><%= f.button "Update", class: "btn btn-primary" %></td>
<%= javascript_tag do %>
var id = "#edit_<%= dom_id(product) %>";

View file

@ -3,5 +3,6 @@
<td><%= product.name %></td>
<td><%= euro(product.price) %></td>
<td><%= product.stock %></td>
<td><%= product.calories %></td>
<td><%= button_to "Edit", edit_product_path(product), method: :get, class: "btn btn-default", remote: true %></td>
</tr>

View file

@ -10,6 +10,7 @@
<th>Name</th>
<th>Price</th>
<th>Stock</th>
<th>Kilocalorieën</th>
<th></th>
</tr>
<%= render partial: 'products_list/product_row', collection: @products, as: :product %>