diff --git a/lib/music_library_web/live/record_live/search_component.ex b/lib/music_library_web/live/record_live/import_component.ex similarity index 82% rename from lib/music_library_web/live/record_live/search_component.ex rename to lib/music_library_web/live/record_live/import_component.ex index 53ab8cae..4fc50276 100644 --- a/lib/music_library_web/live/record_live/search_component.ex +++ b/lib/music_library_web/live/record_live/import_component.ex @@ -1,4 +1,4 @@ -defmodule MusicLibraryWeb.RecordLive.SearchComponent do +defmodule MusicLibraryWeb.RecordLive.ImportComponent do use MusicLibraryWeb, :live_component alias MusicLibrary.Records @@ -17,13 +17,13 @@ defmodule MusicLibraryWeb.RecordLive.SearchComponent do <.input field={@form[:query]} type="text" - label="Search" + label="Search for a record on MusicBrainz" prompt="Search for records" phx-debounce="500" /> """ @@ -33,22 +33,22 @@ defmodule MusicLibraryWeb.RecordLive.SearchComponent do ~H"""
  • - <%= @record.title %> + <%= @release_group.title %> - <%= @record.year %> + <%= @release_group.year %>

    -

    <%= @record.artists %>

    +

    <%= @release_group.artists %>

  • """ @@ -68,17 +68,17 @@ defmodule MusicLibraryWeb.RecordLive.SearchComponent do def mount(socket) do {:ok, socket - |> assign(:records, []) + |> assign(:release_groups, []) |> assign(:form, to_form(%{"query" => ""}))} end @impl true def handle_event("search", %{"query" => query}, socket) do - {:ok, records} = search(query) + {:ok, release_groups} = search(query) {:noreply, socket - |> assign(:records, records) + |> assign(:release_groups, release_groups) |> assign(:form, to_form(%{"query" => query}))} end diff --git a/lib/music_library_web/live/record_live/index.ex b/lib/music_library_web/live/record_live/index.ex index 3b8a80e0..1405095c 100644 --- a/lib/music_library_web/live/record_live/index.ex +++ b/lib/music_library_web/live/record_live/index.ex @@ -23,9 +23,9 @@ defmodule MusicLibraryWeb.RecordLive.Index do {:noreply, apply_action(socket, socket.assigns.live_action, params)} end - defp apply_action(socket, :search, _params) do + defp apply_action(socket, :import, _params) do socket - |> assign(:page_title, "Search Records") + |> assign(:page_title, "Import from MusicBrainz") |> assign(:record, nil) end diff --git a/lib/music_library_web/live/record_live/index.html.heex b/lib/music_library_web/live/record_live/index.html.heex index b2ec60b9..cee5321b 100644 --- a/lib/music_library_web/live/record_live/index.html.heex +++ b/lib/music_library_web/live/record_live/index.html.heex @@ -1,8 +1,8 @@ <.header> Listing Records <:actions> - <.link patch={~p"/records/search"}> - <.button>Search Record + <.link patch={~p"/records/import"}> + <.button>Import from MusicBrainz @@ -50,9 +50,9 @@ /> -<.modal :if={@live_action == :search} id="record-modal" show on_cancel={JS.patch(~p"/records")}> +<.modal :if={@live_action == :import} id="record-modal" show on_cancel={JS.patch(~p"/records")}> <.live_component - module={MusicLibraryWeb.RecordLive.SearchComponent} + module={MusicLibraryWeb.RecordLive.ImportComponent} id={:search} title={@page_title} action={@live_action} diff --git a/lib/music_library_web/router.ex b/lib/music_library_web/router.ex index f383231f..68986c12 100644 --- a/lib/music_library_web/router.ex +++ b/lib/music_library_web/router.ex @@ -21,7 +21,7 @@ defmodule MusicLibraryWeb.Router do get "/images/:record_id", ImageController, :show live "/records", RecordLive.Index, :index - live "/records/search", RecordLive.Index, :search + live "/records/import", RecordLive.Index, :import live "/records/:id/edit", RecordLive.Index, :edit live "/records/:id", RecordLive.Show, :show