1
0

Preliminary MealsController#create

This commit is contained in:
cryptogopher
2020-04-16 22:02:53 +02:00
parent eb939a1be5
commit ed6b1b9fe7
6 changed files with 39 additions and 7 deletions

View File

@@ -10,10 +10,11 @@
<p>
<%= ff.hidden_field :id %>
<%= ff.hidden_field :food_id, {class: "autocomplete-value"} %>
<%= label_tag :food_name, index > 0 ? '' : t(:field_ingredients) %>
<%= label_tag :food_name do %>
<%= index > 0 ? '' : t(:field_ingredients) %><span class="required"> *</span>
<% end %>
<%= text_field_tag :food_name, nil, {class: "autocomplete autocomplete-label",
style: "width: 80%;",
required: true} %>
style: "width: 80%;"} %>
<%= ff.number_field :amount, {style: "width: 8%", step: :any, label: ''} %>
<%= i.food.ref_unit.shortname if i.food %>
<%= ff.hidden_field :_destroy %>
@@ -69,6 +70,7 @@
new_row.find('label:first').hide();
form.find('tr.ingredient:visible a.icon-del').show();
autocompleteFood(new_row);
new_row.find('input:visible:first').focus();
}
function deleteIngredient() {

View File

@@ -0,0 +1,2 @@
$('#new-meal').empty();
$('#meals').html('<%= j render partial: 'meals/index' %>');

View File

@@ -1,2 +1,2 @@
$('#new-meal')
.html('<%= j render partial: 'meals/new_form' %>');
$('#new-meal').html('<%= j render partial: 'meals/new_form' %>');
$('#food_name').focus();