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