Quantity destruction destroys dependent
Table data aligned. Primary quantities highlighted.
This commit is contained in:
parent
c0e3fd2e85
commit
baadd647f8
@ -5,7 +5,7 @@ class Quantity < ActiveRecord::Base
|
|||||||
exercise: 2
|
exercise: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
acts_as_nested_set dependent: :nullify, scope: :project
|
acts_as_nested_set dependent: :destroy, scope: :project
|
||||||
belongs_to :project, required: false
|
belongs_to :project, required: false
|
||||||
|
|
||||||
validates :name, presence: true, uniqueness: {scope: :project_id}
|
validates :name, presence: true, uniqueness: {scope: :project_id}
|
||||||
|
@ -64,13 +64,13 @@
|
|||||||
<% next if i.new_record? %>
|
<% next if i.new_record? %>
|
||||||
<tr id="ingredient-<%= i.id %>" class="ingredient <%= 'hidden' if i.hidden %>">
|
<tr id="ingredient-<%= i.id %>" class="ingredient <%= 'hidden' if i.hidden %>">
|
||||||
<td class="name"><%= i.name %></td>
|
<td class="name"><%= i.name %></td>
|
||||||
<td class="reference"><%= i.ref_amount %> [<%= i.ref_unit.shortname %>]</td>
|
<td class="reference value"><%= i.ref_amount %> [<%= i.ref_unit.shortname %>]</td>
|
||||||
<td class="group"><%= i.group %></td>
|
<td class="group"><%= i.group %></td>
|
||||||
<td class="source">
|
<td class="source">
|
||||||
<%= i.source.name if i.source.present? %>
|
<%= i.source.name if i.source.present? %>
|
||||||
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= delete_link ingredient_path(i), data: {} %></td>
|
<td class="action"><%= delete_link ingredient_path(i), data: {} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -35,13 +35,17 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% Quantity.each_with_level(@quantities) do |q, level| %>
|
<% Quantity.each_with_level(@quantities) do |q, level| %>
|
||||||
<% next if q.new_record? %>
|
<%
|
||||||
<tr id="quantity-<%= q.id %>"
|
next if q.new_record?
|
||||||
class="quantity <%= "project idnt idnt-#{level}" if level > 0 %>">
|
quantity_class = "quantity"
|
||||||
|
quantity_class += " project idnt idnt-#{level}" if level > 0
|
||||||
|
quantity_class += " primary" if q.primary
|
||||||
|
%>
|
||||||
|
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
|
||||||
<td class="name"><span><%= q.name %></span></td>
|
<td class="name"><span><%= q.name %></span></td>
|
||||||
<td class="domain"><%= q.domain %></td>
|
<td class="domain"><%= q.domain %></td>
|
||||||
<td class="description"><%= q.description %></td>
|
<td class="description"><%= q.description %></td>
|
||||||
<td><%= delete_link quantity_path(q), data: {} %></td>
|
<td class="action"><%= delete_link quantity_path(q), data: {} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<tr id="source-<%= s.id %>" class="source">
|
<tr id="source-<%= s.id %>" class="source">
|
||||||
<td class="name"><%= s.name %></td>
|
<td class="name"><%= s.name %></td>
|
||||||
<td class="description"><%= s.description %></td>
|
<td class="description"><%= s.description %></td>
|
||||||
<td><%= delete_link source_path(s), data: {} %></td>
|
<td class="action"><%= delete_link source_path(s), data: {} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<tr id="unit-<%= u.id %>" class="unit">
|
<tr id="unit-<%= u.id %>" class="unit">
|
||||||
<td class="shortname"><%= u.shortname %></td>
|
<td class="shortname"><%= u.shortname %></td>
|
||||||
<td class="unitname"><%= u.name %></td>
|
<td class="unitname"><%= u.name %></td>
|
||||||
<td><%= delete_link unit_path(u), data: {} %></td>
|
<td class="action"><%= delete_link unit_path(u), data: {} %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -1 +1,3 @@
|
|||||||
table.nutrients td.value {text-align:right;}
|
table.list tr.quantity.primary td.name {font-weight: bold;}
|
||||||
|
table.list td.action,
|
||||||
|
table.list td.value {text-align: right;}
|
||||||
|
Reference in New Issue
Block a user