1
0

Updating Quantity to use Formula, WIP

This commit is contained in:
cryptogopher 2020-02-17 22:15:30 +01:00
parent 4e537f3981
commit 544c0c5293
4 changed files with 12 additions and 6 deletions

View File

@ -79,18 +79,21 @@ class QuantitiesController < ApplicationController
end end
def quantity_params def quantity_params
params[:quantity].delete(:formula) if params[:quantity][:formula].blank?
params.require(:quantity).permit( params.require(:quantity).permit(
:domain, :domain,
:parent_id, :parent_id,
:name, :name,
:description, :description,
:formula formula_attributes:
[
:code,
:zero_nil
]
) )
end end
def prepare_quantities def prepare_quantities
@quantities = @project.quantities.filter(@project, session[:q_filters]) @quantities = @project.quantities.filter(@project, session[:q_filters])
.includes(:column_views) .includes(:column_views, :formula)
end end
end end

View File

@ -11,6 +11,8 @@
{required: true, label: :field_parent_quantity, include_blank: t('.null_parent')} %></p> {required: true, label: :field_parent_quantity, include_blank: t('.null_parent')} %></p>
<p><%= f.text_field :name, size: 25, required: true %></p> <p><%= f.text_field :name, size: 25, required: true %></p>
<p><%= f.text_field :description, style: "width: 100%;" %></p> <p><%= f.text_field :description, style: "width: 100%;" %></p>
<p><%= f.text_field :formula, placeholder: t('.formula_placeholder'), <%= f.fields_for :formula do |ff| %>
style: "width: 100%;" %></p> <p><%= ff.text_field :code, placeholder: t('.formula_placeholder'),
style: "width: 100%;" %></p>
<% end %>
</div> </div>

View File

@ -14,6 +14,7 @@ en:
field_domain: 'Domain' field_domain: 'Domain'
field_parent_quantity: 'Parent' field_parent_quantity: 'Parent'
field_formula: 'Formula' field_formula: 'Formula'
field_code: 'Formula'
field_shortname: 'Short name' field_shortname: 'Short name'
button_retake: 'Retake' button_retake: 'Retake'
activerecord: activerecord:

View File

@ -1,7 +1,7 @@
require File.expand_path('../../test_helper', __FILE__) require File.expand_path('../../test_helper', __FILE__)
class FormulaTest < ActiveSupport::TestCase class FormulaTest < ActiveSupport::TestCase
include BodyTracking::Formula include BodyTracking::FormulaBuilder
def setup def setup
end end