Moved notes form from div to td
This commit is contained in:
parent
3706206191
commit
03d0a56474
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 %>
|
||||
|
@ -1,19 +1,18 @@
|
||||
<tr id="meal-<%= m.id %>" class="primary meal project idnt idnt-1">
|
||||
<td class="name" colspan="2">
|
||||
<td class="name unwrappable" style="width: 5%;">
|
||||
<b><%= "#{t '.label_meal'} ##{index+1}" %></b>
|
||||
<% 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 %>
|
||||
<div id="notes-<%= m.id %>" style="display: inline-flex;"> 
|
||||
<td id="notes-<%= m.id %>" class="notes" style="text-align: left;">
|
||||
<%= display_notes(m) %>
|
||||
</div>
|
||||
<div style="float: right; position: relative;"><%= meal_links(m) %></div>
|
||||
</td>
|
||||
<td class="action" style="width: 5%;"><%= meal_links(m) %></td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@ -22,7 +21,7 @@
|
||||
<td class="name unwrappable" style="width: 5%;">
|
||||
<%= i.food.name %>
|
||||
</td>
|
||||
<td style="text-align: left;" class="unwrappable">
|
||||
<td style="text-align: left;" class="unwrappable" colspan="2">
|
||||
<%= adjust_ingredient_links(i) { raw " #{i.amount} " } %>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -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();
|
||||
|
@ -1,2 +1,2 @@
|
||||
var box = $('div[id=notes-<%= @meal.id %>]');
|
||||
var box = $('td[id=notes-<%= @meal.id %>]');
|
||||
box.html('<%= j display_notes(@meal) %>');
|
||||
|
Reference in New Issue
Block a user