forked from fixin.me/fixin.me
Avoid refreshing whole index on create
This commit is contained in:
parent
55b6ff3248
commit
e5cf3dc0ae
@ -19,8 +19,8 @@ class UnitsController < ApplicationController
|
||||
def create
|
||||
@unit = current_user.units.new(unit_params)
|
||||
if @unit.save
|
||||
@before = @unit.successive
|
||||
flash.now[:notice] = t('.success', unit: @unit)
|
||||
run_and_render :index
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
@ -122,7 +122,9 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def render_no_items
|
||||
tag.tr tag.td t('.no_items'), colspan: 10, class: 'hint'
|
||||
tag.tr id: :no_items do
|
||||
tag.td t('.no_items'), colspan: 10, class: 'hint'
|
||||
end
|
||||
end
|
||||
|
||||
def render_turbo_stream(partial, locals = {})
|
||||
|
4
app/views/units/create.turbo_stream.erb
Normal file
4
app/views/units/create.turbo_stream.erb
Normal file
@ -0,0 +1,4 @@
|
||||
<%= turbo_stream.close_form dom_id(Unit.new) %>
|
||||
<%= turbo_stream.remove :no_items %>
|
||||
<%= turbo_stream.replace @unit.base unless @unit.base.nil? %>
|
||||
<%= @before.nil? ? turbo_stream.append(:units, @unit) : turbo_stream.before(@before, @unit) %>
|
Loading…
x
Reference in New Issue
Block a user