Added Ingredient comment attribute
Minor view updates
This commit is contained in:
parent
4d48e86728
commit
cc62ef1002
@ -88,6 +88,7 @@ class IngredientsController < ApplicationController
|
||||
|
||||
i_params = {
|
||||
name: r.delete('Name'),
|
||||
comment: r.delete('Comment'),
|
||||
ref_amount: 100.0,
|
||||
ref_unit: units['g'],
|
||||
group: r.delete('Group') || :other,
|
||||
@ -176,6 +177,7 @@ class IngredientsController < ApplicationController
|
||||
def ingredient_params
|
||||
params.require(:ingredient).permit(
|
||||
:name,
|
||||
:comment,
|
||||
:ref_amount,
|
||||
:ref_unit_id,
|
||||
:group,
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :name, size: 40, required: true %></p>
|
||||
<p><%= f.text_area :comment, cols: 40, rows: 3, required: false,
|
||||
style: "width: 100%;" %></p>
|
||||
<p>
|
||||
<%= f.number_field :ref_amount, size: 8, required: true, min: 0,
|
||||
label: :field_reference %>
|
||||
|
@ -5,18 +5,19 @@
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th style="width:50%"><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_comment) %></th>
|
||||
<th><%= l(:field_reference) %></th>
|
||||
<th><%= l(:field_group) %></th>
|
||||
<th><%= l(:field_source) %></th>
|
||||
<th style="width:10%"><%= l(:field_action) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @ingredients.each do |i| %>
|
||||
<% next if i.new_record? %>
|
||||
<tr id="ingredient-<%= i.id %>" class="ingredient <%= 'hidden' if i.hidden %>">
|
||||
<td class="name">
|
||||
<td class="name ellipsible">
|
||||
<%= link_to '', toggle_ingredient_path(i), {
|
||||
remote: true,
|
||||
method: :post,
|
||||
@ -24,13 +25,14 @@
|
||||
} %>
|
||||
<%= i.name %>
|
||||
</td>
|
||||
<td class="comment ellipsible"><%= i.comment %></td>
|
||||
<td class="reference value"><%= i.ref_amount %> [<%= i.ref_unit.shortname %>]</td>
|
||||
<td class="group"><%= i.group %></td>
|
||||
<td class="source">
|
||||
<%= i.source.name if i.source.present? %>
|
||||
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
||||
</td>
|
||||
<td class="action">
|
||||
<td class="action unwrappable">
|
||||
<%= delete_link ingredient_path(i), {remote: true, data: {}} %>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -18,7 +18,8 @@
|
||||
<% @nutrients.each do |i, values| %>
|
||||
<% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %>
|
||||
<tr id="ingredient-<%= i.id %>" class="primary <%= row_class %>">
|
||||
<td class="name" style="cursor: pointer;" onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;">
|
||||
<td class="name ellipsible" style="cursor: pointer;"
|
||||
onclick="$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;">
|
||||
<span class="icon icon-bullet-closed"><%= i.name %></span>
|
||||
</td>
|
||||
<% values.each do |*, value| %>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<th style="width:5%"><%= l(:field_taken_at_date) %></th>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_source) %></th>
|
||||
<th style="width:10%"><%= l(:field_action) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<th><%= l(:field_domain) %></th>
|
||||
<th><%= l(:field_description) %></th>
|
||||
<th><%= l(:field_formula) %></th>
|
||||
<th style="width:10%"><%= l(:field_action) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<tr>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_description) %></th>
|
||||
<th style="width:10%"><%= l(:field_action) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<tr>
|
||||
<th><%= l(:field_shortname) %></th>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th style="width:10%"><%= l(:field_action) %></th>
|
||||
<th style="width:5%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -5,6 +5,7 @@ en:
|
||||
field_taken_at_date: 'Taken at'
|
||||
field_order: 'Order'
|
||||
field_action: 'Action'
|
||||
field_comment: 'Comment'
|
||||
field_reference: 'Reference'
|
||||
field_group: 'Group'
|
||||
field_source: 'Source'
|
||||
@ -78,8 +79,8 @@ en:
|
||||
import_hints: 'CSV file has to include header with column names. Recognized column
|
||||
names are:
|
||||
(1) ingredient attributes, case sensitive:
|
||||
"Name" - required, "Reference" - defaults to 100[g], "Group" - defaults to "other",
|
||||
"Source" - optional, "SourceIdent" - optional,
|
||||
"Name" - required, "Comment" - optional, "Reference" - defaults to 100[g],
|
||||
"Group" - defaults to "other", "Source" - optional, "SourceIdent" - optional,
|
||||
(2) quantities'' names with unit short name in square brackets.
|
||||
Sample header: "Name,Reference,Group,Proteins[g],Fats[g],Carbohydrates[g]".
|
||||
Sample data row: "Brussels,100[g],other,3.4,300[mg],9".
|
||||
|
@ -41,6 +41,7 @@ class CreateSchema < ActiveRecord::Migration
|
||||
create_table :ingredients do |t|
|
||||
t.references :project
|
||||
t.string :name
|
||||
t.text :comment
|
||||
t.decimal :ref_amount, precision: 12, scale: 6
|
||||
t.references :ref_unit
|
||||
t.integer :group
|
||||
|
Reference in New Issue
Block a user