Skip to content

Commit

Permalink
Backoffice dataset form : gère cas où org est nil (#3614)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Nov 20, 2023
1 parent 009286b commit 2f25655
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ defmodule TransportWeb.Backoffice.PageController do
|> assign(:notifications_last_nb_days, notifications_last_nb_days())
|> assign(:resources_with_history, DB.Dataset.last_resource_history(dataset_id))
|> assign(:contacts_datalist, contacts_datalist())
|> assign(:contacts_in_org, contacts_in_org(conn.assigns[:dataset]))
|> assign(
:import_logs,
LogsImport
Expand All @@ -179,6 +180,12 @@ defmodule TransportWeb.Backoffice.PageController do
|> render("form_dataset.html")
end

defp contacts_in_org(%DB.Dataset{organization_object: organization_object}) do
Enum.sort_by(organization_object.contacts, &DB.Contact.display_name/1)
end

defp contacts_in_org(_), do: []

defp contacts_datalist do
DB.Contact.base_query()
|> select([contact: c], [:first_name, :last_name, :mailing_list_title, :organization, :id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
) %>

<%= unless is_nil(@dataset) do %>
<% contacts_in_org = Enum.sort_by(@dataset.organization_object.contacts, &DB.Contact.display_name/1) %>
<div class="is-centered mt-48">
<%= dgettext("backoffice", "Other actions on the dataset") %>
</div>
Expand Down Expand Up @@ -84,12 +83,12 @@
<i class="fas fa-external-link"></i> Créer un contact
</a>
</div>
<div :if={Enum.count(contacts_in_org) > 0}>
<div :if={Enum.count(@contacts_in_org) > 0}>
<p>
Contacts dans l'organisation s'étant déjà connectés au PAN
</p>
<ul>
<%= for contact <- contacts_in_org do %>
<%= for contact <- @contacts_in_org do %>
<% onclick_fn = ~s{getElementById("contact_id").value =} <> to_string(contact.id) %>
<li class="pb-6">
<a href={backoffice_contact_path(@conn, :edit, contact.id)} target="_blank">
Expand Down

0 comments on commit 2f25655

Please sign in to comment.