forked from fixin.me/fixin.me
- Replace position-based column header lookup (ths[3]/ths[4]) with data-column attribute selectors — immune to column reordering - Add .catch() error handlers to editMeasurementWide and setDefaultUnit fetch calls so failures surface in the console instead of silently disappearing - Add MeasurementsController integration tests covering index auth, create with taken_at, empty-readout create, destroy, cross-user destroy isolation, and update Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.5 KiB
Plaintext
39 lines
1.5 KiB
Plaintext
<%# TODO: show hint when no quantities/units defined %>
|
|
<div class="rightside-area buttongrid">
|
|
<% if current_user.at_least(:active) %>
|
|
<%= image_link_to t('.new_measurement'), 'plus-outline', new_measurement_path,
|
|
id: :new_measurement_link, onclick: 'this.blur();',
|
|
data: {turbo_stream: true} %>
|
|
<% end %>
|
|
<%= image_button_tag '', 'view-rows', name: nil, type: 'button',
|
|
class: 'view-toggle', title: t('.view_compact'),
|
|
data: {view: 'compact'}, onclick: "setMeasurementsView('compact')" %>
|
|
<%= image_button_tag '', 'view-columns', name: nil, type: 'button',
|
|
class: 'view-toggle', title: t('.view_wide'),
|
|
data: {view: 'wide'}, onclick: "setMeasurementsView('wide')" %>
|
|
</div>
|
|
|
|
<div class="main-area measurements-section">
|
|
<%= tag.div id: :measurement_edit_form %>
|
|
<table class="items-table measurements-compact">
|
|
<thead>
|
|
<tr>
|
|
<th><%= Quantity.model_name.human %></th>
|
|
<th><%= Readout.human_attribute_name(:value) %></th>
|
|
<th><%= Unit.model_name.human %></th>
|
|
<th data-column="taken-at"><%= Readout.human_attribute_name(:taken_at) %></th>
|
|
<th data-column="created-at"><%= Readout.human_attribute_name(:created_at) %></th>
|
|
<% if current_user.at_least(:active) %>
|
|
<th></th>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="measurements">
|
|
<%= render(partial: 'readout', collection: @measurements, as: :readout) || render_no_items %>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div id="measurements-wide" class="measurements-wide"></div>
|
|
</div>
|
|
|