From 3276c3765d972a2d935d486cec84dcb2c36ad46e Mon Sep 17 00:00:00 2001 From: Zoey de Souza Pessanha Date: Thu, 25 Jan 2024 13:56:49 -0300 Subject: [PATCH] wip: cadastro pesquisador --- assets/css/app.scss | 1 + assets/css/dropdown.scss | 1 - .../app/researcher/cadastro_pesquisador.scss | 23 ++++ .../pesquisa/cadastro_pesquisador_live.ex | 61 ++++++++ .../cadastro_pesquisador_live.html.heex | 130 ++++++++++++++++++ .../pesquisa/list_pesquisador_live.html.heex | 4 +- .../live/pesquisa/relatorio_live/index.ex | 8 +- lib/pescarte_web/router.ex | 1 + .../templates/landing_html/show.html.heex | 34 ++++- 9 files changed, 255 insertions(+), 8 deletions(-) create mode 100644 assets/css/pages/app/researcher/cadastro_pesquisador.scss create mode 100644 lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.ex create mode 100644 lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.html.heex diff --git a/assets/css/app.scss b/assets/css/app.scss index abe4ff4d..98773924 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -171,6 +171,7 @@ footer { @import "./textarea.scss"; @import "./tabela.scss"; @import "./label.scss"; +@import "./dropdown.scss"; // Páginas // Sem autenticação diff --git a/assets/css/dropdown.scss b/assets/css/dropdown.scss index 1c794b84..e1d416af 100644 --- a/assets/css/dropdown.scss +++ b/assets/css/dropdown.scss @@ -7,7 +7,6 @@ display: none; position: relative; overflow: auto; - } .dropdown:hover .dropdown-options { diff --git a/assets/css/pages/app/researcher/cadastro_pesquisador.scss b/assets/css/pages/app/researcher/cadastro_pesquisador.scss new file mode 100644 index 00000000..769e2b1f --- /dev/null +++ b/assets/css/pages/app/researcher/cadastro_pesquisador.scss @@ -0,0 +1,23 @@ +.nav-menu { + @apply flex flex-col items-center justify-between w-full; + + height: 26.875rem; + + .nav-item { + @apply text-black-60 flex items-center justify-center; + } +} + +.item-secao { + @apply justify-between items-center; + @apply w-full border-black-10 bg-white-100; + + display: flex; + flex-wrap: wrap; + align-content: flex-start; +} + +.item-fieldset { + width: 17.25rem; + height: 5.25rem; +} \ No newline at end of file diff --git a/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.ex b/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.ex new file mode 100644 index 00000000..8d209103 --- /dev/null +++ b/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.ex @@ -0,0 +1,61 @@ +defmodule PlataformaDigital.Pesquisa.CadastroPesquisadorLive do + use PescarteWeb, :auth_live_view + + @impl true + def mount(_params, _session, socket) do + # cadastro_params = %{"form" => form, "field_names" => field_names} + + {:ok, + socket + |> assign(:form_title, "Cadastrar Novo Pesquisador") + |> assign(:form, to_form(%{}, as: :user)) + # |> assign(:form_dados, get_dados_cadastro) + |> assign(:field_names, get_cadastro_field_names(:cadastro))} + end + + # para criar um user no login: + # def create(conn, %{"user" => user_params}) do + # %{"cpf" => cpf, "password" => password} = user_params + + # case UsuarioHandler.fetch_usuario_by_cpf_and_password(cpf, password) do + # {:error, :not_found} -> render(conn, :show, error_message: @err_msg) + # {:ok, user} -> Authentication.log_in_user(conn, user, user_params) + # end + # end + + # @impl true + # def handle_params(params, _uri, socket) do + # {:noreply, apply_action(socket, socket.assigns.live_action, params)} + # end + + # defp apply_action(socket, :new, _params) do + # socket + # |> assign(:title, "Novo Pesquisador") + # |> assign(:cadastro, %Pesquisador{}) + # end + + defp get_cadastro_field_names(:cadastro) do + [ + {"Dados Pessoais", :dados}, + {"Endereço", :endereco}, + {"Vínculo Institucional", :vinculo}, + {"Orientador", :orientador} + ] + + # %{dados: dados, endereco: endereco, vinculo: vinculo} + end + + # defp get_dados_cadastro do + # [ + # {"primeiro_nome", :primeiro_nome}, + # {"sobrenome", :sobrenome}, + # {"data_nascimento", :data_nascimento} + # ] + # end + + # @impl true trecho para entender..... + # {:ok, assign(socket, note_text: "", draft_notes: [], published_notes: [], error: "")} + # def handle_event("create_pesquisador", %{"note_text" => note_text}, socket) do + # {:noreply, assign(socket, draft_notes: [note_text | socket.assigns.draft_notes])} + # end +end diff --git a/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.html.heex b/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.html.heex new file mode 100644 index 00000000..fca0f174 --- /dev/null +++ b/lib/pescarte_web/live/pesquisa/cadastro_pesquisador_live.html.heex @@ -0,0 +1,130 @@ +
+ <.text size="h1" color="text-blue-100"><%= @form_title %> + <.simple_form for={@form} action={~p"/app/pesquisa/cadastro"} class="report-wrapper"> + <.text size="h3" color="text-blue-100"><%= @field_names[:dados] %> + + <.text size="h3" color="text-blue-100">Dados Pessoais + + + +
+
+ + +
+
+ + <.text size="h3" color="text-blue-100">Endereço + + +
+ + +
+ + <.text size="h3" color="text-blue-100">Vínculo Institucional + + +
+ <.button + name="save" + value="save-cadastro" + style="primary" + phx-disable-with="Salvando….." + submit + > + Salvar respostas + + + <.button + name="save" + value="send-cadastro" + style="primary" + phx-disable-with="Enviando..." + submit + > + Enviar cadastro + +
+
diff --git a/lib/pescarte_web/live/pesquisa/list_pesquisador_live.html.heex b/lib/pescarte_web/live/pesquisa/list_pesquisador_live.html.heex index 8b316609..1bb5b642 100644 --- a/lib/pescarte_web/live/pesquisa/list_pesquisador_live.html.heex +++ b/lib/pescarte_web/live/pesquisa/list_pesquisador_live.html.heex @@ -8,7 +8,9 @@ /> <.button :if={@current_user.tipo == :admin} style="primary" click="register"> - Cadastrar + + Cadastrar + diff --git a/lib/pescarte_web/live/pesquisa/relatorio_live/index.ex b/lib/pescarte_web/live/pesquisa/relatorio_live/index.ex index ef5f1a96..bd0444cf 100644 --- a/lib/pescarte_web/live/pesquisa/relatorio_live/index.ex +++ b/lib/pescarte_web/live/pesquisa/relatorio_live/index.ex @@ -31,20 +31,20 @@ defmodule PescarteWeb.Pesquisa.RelatorioLive.Index do # ================= Vamos trabalhar o dropdown do "Preencher Relatório" 09-14/10/2023 @impl true def handle_event("mensal_report", _, socket) do - {:noreply, Phoenix.LiveView.redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} + {:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} # ~p"/app/pesquisa/relatorios" end def handle_event("trimestral_report", _, socket) do - {:noreply, Phoenix.LiveView.redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} + {:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} end def handle_event("bienal_report", _, socket) do - {:noreply, Phoenix.LiveView.redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} + {:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} end def handle_event("anual_report", _, socket) do - {:noreply, Phoenix.LiveView.redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} + {:noreply, redirect(socket, to: ~p"/app/pesquisa/pesquisadores")} end defp apply_action(socket, :edit, %{"id" => id}) do diff --git a/lib/pescarte_web/router.ex b/lib/pescarte_web/router.ex index 7d3b7d41..4ee8756d 100644 --- a/lib/pescarte_web/router.ex +++ b/lib/pescarte_web/router.ex @@ -51,6 +51,7 @@ defmodule PescarteWeb.Router do on_mount: [{PescarteWeb.Authentication, :ensure_authenticated}] do live("/perfil", ProfileLive) live("/pesquisadores", ListPesquisadorLive) + live("/cadastro", CadastroPesquisadorLive) scope "/relatorios" do live("/", RelatorioLive.Index, :index) diff --git a/lib/pescarte_web/templates/landing_html/show.html.heex b/lib/pescarte_web/templates/landing_html/show.html.heex index 1eef9894..0b587470 100644 --- a/lib/pescarte_web/templates/landing_html/show.html.heex +++ b/lib/pescarte_web/templates/landing_html/show.html.heex @@ -3,9 +3,11 @@