Skip to content

Commit

Permalink
bugfix: wrong field name for text area
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed Nov 10, 2023
1 parent b423733 commit 9f157c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ defmodule ModuloPesquisa.Models.RelatorioPesquisa do
end

@spec changeset(RelatorioPesquisa.t(), map) :: changeset
def changeset(%RelatorioPesquisa{status: :entregue} = relatorio, attrs) do
relatorio
|> cast(attrs, @required_fields ++ @optional_fields)
|> add_error(:status, "O relatório já foi entregue")
end

def changeset(%RelatorioPesquisa{} = relatorio, attrs) do
relatorio
|> cast(attrs, @required_fields ++ @optional_fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ defmodule PlataformaDigital.DesignSystem do
attr(:name, :string, required: true)
attr(:content, :list, default: [])
attr(:placeholder, :string, default: "Faça uma pesquisa...")
attr(:field, Phoenix.HTML.FormFieldcontent)
attr(:field, Phoenix.HTML.FormField)
attr(:size, :string, values: ~w(base large), default: "base")

def search_input(%{field: %Phoenix.HTML.FormField{}} = assigns) do
Expand All @@ -403,7 +403,7 @@ defmodule PlataformaDigital.DesignSystem do
defp input(%{field: %Phoenix.HTML.FormField{} = field} = assigns) do
assigns
|> assign(field: nil, id: assigns.id || field.id)
|> assign_new(:name, fn -> field.name end)
|> assign(:name, field.name)
|> assign_new(:value, fn -> field.value end)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,17 @@ defmodule PlataformaDigital.Pesquisa.Relatorio.FormComponent do

defp get_data_limite(%{tipo_relatorio: tipo_relatorio, today: today}) do
case tipo_relatorio do
"mensal" ->
Date.from_iso8601!("#{today.year}-#{today.month}-15")

"trimestral" ->
Date.from_iso8601!("#{today.year}-#{today.month}-10")

"anual" ->
Date.utc_today()
"mensal" -> Date.from_iso8601!("#{today.year}-#{today.month}-15")
"trimestral" -> Date.from_iso8601!("#{today.year}-#{today.month}-10")
"anual" -> Date.utc_today()
end
end

defp notify_parent(msg), do: send(self(), {__MODULE__, msg})

defp report_field(assigns) do
~H"""
<.text_area
id={@field.id}
name={@field.name}
value={@field.value}
disabled={@disabled}
class="report-field"
>
<.text_area field={@field} disabled={@disabled} class="report-field">
<:label>
<.text size="h3" color="text-blue-100">
<%= @label %>
Expand Down

0 comments on commit 9f157c1

Please sign in to comment.