From e3f480b47667151dd3cbac392cd3981183a5de8a Mon Sep 17 00:00:00 2001 From: Dan Elbert Date: Mon, 24 Apr 2017 11:57:34 -0500 Subject: [PATCH] recipe list cleanup --- app/assets/stylesheets/recipes.scss | 4 ++++ app/decorators/recipe_decorator.rb | 6 +++++- app/views/recipes/index.html.erb | 10 +++++----- app/views/recipes/show.html.erb | 12 +++--------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/recipes.scss b/app/assets/stylesheets/recipes.scss index 905e104..9104b9c 100644 --- a/app/assets/stylesheets/recipes.scss +++ b/app/assets/stylesheets/recipes.scss @@ -2,6 +2,10 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ +div.table_tags { + width: 275px; +} + @mixin editor { @extend .well; diff --git a/app/decorators/recipe_decorator.rb b/app/decorators/recipe_decorator.rb index 8629c04..03fe0f0 100644 --- a/app/decorators/recipe_decorator.rb +++ b/app/decorators/recipe_decorator.rb @@ -10,11 +10,15 @@ class RecipeDecorator < BaseDecorator end end + def created_at + wrapped.created_at ? wrapped.created_at.strftime('%D') : '' + end + def tag_names tags = wrapped.tag_names tags.map do |t| h.content_tag('span', t, class: 'label label-default') - end.join(' ').html_safe + end.join(' ').html_safe end def source_markup diff --git a/app/views/recipes/index.html.erb b/app/views/recipes/index.html.erb index 77d15c2..2688275 100644 --- a/app/views/recipes/index.html.erb +++ b/app/views/recipes/index.html.erb @@ -47,7 +47,7 @@ <% decorate(@recipes, RecipeDecorator).each do |recipe| %> <%= link_to recipe.short_name, recipe %> - <%= recipe.tag_names %> +
<%= recipe.tag_names %>
<% if recipe.rating %> <%= text_field_tag('rating', recipe.rating, disabled: true, data: {rating: true, size: '20px', interval: '0.25'}) %> @@ -57,17 +57,17 @@ <%= recipe.yields %> <%= recipe_time(recipe) %> - <%= timestamp(recipe.created_at) %> + <%= recipe.created_at %> <% if current_user? %> - <%= link_to new_recipe_log_path(recipe), class: 'btn btn-sm btn-primary' do %> + <%= link_to new_recipe_log_path(recipe), class: 'btn btn-xs btn-primary' do %> <% end %> - <%= link_to edit_recipe_path(recipe), class: 'btn btn-sm btn-primary' do %> + <%= link_to edit_recipe_path(recipe), class: 'btn btn-xs btn-primary' do %> <% end %> - <%= link_to recipe, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %> + <%= link_to recipe, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %> <% end %> <% end %> diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index 86f2f2f..585bb6a 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -98,15 +98,9 @@ - <%= nutrient_row(@recipe, nutrition_data, 'Calories', :kcal) %> - <%= nutrient_row(@recipe, nutrition_data, 'g Protein', :protein) %> - <%= nutrient_row(@recipe, nutrition_data, 'g Fat', :lipids) %> - <%= nutrient_row(@recipe, nutrition_data, 'g Carbohydrates', :carbohydrates) %> - <%= nutrient_row(@recipe, nutrition_data, 'mg Sodium', :sodium) %> - <%= nutrient_row(@recipe, nutrition_data, 'g Sugar', :sugar) %> - <%= nutrient_row(@recipe, nutrition_data, 'g Fiber', :fiber) %> - <%= nutrient_row(@recipe, nutrition_data, 'µg Vitamin K', :vit_k) %> - + <% NutritionData::NUTRIENTS.select { |_, v| v.present? }.each do |k, v| %> + <%= nutrient_row(@recipe, nutrition_data, v, k) %> + <% end %> <% end %>