Added Measurement readouts action
This commit is contained in:
@@ -2,10 +2,11 @@ class MeasurementsController < ApplicationController
|
||||
menu_item :body_trackers
|
||||
|
||||
before_action :find_project_by_project_id, only: [:index, :new, :create]
|
||||
before_action :find_measurement, only: [:edit, :update, :destroy, :retake]
|
||||
before_action :find_measurement, only: [:edit, :update, :destroy, :retake, :readouts]
|
||||
before_action :authorize
|
||||
|
||||
def index
|
||||
session[:m_scope] = {}
|
||||
prepare_measurements
|
||||
end
|
||||
|
||||
@@ -53,6 +54,11 @@ class MeasurementsController < ApplicationController
|
||||
render :new
|
||||
end
|
||||
|
||||
def readouts
|
||||
session[:m_scope] = {name: @measurement.name}
|
||||
prepare_measurements
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def measurement_params
|
||||
@@ -81,5 +87,6 @@ class MeasurementsController < ApplicationController
|
||||
|
||||
def prepare_measurements
|
||||
@measurements = @project.measurements.includes(:source, :readouts)
|
||||
.where(session[:m_scope])
|
||||
end
|
||||
end
|
||||
|
||||
4
app/views/measurements/_contextual.html.erb
Normal file
4
app/views/measurements/_contextual.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<% if User.current.allowed_to?(:manage_common, @project) %>
|
||||
<%= link_to t(".link_new_measurement"), new_project_measurement_path(@project),
|
||||
{remote: true, class: 'icon icon-add'} %>
|
||||
<% end %>
|
||||
@@ -16,7 +16,9 @@
|
||||
<%= m.taken_at.getlocal.strftime("%F <small>%R</small>").html_safe %>
|
||||
</td>
|
||||
<td class="name">
|
||||
<div style="float:left;"><%= m.name %></div>
|
||||
<div style="float:left;">
|
||||
<%= link_to m.name, readouts_measurement_path(m) %>
|
||||
</div>
|
||||
<div style="float:right;">
|
||||
<small><%= " (#{pluralize(m.readouts.size, 'readout')})" %></small>
|
||||
</div>
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
<% end %>
|
||||
|
||||
<div class="contextual">
|
||||
<% if User.current.allowed_to?(:manage_common, @project) %>
|
||||
<%= link_to t(".link_new_measurement"), new_project_measurement_path(@project), {
|
||||
remote: true,
|
||||
class: 'icon icon-add'
|
||||
} %>
|
||||
<% end %>
|
||||
<%= render partial: 'measurements/contextual' %>
|
||||
</div>
|
||||
|
||||
<div id="new-measurement">
|
||||
|
||||
19
app/views/measurements/readouts.html.erb
Normal file
19
app/views/measurements/readouts.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<% content_for :sidebar do %>
|
||||
<%= render partial: 'body_trackers/sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<div class="contextual">
|
||||
<%= render partial: 'measurements/contextual' %>
|
||||
</div>
|
||||
|
||||
<div id="new-measurement">
|
||||
</div>
|
||||
|
||||
<h2>
|
||||
<%= link_to t("measurements.index.heading"), project_measurements_path(@project) %>
|
||||
>
|
||||
<%= @measurements.first.name %>
|
||||
</h2>
|
||||
<div id='measurements'>
|
||||
<%= render partial: 'measurements/index' %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user