1
0

Create Readouts controller

Move #readouts + #toggle_exposure from Measurements to Readouts
This commit is contained in:
cryptogopher
2021-05-08 01:02:57 +02:00
parent 40cce31bff
commit 7b2b855d56
13 changed files with 62 additions and 49 deletions

View File

@@ -7,13 +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_exposure]
before_action :find_measurement, only: [:edit, :update, :destroy, :retake]
# @routine is set for :readouts view ONLY
before_action :find_measurement_routine, only: [:readouts, :toggle_exposure]
before_action :find_measurement_routine_by_measurement_routine_id,
only: [:new, :create, :edit, :update, :retake, :filter],
if: -> { params[:view] == 'readouts' }
only: [:new, :create, :edit, :update, :retake, :filter]
before_action :authorize
before_action :set_view_params
@@ -84,15 +80,6 @@ class MeasurementsController < ApplicationController
render :new
end
def readouts
prepare_readouts
end
def toggle_exposure
@routine.readout_exposures.toggle!(@quantity)
prepare_readouts
end
def filter
session[:m_filters] = params.permit(:name, formula: [:code, :zero_nil])
prepare_items
@@ -141,12 +128,6 @@ class MeasurementsController < ApplicationController
.filter(session[:m_filters])
end
def prepare_readouts
@quantities = @routine.quantities.includes(:formula)
@measurements, @filter_q = @routine.measurements.includes(:routine, :source)
.filter(session[:m_filters], @quantities)
end
def set_view_params
@view_params =
if @routine

View File

@@ -0,0 +1,31 @@
class ReadoutsController < ApplicationController
layout 'body_tracking'
menu_item :body_trackers
helper :body_trackers
helper :measurements
include Concerns::Finders
before_action :find_measurement_routine_by_measurement_routine_id,
only: [:index, :toggle_exposure]
before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
before_action :authorize
def index
prepare_readouts
end
def toggle_exposure
@routine.readout_exposures.toggle!(@quantity)
prepare_readouts
end
private
def prepare_readouts
@quantities = @routine.quantities.includes(:formula)
@measurements, @filter_q = @routine.measurements.includes(:routine, :source)
.filter(session[:m_filters], @quantities)
end
end