forked from fixin.me/fixin.me
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
<div class="rightside">
|
|
<% if current_user.at_least(:active) %>
|
|
<%= turbo_frame_tag do %>
|
|
<%= image_link_to t('.add_unit'), 'plus-outline', new_unit_path, id: :add_unit,
|
|
onclick: 'this.blur(); this.style.visibility = "hidden";', data: {turbo_stream: true} %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= turbo_frame_tag 'unit_form_frame' %>
|
|
|
|
<table class="main items">
|
|
<thead>
|
|
<tr>
|
|
<th><%= User.human_attribute_name(:symbol).capitalize %></th>
|
|
<th><%= User.human_attribute_name(:name).capitalize %></th>
|
|
<th><%= User.human_attribute_name(:multiplier).capitalize %></th>
|
|
<% if current_user.at_least(:active) %>
|
|
<th><%= t :actions %></th>
|
|
<% end %>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="units" is="turbo-frame">
|
|
<%= render(@units) || render_no_items %>
|
|
</tbody>
|
|
</table>
|
|
|
|
<%= javascript_tag do %>
|
|
function closeForm(event) {
|
|
event.target.closest("tr").remove();
|
|
focusAddLink(event);
|
|
}
|
|
|
|
function focusAddLink(event) {
|
|
var add_unit_link = document.querySelector("a#add_unit");
|
|
add_unit_link.style.visibility = "visible";
|
|
add_unit_link.focus({ focusVisible: true });
|
|
}
|
|
|
|
function processKey(event) {
|
|
if (event.key == "Escape") {
|
|
closeForm(event);
|
|
}
|
|
}
|
|
<% end %>
|