Files
fixin.me/app/views/units/index.html.erb
T

42 lines
1.6 KiB
Plaintext

<div class="rightside-area buttongrid">
<% if current_user.at_least(:active) %>
<%= image_link_to t('.new_unit'), 'plus-outline', new_unit_path,
id: :new_unit_link, onclick: 'this.blur();', data: {turbo_stream: true} %>
<% end %>
<%= image_link_to t('.import_units'), 'download-outline', default_units_path,
class: 'tools-area' %>
</div>
<table class="main-area items-table">
<caption class="hint"><%= t '.no_items' %></caption>
<tbody>
<tr>
<th class="hmintext"><%= Unit.human_attribute_name(:symbol) %>
<th class="hminnumber"><%= Unit.human_attribute_name(:multiplier) %>
<th class="hexpand"><%= Unit.human_attribute_name(:description) %>
<% if current_user.at_least(:active) %>
<th colspan="3"><%= t :actions %>
<tr id="unit_" hidden
ondragover="dragOver(event)" ondrop="drop(event)"
ondragenter="dragEnter(event)" ondragleave="dragLeave(event)"
data-drop-id="unit_" data-drop-id-param="<%= field_name(:unit, :base_id) %>">
<th colspan="6"><%= t '.top_level_drop' %>
<% end %>
<%= render @units %>
<% if current_user.at_least(:active) %>
<%# Hidden header and `#endmark` rows allows simplier row insertion by using only
turbo_stream #after/#before instead of #after + #prepend/#before + #append. %>
<%# TODO: replace with custom turbo_stream action, e.g. #afterrow that #prepend-s
if ID has `rows` property (`rows` in object) and #after otherwise? %>
<tr id="endmark" hidden>
<tfoot>
<%# Insert form to prevent actions column width change on form toggle. %>
<%= render partial: 'form', locals: {hidden: true} %>
<% end %>
</table>