Last changes on Redmine 4.0
This commit is contained in:
@@ -40,15 +40,6 @@ module Concerns::Finders
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_measurement
|
||||
@measurement = Measurement.find(params[:id])
|
||||
# DON'T set @routine here: @routine is a context for :readouts view (set
|
||||
# elsewhere), not a # @measurement.routine
|
||||
@project = @measurement.routine.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_measurement_routine(id = params[:id])
|
||||
@routine = MeasurementRoutine.find(id)
|
||||
@project = @routine.project
|
||||
@@ -60,6 +51,17 @@ module Concerns::Finders
|
||||
find_measurement_routine(params[:measurement_routine_id])
|
||||
end
|
||||
|
||||
def find_measurement(id = params[:id])
|
||||
@measurement = Measurement.find(id)
|
||||
@project = @measurement.routine.project
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_measurement_by_measurement_id
|
||||
find_measurement(params[:measurement_id])
|
||||
end
|
||||
|
||||
def find_quantity(id = params[:id])
|
||||
@quantity = Quantity.find(id)
|
||||
@project = @quantity.project
|
||||
|
||||
@@ -9,7 +9,7 @@ class MeasurementsController < ApplicationController
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create, :filter]
|
||||
before_action :find_measurement, only: [:edit, :update, :destroy, :retake]
|
||||
before_action :find_measurement_routine_by_measurement_routine_id,
|
||||
only: [:new, :create, :edit, :update, :retake, :filter]
|
||||
only: [:new, :create, :filter]
|
||||
before_action :authorize
|
||||
before_action :set_view_params
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@ 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_measurement_by_measurement_id, only: [:edit, :update]
|
||||
before_action :find_quantity_by_quantity_id, only: [:toggle_exposure]
|
||||
before_action :authorize
|
||||
|
||||
@@ -15,6 +15,22 @@ class ReadoutsController < ApplicationController
|
||||
prepare_readouts
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @measurement.update(measurement_params)
|
||||
count = @measurement.readouts.target.count { |r| r.previous_changes.present? }
|
||||
flash.now[:notice] = t('.success', count: count)
|
||||
|
||||
@routine = @measurement.routine
|
||||
prepare_readouts
|
||||
render :index
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_exposure
|
||||
@routine.readout_exposures.toggle!(@quantity)
|
||||
prepare_readouts
|
||||
@@ -22,6 +38,21 @@ class ReadoutsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def measurement_params
|
||||
params.require(:measurement).permit(
|
||||
:notes,
|
||||
:source_id,
|
||||
readouts_attributes:
|
||||
[
|
||||
:id,
|
||||
:quantity_id,
|
||||
:value,
|
||||
:unit_id,
|
||||
:_destroy
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
def prepare_readouts
|
||||
@quantities = @routine.quantities.includes(:formula)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user