1
0

Added Quantity.primary to form

Fixed setting parent on Quantity form
This commit is contained in:
cryptogopher 2019-10-26 21:48:52 +02:00
parent 7b46f131c0
commit 26f653819d
3 changed files with 7 additions and 1 deletions

View File

@ -58,7 +58,8 @@ class QuantitiesController < ApplicationController
:name,
:description,
:domain,
:parent_id
:parent_id,
:primary
)
end

View File

@ -10,13 +10,17 @@
<% end %>
<p><%= f.text_field :name, size: 25, required: true %></p>
<p><%= f.text_field :description, size: 200 %></p>
<p><%= f.check_box :primary %></p>
</div>
<%= javascript_tag do %>
function domainChange() {
$('[id^=parent_select_]').prop('disabled', true).hide();
$('[id^=parent_select_] select').attr('name', 'placeholder');
$('[id=parent_select_'+$('#quantity_domain option:selected').val()+']')
.prop('disabled', false).show();
$('[id=parent_select_'+$('#quantity_domain option:selected').val()+'] select')
.attr('name', 'quantity[parent_id]');
}
$('#quantity-form').on('click', '#quantity_domain', domainChange);

View File

@ -10,6 +10,7 @@ en:
field_nutrients: 'Nutrients:'
field_domain: 'Domain'
field_parent_quantity: 'Parent'
field_primary: 'Primary'
field_shortname: 'Short name'
button_primary: 'Primary'
activerecord: