Replaced Quantity 'primary' attr with ColumnView model
This commit is contained in:
@@ -6,7 +6,7 @@ class IngredientsController < ApplicationController
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id,
|
||||
only: [:index, :nutrients, :create, :import, :filter, :filter_nutrients]
|
||||
before_action :find_quantity, only: [:toggle_nutrient_column]
|
||||
before_action :find_quantity_by_quantity_id, only: [:toggle_column]
|
||||
before_action :find_ingredient, only: [:destroy, :toggle]
|
||||
before_action :authorize
|
||||
|
||||
@@ -25,8 +25,8 @@ class IngredientsController < ApplicationController
|
||||
prepare_nutrients
|
||||
end
|
||||
|
||||
def toggle_nutrient_column
|
||||
@quantity.toggle_primary!
|
||||
def toggle_column
|
||||
@project.nutrients_column_view.toggle_column!(@quantity)
|
||||
prepare_nutrients
|
||||
end
|
||||
|
||||
@@ -207,7 +207,7 @@ class IngredientsController < ApplicationController
|
||||
end
|
||||
|
||||
def prepare_nutrients
|
||||
@quantities = @project.quantities.diet.where(primary: true)
|
||||
@quantities = @project.nutrients_column_view.quantities
|
||||
ingredients, requested_n, extra_n, @formula_q = @project.ingredients
|
||||
.filter(@project, session[:i_filters], @quantities)
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@ class MeasurementsController < ApplicationController
|
||||
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create]
|
||||
before_action :find_quantity, only: [:toggle_quantity]
|
||||
before_action :find_measurement, only: [:edit, :update, :destroy, :retake, :readouts]
|
||||
before_action :find_quantity_by_quantity_id, only: [:toggle_column]
|
||||
before_action :find_measurement,
|
||||
only: [:edit, :update, :destroy, :retake, :readouts, :toggle_column]
|
||||
before_action :authorize
|
||||
|
||||
def index
|
||||
@@ -61,8 +62,8 @@ class MeasurementsController < ApplicationController
|
||||
prepare_readouts
|
||||
end
|
||||
|
||||
def toggle_quantity
|
||||
@quantity.toggle_primary!
|
||||
def toggle_column
|
||||
@measurement.column_view.toggle_column!(@quantity)
|
||||
prepare_readouts
|
||||
end
|
||||
|
||||
@@ -103,7 +104,7 @@ class MeasurementsController < ApplicationController
|
||||
end
|
||||
|
||||
def prepare_readouts
|
||||
@quantities = @project.quantities.measurement.where(primary: true)
|
||||
@quantities = @measurement.column_view.quantities
|
||||
@measurements, @requested_r, @extra_r, @formula_q = @project.measurements
|
||||
.includes(:source)
|
||||
.filter(session[:m_filters], @quantities)
|
||||
|
||||
@@ -3,7 +3,7 @@ class QuantitiesController < ApplicationController
|
||||
|
||||
before_action :init_session_filters
|
||||
before_action :find_project_by_project_id, only: [:index, :parents, :create, :filter]
|
||||
before_action :find_quantity, only: [:edit, :update, :destroy, :toggle, :move]
|
||||
before_action :find_quantity, only: [:edit, :update, :destroy, :move]
|
||||
before_action :authorize
|
||||
|
||||
def index
|
||||
@@ -55,11 +55,6 @@ class QuantitiesController < ApplicationController
|
||||
render :index
|
||||
end
|
||||
|
||||
def toggle
|
||||
@quantity.toggle_primary!
|
||||
prepare_quantities
|
||||
end
|
||||
|
||||
def move
|
||||
direction = params[:direction].to_sym
|
||||
case direction
|
||||
@@ -90,8 +85,7 @@ class QuantitiesController < ApplicationController
|
||||
:parent_id,
|
||||
:name,
|
||||
:description,
|
||||
:formula,
|
||||
:primary
|
||||
:formula
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user