Use aliases

This commit is contained in:
Claudio Ortolina
2025-02-20 15:19:06 +00:00
parent 26297a8bb1
commit b2daa561d7
4 changed files with 19 additions and 15 deletions
@@ -16,6 +16,7 @@ defmodule MusicLibraryWeb.CoreComponents do
""" """
use Phoenix.Component use Phoenix.Component
alias Phoenix.HTML.Form
alias Phoenix.LiveView.JS alias Phoenix.LiveView.JS
use Gettext, backend: MusicLibraryWeb.Gettext use Gettext, backend: MusicLibraryWeb.Gettext
@@ -308,7 +309,7 @@ defmodule MusicLibraryWeb.CoreComponents do
def input(%{type: "checkbox"} = assigns) do def input(%{type: "checkbox"} = assigns) do
assigns = assigns =
assign_new(assigns, :checked, fn -> assign_new(assigns, :checked, fn ->
Phoenix.HTML.Form.normalize_value("checkbox", assigns[:value]) Form.normalize_value("checkbox", assigns[:value])
end) end)
~H""" ~H"""
@@ -353,7 +354,7 @@ defmodule MusicLibraryWeb.CoreComponents do
{@rest} {@rest}
> >
<option :if={@prompt} value="">{@prompt}</option> <option :if={@prompt} value="">{@prompt}</option>
{Phoenix.HTML.Form.options_for_select(@options, @value)} {Form.options_for_select(@options, @value)}
</select> </select>
<.error :for={msg <- @errors}>{msg}</.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
@@ -373,7 +374,7 @@ defmodule MusicLibraryWeb.CoreComponents do
@errors != [] && "border-rose-400 focus:border-rose-400" @errors != [] && "border-rose-400 focus:border-rose-400"
]} ]}
{@rest} {@rest}
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea> ><%= Form.normalize_value("textarea", @value) %></textarea>
<.error :for={msg <- @errors}>{msg}</.error> <.error :for={msg <- @errors}>{msg}</.error>
</div> </div>
""" """
@@ -388,7 +389,7 @@ defmodule MusicLibraryWeb.CoreComponents do
type={@type} type={@type}
name={@name} name={@name}
id={@id} id={@id}
value={Phoenix.HTML.Form.normalize_value(@type, @value)} value={Form.normalize_value(@type, @value)}
class={[ class={[
"mt-2 block w-full rounded-md", "mt-2 block w-full rounded-md",
"border-0 border-zinc-300", "border-0 border-zinc-300",
+7 -7
View File
@@ -11,7 +11,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:506 #: lib/music_library_web/components/core_components.ex:507
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Actions" msgid "Actions"
msgstr "" msgstr ""
@@ -69,7 +69,7 @@ msgstr ""
msgid "Error importing record" msgid "Error importing record"
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:161 #: lib/music_library_web/components/core_components.ex:162
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Error!" msgid "Error!"
msgstr "" msgstr ""
@@ -90,7 +90,7 @@ msgstr ""
msgid "Genres" msgid "Genres"
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:170 #: lib/music_library_web/components/core_components.ex:171
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Hang in there while we get back on track" msgid "Hang in there while we get back on track"
msgstr "" msgstr ""
@@ -241,7 +241,7 @@ msgstr ""
msgid "Showing <b>%{visible}</b> of <b>%{total}</b> records" msgid "Showing <b>%{visible}</b> of <b>%{total}</b> records"
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:165 #: lib/music_library_web/components/core_components.ex:166
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Something went wrong!" msgid "Something went wrong!"
msgstr "" msgstr ""
@@ -252,7 +252,7 @@ msgstr ""
msgid "Stats" msgid "Stats"
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:160 #: lib/music_library_web/components/core_components.ex:161
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Success!" msgid "Success!"
msgstr "" msgstr ""
@@ -314,8 +314,8 @@ msgstr ""
msgid "You must be logged in to access this page" msgid "You must be logged in to access this page"
msgstr "" msgstr ""
#: lib/music_library_web/components/core_components.ex:81 #: lib/music_library_web/components/core_components.ex:82
#: lib/music_library_web/components/core_components.ex:137 #: lib/music_library_web/components/core_components.ex:138
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "close" msgid "close"
msgstr "" msgstr ""
+3 -2
View File
@@ -2,13 +2,14 @@ defmodule MusicLibrary.Records.CoverTest do
use ExUnit.Case, async: true use ExUnit.Case, async: true
import MusicLibrary.Fixtures.Records import MusicLibrary.Fixtures.Records
alias MusicLibrary.Records.Cover
describe "resize/1" do describe "resize/1" do
test "it resizes to the desired size" do test "it resizes to the desired size" do
cover_data = File.read!(marbles_cover_fixture()) cover_data = File.read!(marbles_cover_fixture())
{:ok, resized_cover} = MusicLibrary.Records.Cover.resize(cover_data) {:ok, resized_cover} = Cover.resize(cover_data)
assert cover_data !== resized_cover assert cover_data !== resized_cover
assert MusicLibrary.Records.Cover.correct_size?(resized_cover) assert Cover.correct_size?(resized_cover)
end end
end end
end end
+4 -2
View File
@@ -16,6 +16,8 @@ defmodule MusicLibrary.DataCase do
use ExUnit.CaseTemplate use ExUnit.CaseTemplate
alias Ecto.Adapters.SQL.Sandbox
using do using do
quote do quote do
alias MusicLibrary.Repo alias MusicLibrary.Repo
@@ -36,8 +38,8 @@ defmodule MusicLibrary.DataCase do
Sets up the sandbox based on the test tags. Sets up the sandbox based on the test tags.
""" """
def setup_sandbox(tags) do def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(MusicLibrary.Repo, shared: not tags[:async]) pid = Sandbox.start_owner!(MusicLibrary.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) on_exit(fn -> Sandbox.stop_owner(pid) end)
end end
@doc """ @doc """