Measurements#new form improvements

This commit is contained in:
2025-05-13 22:30:58 +02:00
parent ef3484dfdf
commit e12369cea1
8 changed files with 50 additions and 34 deletions

View File

@@ -15,7 +15,7 @@
</td>
<td class="actions">
<%= image_button_tag t(:delete), 'delete-outline', class: 'dangerous',
<%= image_button_tag '', 'delete-outline', class: 'dangerous',
formaction: discard_new_measurement_path(readout.quantity),
formmethod: :get, formnovalidate: true, data: {turbo_stream: true} %>
<%= form.hidden_field :quantity_id %>

View File

@@ -1,21 +1,16 @@
<%= tabular_form_with url: new_measurement_path, html: {id: :new_readouts_form} do %>
<% if @readouts&.present? %>
<fieldset>
<%= tag.legend id: :new_readouts_form_legend %>
<table class="items centered">
<tbody id="readouts">
<tr id="new_readouts_actions">
<td></td>
<td></td>
<td><div class="actions"><%= button_tag %></div></td>
<td><div class="actions">
<%= image_link_to t(:cancel), "close-outline", measurements_path,
class: 'dangerous', name: :cancel,
onclick: render_turbo_stream('form_close') %>
</div></td>
</tr>
</tbody>
</table>
</fieldset>
<% end %>
<%= tabular_fields_for Readout.new do |form| %>
<fieldset>
<legend>
<%= tag.span id: :new_readouts_form_legend %>
<%= image_link_to '', "close-outline", measurements_path, name: :cancel,
class: 'dangerous', onclick: render_turbo_stream('form_close') %>
</legend>
<table class="items centered">
<tbody id="readouts">
<tr id="new_readouts_actions">
<td colspan="4"><div class="actions centered"><%= form.button %></div></td>
</tr>
</tbody>
</table>
</fieldset>
<% end %>

View File

@@ -1,15 +1,16 @@
<div class="topside vflex">
<% if current_user.at_least(:active) %>
<%= render partial: 'form_frame' %>
<%# TODO: show hint when no quantities/units defined %>
<%= tabular_form_with url: new_measurement_path,
html: {id: :new_readouts_form} do |f| %>
<% end %>
<div class="hflex">
<%= select_tag :id, options_from_collection_for_select(
@quantities, :id, ->(q){ sanitize('&emsp;' * q.depth + q.name) }
), form: :new_readouts_form %>
<% common_options = {form: :new_readouts_form, formmethod: :get,
formnovalidate: true, data: {turbo_stream: true}} %>
<%= image_button_tag t('.new_quantity'), 'plus-outline',
formaction: new_measurement_path, **common_options -%>
<%= image_button_tag t('.new_quantity'), 'plus-outline', **common_options -%>
<%= image_button_tag t('.new_children'), 'plus-multiple-outline',
formaction: new_measurement_path(:children), **common_options -%>
<%= image_button_tag t('.new_subtree'), 'plus-multiple-outline',

View File

@@ -1,4 +1,4 @@
<%= turbo_stream.replace :new_readouts_form do %>
<%= turbo_stream.update :new_readouts_form do %>
<%= render partial: 'form_frame' %>
<% end if @prev_quantities.empty? %>