Add child Quantity action added
This commit is contained in:
@@ -46,6 +46,10 @@
|
||||
<td class="description"><%= q.description %></td>
|
||||
<td class="formula"><%= checked_image q.formula %></td>
|
||||
<td class="action unwrappable">
|
||||
<%= link_to l(:button_child), new_child_quantity_path(q), {
|
||||
remote: true,
|
||||
class: "icon icon-add"
|
||||
} %>
|
||||
<%= link_to l(:button_edit), edit_quantity_path(q), {
|
||||
remote: true,
|
||||
class: "icon icon-edit"
|
||||
|
||||
15
app/views/quantities/_new_child_form.html.erb
Normal file
15
app/views/quantities/_new_child_form.html.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
<%= labelled_form_for @quantity,
|
||||
url: create_child_quantity_path(@parent_quantity),
|
||||
remote: true,
|
||||
html: {id: 'new-child-form', name: 'new-child-form'} do |f| %>
|
||||
|
||||
<%= render partial: 'quantities/form', locals: {f: f} %>
|
||||
|
||||
<div class="tabular">
|
||||
<p>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to l(:button_cancel), "#",
|
||||
onclick: '$(this).closest("tr").remove(); return false;' %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
2
app/views/quantities/create_child.js.erb
Normal file
2
app/views/quantities/create_child.js.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%= render partial: 'body_trackers/flash' %>
|
||||
$('#quantities').html('<%= j render partial: 'quantities/index' %>');
|
||||
8
app/views/quantities/new_child.js.erb
Normal file
8
app/views/quantities/new_child.js.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<%= render partial: 'body_trackers/flash' %>
|
||||
$('tr[id=quantity-<%= @parent_quantity.id %>]').nextUntil('tr.quantity').remove();
|
||||
var columns = $('table > thead > tr > th').length;
|
||||
$('tr[id=quantity-<%= @parent_quantity.id %>]').nextAll('tr.quantity').first().before(
|
||||
'<tr><td class="form" colspan="'+columns+'">' +
|
||||
'<div id="new-child-quantity"><%= j render partial: "quantities/new_child_form" %></div>' +
|
||||
'</td></tr>'
|
||||
);
|
||||
Reference in New Issue
Block a user