Skip to content

Commit

Permalink
Contact person submissions same household address (#729)
Browse files Browse the repository at this point in the history
* Added step that checks if client server connection is 'https'. If the connection is 'https' it sets secure flag for cookie(s).

* Intermediate commit.

* Added copy household address button.
  • Loading branch information
atoncetti committed Oct 14, 2021
1 parent e20780a commit f987a11
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
5 changes: 4 additions & 1 deletion apps/hygeia_gettext/priv/gettext/de/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
"X-Generator: Poedit 2.3\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "\"Merge\" and \"Into\" must not be the same"
Expand Down Expand Up @@ -3900,6 +3900,9 @@ msgctxt "Field"
msgid "Updated At"
msgstr "Aktualisiert Am"

msgid "Use my household address"
msgstr "Meine Adresse kopieren"

msgid "User"
msgstr "Benutzer"

Expand Down
3 changes: 3 additions & 0 deletions apps/hygeia_gettext/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,9 @@ msgctxt "Field"
msgid "Updated At"
msgstr ""

msgid "Use my household address"
msgstr ""

msgid "User"
msgstr ""

Expand Down
8 changes: 6 additions & 2 deletions apps/hygeia_gettext/priv/gettext/fr/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
msgid ""
msgstr ""
"Language: frplural\n"
"Language: fr\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
Expand All @@ -9,7 +9,8 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
"X-Generator: Poedit 2.3\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#, fuzzy
msgid "\"Merge\" and \"Into\" must not be the same"
Expand Down Expand Up @@ -4950,6 +4951,9 @@ msgctxt "Field"
msgid "Updated At"
msgstr "Mis à jour à"

msgid "Use my household address"
msgstr "Utiliser mon adresse personnelle "

#, fuzzy
msgid "User"
msgstr "Utilisateur"
Expand Down
5 changes: 4 additions & 1 deletion apps/hygeia_gettext/priv/gettext/it/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
"X-Generator: Poedit 2.3\n"

#, fuzzy
msgid "\"Merge\" and \"Into\" must not be the same"
Expand Down Expand Up @@ -4458,6 +4458,9 @@ msgctxt "Field"
msgid "Updated At"
msgstr "Aggiornato a"

msgid "Use my household address"
msgstr "Usa il mio indirizzo di casa"

#, fuzzy
msgid "User"
msgstr "Utente"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ defmodule HygeiaWeb.PossibleIndexSubmissionLive.Create do

use HygeiaWeb, :surface_view

import Ecto.Changeset

alias Phoenix.LiveView.Socket

alias Hygeia.AutoTracingContext
alias Hygeia.CaseContext
alias Hygeia.CaseContext.Case
Expand All @@ -25,7 +29,7 @@ defmodule HygeiaWeb.PossibleIndexSubmissionLive.Create do

@impl Phoenix.LiveView
def mount(%{"case_uuid" => case_uuid} = params, _session, socket) do
case = case_uuid |> CaseContext.get_case!() |> Repo.preload(auto_tracing: [])
case = case_uuid |> CaseContext.get_case!() |> Repo.preload(person: [], auto_tracing: [])
auth = get_auth(socket)

socket =
Expand All @@ -51,6 +55,7 @@ defmodule HygeiaWeb.PossibleIndexSubmissionLive.Create do
true ->
assign(socket,
case: case,
person: case.person,
changeset:
case
|> Ecto.build_assoc(:possible_index_submissions)
Expand All @@ -76,6 +81,14 @@ defmodule HygeiaWeb.PossibleIndexSubmissionLive.Create do
})}
end

def handle_event(
"copy_household_address",
_params,
%Socket{assigns: %{changeset: changeset, person: person}} = socket
) do
{:noreply, assign(socket, changeset: put_embed(changeset, :address, person.address))}
end

def handle_event("goto_step", %{"active" => "1", "step" => step}, socket),
do: {:noreply, assign(socket, step: String.to_existing_atom(step))}

Expand Down Expand Up @@ -144,7 +157,7 @@ defmodule HygeiaWeb.PossibleIndexSubmissionLive.Create do
defp has_error?(%Ecto.Changeset{errors: errors} = changeset, [relation_or_embed | path_tail]) do
Keyword.has_key?(errors, relation_or_embed) ||
changeset
|> Ecto.Changeset.get_change(relation_or_embed)
|> get_change(relation_or_embed)
|> has_error?(path_tail)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,18 @@
</div>

<div :show={@step == :address} id="step_address">
<h2>
{gettext(
"Where does %{first_name} %{last_name} live?",
first_name: Phoenix.HTML.FormData.input_value(form.source, form, :first_name),
last_name: Phoenix.HTML.FormData.input_value(form.source, form, :last_name)
)}
</h2>
<div class="d-flex">
<h2>
{gettext(
"Where does %{first_name} %{last_name} live?",
first_name: Phoenix.HTML.FormData.input_value(form.source, form, :first_name),
last_name: Phoenix.HTML.FormData.input_value(form.source, form, :last_name)
)}
</h2>
<button type="button" class="btn btn-outline-info ms-auto" :on-click="copy_household_address">
{gettext("Use my household address")}
</button>
</div>

<Inputs for={:address}>
<HygeiaWeb.AddressForm id="address" />
Expand Down

0 comments on commit f987a11

Please sign in to comment.