From 0b07eaf6a116e6638a41bb63c25f64265b7429c4 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Tue, 24 Sep 2024 09:57:05 +0100 Subject: [PATCH] Restrict metadata editing for records Most of the information is correct via the MusicBrainz API, however _sometimes_ it's necessary to fix the year or the type of the album (e.g. because of new releases). --- .../live/record_live/form_component.ex | 12 +----------- lib/music_library_web/live/record_live/index.ex | 2 +- lib/music_library_web/live/record_live/show.ex | 2 +- .../live/record_live/show.html.heex | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/music_library_web/live/record_live/form_component.ex b/lib/music_library_web/live/record_live/form_component.ex index 71366e00..1b2f5200 100644 --- a/lib/music_library_web/live/record_live/form_component.ex +++ b/lib/music_library_web/live/record_live/form_component.ex @@ -9,7 +9,7 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do
<.header> <%= @title %> - <:subtitle>Use this form to manage record records in your database. + <:subtitle> <.simple_form @@ -26,17 +26,7 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do prompt="Choose a value" options={Ecto.Enum.values(MusicLibrary.Records.Record, :type)} /> - <.input field={@form[:title]} type="text" label="Title" /> - <.input field={@form[:musicbrainz_id]} type="text" label="Musicbrainz" /> <.input field={@form[:year]} type="number" label="Year" /> - <.input - field={@form[:genres]} - type="select" - multiple - label="Genres" - options={[{"Option 1", "option1"}, {"Option 2", "option2"}]} - /> - <.input field={@form[:image_url]} type="text" label="Image url" /> <:actions> <.button phx-disable-with="Saving...">Save Record diff --git a/lib/music_library_web/live/record_live/index.ex b/lib/music_library_web/live/record_live/index.ex index fd669c1c..104286d3 100644 --- a/lib/music_library_web/live/record_live/index.ex +++ b/lib/music_library_web/live/record_live/index.ex @@ -31,7 +31,7 @@ defmodule MusicLibraryWeb.RecordLive.Index do defp apply_action(socket, :edit, %{"id" => id}) do socket - |> assign(:page_title, "Edit Record") + |> assign(:page_title, "Edit Metadata") |> assign(:record, Records.get_record!(id)) end diff --git a/lib/music_library_web/live/record_live/show.ex b/lib/music_library_web/live/record_live/show.ex index 0f43787e..3f582b61 100644 --- a/lib/music_library_web/live/record_live/show.ex +++ b/lib/music_library_web/live/record_live/show.ex @@ -17,7 +17,7 @@ defmodule MusicLibraryWeb.RecordLive.Show do end defp page_title(:show), do: "Show Record" - defp page_title(:edit), do: "Edit Record" + defp page_title(:edit), do: "Edit Metadata" defp musicbrainz_url(record) do "https://musicbrainz.org/release-group/#{record.musicbrainz_id}" diff --git a/lib/music_library_web/live/record_live/show.html.heex b/lib/music_library_web/live/record_live/show.html.heex index 227ffcb9..5292aa05 100644 --- a/lib/music_library_web/live/record_live/show.html.heex +++ b/lib/music_library_web/live/record_live/show.html.heex @@ -3,7 +3,7 @@ <:subtitle><%= Enum.map(@record.artists, fn a -> a.name end) %> <:actions> <.link patch={~p"/records/#{@record}/show/edit"} phx-click={JS.push_focus()}> - <.button>Edit record + <.button>Edit Metadata