forked from fixin.me/fixin.me
Readouts gain a taken_at timestamp (distinct from created_at) that records
when the measurement was actually taken. Measurements are now ordered by
taken_at descending.
Quantities gain an optional default_unit association. When set, the unit
is pre-selected in the measurement form. A "Set as default" button on the
unit selector lets users update the default directly from the form.
- Migrations: add taken_at (datetime) to readouts,
add default_unit_id (fk → units) to quantities
- Readout: expose taken_at in ATTRIBUTES permit-list
- Quantity: add default_unit belongs_to, expose in ATTRIBUTES
- QuantitiesController: load @user_units for form actions
- Quantities views: add Default unit column and select to form
- Readouts form: pre-select default unit; add "Set as default" button
(readoutUnitChanged / setDefaultUnit wired up in a later commit)
- Measurements form: default taken_at input to current time
- ApplicationHelper: propagate :form option to html_options in builder
- config/environments/test.rb: allow Capybara's dynamic host
- Tests: system tests for default-unit UI on the Quantities page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.4 KiB
Plaintext
32 lines
1.4 KiB
Plaintext
<%# TODO: add readout reordering by dragging %>
|
|
<%= tabular_fields_for 'readouts[]', readout do |form| %>
|
|
<%- tag.tr id: dom_id(readout.quantity, :new, :readout) do %>
|
|
<td>
|
|
<%# TODO: add grayed readout index (in separate column?) %>
|
|
<%= readout.quantity.relative_pathname(@superquantity) %>
|
|
<%= form.hidden_field :quantity_id %>
|
|
</td>
|
|
<td>
|
|
<%= form.number_field :value, required: true, autofocus: readout_counter == 0 %>
|
|
</td>
|
|
<td>
|
|
<%= form.collection_select :unit_id, @user_units, :id,
|
|
->(u){ sanitize(' ' * (u.base_id ? 1 : 0) + u.symbol) },
|
|
{prompt: '', disabled: '', selected: readout.quantity.default_unit_id || ''}, required: true,
|
|
data: {default_unit_id: readout.quantity.default_unit_id || ''},
|
|
onchange: "readoutUnitChanged(this)" %>
|
|
</td>
|
|
<td class="flex">
|
|
<%# TODO: change to _link_ after giving up displaying relative paths %>
|
|
<%= image_button_tag '', 'check-circle-outline',
|
|
class: 'set-default-unit', name: nil, type: 'button', disabled: true,
|
|
title: t('readouts.form.set_default_unit'),
|
|
data: {path: quantity_path(readout.quantity)},
|
|
onclick: 'setDefaultUnit(this)' %>
|
|
<%= image_button_tag '', 'delete-outline', class: 'dangerous', name: nil,
|
|
formaction: discard_readouts_path(readout.quantity),
|
|
formmethod: :get, formnovalidate: true, data: {turbo_stream: true} %>
|
|
</td>
|
|
<% end %>
|
|
<% end %>
|