Adding calories to several views
This commit is contained in:
parent
849d9ce04b
commit
a8055d6f09
6 changed files with 22 additions and 0 deletions
|
@ -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 %>
|
||||
|
||||
<% end %>
|
||||
</h6>
|
||||
<h4 class="text-nowrap">
|
||||
<%= content_tag :span, product.name %>
|
||||
<%= content_tag :small, euro(product.price) %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -4,6 +4,13 @@
|
|||
<%= image_tag product.avatar %>
|
||||
</div>
|
||||
<div class="caption">
|
||||
<h6>
|
||||
<% if product.calories != nil %>
|
||||
<%= product.calories %> kcal
|
||||
<% else %>
|
||||
|
||||
<% end %>
|
||||
</h6>
|
||||
<h4><%= product.name %></h4>
|
||||
<h3><%= euro(product.price) %></h3>
|
||||
<h6>(In stock: <%= product.stock %>)</h6>
|
||||
|
|
|
@ -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) %>";
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
Loading…
Reference in a new issue