Updated style; ingredient editor work
This commit is contained in:
parent
ff231ceee0
commit
205a29ce77
@ -16,9 +16,10 @@
|
||||
*/
|
||||
|
||||
@import "bootstrap-sprockets";
|
||||
@import "readable/_variables";
|
||||
@import "journal_custom_colors";
|
||||
@import "journal/_variables";
|
||||
@import "bootstrap";
|
||||
@import "readable/_bootswatch";
|
||||
@import "journal/_bootswatch";
|
||||
|
||||
@import "typeahead-bootstrap";
|
||||
@import "recipes";
|
||||
|
2
app/assets/stylesheets/journal_custom_colors.scss
Normal file
2
app/assets/stylesheets/journal_custom_colors.scss
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$brand-primary: darken(#93C54B, 10%);
|
@ -1,2 +1,11 @@
|
||||
module IngredientsHelper
|
||||
|
||||
def ndbn_button_class(ingredient)
|
||||
if ingredient.ndbn.present?
|
||||
'btn btn-success'
|
||||
else
|
||||
'btn btn-default'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -14,6 +14,25 @@ class Ingredient < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def ndbn=(value)
|
||||
@usda_food = nil
|
||||
super
|
||||
end
|
||||
|
||||
def usda_food
|
||||
if self.ndbn.present?
|
||||
@usda_food ||= UsdaFood.find_by_ndbn(self.ndbn)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def usda_food_name
|
||||
if usda_food
|
||||
usda_food.long_description
|
||||
end
|
||||
end
|
||||
|
||||
def set_usda_food(food)
|
||||
return unless food
|
||||
|
||||
|
@ -17,57 +17,65 @@
|
||||
<%= f.label :ndbn, "Nutrient Databank Number", class: 'control-label' %>
|
||||
<div class="input-group">
|
||||
<div class="input-group-btn">
|
||||
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#link_ndbn_modal">
|
||||
<button type="button" class="<%= ndbn_button_class(@ingredient) %>" data-toggle="modal" data-target="#link_ndbn_modal">
|
||||
<span class="glyphicon glyphicon-link"></span><span class="ndbn"><%= @ingredient.ndbn %></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="form-control-static" style="padding-left: 7px;"><%= @ingredient.ndbn ? UsdaFood.find_by_ndbn(@ingredient.ndbn).long_description : '' %></p>
|
||||
<%= f.text_field :usda_food_name, class: 'form-control', readonly: true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :density, class: 'control-label' %>
|
||||
<%= f.text_field :density, class: 'form-control', disabled: has_ndbn %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :notes, class: 'control-label' %>
|
||||
<%= f.text_area :notes, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend>Per 100 Grams</legend>
|
||||
<div class="form-group">
|
||||
<%= f.label :density, class: 'control-label' %>
|
||||
<%= f.text_field :density, class: 'form-control', disabled: has_ndbn %>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Per 100 grams</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<fieldset <%= 'disabled=disabled' if has_ndbn %>>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :water, "Grams of Water", class: 'control-label' %>
|
||||
<%= f.text_field :water, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :water, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :protein, "Grams of Protein", class: 'control-label' %>
|
||||
<%= f.text_field :protein, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :protein, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :lipids, "Grams of Fat", class: 'control-label' %>
|
||||
<%= f.text_field :lipids, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :lipids, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :kcal, "Calories", class: 'control-label' %>
|
||||
<%= f.text_field :kcal, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :kcal, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :fiber, "Grams of Fiber", class: 'control-label' %>
|
||||
<%= f.text_field :fiber, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :fiber, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :sugar, "Grams of Sugar", class: 'control-label' %>
|
||||
<%= f.text_field :sugar, class: 'form-control', disabled: has_ndbn %>
|
||||
<%= f.text_field :sugar, class: 'form-control' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit class: 'btn btn-primary' %>
|
||||
@ -94,7 +102,6 @@
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary" form="conversion_form">Link</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', ingredients_path, class: 'btn btn-primary' %>
|
||||
<%= link_to 'Back', ingredients_path, class: 'btn btn-default' %>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -1,18 +1,28 @@
|
||||
|
||||
<table class="table">
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"></th>
|
||||
<th colspan="3">per 100 grams</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>NDBN</th>
|
||||
<th>Name</th>
|
||||
<th>KCal</th>
|
||||
<th>Carbs</th>
|
||||
<th>Sugar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<% @foods.each do |f| %>
|
||||
|
||||
<tr>
|
||||
<th><%= f.ndbn %></th>
|
||||
<th><%= link_to f.long_description, '#', class: 'food_result', data: {ndbn: f.ndbn} %></th>
|
||||
<td><%= f.ndbn %></td>
|
||||
<td><%= link_to f.long_description, '#', class: 'food_result', data: {ndbn: f.ndbn} %></td>
|
||||
<td><%= f.kcal %></td>
|
||||
<td><%= f.carbohydrates %></td>
|
||||
<td><%= f.sugar %></td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user