Render scrobble rule type with badge
This commit is contained in:
@@ -103,12 +103,13 @@ defmodule MusicLibraryWeb.ScrobbleRulesLive.Index do
|
||||
{:noreply, put_flash(socket, :info, message)}
|
||||
end
|
||||
|
||||
defp rule_type_badge(type) do
|
||||
case type do
|
||||
"album" -> "Album"
|
||||
"artist" -> "Artist"
|
||||
_ -> type
|
||||
end
|
||||
attr :type, :atom, required: true, values: [:album, :artist]
|
||||
|
||||
defp type_badge(assigns) do
|
||||
~H"""
|
||||
<.badge :if={@type == :album} color="green">{gettext("Album")}</.badge>
|
||||
<.badge :if={@type == :artist} color="blue">{gettext("Artist")}</.badge>
|
||||
"""
|
||||
end
|
||||
|
||||
defp enabled_badge(enabled) do
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
</.table_head>
|
||||
<.table_body phx-update="stream" id="scrobble-rules">
|
||||
<.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 class="whitespace-nowrap font-mono">{scrobble_rule.target_musicbrainz_id}</:cell>
|
||||
<:cell>{enabled_badge(scrobble_rule.enabled)}</:cell>
|
||||
|
||||
@@ -434,6 +434,7 @@ msgstr ""
|
||||
|
||||
#: 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/index.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Album"
|
||||
msgstr ""
|
||||
@@ -978,6 +979,7 @@ msgid "Apply All Rules"
|
||||
msgstr ""
|
||||
|
||||
#: 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
|
||||
msgid "Artist"
|
||||
msgstr ""
|
||||
|
||||
@@ -434,6 +434,7 @@ msgstr ""
|
||||
|
||||
#: 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/index.ex
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Album"
|
||||
msgstr ""
|
||||
@@ -978,6 +979,7 @@ msgid "Apply All Rules"
|
||||
msgstr ""
|
||||
|
||||
#: 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
|
||||
msgid "Artist"
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user