Render scrobble rule type with badge

This commit is contained in:
Claudio Ortolina
2025-07-04 14:53:27 +01:00
parent b689b99be4
commit 40346d9123
4 changed files with 14 additions and 7 deletions
@@ -103,12 +103,13 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
{:noreply, put_flash(socket, :info, message)} {:noreply, put_flash(socket, :info, message)}
end end
defp rule_type_badge(type) do attr :type, :atom, required: true, values: [:album, :artist]
case type do
"album" -> "Album" defp type_badge(assigns) do
"artist" -> "Artist" ~H"""
_ -> type <.badge :if={@type == :album} color="green">{gettext("Album")}</.badge>
end <.badge :if={@type == :artist} color="blue">{gettext("Artist")}</.badge>
"""
end end
defp enabled_badge(enabled) do defp enabled_badge(enabled) do
@@ -36,7 +36,9 @@
</.table_head> </.table_head>
<.table_body phx-update="stream" id="scrobble-rules"> <.table_body phx-update="stream" id="scrobble-rules">
<.table_row :for={{dom_id, scrobble_rule} <- @streams.scrobble_rules} id={dom_id}> <.table_row :for={{dom_id, scrobble_rule} <- @streams.scrobble_rules} id={dom_id}>
<:cell>{rule_type_badge(scrobble_rule.type)}</:cell> <:cell>
<.type_badge type={scrobble_rule.type} />
</:cell>
<:cell>{scrobble_rule.match_value}</:cell> <:cell>{scrobble_rule.match_value}</:cell>
<:cell class="whitespace-nowrap font-mono">{scrobble_rule.target_musicbrainz_id}</:cell> <:cell class="whitespace-nowrap font-mono">{scrobble_rule.target_musicbrainz_id}</:cell>
<:cell>{enabled_badge(scrobble_rule.enabled)}</:cell> <:cell>{enabled_badge(scrobble_rule.enabled)}</:cell>
+2
View File
@@ -434,6 +434,7 @@ msgstr ""
#: lib/music_library_web/components/record_components.ex #: lib/music_library_web/components/record_components.ex
#: lib/music_library_web/live/scrobble_rules_live/form_component.ex #: lib/music_library_web/live/scrobble_rules_live/form_component.ex
#: lib/music_library_web/live/scrobble_rules_live/index.ex
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Album" msgid "Album"
msgstr "" msgstr ""
@@ -978,6 +979,7 @@ msgid "Apply All Rules"
msgstr "" msgstr ""
#: lib/music_library_web/live/scrobble_rules_live/form_component.ex #: lib/music_library_web/live/scrobble_rules_live/form_component.ex
#: lib/music_library_web/live/scrobble_rules_live/index.ex
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Artist" msgid "Artist"
msgstr "" msgstr ""
+2
View File
@@ -434,6 +434,7 @@ msgstr ""
#: lib/music_library_web/components/record_components.ex #: lib/music_library_web/components/record_components.ex
#: lib/music_library_web/live/scrobble_rules_live/form_component.ex #: lib/music_library_web/live/scrobble_rules_live/form_component.ex
#: lib/music_library_web/live/scrobble_rules_live/index.ex
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Album" msgid "Album"
msgstr "" msgstr ""
@@ -978,6 +979,7 @@ msgid "Apply All Rules"
msgstr "" msgstr ""
#: lib/music_library_web/live/scrobble_rules_live/form_component.ex #: lib/music_library_web/live/scrobble_rules_live/form_component.ex
#: lib/music_library_web/live/scrobble_rules_live/index.ex
#, elixir-autogen, elixir-format, fuzzy #, elixir-autogen, elixir-format, fuzzy
msgid "Artist" msgid "Artist"
msgstr "" msgstr ""