Render units from collection, without redirects

This commit is contained in:
2024-01-15 18:45:30 +01:00
parent de995aa586
commit 5047d4909f
9 changed files with 37 additions and 22 deletions

View File

@@ -1,15 +0,0 @@
<% Unit.each_with_level(@units) do |unit, level| %>
<tr>
<td class="link">
<%= link_to unit.symbol, edit_unit_path(unit), class: level > 0 ? 'subunit' : '' %>
</td>
<td><%= unit.name %></td>
<td class="number"><%= scientifize(unit.multiplier) if unit.multiplier %></td>
<% if current_user.at_least(:active) %>
<td class="actions">
<%= image_button_to t(".delete_unit"), "delete-outline", unit_path(unit),
method: :delete %>
</td>
<% end %>
</tr>
<% end %>

View File

@@ -0,0 +1,13 @@
<tr>
<td class="link">
<%= link_to unit.symbol, edit_unit_path(unit), class: unit.base.nil? ? '' : 'subunit' %>
</td>
<td><%= unit.name %></td>
<td class="number"><%= scientifize(unit.multiplier) if unit.multiplier %></td>
<% if current_user.at_least(:active) %>
<td class="actions">
<%= image_button_to t(".delete_unit"), "delete-outline", unit_path(unit),
method: :delete %>
</td>
<% end %>
</tr>

View File

@@ -21,7 +21,7 @@
</tr>
</thead>
<tbody id="units" is="turbo-frame">
<%= render partial: 'index' %>
<%= render(@units) || render_no_items %>
</tbody>
</table>

View File

@@ -1,3 +1,3 @@
<%= turbo_stream.update :units do %>
<%= render partial: 'index' %>
<%= render(@units) || render_no_items %>
<% end %>