diff --git a/app/controllers/foods_controller.rb b/app/controllers/foods_controller.rb
index efa84c2..e8bd51d 100644
--- a/app/controllers/foods_controller.rb
+++ b/app/controllers/foods_controller.rb
@@ -10,7 +10,7 @@ class FoodsController < ApplicationController
before_action :init_session_filters
before_action :find_project_by_project_id,
only: [:index, :new, :create, :nutrients, :filter, :autocomplete, :import]
- before_action :find_quantity_by_quantity_id, only: [:toggle_column]
+ before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
before_action :find_food, only: [:edit, :update, :destroy, :toggle]
before_action :authorize
@@ -62,7 +62,7 @@ class FoodsController < ApplicationController
prepare_nutrients
end
- def toggle_column
+ def toggle_exposure
@project.nutrient_exposures.toggle!(@quantity)
prepare_nutrients
end
diff --git a/app/controllers/measurements_controller.rb b/app/controllers/measurements_controller.rb
index f19cb23..6e1e9cb 100644
--- a/app/controllers/measurements_controller.rb
+++ b/app/controllers/measurements_controller.rb
@@ -7,9 +7,9 @@ class MeasurementsController < ApplicationController
before_action :init_session_filters
before_action :find_project_by_project_id, only: [:index, :new, :create, :filter]
- before_action :find_quantity_by_quantity_id, only: [:toggle_column]
+ before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
before_action :find_measurement, only: [:edit, :update, :destroy, :retake]
- before_action :find_measurement_routine, only: [:readouts, :toggle_column]
+ before_action :find_measurement_routine, only: [:readouts, :toggle_exposure]
before_action :authorize
def index
@@ -82,7 +82,7 @@ class MeasurementsController < ApplicationController
prepare_readouts
end
- def toggle_column
+ def toggle_exposure
@routine.readout_exposures.toggle!(@quantity)
prepare_readouts
end
diff --git a/app/helpers/body_trackers_helper.rb b/app/helpers/body_trackers_helper.rb
index 8518e65..31f5d79 100644
--- a/app/helpers/body_trackers_helper.rb
+++ b/app/helpers/body_trackers_helper.rb
@@ -15,6 +15,16 @@ module BodyTrackersHelper
t.strftime("%R") if t
end
+ def toggle_exposure_options(enabled, domain)
+ disabled = []
+ enabled = enabled.to_a
+ options = nested_set_options(@project.quantities.send(domain)) do |q|
+ disabled << q.id if enabled.include?(q)
+ raw("#{' ' * q.level}#{q.name}")
+ end
+ options_for_select(options, disabled: disabled)
+ end
+
def unit_options
@project.units.map do |u|
[u.shortname, u.id]
diff --git a/app/helpers/foods_helper.rb b/app/helpers/foods_helper.rb
index 5254c53..8940039 100644
--- a/app/helpers/foods_helper.rb
+++ b/app/helpers/foods_helper.rb
@@ -5,16 +5,6 @@ module FoodsHelper
end
end
- def toggle_column_options
- disabled = []
- enabled_quantities = @project.nutrient_quantities.to_a
- options = nested_set_options(@project.quantities.diet) do |q|
- disabled << q.id if enabled_quantities.include?(q)
- raw("#{' ' * q.level}#{q.name}")
- end
- options_for_select(options, disabled: disabled)
- end
-
def visibility_options(selected)
options = [["visible", 1], ["hidden", 0]]
options_for_select(options, selected)
diff --git a/app/helpers/measurements_helper.rb b/app/helpers/measurements_helper.rb
index 724ccdf..ef376e2 100644
--- a/app/helpers/measurements_helper.rb
+++ b/app/helpers/measurements_helper.rb
@@ -5,16 +5,6 @@ module MeasurementsHelper
.html_safe
end
- def toggle_column_options
- disabled = []
- enabled_quantities = @routine.quantities.to_a
- options = nested_set_options(@project.quantities.measurement) do |q|
- disabled << q.id if enabled_quantities.include?(q)
- raw("#{' ' * q.level}#{q.name}")
- end
- options_for_select(options, disabled: disabled)
- end
-
def quantity_options
nested_set_options(@project.quantities.measurement) do |q|
raw("#{' ' * q.level}#{q.name}")
diff --git a/app/models/measurement_routine.rb b/app/models/measurement_routine.rb
index 44f05d7..4cb6a04 100644
--- a/app/models/measurement_routine.rb
+++ b/app/models/measurement_routine.rb
@@ -4,7 +4,7 @@ class MeasurementRoutine < ActiveRecord::Base
foreign_key: 'routine_id', dependent: :restrict_with_error,
extend: BodyTracking::ItemsWithQuantities
has_many :readout_exposures, as: :view, dependent: :destroy,
- class_name: 'Exposure', extend: BodyTracking::TogglableColumns
+ class_name: 'Exposure', extend: BodyTracking::TogglableExposures
has_many :quantities, -> { order "lft" }, through: :readout_exposures
validates :name, presence: true, uniqueness: {scope: :project_id}
diff --git a/app/views/foods/_nutrients.html.erb b/app/views/foods/_nutrients.html.erb
index a2c7d0b..e3b8771 100644
--- a/app/views/foods/_nutrients.html.erb
+++ b/app/views/foods/_nutrients.html.erb
@@ -17,7 +17,7 @@
<%= link_to '',
- toggle_column_project_foods_path(@project, quantity_id: q.id),
+ toggle_exposure_project_foods_path(@project, quantity_id: q.id),
{class: "icon icon-close", method: :post, remote: true} %>
<%= q.name %>
diff --git a/app/views/foods/_options.html.erb b/app/views/foods/_options.html.erb
index 387a970..7610244 100644
--- a/app/views/foods/_options.html.erb
+++ b/app/views/foods/_options.html.erb
@@ -1,14 +1,15 @@
|