diff --git a/lib/music_library/records/record.ex b/lib/music_library/records/record.ex
index 83cbbbe2..bd58097a 100644
--- a/lib/music_library/records/record.ex
+++ b/lib/music_library/records/record.ex
@@ -6,6 +6,7 @@ defmodule MusicLibrary.Records.Record do
@foreign_key_type :binary_id
schema "records" do
field :type, Ecto.Enum, values: [:album, :ep, :live, :compilation, :single, :other]
+ field :format, Ecto.Enum, values: [:cd, :vinyl, :blu_ray, :dvd, :multi]
field :title, :string
field :image_url, :string
field :image_data, :binary
@@ -26,7 +27,16 @@ defmodule MusicLibrary.Records.Record do
@doc false
def changeset(record, attrs) do
record
- |> cast(attrs, [:type, :title, :musicbrainz_id, :year, :genres, :image_url, :image_data])
+ |> cast(attrs, [
+ :type,
+ :format,
+ :title,
+ :musicbrainz_id,
+ :year,
+ :genres,
+ :image_url,
+ :image_data
+ ])
|> cast_embed(:artists, with: &artist_changeset/2)
|> validate_required([:type, :title, :musicbrainz_id, :year, :genres])
end
@@ -47,4 +57,10 @@ defmodule MusicLibrary.Records.Record do
def add_image_data(record, image_data) do
change(record, image_data: image_data)
end
+
+ def format_short_label(:cd), do: "CD"
+ def format_short_label(:vinyl), do: "V"
+ def format_short_label(:blu_ray), do: "BR"
+ def format_short_label(:dvd), do: "DVD"
+ def format_short_label(:multi), do: "MLT"
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 abd3eae2..aa4bbdc0 100644
--- a/lib/music_library_web/live/record_live/index.html.heex
+++ b/lib/music_library_web/live/record_live/index.html.heex
@@ -24,7 +24,12 @@
row_click={fn {_id, record} -> JS.navigate(~p"/records/#{record}") end}
>
<:col :let={{_id, record}} label="Image">
-
+
+
+
+ <%= Records.Record.format_short_label(record.format) %>
+
+
<:col :let={{_id, record}} label="Record">
<%= Enum.map(record.artists, fn a -> a.name end) %>
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 8559528e..153e2f3c 100644 --- a/lib/music_library_web/live/record_live/show.html.heex +++ b/lib/music_library_web/live/record_live/show.html.heex @@ -12,7 +12,12 @@