Can refresh data for wishlist records

This commit is contained in:
Claudio Ortolina
2024-11-15 10:03:45 +00:00
parent 60b098785b
commit 5babccfeb8
3 changed files with 40 additions and 12 deletions
@@ -41,6 +41,26 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
{:noreply, push_navigate(socket, to: ~p"/wishlist")}
end
def handle_event("refresh_musicbrainz_data", %{"id" => id}, socket) do
record = Records.get_record!(id)
case Records.refresh_musicbrainz_data(record) do
{:ok, updated_record} ->
{:noreply,
socket
|> put_flash(:info, gettext("MusicBrainz data refreshed successfully"))
|> assign(:record, updated_record)}
{:error, reason} ->
{:noreply,
socket
|> put_flash(
:error,
gettext("Error refreshing MusicBrainz data") <> "," <> inspect(reason)
)}
end
end
@impl true
def handle_info({MusicLibraryWeb.RecordLive.FormComponent, {:saved, record}}, socket) do
{:noreply, assign(socket, :record, record)}
@@ -4,6 +4,11 @@
<%= gettext("Edit") %>
</.button>
</.link>
<.link phx-click={JS.push("refresh_musicbrainz_data", value: %{id: @record.id})}>
<.button>
<%= gettext("Refresh MB Data") %>
</.button>
</.link>
<.link
phx-click={JS.push("delete", value: %{id: @record.id})}
data-confirm={gettext("Are you sure?")}
+15 -12
View File
@@ -19,7 +19,7 @@ msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:185
#: lib/music_library_web/live/record_live/show.html.heex:14
#: lib/music_library_web/live/wishlist_live/index.html.heex:195
#: lib/music_library_web/live/wishlist_live/show.html.heex:9
#: lib/music_library_web/live/wishlist_live/show.html.heex:14
#, elixir-autogen, elixir-format
msgid "Are you sure?"
msgstr ""
@@ -34,7 +34,7 @@ msgstr ""
msgid "Back to records"
msgstr ""
#: lib/music_library_web/live/wishlist_live/show.html.heex:120
#: lib/music_library_web/live/wishlist_live/show.html.heex:125
#, elixir-autogen, elixir-format
msgid "Back to wishlist"
msgstr ""
@@ -64,7 +64,7 @@ msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:187
#: lib/music_library_web/live/record_live/show.html.heex:17
#: lib/music_library_web/live/wishlist_live/index.html.heex:197
#: lib/music_library_web/live/wishlist_live/show.html.heex:12
#: lib/music_library_web/live/wishlist_live/show.html.heex:17
#, elixir-autogen, elixir-format
msgid "Delete"
msgstr ""
@@ -75,7 +75,7 @@ msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:4
#: lib/music_library_web/live/wishlist_live/index.ex:55
#: lib/music_library_web/live/wishlist_live/index.html.heex:176
#: lib/music_library_web/live/wishlist_live/show.ex:50
#: lib/music_library_web/live/wishlist_live/show.ex:70
#: lib/music_library_web/live/wishlist_live/show.html.heex:4
#, elixir-autogen, elixir-format
msgid "Edit"
@@ -106,7 +106,7 @@ msgid "Formats"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:54
#: lib/music_library_web/live/wishlist_live/show.html.heex:50
#: lib/music_library_web/live/wishlist_live/show.html.heex:55
#, elixir-autogen, elixir-format
msgid "Genres"
msgstr ""
@@ -129,7 +129,7 @@ msgid "Import from MusicBrainz"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:107
#: lib/music_library_web/live/wishlist_live/show.html.heex:95
#: lib/music_library_web/live/wishlist_live/show.html.heex:100
#, elixir-autogen, elixir-format
msgid "Inserted at"
msgstr ""
@@ -155,7 +155,7 @@ msgid "Logout"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:62
#: lib/music_library_web/live/wishlist_live/show.html.heex:58
#: lib/music_library_web/live/wishlist_live/show.html.heex:63
#, elixir-autogen, elixir-format
msgid "MusicBrainz ID"
msgstr ""
@@ -256,7 +256,7 @@ msgstr ""
#: lib/music_library_web/live/record_live/index.html.heex:156
#: lib/music_library_web/live/record_live/show.ex:71
#: lib/music_library_web/live/wishlist_live/index.html.heex:156
#: lib/music_library_web/live/wishlist_live/show.ex:49
#: lib/music_library_web/live/wishlist_live/show.ex:69
#, elixir-autogen, elixir-format
msgid "Show"
msgstr ""
@@ -312,7 +312,7 @@ msgid "Types"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:115
#: lib/music_library_web/live/wishlist_live/show.html.heex:103
#: lib/music_library_web/live/wishlist_live/show.html.heex:108
#, elixir-autogen, elixir-format
msgid "Updated at"
msgstr ""
@@ -351,13 +351,13 @@ msgid "close"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:72
#: lib/music_library_web/live/wishlist_live/show.html.heex:68
#: lib/music_library_web/live/wishlist_live/show.html.heex:73
#, elixir-autogen, elixir-format
msgid "Copy MusicBrainz ID to clipboard"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:126
#: lib/music_library_web/live/wishlist_live/show.html.heex:114
#: lib/music_library_web/live/wishlist_live/show.html.heex:119
#, elixir-autogen, elixir-format
msgid "MusicBrainz data"
msgstr ""
@@ -391,22 +391,25 @@ msgid "Number of included records"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:95
#: lib/music_library_web/live/wishlist_live/show.html.heex:83
#: lib/music_library_web/live/wishlist_live/show.html.heex:88
#, elixir-autogen, elixir-format
msgid "Includes"
msgstr ""
#: lib/music_library_web/live/record_live/show.ex:61
#: lib/music_library_web/live/wishlist_live/show.ex:59
#, elixir-autogen, elixir-format
msgid "Error refreshing MusicBrainz data"
msgstr ""
#: lib/music_library_web/live/record_live/show.ex:53
#: lib/music_library_web/live/wishlist_live/show.ex:51
#, elixir-autogen, elixir-format
msgid "MusicBrainz data refreshed successfully"
msgstr ""
#: lib/music_library_web/live/record_live/show.html.heex:9
#: lib/music_library_web/live/wishlist_live/show.html.heex:9
#, elixir-autogen, elixir-format
msgid "Refresh MB Data"
msgstr ""