Skip to content

Commit

Permalink
Merge pull request #481 from eyra/make-consent-optional
Browse files Browse the repository at this point in the history
Made consent optional in assignment settings
  • Loading branch information
mellelieuwes authored Nov 21, 2023
2 parents edfa9e7 + 794b848 commit 1f8b458
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 315 deletions.
81 changes: 81 additions & 0 deletions core/frameworks/pixel/components/switch.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
defmodule Frameworks.Pixel.Switch do
use CoreWeb, :live_component_fabric
use Fabric.LiveComponent

alias Frameworks.Pixel

# Handle Selector Update
@impl true
def update(%{active_item_id: status, selector_id: :selector}, socket) do
{:ok, socket |> update_status(status)}
end

@impl true
def update(
%{id: id, on_text: on_text, off_text: off_text, opt_in?: opt_in?, status: status},
socket
) do
{
:ok,
socket
|> assign(
id: id,
on_text: on_text,
off_text: off_text,
opt_in?: opt_in?,
status: status
)
|> compose_child(:selector)
}
end

defp update_status(%{assigns: %{status: status}} = socket, new_status)
when status != new_status do
socket
|> assign(status: new_status)
|> send_event(:parent, "switch", %{status: new_status})
end

defp update_status(socket, _status) do
socket
end

@impl true
def compose(:selector, %{
id: id,
on_text: on_text,
off_text: off_text,
opt_in?: opt_in?,
status: status
}) do
off = %{id: :off, value: off_text, active: status == :off}
on = %{id: :on, value: on_text, active: status == :on}

items =
if opt_in? do
[off, on]
else
[on, off]
end

%{
module: Pixel.Selector,
params: %{
grid_options: "flex flex-row gap-8",
items: items,
type: :radio,
optional?: false,
parent: %{id: id, type: __MODULE__}
}
}
end

@impl true
def render(assigns) do
~H"""
<div>
<.stack fabric={@fabric} />
</div>
"""
end
end
24 changes: 16 additions & 8 deletions core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ msgstr "Settings"
msgid "settings.data_storage.title"
msgstr "Storage"

#, elixir-autogen, elixir-format
msgid "panel.title"
msgstr "Panel"

#, elixir-autogen, elixir-format, fuzzy
msgid "panel.label"
msgstr "Select your panel"

#, elixir-autogen, elixir-format, fuzzy
msgid "connect.button"
msgstr "Set up connection"
Expand Down Expand Up @@ -173,3 +165,19 @@ msgstr "<div>Copy the url below and hand it over to your contact person at I&O R
#, elixir-autogen, elixir-format, fuzzy
msgid "panel.liss.connection.annotation"
msgstr "<div>Copy the url below and hand it over to your contact person at LISS. They use this url to send participants to this assignment.</div>"

#, elixir-autogen, elixir-format
msgid "gdpr_form.off.label"
msgstr "Skip consent"

#, elixir-autogen, elixir-format
msgid "gdpr_form.on.label"
msgstr "Show consent"

#, elixir-autogen, elixir-format, fuzzy
msgid "settings.consent.body"
msgstr "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "

#, elixir-autogen, elixir-format, fuzzy
msgid "settings.consent.title"
msgstr "Consent"
24 changes: 0 additions & 24 deletions core/priv/gettext/en/LC_MESSAGES/eyra-project.po
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ msgstr "Settings"
msgid "tabbar.item.config.forward"
msgstr "Go to Settings"

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel"
msgstr "Panel"

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel.forward"
msgstr "Go to Panel"

#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr "Monitor"
Expand Down Expand Up @@ -159,26 +151,10 @@ msgstr "Support"
msgid "tabbar.item.support.forward"
msgstr "Go to Support"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.gdpr"
msgstr "Consent"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.gdpr.forward"
msgstr "Go to Consent"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.settings"
msgstr "Settings"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.settings.forward"
msgstr "Go to Settings"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.invite"
msgstr "Panel"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.invite.forward"
msgstr "Go to Settings"
24 changes: 16 additions & 8 deletions core/priv/gettext/eyra-assignment.pot
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ msgstr ""
msgid "settings.data_storage.title"
msgstr ""

#, elixir-autogen, elixir-format
msgid "panel.title"
msgstr ""

#, elixir-autogen, elixir-format
msgid "panel.label"
msgstr ""

#, elixir-autogen, elixir-format
msgid "connect.button"
msgstr ""
Expand Down Expand Up @@ -173,3 +165,19 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "panel.liss.connection.annotation"
msgstr ""

#, elixir-autogen, elixir-format
msgid "gdpr_form.off.label"
msgstr ""

#, elixir-autogen, elixir-format
msgid "gdpr_form.on.label"
msgstr ""

#, elixir-autogen, elixir-format
msgid "settings.consent.body"
msgstr ""

#, elixir-autogen, elixir-format
msgid "settings.consent.title"
msgstr ""
24 changes: 0 additions & 24 deletions core/priv/gettext/eyra-project.pot
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ msgstr ""
msgid "tabbar.item.config.forward"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel.forward"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr ""
Expand Down Expand Up @@ -159,26 +151,10 @@ msgstr ""
msgid "tabbar.item.support.forward"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.gdpr"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.gdpr.forward"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.settings"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.settings.forward"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.invite"
msgstr ""

#, elixir-autogen, elixir-format
msgid "tabbar.item.invite.forward"
msgstr ""
24 changes: 16 additions & 8 deletions core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ msgstr "Instellingen"
msgid "settings.data_storage.title"
msgstr "Opslag van deelnemers data"

#, elixir-autogen, elixir-format
msgid "panel.title"
msgstr "Panel"

#, elixir-autogen, elixir-format, fuzzy
msgid "panel.label"
msgstr "Selecteer jou panel"

#, elixir-autogen, elixir-format, fuzzy
msgid "connect.button"
msgstr "Koppeling maken"
Expand Down Expand Up @@ -173,3 +165,19 @@ msgstr "<h3>I&O Research</h3><div>Lorem ipsum dolor sit amet, consectetur adipis
#, elixir-autogen, elixir-format, fuzzy
msgid "panel.liss.connection.annotation"
msgstr "<h3>LISS</h3><div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam.</div><div>Ga naar <a href=\"https://www.lissdata.nl\">www.lissdata.nl</a> voor meer informatie.</div>"

#, elixir-autogen, elixir-format
msgid "gdpr_form.off.label"
msgstr "Consent overslaan"

#, elixir-autogen, elixir-format
msgid "gdpr_form.on.label"
msgstr "Consent tonen"

#, elixir-autogen, elixir-format, fuzzy
msgid "settings.consent.body"
msgstr "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "

#, elixir-autogen, elixir-format, fuzzy
msgid "settings.consent.title"
msgstr "Toestemming"
24 changes: 0 additions & 24 deletions core/priv/gettext/nl/LC_MESSAGES/eyra-project.po
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ msgstr "Instellingen"
msgid "tabbar.item.config.forward"
msgstr "Ga naar Instellingen"

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel"
msgstr "Uitnodigen"

#, elixir-autogen, elixir-format
msgid "tabbar.item.panel.forward"
msgstr "Ga naar Uitnodigen"

#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr "Monitor"
Expand Down Expand Up @@ -159,26 +151,10 @@ msgstr "Support"
msgid "tabbar.item.support.forward"
msgstr "Ga naar Support"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.gdpr"
msgstr "Consent"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.gdpr.forward"
msgstr "Ga naar Consent"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.settings"
msgstr "Instellingen"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.settings.forward"
msgstr "Ga naar Instellingen"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.invite"
msgstr "Uitnodigen"

#, elixir-autogen, elixir-format, fuzzy
msgid "tabbar.item.invite.forward"
msgstr "Ga naar Instellingen"
8 changes: 8 additions & 0 deletions core/systems/assignment/_public.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ defmodule Systems.Assignment.Public do
Core.Persister.save(assignment, changeset)
end

def update_consent_agreement(assignment, consent_agreement) do
changeset =
Assignment.Model.changeset(assignment, %{})
|> Ecto.Changeset.put_assoc(:consent_agreement, consent_agreement)

Core.Persister.save(assignment, changeset)
end

def is_owner?(assignment, user) do
Core.Authorization.user_has_role?(user, assignment, :owner)
end
Expand Down
47 changes: 1 addition & 46 deletions core/systems/assignment/content_page_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ defmodule Systems.Assignment.ContentPageBuilder do
end

defp get_tab_keys() do
[:config, :gdpr, :items, :invite]
[:config, :items]
end

defp create_tab(
Expand Down Expand Up @@ -246,28 +246,6 @@ defmodule Systems.Assignment.ContentPageBuilder do
}
end

defp create_tab(
:gdpr,
%{consent_agreement: consent_agreement},
show_errors,
_assigns
) do
ready? = false

%{
id: :gdpr_form,
ready: ready?,
show_errors: show_errors,
title: dgettext("eyra-project", "tabbar.item.gdpr"),
forward_title: dgettext("eyra-project", "tabbar.item.gdpr.forward"),
type: :fullpage,
live_component: Assignment.GdprForm,
props: %{
entity: consent_agreement
}
}
end

defp create_tab(
:support,
assignment,
Expand All @@ -286,29 +264,6 @@ defmodule Systems.Assignment.ContentPageBuilder do
}
end

defp create_tab(
:invite,
assignment,
show_errors,
%{uri_origin: uri_origin}
) do
ready? = false

%{
id: :panel_form,
ready: ready?,
show_errors: show_errors,
title: dgettext("eyra-project", "tabbar.item.panel"),
forward_title: dgettext("eyra-project", "tabbar.item.panel.forward"),
type: :fullpage,
live_component: Assignment.PanelForm,
props: %{
uri_origin: uri_origin,
entity: assignment
}
}
end

defp create_tab(
:monitor,
assignment,
Expand Down
Loading

0 comments on commit 1f8b458

Please sign in to comment.