Close form on Esc key. Localize submit button.

This commit is contained in:
2024-01-06 18:06:36 +01:00
parent ce4770a25c
commit 0801e8059c
6 changed files with 51 additions and 35 deletions

View File

@@ -24,3 +24,22 @@
<%= render partial: 'index' %>
</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 %>