diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index fee1554..5fbeb62 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -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"; diff --git a/app/assets/stylesheets/journal_custom_colors.scss b/app/assets/stylesheets/journal_custom_colors.scss new file mode 100644 index 0000000..eff77a8 --- /dev/null +++ b/app/assets/stylesheets/journal_custom_colors.scss @@ -0,0 +1,2 @@ + +$brand-primary: darken(#93C54B, 10%); \ No newline at end of file diff --git a/app/helpers/ingredients_helper.rb b/app/helpers/ingredients_helper.rb index dd54783..e2c8b6e 100644 --- a/app/helpers/ingredients_helper.rb +++ b/app/helpers/ingredients_helper.rb @@ -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 diff --git a/app/models/ingredient.rb b/app/models/ingredient.rb index bf15369..059797c 100644 --- a/app/models/ingredient.rb +++ b/app/models/ingredient.rb @@ -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 diff --git a/app/views/ingredients/_form.html.erb b/app/views/ingredients/_form.html.erb index 12ef671..238b5f2 100644 --- a/app/views/ingredients/_form.html.erb +++ b/app/views/ingredients/_form.html.erb @@ -17,57 +17,65 @@ <%= f.label :ndbn, "Nutrient Databank Number", class: 'control-label' %>
<%= @ingredient.ndbn ? UsdaFood.find_by_ndbn(@ingredient.ndbn).long_description : '' %>
+ <%= f.text_field :usda_food_name, class: 'form-control', readonly: true %>