Renamed Ingredient -> Food
Ingredient is now part of composition (meal/recipe/dish)
This commit is contained in:
6
app/views/foods/_contextual.html.erb
Normal file
6
app/views/foods/_contextual.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% if User.current.allowed_to?(:manage_common, @project) %>
|
||||
<%= link_to t(".link_import_foods"), '#', class: 'icon icon-multiple',
|
||||
onclick: '$("#import-foods").show(); $("#filename").focus(); return false;' %>
|
||||
<%= link_to t(".link_new_food"), new_project_food_path(@project, view: view),
|
||||
{remote: true, class: 'icon icon-add'} %>
|
||||
<% end %>
|
||||
@@ -1,9 +1,9 @@
|
||||
<%= labelled_form_for @ingredient,
|
||||
url: ingredient_path(@ingredient, view: view),
|
||||
<%= labelled_form_for @food,
|
||||
url: food_path(@food, view: view),
|
||||
method: :patch, remote: true,
|
||||
html: {id: 'ingredient-edit-form', name: 'ingredient-edit-form'} do |f| %>
|
||||
html: {id: 'food-edit-form', name: 'food-edit-form'} do |f| %>
|
||||
|
||||
<%= render partial: 'ingredients/form', locals: {f: f} %>
|
||||
<%= render partial: 'foods/form', locals: {f: f} %>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
@@ -9,14 +9,14 @@
|
||||
<table class="filter">
|
||||
<tr>
|
||||
<td>
|
||||
<%= text_field_tag 'name', session[:i_filters][:name], placeholder: 'name' %>
|
||||
<%= text_field_tag 'name', session[:f_filters][:name], placeholder: 'name' %>
|
||||
</td>
|
||||
<td>
|
||||
<%= select_tag 'visibility', visibility_options(session[:i_filters][:visibility]),
|
||||
<%= select_tag 'visibility', visibility_options(session[:f_filters][:visibility]),
|
||||
prompt: t('.visibility_prompt'), onchange: '$("#filters-form").submit();' %>
|
||||
</td>
|
||||
<td style="width:100%;">
|
||||
<%= text_field_tag 'formula[code]', session[:i_filters][:formula][:code],
|
||||
<%= text_field_tag 'formula[code]', session[:f_filters][:formula][:code],
|
||||
placeholder: 'conditional expression including nutrients', size: 40,
|
||||
style: 'box-sizing:border-box; width:100%;' %>
|
||||
</td>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= error_messages_for @ingredient %>
|
||||
<%= error_messages_for @food %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :name, size: 40, required: true %></p>
|
||||
@@ -21,7 +21,7 @@
|
||||
<p><%= f.text_field :source_ident, size: 25, required: false %></p>
|
||||
</div>
|
||||
</div>
|
||||
<% @ingredient.nutrients.each_with_index do |n, index| %>
|
||||
<% @food.nutrients.each_with_index do |n, index| %>
|
||||
<%= f.fields_for 'nutrients_attributes', n, index: '' do |ff| %>
|
||||
<p class="nutrient">
|
||||
<%= ff.hidden_field :id %>
|
||||
@@ -32,7 +32,7 @@
|
||||
<%= ff.hidden_field :_destroy %>
|
||||
<%= link_to t(".button_delete_nutrient"), '#',
|
||||
class: 'icon icon-del',
|
||||
style: (@ingredient.nutrients.length > 1 ? "" : "display:none"),
|
||||
style: (@food.nutrients.length > 1 ? "" : "display:none"),
|
||||
onclick: "deleteNutrient(); return false;" %>
|
||||
</p>
|
||||
<% end %>
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="import-ingredients" style="display:none;">
|
||||
<h2><%= t ".heading_import_ingredients" %></h2>
|
||||
<div id="import-foods" style="display:none;">
|
||||
<h2><%= t ".heading_import_foods" %></h2>
|
||||
|
||||
<%= form_tag import_project_ingredients_path(@project),
|
||||
<%= form_tag import_project_foods_path(@project),
|
||||
id: 'import-form', name: 'import-form', multipart: true do %>
|
||||
|
||||
<div class="box tabular">
|
||||
@@ -14,8 +14,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<%= submit_tag l(:button_import) %>
|
||||
<%= link_to l(:button_cancel), "#",
|
||||
onclick: '$("#import-ingredients").hide(); return false;' %>
|
||||
<%= link_to l(:button_cancel), "#", onclick: '$("#import-foods").hide(); return false;' %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= render partial: 'ingredients/filters',
|
||||
locals: {url: filter_project_ingredients_path(@project, view: :index)} %>
|
||||
<%= render partial: 'foods/filters',
|
||||
locals: {url: filter_project_foods_path(@project, view: :index)} %>
|
||||
|
||||
<% if @ingredients.any? { |i| i.persisted? } %>
|
||||
<% if @foods.any? { |f| f.persisted? } %>
|
||||
<%= error_messages_for @formula_q.formula if @formula_q %>
|
||||
|
||||
<table class="list">
|
||||
@@ -16,26 +16,26 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @ingredients.each do |i| %>
|
||||
<% next if i.new_record? %>
|
||||
<tr id="ingredient-<%= i.id %>"
|
||||
class="ingredient primary<%= ' hidden' if i.hidden %>">
|
||||
<% @foods.each do |f| %>
|
||||
<% next if f.new_record? %>
|
||||
<tr id="food-<%= f.id %>"
|
||||
class="food primary<%= ' hidden' if f.hidden %>">
|
||||
<td class="name ellipsible">
|
||||
<%= link_to '', toggle_ingredient_path(i), {
|
||||
<%= link_to '', toggle_food_path(f), {
|
||||
remote: true,
|
||||
method: :post,
|
||||
class: "icon icon-eye"
|
||||
} %>
|
||||
<%= i.name %>
|
||||
<%= f.name %>
|
||||
</td>
|
||||
<td class="notes ellipsible"><%= i.notes %></td>
|
||||
<td class="reference value"><%= i.ref_amount %> [<%= i.ref_unit.shortname %>]</td>
|
||||
<td class="group"><%= i.group %></td>
|
||||
<td class="notes ellipsible"><%= f.notes %></td>
|
||||
<td class="reference value"><%= f.ref_amount %> [<%= f.ref_unit.shortname %>]</td>
|
||||
<td class="group"><%= f.group %></td>
|
||||
<td class="source">
|
||||
<%= i.source.name if i.source.present? %>
|
||||
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
||||
<%= f.source.name if f.source.present? %>
|
||||
<%= ", #{f.source_ident}" if f.source_ident.present? %>
|
||||
</td>
|
||||
<td class="action unwrappable"><%= action_links(i, :index) %></td>
|
||||
<td class="action unwrappable"><%= action_links(f, :index) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
18
app/views/foods/_new_form.html.erb
Normal file
18
app/views/foods/_new_form.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<h2><%= t ".heading_new_food" %></h2>
|
||||
|
||||
<%= labelled_form_for @food,
|
||||
url: project_foods_path(@project, view: view),
|
||||
remote: true,
|
||||
html: {id: 'new-food-form', name: 'new-food-form'} do |f| %>
|
||||
|
||||
<%= render partial: 'foods/form', locals: {f: f} %>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to l(:button_cancel), "#",
|
||||
onclick: '$("#new-food").empty(); return false;' %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<hr>
|
||||
@@ -1,8 +1,8 @@
|
||||
<%= render partial: 'ingredients/filters',
|
||||
locals: {url: filter_project_ingredients_path(@project, view: :nutrients)} %>
|
||||
<%= render partial: 'foods/filters',
|
||||
locals: {url: filter_project_foods_path(@project, view: :nutrients)} %>
|
||||
|
||||
<% if @ingredients.any? %>
|
||||
<%= render partial: 'ingredients/options' %>
|
||||
<% if @foods.any? %>
|
||||
<%= render partial: 'foods/options' %>
|
||||
|
||||
<% formulas = @quantities.map { |q| q.formula } %>
|
||||
<% formulas.unshift(@formula_q.formula) if @formula_q %>
|
||||
@@ -17,7 +17,7 @@
|
||||
<th style="width:<%= 100/total_width %>%" class="closable ellipsible">
|
||||
<div style="float:right;position:relative;">
|
||||
<%= link_to '',
|
||||
toggle_column_project_ingredients_path(@project, quantity_id: q.id),
|
||||
toggle_column_project_foods_path(@project, quantity_id: q.id),
|
||||
{class: "icon icon-close", method: :post, remote: true} %>
|
||||
</div>
|
||||
<%= q.name %>
|
||||
@@ -28,17 +28,17 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @ingredients.each_with_index do |i, index| %>
|
||||
<% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %>
|
||||
<tr id="ingredient-<%= i.id %>" class="primary <%= row_class %>">
|
||||
<% @foods.each_with_index do |f, index| %>
|
||||
<% row_class = "food#{' hidden' if f.hidden} #{cycle('odd', 'even')}" %>
|
||||
<tr id="food-<%= f.id %>" class="primary <%= row_class %>">
|
||||
<td class="name ellipsible" style="cursor: pointer;"
|
||||
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', '.ingredient').toggle(); return false;">
|
||||
<span class="icon icon-bullet-closed"><%= i.name %></span>
|
||||
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', '.food').toggle(); return false;">
|
||||
<span class="icon icon-bullet-closed"><%= f.name %></span>
|
||||
</td>
|
||||
<% @requested_n[index].each do |*, value| %>
|
||||
<td class="primary value ellipsible"><%= format_value(value) %></td>
|
||||
<% end %>
|
||||
<td class="action unwrappable"><%= action_links(i, :nutrients) %></td>
|
||||
<td class="action unwrappable"><%= action_links(f, :nutrients) %></td>
|
||||
</tr>
|
||||
|
||||
<tr class="<%= row_class %>" style="display:none">
|
||||
@@ -48,8 +48,8 @@
|
||||
rows = 1
|
||||
end %>
|
||||
<td rowspan="<%= rows %>" class="name ellipsible" style="cursor: pointer;"
|
||||
onclick="$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', '.ingredient').toggle(); return false;">
|
||||
<span class="icon icon-bullet-open"><%= i.name %></span>
|
||||
onclick="$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', '.food').toggle(); return false;">
|
||||
<span class="icon icon-bullet-open"><%= f.name %></span>
|
||||
</td>
|
||||
<% @requested_n[index].each do |q, value| %>
|
||||
<td class="primary quantity ellipsible">
|
||||
@@ -58,7 +58,7 @@
|
||||
</td>
|
||||
<% end %>
|
||||
<td rowspan="<%= rows %>" class="action unwrappable">
|
||||
<%= action_links(i, :nutrients) %>
|
||||
<%= action_links(f, :nutrients) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<fieldset id="options" class="collapsible">
|
||||
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
|
||||
<div>
|
||||
<%= form_tag toggle_column_project_ingredients_path(@project),
|
||||
<%= form_tag toggle_column_project_foods_path(@project),
|
||||
id: 'toggle-column-form', name: 'toggle-column-form',
|
||||
method: :post, remote: true do %>
|
||||
|
||||
6
app/views/foods/create.js.erb
Normal file
6
app/views/foods/create.js.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
$('#new-food').empty();
|
||||
<% if params[:view] == 'index' %>
|
||||
$('#foods').html('<%= j render partial: 'foods/index' %>');
|
||||
<% else %>
|
||||
$('#nutrients').html('<%= j render partial: 'foods/nutrients' %>');
|
||||
<% end %>
|
||||
3
app/views/foods/destroy.js.erb
Normal file
3
app/views/foods/destroy.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% if @food.destroyed? %>
|
||||
$('tr[id=food-<%= @food.id %>]').nextUntil('tr.primary').addBack().remove();
|
||||
<% end %>
|
||||
8
app/views/foods/edit.js.erb
Normal file
8
app/views/foods/edit.js.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
$('tr[id=food-<%= @food.id %>]').nextUntil('tr.primary', ':not(.food)')
|
||||
.remove();
|
||||
var columns = $('table > thead > tr > th').length;
|
||||
$('tr[id=food-<%= @food.id %>]').nextUntil('tr.primary').addBack().last().after(
|
||||
'<tr><td class="form" colspan="'+columns+'"><div id="edit-food">' +
|
||||
'<%= j render partial: 'foods/edit_form', locals: {view: params[:view]} %>' +
|
||||
'</div></td></tr>'
|
||||
);
|
||||
15
app/views/foods/index.html.erb
Normal file
15
app/views/foods/index.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="contextual">
|
||||
<%= link_to t(".heading_nutrient_view"), nutrients_project_foods_path(@project),
|
||||
class: 'icon icon-stats' %>
|
||||
<%= render partial: 'foods/contextual', locals: {view: :index} %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'foods/import' %>
|
||||
|
||||
<div id="new-food">
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<div id='foods'>
|
||||
<%= render partial: 'foods/index' %>
|
||||
</div>
|
||||
5
app/views/foods/index.js.erb
Normal file
5
app/views/foods/index.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<% if params[:view] == 'index' %>
|
||||
$('#foods').html('<%= j render partial: 'foods/index' %>');
|
||||
<% else %>
|
||||
$('#nutrients').html('<%= j render partial: 'foods/nutrients' %>');
|
||||
<% end %>
|
||||
2
app/views/foods/new.js.erb
Normal file
2
app/views/foods/new.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
$('#new-food')
|
||||
.html('<%= j render partial: 'foods/new_form', locals: {view: params[:view]} %>');
|
||||
15
app/views/foods/nutrients.html.erb
Normal file
15
app/views/foods/nutrients.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="contextual">
|
||||
<%= link_to t(".heading_food_list"), project_foods_path(@project),
|
||||
class: 'icon icon-list' %>
|
||||
<%= render partial: 'foods/contextual', locals: {view: :nutrients} %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'foods/import' %>
|
||||
|
||||
<div id="new-food">
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<div id='nutrients'>
|
||||
<%= render partial: 'foods/nutrients' %>
|
||||
</div>
|
||||
1
app/views/foods/toggle.js.erb
Normal file
1
app/views/foods/toggle.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#foods').html('<%= j render partial: 'foods/index' %>');
|
||||
1
app/views/foods/toggle_column.js.erb
Normal file
1
app/views/foods/toggle_column.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$('#nutrients').html('<%= j render partial: 'foods/nutrients' %>');
|
||||
@@ -1,6 +0,0 @@
|
||||
<% if User.current.allowed_to?(:manage_common, @project) %>
|
||||
<%= link_to t(".link_import_ingredients"), '#', class: 'icon icon-multiple',
|
||||
onclick: '$("#import-ingredients").show(); $("#filename").focus(); return false;' %>
|
||||
<%= link_to t(".link_new_ingredient"), new_project_ingredient_path(@project, view: view),
|
||||
{remote: true, class: 'icon icon-add'} %>
|
||||
<% end %>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h2><%= t ".heading_new_ingredient" %></h2>
|
||||
|
||||
<%= labelled_form_for @ingredient,
|
||||
url: project_ingredients_path(@project, view: view),
|
||||
remote: true,
|
||||
html: {id: 'new-ingredient-form', name: 'new-ingredient-form'} do |f| %>
|
||||
|
||||
<%= render partial: 'ingredients/form', locals: {f: f} %>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to l(:button_cancel), "#",
|
||||
onclick: '$("#new-ingredient").empty(); return false;' %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<hr>
|
||||
@@ -1,6 +0,0 @@
|
||||
$('#new-ingredient').empty();
|
||||
<% if params[:view] == 'index' %>
|
||||
$('#ingredients').html('<%= j render partial: 'ingredients/index' %>');
|
||||
<% else %>
|
||||
$('#nutrients').html('<%= j render partial: 'ingredients/nutrients' %>');
|
||||
<% end %>
|
||||
@@ -1,3 +0,0 @@
|
||||
<% if @ingredient.destroyed? %>
|
||||
$('tr[id=ingredient-<%= @ingredient.id %>]').nextUntil('tr.primary').addBack().remove();
|
||||
<% end %>
|
||||
@@ -1,8 +0,0 @@
|
||||
$('tr[id=ingredient-<%= @ingredient.id %>]').nextUntil('tr.primary', ':not(.ingredient)')
|
||||
.remove();
|
||||
var columns = $('table > thead > tr > th').length;
|
||||
$('tr[id=ingredient-<%= @ingredient.id %>]').nextUntil('tr.primary').addBack().last().after(
|
||||
'<tr><td class="form" colspan="'+columns+'"><div id="edit-ingredient">' +
|
||||
'<%= j render partial: 'ingredients/edit_form', locals: {view: params[:view]} %>' +
|
||||
'</div></td></tr>'
|
||||
);
|
||||
@@ -1,15 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to t(".heading_nutrient_view"), nutrients_project_ingredients_path(@project),
|
||||
class: 'icon icon-stats' %>
|
||||
<%= render partial: 'ingredients/contextual', locals: {view: :index} %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'ingredients/import' %>
|
||||
|
||||
<div id="new-ingredient">
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<div id='ingredients'>
|
||||
<%= render partial: 'ingredients/index' %>
|
||||
</div>
|
||||
@@ -1,5 +0,0 @@
|
||||
<% if params[:view] == 'index' %>
|
||||
$('#ingredients').html('<%= j render partial: 'ingredients/index' %>');
|
||||
<% else %>
|
||||
$('#nutrients').html('<%= j render partial: 'ingredients/nutrients' %>');
|
||||
<% end %>
|
||||
@@ -1,2 +0,0 @@
|
||||
$('#new-ingredient')
|
||||
.html('<%= j render partial: 'ingredients/new_form', locals: {view: params[:view]} %>');
|
||||
@@ -1,15 +0,0 @@
|
||||
<div class="contextual">
|
||||
<%= link_to t(".heading_ingredient_list"), project_ingredients_path(@project),
|
||||
class: 'icon icon-list' %>
|
||||
<%= render partial: 'ingredients/contextual', locals: {view: :nutrients} %>
|
||||
</div>
|
||||
|
||||
<%= render partial: 'ingredients/import' %>
|
||||
|
||||
<div id="new-ingredient">
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<div id='nutrients'>
|
||||
<%= render partial: 'ingredients/nutrients' %>
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
$('#ingredients').html('<%= j render partial: 'ingredients/index' %>');
|
||||
@@ -1 +0,0 @@
|
||||
$('#nutrients').html('<%= j render partial: 'ingredients/nutrients' %>');
|
||||
@@ -12,9 +12,9 @@
|
||||
<ul>
|
||||
<li><%= link_to t(".link_meals"), project_meals_path(@project) %></li>
|
||||
<li>
|
||||
<%= link_to t(".link_ingredients"), project_ingredients_path(@project) %>
|
||||
<%= link_to t(".link_foods"), project_foods_path(@project) %>
|
||||
/
|
||||
<%= link_to t(".link_nutrients"), nutrients_project_ingredients_path(@project) %>
|
||||
<%= link_to t(".link_nutrients"), nutrients_project_foods_path(@project) %>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user