From 5ea1f8782450e95ec564cfa2cb7eaf600af3c87d Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Mon, 22 Jan 2024 02:33:23 +0100 Subject: [PATCH] Unit#edit action --- app/views/units/_unit.html.erb | 2 +- app/views/units/edit.html.erb | 1 - app/views/units/edit.turbo_stream.erb | 10 ++++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) delete mode 120000 app/views/units/edit.html.erb create mode 100644 app/views/units/edit.turbo_stream.erb diff --git a/app/views/units/_unit.html.erb b/app/views/units/_unit.html.erb index 88fab3e..cd2332b 100644 --- a/app/views/units/_unit.html.erb +++ b/app/views/units/_unit.html.erb @@ -1,6 +1,6 @@ - <%= link_to unit.symbol, edit_unit_path(unit) %> + <%= link_to unit.symbol, edit_unit_path(unit), data: {turbo_stream: true} %> <%= unit.name %> <%= scientifize(unit.multiplier) if unit.multiplier %> diff --git a/app/views/units/edit.html.erb b/app/views/units/edit.html.erb deleted file mode 120000 index f9a278c..0000000 --- a/app/views/units/edit.html.erb +++ /dev/null @@ -1 +0,0 @@ -/var/www/app/views/units/new.html.erb \ No newline at end of file diff --git a/app/views/units/edit.turbo_stream.erb b/app/views/units/edit.turbo_stream.erb new file mode 100644 index 0000000..ebb2aed --- /dev/null +++ b/app/views/units/edit.turbo_stream.erb @@ -0,0 +1,10 @@ +<%# 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.update :unit_form_frame do %> + <%= form_with model: @unit, html: {id: :unit_form} do %> + <% end %> +<% end %>