From afa0f341bec1aee5349692198796c6e3d2a09f97 Mon Sep 17 00:00:00 2001 From: Aaron Date: Sat, 2 Nov 2024 11:53:17 -0700 Subject: [PATCH] Update phx.gen.html.ex Update :text column to textarea to match intent for html generator --- lib/mix/tasks/phx.gen.html.ex | 2 +- lib/mix/tasks/phx.gen.live.ex | 2 +- test/mix/tasks/phx.gen.html_test.exs | 4 +++- test/mix/tasks/phx.gen.live_test.exs | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/mix/tasks/phx.gen.html.ex b/lib/mix/tasks/phx.gen.html.ex index b435d3a4d3..76fe2aa388 100644 --- a/lib/mix/tasks/phx.gen.html.ex +++ b/lib/mix/tasks/phx.gen.html.ex @@ -198,7 +198,7 @@ defmodule Mix.Tasks.Phx.Gen.Html do ~s(<.input field={f[#{inspect(key)}]} type="checkbox" label="#{label(key)}" />) {key, :text} -> - ~s(<.input field={f[#{inspect(key)}]} type="text" label="#{label(key)}" />) + ~s(<.input field={f[#{inspect(key)}]} type="textarea" label="#{label(key)}" />) {key, :date} -> ~s(<.input field={f[#{inspect(key)}]} type="date" label="#{label(key)}" />) diff --git a/lib/mix/tasks/phx.gen.live.ex b/lib/mix/tasks/phx.gen.live.ex index 59a51514d5..f0b6aa28aa 100644 --- a/lib/mix/tasks/phx.gen.live.ex +++ b/lib/mix/tasks/phx.gen.live.ex @@ -285,7 +285,7 @@ defmodule Mix.Tasks.Phx.Gen.Live do ~s(<.input field={@form[#{inspect(key)}]} type="checkbox" label="#{label(key)}" />) {key, :text} -> - ~s(<.input field={@form[#{inspect(key)}]} type="text" label="#{label(key)}" />) + ~s(<.input field={@form[#{inspect(key)}]} type="textarea" label="#{label(key)}" />) {key, :date} -> ~s(<.input field={@form[#{inspect(key)}]} type="date" label="#{label(key)}" />) diff --git a/test/mix/tasks/phx.gen.html_test.exs b/test/mix/tasks/phx.gen.html_test.exs index b0eb2d309d..450e0599b7 100644 --- a/test/mix/tasks/phx.gen.html_test.exs +++ b/test/mix/tasks/phx.gen.html_test.exs @@ -44,7 +44,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do datetime = %{DateTime.utc_now() | second: 0, microsecond: {0, 6}} in_tmp_project(config.test, fn -> - Gen.Html.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal + Gen.Html.run(~w(Blog Post posts title content:text slug:unique votes:integer cost:decimal tags:array:text popular:boolean drafted_at:datetime status:enum:unpublished:published:deleted published_at:utc_datetime @@ -110,6 +110,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do assert_file(path, fn file -> assert file =~ "create table(:posts)" assert file =~ "add :title, :string" + assert file =~ "add :content, :text" assert file =~ "add :status, :string" assert file =~ "create unique_index(:posts, [:slug])" end) @@ -151,6 +152,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do assert_file("lib/phoenix_web/controllers/post_html/post_form.html.heex", fn file -> assert file =~ ~S(<.simple_form :let={f} for={@changeset} action={@action}>) assert file =~ ~s(<.input field={f[:title]} type="text") + assert file =~ ~s(<.input field={f[:content]} type="textarea") assert file =~ ~s(<.input field={f[:votes]} type="number") assert file =~ ~s(<.input field={f[:cost]} type="number" label="Cost" step="any") diff --git a/test/mix/tasks/phx.gen.live_test.exs b/test/mix/tasks/phx.gen.live_test.exs index e67f57a304..dd5cb47564 100644 --- a/test/mix/tasks/phx.gen.live_test.exs +++ b/test/mix/tasks/phx.gen.live_test.exs @@ -55,7 +55,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do test "generates live resource and handles existing contexts", config do in_tmp_live_project config.test, fn -> - Gen.Live.run(~w(Blog Post posts title slug:unique votes:integer cost:decimal + Gen.Live.run(~w(Blog Post posts title content:text slug:unique votes:integer cost:decimal tags:array:text popular:boolean drafted_at:datetime status:enum:unpublished:published:deleted published_at:utc_datetime @@ -88,6 +88,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do assert_file path, fn file -> assert file =~ "create table(:posts)" assert file =~ "add :title, :string" + assert file =~ "add :content, :text" assert file =~ "create unique_index(:posts, [:slug])" end @@ -102,6 +103,7 @@ defmodule Mix.Tasks.Phx.Gen.LiveTest do assert_file "lib/phoenix_web/live/post_live/form.ex", fn file -> assert file =~ ~s(<.simple_form) assert file =~ ~s(<.input field={@form[:title]} type="text") + assert file =~ ~s(<.input field={@form[:content]} type="textarea") assert file =~ ~s(<.input field={@form[:votes]} type="number") assert file =~ ~s(<.input field={@form[:cost]} type="number" label="Cost" step="any") assert file =~ """