forked from fixin.me/fixin.me
Don't render index on Unit actions
This commit is contained in:
parent
d726e92445
commit
0659c1e1c1
@ -32,32 +32,29 @@ class UnitsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
if @unit.update(unit_params.except(:base_id))
|
if @unit.update(unit_params.except(:base_id))
|
||||||
flash.now[:notice] = t('.success', unit: @unit)
|
flash.now[:notice] = t('.success', unit: @unit)
|
||||||
run_and_render :index
|
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: Avoid double table width change by first un-hiding table header,
|
||||||
|
# then displaying index, e.g. by re-displaying header in index
|
||||||
def rebase
|
def rebase
|
||||||
permitted = params.require(:unit).permit(:base_id)
|
permitted = params.require(:unit).permit(:base_id)
|
||||||
permitted.merge!(multiplier: 1) if permitted[:base_id].blank? && @unit.multiplier != 1
|
permitted.merge!(multiplier: 1) if permitted[:base_id].blank? && @unit.multiplier != 1
|
||||||
|
|
||||||
|
@previous_base = @unit.base
|
||||||
@unit.update!(permitted)
|
@unit.update!(permitted)
|
||||||
|
|
||||||
|
@before = @unit.successive
|
||||||
if @unit.multiplier_previously_changed?
|
if @unit.multiplier_previously_changed?
|
||||||
flash.now[:notice] = t(".multiplier_reset", unit: @unit)
|
flash.now[:notice] = t(".multiplier_reset", unit: @unit)
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
# TODO: Avoid double table width change by first un-hiding table header,
|
|
||||||
# then displaying index, e.g. by re-displaying header in index
|
|
||||||
run_and_render :index
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@unit.destroy!
|
@unit.destroy!
|
||||||
flash.now[:notice] = t('.success', unit: @unit)
|
flash.now[:notice] = t('.success', unit: @unit)
|
||||||
ensure
|
|
||||||
run_and_render :index
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -123,7 +123,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
def render_no_items
|
def render_no_items
|
||||||
tag.tr id: :no_items do
|
tag.tr id: :no_items do
|
||||||
tag.td t('.no_items'), colspan: 10, class: 'hint'
|
tag.td t("#{controller_name}.no_items"), colspan: 10, class: 'hint'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
3
app/views/units/destroy.turbo_stream.erb
Normal file
3
app/views/units/destroy.turbo_stream.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<%= turbo_stream.replace @unit.base unless @unit.base.nil? %>
|
||||||
|
<%= turbo_stream.remove @unit %>
|
||||||
|
<%= turbo_stream.append(:units, render_no_items) if current_user.units.empty? %>
|
@ -1 +1,4 @@
|
|||||||
<% render_errors @unit %>
|
<%= turbo_stream.remove @unit %>
|
||||||
|
<%= turbo_stream.replace @previous_base unless @previous_base.nil? %>
|
||||||
|
<%= turbo_stream.replace @unit.base unless @unit.base.nil? || @previous_base == @unit.base %>
|
||||||
|
<%= @before.nil? ? turbo_stream.append(:units, @unit) : turbo_stream.before(@before, @unit) %>
|
||||||
|
3
app/views/units/update.turbo_stream.erb
Normal file
3
app/views/units/update.turbo_stream.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<%= turbo_stream.close_form dom_id(@unit, :edit) %>
|
||||||
|
<%= turbo_stream.replace @unit.base unless @unit.base.nil? %>
|
||||||
|
<%= turbo_stream.replace @unit %>
|
@ -56,13 +56,13 @@ en:
|
|||||||
units: Units
|
units: Units
|
||||||
users: Users
|
users: Users
|
||||||
units:
|
units:
|
||||||
|
no_items: There are no configured units. You can Add some or Import from defaults.
|
||||||
unit:
|
unit:
|
||||||
new_subunit: Subunit
|
new_subunit: Subunit
|
||||||
delete_unit: Delete
|
delete_unit: Delete
|
||||||
index:
|
index:
|
||||||
new_unit: Add unit
|
new_unit: Add unit
|
||||||
import_units: Import
|
import_units: Import
|
||||||
no_items: There are no configured units. You can Add some or Import from defaults.
|
|
||||||
top_level_drop: Drop here to reposition into top-level unit
|
top_level_drop: Drop here to reposition into top-level unit
|
||||||
new:
|
new:
|
||||||
none: none
|
none: none
|
||||||
|
Loading…
x
Reference in New Issue
Block a user