Skip to content

Commit

Permalink
Merge branch 'feat/remove-umbrella'
Browse files Browse the repository at this point in the history
* feat/remove-umbrella:
  feat: add annabell changes
  Refatoração de relatório (#141)
  fix: docker tests
  19f30b7
  fix: fixed tests
  chore: fix credo warning
  chore: delete apps
  no umbrella
  • Loading branch information
zoedsoupe committed Jan 14, 2024
2 parents 25595c6 + b9e39f0 commit 5d0f1a2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 14 deletions.
15 changes: 15 additions & 0 deletions assets/css/dropdown.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.dropdown {
display: inline-block;
position: relative;
}

.dropdown-options {
display: none;
position: relative;
overflow: auto;

}

.dropdown:hover .dropdown-options {
display: block;
}
10 changes: 7 additions & 3 deletions lib/pescarte/modulo_pesquisa/adapters/relatorio_adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ defmodule Pescarte.ModuloPesquisa.Adapters.RelatorioAdapter do
import Timex.Format.DateTime.Formatter, only: [lformat!: 3]

alias Pescarte.Identidades.Handlers.UsuarioHandler
alias Pescarte.ModuloPesquisa.Models.RelatorioPesquisa, as: RelatorioPesquisaModel
alias Pescarte.ModuloPesquisa.Models.RelatorioAnualPesquisa, as: Anual
alias Pescarte.ModuloPesquisa.Models.RelatorioMensalPesquisa, as: Mensal
alias Pescarte.ModuloPesquisa.Models.RelatorioTrimestralPesquisa, as: Trimestral
alias Pescarte.ModuloPesquisa.Schemas.RelatorioPesquisa

@locale Application.compile_env(:pescarte, :locale, "pt_BR")

@type relatorio :: Anual.t() | Mensal.t() | Trimestral.t()
@typep changeset :: Ecto.Changeset.t()

@spec internal_to_external(RelatorioPesquisaModel.t()) ::
{:ok, RelatorioPesquisa.t()} | {:error, changeset}
@spec internal_to_external(relatorio) :: {:ok, RelatorioPesquisa.t()} | {:error, changeset}
def internal_to_external(%{pesquisador: pesquisador} = relatorio) do
attrs = %{
id: relatorio.id_publico,
status: relatorio.status,
data: relatorio.data_entrega,
link: relatorio.link,
tipo: get_relatorio_tipo(relatorio),
periodo: get_relatorio_periodo!(relatorio),
nome_pesquisador: UsuarioHandler.build_usuario_name(pesquisador.usuario)
Expand Down
19 changes: 19 additions & 0 deletions lib/pescarte_web/design_system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,23 @@ defmodule PescarteWeb.DesignSystem do
</div>
"""
end

@doc """
Renderiza um dropdown - versão 4/10/2023:
"""
def report_menu_link(assigns) do
~H"""
<div class="profile-menu-link">
<span class="flex items-center justify-center bg-white-100">
<%= render_slot(@inner_block) %>
</span>
<.button style="link" class="whitespace-nowrap" click={@click} phx-target=".profile-menu-link">
<.text size="base" color="text-blue-80">
<Lucideicons.edit class="text-blue-100" />
<%= @label %>
</.text>
</.button>
</div>
"""
end
end
19 changes: 19 additions & 0 deletions lib/pescarte_web/live/pesquisa/relatorio_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ defmodule PescarteWeb.Pesquisa.RelatorioLive.Index do
|> push_patch(to: ~p"/app/pesquisa/relatorios/new")}
end

# ================= 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")}
# ~p"/app/pesquisa/relatorios"
end

def handle_event("trimestral_report", _, socket) do
{:noreply, Phoenix.LiveView.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")}
end

def handle_event("anual_report", _, socket) do
{:noreply, Phoenix.LiveView.redirect(socket, to: ~p"/app/pesquisa/pesquisadores")}
end

defp apply_action(socket, :edit, %{"id" => id}) do
socket
|> assign(:page_title, "Editar Relatório")
Expand Down
48 changes: 37 additions & 11 deletions lib/pescarte_web/live/pesquisa/relatorio_live/index.html.heex
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
<div :if={@live_action == :index}>
<.table id="relatorios" rows={@streams.relatorios} text-color="blue">
<:column :let={{_id, relatorio}} label="Teste">
<%= relatorio.data_inicio %>
</:column>
</.table>
<div class="search">
<.search_input name="busca-relatorio" id="busca-relatorio" />

<button phx-click="report-type" phx-value-type="mensal" style="primary">
Mensal
</button>
<div class="dropdown">
<.button id="preencher-relatorio-button" style="primary" phx-click="toggleDropdown">
<Lucideicons.book class="text-white-100" />
<.text size="sm" color="text-white-100">Preencher Relatório</.text>
<Lucideicons.chevron_down class="text-blue-100" />
</.button>
<div class="dropdown-options">
<.report_menu_link click="mensal_report" label="Mensal"></.report_menu_link>
<.report_menu_link click="trimestral_report" label="Trimestral"></.report_menu_link>
<.report_menu_link click="anual_report" label="Anual"></.report_menu_link>
</div>
</div>

<button phx-click="report-type" phx-value-type="trimestral" style="primary">
Trimestral
</button>
<div :if={@current_user.tipo == :admin} class="links-item">
<.button class="icon-button" style="primary" submit>
<Lucideicons.files class="text-white-100" />
<.text size="sm" color="text-white-100">Compilar</.text>
</.button>
</div>
</div>

<.table rows={@streams.relatorios} text-color="text-blue-100">
<:column :let={_} label=" ">
<div class="flex-center"><.checkbox name="check" id="usuario" /></div>
</:column>
<:column :let={relatorio} label="Data"><%= relatorio.data %></:column>
<:column :let={relatorio} label="Tipo" class="linhas"><%= relatorio.tipo %></:column>
<:column :let={relatorio} label="Mês/Ano">
<%= relatorio.mes <> " / " <> relatorio.ano %>
</:column>
<:column :let={relatorio} label="Nome"><%= relatorio.name %></:column>
<:column :let={relatorio} label="Status"><%= relatorio.status %></:column>
<:column :let={_} label="Baixar">
<div class="flex-center"><Lucideicons.download /></div>
</:column>
</.table>
</div>

<.live_component
Expand Down

0 comments on commit 5d0f1a2

Please sign in to comment.