Recover edit form after disconnection

This commit is contained in:
Claudio Ortolina
2025-03-06 09:55:59 +00:00
parent 0c54be4474
commit d253150077
2 changed files with 19 additions and 14 deletions
@@ -30,6 +30,7 @@ defmodule MusicLibraryWeb.FormComponent do
id="record-form" id="record-form"
phx-target={@myself} phx-target={@myself}
phx-change="validate" phx-change="validate"
phx-auto-recover="recover_form"
phx-submit="save" phx-submit="save"
> >
<div class="sm:columns-2"> <div class="sm:columns-2">
@@ -146,6 +147,10 @@ defmodule MusicLibraryWeb.FormComponent do
save_record(socket, record_params, uploaded_covers) save_record(socket, record_params, uploaded_covers)
end end
def handle_event("recover_form", params, socket) do
handle_event("validate", params, socket)
end
defp save_record(socket, record_params, uploaded_covers) do defp save_record(socket, record_params, uploaded_covers) do
params = params =
case uploaded_covers do case uploaded_covers do
+14 -14
View File
@@ -23,8 +23,8 @@ msgstr ""
msgid "Are you sure?" msgid "Are you sure?"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:40 #: lib/music_library_web/components/form_component.ex:41
#: lib/music_library_web/components/form_component.ex:47 #: lib/music_library_web/components/form_component.ex:48
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Choose a value" msgid "Choose a value"
msgstr "" msgstr ""
@@ -38,7 +38,7 @@ msgstr ""
msgid "Collection" msgid "Collection"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:61 #: lib/music_library_web/components/form_component.ex:62
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Cover art" msgid "Cover art"
msgstr "" msgstr ""
@@ -74,7 +74,7 @@ msgstr ""
msgid "Error!" msgid "Error!"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:46 #: lib/music_library_web/components/form_component.ex:47
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Format" msgid "Format"
msgstr "" msgstr ""
@@ -128,7 +128,7 @@ msgstr ""
msgid "Logout" msgid "Logout"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:51 #: lib/music_library_web/components/form_component.ex:52
#: lib/music_library_web/live/collection_live/show.html.heex:178 #: lib/music_library_web/live/collection_live/show.html.heex:178
#: lib/music_library_web/live/wishlist_live/show.html.heex:198 #: lib/music_library_web/live/wishlist_live/show.html.heex:198
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
@@ -169,7 +169,7 @@ msgstr ""
msgid "Purchase" msgid "Purchase"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:57 #: lib/music_library_web/components/form_component.ex:58
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Purchased at" msgid "Purchased at"
msgstr "" msgstr ""
@@ -188,22 +188,22 @@ msgstr ""
msgid "Record imported successfully" msgid "Record imported successfully"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:166 #: lib/music_library_web/components/form_component.ex:171
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Record updated successfully" msgid "Record updated successfully"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:52 #: lib/music_library_web/components/form_component.ex:53
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Release" msgid "Release"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:117 #: lib/music_library_web/components/form_component.ex:118
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Save" msgid "Save"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:117 #: lib/music_library_web/components/form_component.ex:118
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Saving..." msgid "Saving..."
msgstr "" msgstr ""
@@ -270,7 +270,7 @@ msgstr ""
msgid "Total wishlist" msgid "Total wishlist"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:39 #: lib/music_library_web/components/form_component.ex:40
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Type" msgid "Type"
msgstr "" msgstr ""
@@ -671,17 +671,17 @@ msgstr ""
msgid "Similar artists" msgid "Similar artists"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:111 #: lib/music_library_web/components/form_component.ex:112
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "PNG, JPG, WEBP up to 8MB" msgid "PNG, JPG, WEBP up to 8MB"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:105 #: lib/music_library_web/components/form_component.ex:106
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Upload a file" msgid "Upload a file"
msgstr "" msgstr ""
#: lib/music_library_web/components/form_component.ex:108 #: lib/music_library_web/components/form_component.ex:109
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "or drag and drop" msgid "or drag and drop"
msgstr "" msgstr ""