From 28b2eabe1f8cf95f7f91ad17721812477db51211 Mon Sep 17 00:00:00 2001 From: douglastofoli Date: Wed, 29 Nov 2023 16:12:06 -0300 Subject: [PATCH] fix: resolved form fields blank when typing --- .envrc | 8 ++++- .../handlers/i_manage_relatorios_handler.ex | 1 + .../models/relatorio_pesquisa.ex | 16 +++++++++ apps/plataforma_digital/assets/css/app.scss | 4 +-- .../lib/plataforma_digital/design_system.ex | 5 ++- .../live/pesquisa/relatorio/form_component.ex | 30 ++++++++++------ .../lib/plataforma_digital/router.ex | 36 +++++++++---------- 7 files changed, 67 insertions(+), 33 deletions(-) diff --git a/.envrc b/.envrc index c1fdce0b..677357fa 100644 --- a/.envrc +++ b/.envrc @@ -20,11 +20,13 @@ if ! test -d apps/plataforma_digital/assets/node_modules && test -f apps/platafo cd apps/plataforma_digital/assets && npm install && cd $PWD fi +USE_LOCAL_POSTGRES=false + # Setup postgresql if test -d "/Applications/Postgres.app"; then export DATABASE_USER="$(whoami)" export DATABASE_PASSWORD="" -else +elif $USE_LOCAL_POSTGRES; then # postges related export DATABASE_USER="peapescarte" export DATABASE_PASSWORD="peapescarte" @@ -45,4 +47,8 @@ else # creates local databse echo "CREATE DATABASE $PG_DATABASE;" | postgres --single -E postgres fi +else + export DATABASE_USER="postgres" + export DATABASE_PASSWORD="postgres" + export PG_DATABASE="peapescarte_dev" fi diff --git a/apps/modulo_pesquisa/lib/modulo_pesquisa/handlers/i_manage_relatorios_handler.ex b/apps/modulo_pesquisa/lib/modulo_pesquisa/handlers/i_manage_relatorios_handler.ex index 26ba210f..6973f4ab 100644 --- a/apps/modulo_pesquisa/lib/modulo_pesquisa/handlers/i_manage_relatorios_handler.ex +++ b/apps/modulo_pesquisa/lib/modulo_pesquisa/handlers/i_manage_relatorios_handler.ex @@ -1,6 +1,7 @@ defmodule ModuloPesquisa.Handlers.IManageRelatoriosHandler do alias ModuloPesquisa.Schemas.RelatorioPesquisa + @callback change_relatorio_pesquisa(RelatorioPesquisa.t(), map()) :: Ecto.Changeset.t() @callback list_relatorios(sorter) :: list(RelatorioPesquisa.t()) when sorter: function @callback list_relatorios_from_pesquisador(id, sorter) :: list(RelatorioPesquisa.t()) diff --git a/apps/modulo_pesquisa/lib/modulo_pesquisa/models/relatorio_pesquisa.ex b/apps/modulo_pesquisa/lib/modulo_pesquisa/models/relatorio_pesquisa.ex index 60674503..b17a10ca 100644 --- a/apps/modulo_pesquisa/lib/modulo_pesquisa/models/relatorio_pesquisa.ex +++ b/apps/modulo_pesquisa/lib/modulo_pesquisa/models/relatorio_pesquisa.ex @@ -67,6 +67,22 @@ defmodule ModuloPesquisa.Models.RelatorioPesquisa do |> validate_inclusion(:status, @status) |> foreign_key_constraint(:pesquisador_id) |> validate_period() + |> put_limit_date() + end + + defp put_limit_date(changeset) do + report_type = get_field(changeset, :tipo) + today = Date.utc_today() + + limit_date = + case report_type do + :mensal -> Date.from_iso8601!("#{today.year}-#{today.month}-15") + :trimestral -> Date.from_iso8601!("#{today.year}-#{today.month}-10") + :anual -> today + nil -> changeset + end + + put_change(changeset, :data_limite, limit_date) end defp validate_period(changeset) do diff --git a/apps/plataforma_digital/assets/css/app.scss b/apps/plataforma_digital/assets/css/app.scss index 6da93a31..f47bf9ba 100644 --- a/apps/plataforma_digital/assets/css/app.scss +++ b/apps/plataforma_digital/assets/css/app.scss @@ -90,7 +90,7 @@ footer { @apply h-screen; } - header > nav { + header>nav { @apply h-full; } @@ -182,4 +182,4 @@ footer { @import "./pages/app/researcher/relatorio/report.scss"; // Páginas de Erros -@import "./errors/404.scss"; +@import "./errors/404.scss"; \ No newline at end of file diff --git a/apps/plataforma_digital/lib/plataforma_digital/design_system.ex b/apps/plataforma_digital/lib/plataforma_digital/design_system.ex index 2c58289b..e40b7634 100644 --- a/apps/plataforma_digital/lib/plataforma_digital/design_system.ex +++ b/apps/plataforma_digital/lib/plataforma_digital/design_system.ex @@ -114,6 +114,8 @@ defmodule PlataformaDigital.DesignSystem do <.button style="primary" submit> Submissão """ + attr(:name, :string, default: "") + attr(:value, :string, default: "") attr(:style, :string, values: ~w(primary secondary link), required: true) attr(:submit, :boolean, default: false) attr(:disabled, :boolean, default: false) @@ -126,6 +128,8 @@ defmodule PlataformaDigital.DesignSystem do def button(assigns) do ~H"""