1
0

Added MeasurementRoutine as a nested Measurement model

Updated ItemsWithQuantities to work with MeasurementRoutine
Replaced ColumnViews HABTM with polymorphic HMT
Added Measurement notes
Added destroy restrictions on Quantity
Replaced BodyTrackingPluginController with Finders concern
Removed 'body_trackers' prefix from paths
Unified styling for textarea
This commit is contained in:
cryptogopher
2020-03-29 00:56:37 +01:00
parent e7a33c684f
commit 18419f1aeb
28 changed files with 260 additions and 243 deletions

View File

@@ -1,17 +1,29 @@
<%= error_messages_for @measurement %>
<div class="box tabular">
<p><%= f.select :source_id, source_options,
{required: false, include_blank: t('.null_source')} %></p>
<p><%= f.text_field :name, size: 40, required: true %></p>
<p>
<fieldset class="box">
<legend ><%= t('.label_routine') %></legend>
<div class="tabular">
<%= f.fields_for :routine do |ff| %>
<p><%= ff.text_field :name, required: true, style: "width: 95%;" %></p>
<p><%= ff.text_area :description, cols: 40, rows: 3, style: "width: 95%;" %></p>
<% end %>
</div>
</fieldset>
<fieldset class="box">
<legend ><%= t('.label_measurement') %></legend>
<div class="tabular">
<p><%= f.select :source_id, source_options,
{required: false, include_blank: t('.null_source')} %></p>
<p><%= f.text_area :notes, cols: 40, rows: 1, style: "width: 95%;" %></p>
<p>
<%= f.date_field :taken_at_date, required: true %>
<%= f.time_field :taken_at_time, value: format_time(@measurement), required: true,
label: '' %>
</p>
<% @measurement.readouts.each_with_index do |r, index| %>
<%= f.fields_for 'readouts_attributes', r, index: '' do |ff| %>
<p class="readout">
</p>
<% @measurement.readouts.each_with_index do |r, index| %>
<%= f.fields_for 'readouts_attributes', r, index: '' do |ff| %>
<p class="readout">
<%= ff.hidden_field :id %>
<%= ff.select :quantity_id, quantity_options,
{include_blank: true, required: true, label: (index > 0 ? '' : :field_readouts)} %>
@@ -22,14 +34,15 @@
class: 'icon icon-del',
style: (@measurement.readouts.length > 1 ? "" : "display:none"),
onclick: "deleteReadout(); return false;" %>
</p>
</p>
<% end %>
<% end %>
<% end %>
<p>
<p>
<%= link_to t(".button_new_readout"), '#', class: 'icon icon-add',
onclick: 'newReadout(); return false;' %>
</p>
</div>
</p>
</div>
</fieldset>
<%= javascript_tag do %>
function newReadout() {

View File

@@ -20,7 +20,7 @@
<td class="date unwrappable"><%= format_datetime(m) %></td>
<td class="name">
<div style="float:left;">
<%= link_to m.name, readouts_measurement_path(m) %>
<%= link_to m.routine.name, readouts_measurement_routine_path(m.routine) %>
</div>
<div style="float:right;">
<small><%= " (#{pluralize(m.readouts.size, 'readout')})" %></small>

View File

@@ -1,7 +1,7 @@
<fieldset id="options" class="collapsible">
<legend onclick="toggleFieldset(this);"><%= l(:label_options) %></legend>
<div>
<%= form_tag toggle_column_measurement_path(@scoping_measurement),
<%= form_tag toggle_column_measurement_routine_path(@routine),
id: 'toggle-column-form', name: 'toggle-column-form',
method: :post, remote: true do %>

View File

@@ -17,7 +17,7 @@
<th style="width:<%= 100/total_width %>%" class="closable ellipsible">
<div style="float:right;position:relative;">
<%= link_to '',
toggle_column_measurement_path(@scoping_measurement, quantity_id: q.id),
toggle_column_measurement_routine_path(@routine, quantity_id: q.id),
{class: "icon icon-close", method: :post, remote: true} %>
</div>
<%= q.name %>

View File

@@ -8,7 +8,7 @@
<h2>
<%= link_to t("measurements.index.heading"), project_measurements_path(@project) %>
>
<%= @measurements.first.name %>
<%= @routine.name %>
</h2>
<div id='readouts'>
<%= render partial: 'measurements/readouts' %>

View File

@@ -18,12 +18,12 @@
<%
next if q.new_record?
quantity_class = "quantity"
quantity_class += " primary" unless q.column_views.empty?
quantity_class += " primary" unless q.columns.empty?
quantity_class += " project idnt idnt-#{level+1}"
%>
<tr id="quantity-<%= q.id %>" class="<%= quantity_class %>">
<td class="name unwrappable">
<div class="icon <%= q.column_views.empty? ? 'icon-fav-off' : 'icon-fav' %>">
<div class="icon <%= q.columns.empty? ? 'icon-fav-off' : 'icon-fav' %>">
<%= q.name %>
</div>
</td>