1
0

Measurement improvements

Added 'new' action.
Separated js views for new/create/edit.
Displaying taken_at in local time.
Fixed readout destruction on edit.
This commit is contained in:
cryptogopher
2019-12-06 21:48:06 +01:00
parent 65d811d9fb
commit 681c0279fb
14 changed files with 91 additions and 79 deletions

View File

@@ -1,33 +1,31 @@
class MeasurementsController < ApplicationController
menu_item :body_trackers
before_action :find_project_by_project_id, only: [:index, :create]
before_action :find_project_by_project_id, only: [:index, :new, :create]
before_action :find_measurement, only: [:edit, :update, :destroy, :retake]
before_action :authorize
def index
prepare_measurements
end
def new
@measurement = @project.measurements.new
@measurement.readouts.new
prepare_measurements
@measurements << @measurement
end
def create
@measurement = @project.measurements.new(measurement_params)
if @measurement.save
flash[:notice] = 'Created new measurement'
redirect_to :back
else
prepare_measurements
else
@measurement.readouts.new if @measurement.readouts.empty?
render :index
render :new
end
end
def edit
prepare_measurements
render :index
end
def update