Change 'Add unit' link to turbo_stream

This commit is contained in:
cryptogopher 2024-01-04 23:11:33 +01:00
parent c96b646087
commit 6d9f4918f1
4 changed files with 11 additions and 14 deletions

View File

@ -1,8 +1,8 @@
<div class="rightside">
<% if current_user.at_least(:active) %>
<%= turbo_frame_tag target: dom_id(Unit.new) do %>
<%= turbo_frame_tag do %>
<%= image_link_to t('.add_unit'), 'plus-outline', new_unit_path, id: :add_unit,
onclick: 'this.style.visibility = "hidden";' %>
onclick: 'this.style.visibility = "hidden";', data: {turbo_stream: true} %>
<% end %>
<% end %>
</div>

View File

@ -1,12 +0,0 @@
<!-- NOTE: as of turbo-rails 2.0.0.pre.beta.1/turbo 8.0.0-beta.1
loading <form> through *.turbo_stream.erb does not autofocus -->
<%= turbo_frame_tag @unit do %>
<%= turbo_stream.update @unit do %>
<%= render partial: 'form', locals: {unit: @unit} %>
<% end %>
<%= turbo_stream.update :unit_form_frame do %>
<%= form_with model: @unit, html: {id: :unit_form} do %>
<% end %>
<% end %>
<% end %>

View File

@ -0,0 +1,8 @@
<%= turbo_stream.update @unit do %>
<%= render partial: 'form', locals: {unit: @unit} %>
<% end %>
<%= turbo_stream.update :unit_form_frame do %>
<%= form_with model: @unit, html: {id: :unit_form} do %>
<% end %>
<% end %>

View File

@ -58,6 +58,7 @@ en:
actions: Actions
add: Add
back: Back
cancel: Cancel
or: or
register: Register
sign_in: Sign in