diff --git a/app/controllers/meals_controller.rb b/app/controllers/meals_controller.rb index 5773c41..c8948f9 100644 --- a/app/controllers/meals_controller.rb +++ b/app/controllers/meals_controller.rb @@ -41,7 +41,7 @@ class MealsController < ApplicationController def update_notes if @meal.update(params.require(:meal).permit(:notes)) - flash[:notice] = 'Updated meal notes' + flash[:notice] = 'Updated meal notes' unless @meal.previous_changes.empty? end end diff --git a/app/helpers/meals_helper.rb b/app/helpers/meals_helper.rb index 353d333..f4e10de 100644 --- a/app/helpers/meals_helper.rb +++ b/app/helpers/meals_helper.rb @@ -17,8 +17,8 @@ module MealsHelper end def display_notes(m) - content_tag :div, link_to(l(:button_notes), edit_notes_meal_path(m), - {remote: true, class: "icon icon-wiki-page"}) + - (m.notes.blank? ? "" : ": #{m.notes}") + link_to(l(:button_notes), edit_notes_meal_path(m), + {remote: true, class: "icon icon-wiki-page"}) + + content_tag(:span, m.notes.blank? ? "" : ": #{m.notes}") end end diff --git a/app/views/meals/_edit_notes_form.html.erb b/app/views/meals/_edit_notes_form.html.erb index 1b94afc..175d662 100644 --- a/app/views/meals/_edit_notes_form.html.erb +++ b/app/views/meals/_edit_notes_form.html.erb @@ -3,11 +3,11 @@ remote: true, html: {id: 'edit-meal-notes-form', name: 'edit-meal-notes-form'} do |f| %> + <%= f.text_field :notes, size: 50, required: false, label: '' %> <%= link_to l(:button_save), '', class: 'icon icon-save', onclick: "$(event.target).closest('form').submit(); return false;" %> - <%= f.text_field :notes, rows: 1, required: false, label: '' %> - <%= link_to l(:button_cancel), '', + <%= link_to l(:button_cancel), '', class: 'icon icon-cancel', onclick: "$(event.target).closest('form').remove(); - $('div[id=notes-#{@meal.id}]').contents().show(); + $('td[id=notes-#{@meal.id}]').contents().show(); return false;" %> <% end %> diff --git a/app/views/meals/_show.html.erb b/app/views/meals/_show.html.erb index dcc5b93..b13801a 100644 --- a/app/views/meals/_show.html.erb +++ b/app/views/meals/_show.html.erb @@ -1,19 +1,18 @@ - + <%= "#{t '.label_meal'} ##{index+1}" %> <% if m.eaten_at %> <%= " at #{m.eaten_at.strftime('%R')}" %> <%= link_to '', toggle_eaten_meal_path(m), - {remote: true, method: :post, class: "icon icon-close", - style: "margin-left: -0.2em;"} %> + {remote: true, method: :post, class: "icon icon-close"} %> <% else %> <%= link_to l(:button_eat), toggle_eaten_meal_path(m), {remote: true, method: :post, class: "icon icon-ok"} %> <% end %> -
  + <%= display_notes(m) %> -
-
<%= meal_links(m) %>
+ + <%= meal_links(m) %> @@ -22,7 +21,7 @@ <%= i.food.name %> - + <%= adjust_ingredient_links(i) { raw " #{i.amount} " } %> diff --git a/app/views/meals/edit_notes.js.erb b/app/views/meals/edit_notes.js.erb index 931117c..56e1c03 100644 --- a/app/views/meals/edit_notes.js.erb +++ b/app/views/meals/edit_notes.js.erb @@ -1,4 +1,4 @@ -var box = $('div[id=notes-<%= @meal.id %>]'); +var box = $('td[id=notes-<%= @meal.id %>]'); box.contents().hide(); box.append('<%= j render partial: 'meals/edit_notes_form' %>'); box.find('input[type=text]').focus(); diff --git a/app/views/meals/update_notes.js.erb b/app/views/meals/update_notes.js.erb index c9603b3..f628ba6 100644 --- a/app/views/meals/update_notes.js.erb +++ b/app/views/meals/update_notes.js.erb @@ -1,2 +1,2 @@ -var box = $('div[id=notes-<%= @meal.id %>]'); +var box = $('td[id=notes-<%= @meal.id %>]'); box.html('<%= j display_notes(@meal) %>');