forked from fixin.me/fixin.me
Disable only form-opening link
Close other forms on new form open
This commit is contained in:
parent
76aae56ed5
commit
759a0b31b7
@ -1,4 +1,3 @@
|
||||
<%= turbo_stream.remove @unit %>
|
||||
<%= turbo_stream.enable_all 'td.actions .button' %>
|
||||
<%= turbo_stream.enable :add_unit %>
|
||||
<%= turbo_stream.focus :add_unit %>
|
||||
<%= @unit.persisted? ? turbo_stream.replace(@unit) : turbo_stream.remove(@unit) %>
|
||||
<%= turbo_stream.enable id %>
|
||||
<%= turbo_stream.focus id %>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<tr id="<%= dom_id(unit) %>">
|
||||
<td class="<%= class_names('link', {subunit: unit.base}) %>">
|
||||
<%= link_to unit.symbol, edit_unit_path(unit), data: {turbo_stream: true} %>
|
||||
<%= link_to unit.symbol, edit_unit_path(unit), id: dom_id(unit, :edit),
|
||||
data: {turbo_stream: true} %>
|
||||
</td>
|
||||
<td><%= unit.name %></td>
|
||||
<td class="number"><%= scientifize(unit.multiplier) if unit.multiplier %></td>
|
||||
@ -9,7 +10,8 @@
|
||||
<td class="actions">
|
||||
<% if unit.base.nil? %>
|
||||
<%= image_link_to t(".add_subunit"), "plus-outline", new_unit_path(unit),
|
||||
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
||||
id: dom_id(unit, :add), onclick: 'this.blur();',
|
||||
data: {turbo_stream: true} %>
|
||||
<% end %>
|
||||
|
||||
<%= image_button_to t(".delete_unit"), "delete-outline", unit_path(unit),
|
||||
|
@ -1,10 +1,7 @@
|
||||
<%# TODO: make sure turbo_stream layout is used in new/edit %>
|
||||
<%= turbo_stream.disable :add_unit %>
|
||||
<%= turbo_stream.disable_all 'td.actions .button' %>
|
||||
|
||||
<%= turbo_stream.replace @unit, partial: 'form' %>
|
||||
<%= turbo_stream.replace @unit, partial: 'form', locals: {id: dom_id(@unit, :edit)} %>
|
||||
|
||||
<%= turbo_stream.update :unit_form_frame do %>
|
||||
<%= form_with model: @unit, html: {id: :unit_form} do %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end unless @unit.errors.present? %>
|
||||
|
@ -1,14 +1,16 @@
|
||||
<%= turbo_stream.disable :add_unit %>
|
||||
<%# TODO: disable only form-opening actions %>
|
||||
<%= turbo_stream.disable_all 'td.actions .button' %>
|
||||
<% options = {partial: 'form', locals: {id: dom_id(@unit.base || @unit, :add)}} %>
|
||||
|
||||
<% if @unit.errors.present? %>
|
||||
<%= turbo_stream.replace @unit, partial: 'form' %>
|
||||
<%= turbo_stream.replace @unit, **options -%>
|
||||
<% else %>
|
||||
<%= turbo_stream.disable options[:locals][:id] -%>
|
||||
<%= turbo_stream.click_all 'tbody a[name=cancel]' -%>
|
||||
<%#= turbo_stream.blur_all %>
|
||||
|
||||
<% if @unit.base.nil? %>
|
||||
<%= turbo_stream.prepend :units, partial: 'form' %>
|
||||
<%= turbo_stream.prepend :units, **options -%>
|
||||
<% else %>
|
||||
<%= turbo_stream.after @unit.base, partial: 'form' %>
|
||||
<%= turbo_stream.after @unit.base, **options -%>
|
||||
<% end %>
|
||||
|
||||
<%= turbo_stream.update :unit_form_frame do %>
|
||||
|
Loading…
x
Reference in New Issue
Block a user