Skip to content

Commit

Permalink
Feature/2204 add hints (#441)
Browse files Browse the repository at this point in the history
* add hints to mailing form is there are no upcoming sessions

* remove hint that callback url is required

* add hint about canceling and deleting assignments

---------

Co-authored-by: Timo Huber <[email protected]>
  • Loading branch information
timohuber and Timo Huber authored Oct 4, 2024
1 parent 78ac0bb commit 7ea6b9a
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 17 deletions.
3 changes: 3 additions & 0 deletions pool/app/pool_common/entity_i18n.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type t =
| LoginTitle
| MailingDetailTitle of Ptime.t
| MailingDistributionDescription
| MailingExperimentNoUpcomingSession
| MailingExperimentNoUpcomingTimewindow
| MailingExperimentSessionFullyBooked
| MailingNewTitle
| MessageHistory of string
Expand Down Expand Up @@ -211,6 +213,7 @@ type hint =
| ExperimentMailingsRegistrationDisabled
| ExperimentMessageTemplates
| ExperimentSessions
| ExperimentSessionsCancelDelete
| ExperimentSessionsPublic
| ExperimentSmtp of string
| ExperimentStatisticsRegistrationPossible
Expand Down
15 changes: 13 additions & 2 deletions pool/app/pool_common/locales/i18n_de.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ let to_string = function
<li>Drücken Sie die Schaltfläche "Hinzufügen", um den Sortierparameter hinzuzufügen.</li>
<li>Wiederholen Sie diesen Vorgang, um weitere Parameter hinzuzufügen. Sie können sie durch "drag and drop" sortieren.</li>
</ol>|}
| MailingExperimentNoUpcomingSession ->
"Es gibt keine Sessions, an die sich Kontakte anmelden können. Es werden \
keine Einladungen versendet. Legen Sie neue Sessions an, bevor Sie das \
Mailing starten."
| MailingExperimentNoUpcomingTimewindow ->
"Es gibt kein aktives oder zukünftiges Zeitfenster, während dem die \
Teilnehmer die Umfrage beantworten können. Es werden keine Einladungen \
versendet. Legen Sie zuerst ein Zeitfenster an."
| MailingExperimentSessionFullyBooked ->
"Alle Sessions sind ausgebucht. Es werden keine Einladungen versendet \
(unabhängig ob z.Z. Mailings aktiv sind).\n\n\
Expand Down Expand Up @@ -400,6 +408,9 @@ Wenn eine Experimentsprache angegeben ist, werden alle Nachrichten in dieser Spr
| ExperimentSessions ->
{|Alle existierenden Session dieses Experiments.
Sobald sich jemand angemeldet hat, kann die Session nicht mehr gelöscht werden.|}
| ExperimentSessionsCancelDelete ->
{|Wird eine Sessionanmeldung abgesagt, wird der Kontakt darüber informiert und kann sich anschliessend nicht mehr für dieses Experiment anmelden.
Wird eine Sessionanmeldung als gelöscht markiert, wird der Kontkt nicht darüber informiert, kann sich jedoch wieder für dieses Experiment anmelden.|}
| ExperimentSessionsPublic ->
"Hinweis: Möglicherweise werden einzelne Sessions oder komplette \
Experimente nicht mehr angezeigt, obwohl im E-Mail aufgeführt. Sobald \
Expand Down Expand Up @@ -438,8 +449,8 @@ Scheduled: Es läuft kein Mailing, aber zukünftige Mailings sind geplant|}
"Pro Anmeldung ist ein Identifikator für externe Daten obligatorisch \
(spätestens wenn eine Session abgeschlossen wird)."
| SurveyUrl ->
"ine URL inkl. Protokoll. Der URL-Parameter 'callbackUrl' ist \
erforderlich. Z.B.: \
"ine URL inkl. Protokoll. Sie können Informationen an Ihre Umfrage \
übermitteln, indem Sie Query-Parameter zu Ihrere URL hinzufügen. Z.B.: \
https://www.domain.com/survey/id?callbackUrl={callbackUrl}"
| FilterTemplates ->
"Änderungen an einem dieser Filter wird auf alle Experimentfilter \
Expand Down
13 changes: 12 additions & 1 deletion pool/app/pool_common/locales/i18n_en.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ let to_string = function
<li>Press the 'add' button to add the sorting parameter.</li>
<li>Repeat that to add more parameters. You can sort them by dragging and dropping them.</li>
</ol>|}
| MailingExperimentNoUpcomingSession ->
"There are no sessions to which contacts can sign up. No invitations will \
be sent. Create new sessions before you start the mailing."
| MailingExperimentNoUpcomingTimewindow ->
"There is no active or future time window during which participants can \
answer the survey. No invitations will be sent. Create a time window \
first."
| MailingExperimentSessionFullyBooked ->
"All sessions are fully booked. No invitations will be sent (independent \
if mailings are active at the moment).\n\n\
Expand Down Expand Up @@ -393,6 +400,9 @@ By clicking on the template labels below you can open the default text message:
{|All existing session of this experiment.
Once someone has registered for the session, it can no longer be deleted.
|}
| ExperimentSessionsCancelDelete ->
{|Canceling an assignment will inform the contact. The concat will be able to sign up for this experiment again.
Marking an assignment as deleted will not inform the contact. The contact will not be able to sign up for this experiment again.|}
| ExperimentSessionsPublic ->
"Please note: Sessions or completed experiments may no longer be \
displayed, although listed in your email. Once all the available seats \
Expand Down Expand Up @@ -663,7 +673,8 @@ If you trigger the reminders manually now, no more automatic reminders will be s
Only sessions with open spots can be selected.|}
| SurveyUrl ->
"A URL incl. protocol. The url parameter 'callbackUrl' is required. E.g: \
"A URL incl. protocol. You can pass information to your survey by adding \
query parameters. E.g: \
https://www.domain.com/survey/id?callbackUrl={callbackUrl}"
| TagsIntro ->
"The defined tags can be added to several types (e.g. contacts). The tags \
Expand Down
15 changes: 14 additions & 1 deletion pool/web/handler/admin_experiments_mailing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,26 @@ let new_form req =
let result ({ Pool_context.database_label; _ } as context) =
Utils.Lwt_result.map_error (fun err -> err, experiment_path id)
@@ let* experiment = Experiment.find database_label id in
let%lwt has_no_upcoming_session =
match experiment.Experiment.online_experiment with
| None ->
Session.find_upcoming_for_experiment database_label id
||> CCList.is_empty
| Some _ ->
Time_window.find_upcoming_by_experiment database_label id
||> CCOption.is_none
in
let%lwt is_bookable =
Matcher.experiment_has_bookable_spots database_label experiment
match has_no_upcoming_session with
| true -> Lwt.return false
| false ->
Matcher.experiment_has_bookable_spots database_label experiment
in
let* matching_filter_count =
matching_filter_count database_label experiment
in
Page.Admin.Mailing.form
~has_no_upcoming_session
~fully_booked:(not is_bookable)
~matching_filter_count
context
Expand Down
10 changes: 8 additions & 2 deletions pool/web/view/component/component_table.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ let legend_icon_item icon =

let legend_text_item text = div ~a:[ a_class [ "legend-item" ] ] [ txt text ]

let table_legend items =
let table_legend ?hint items =
let hint =
match hint with
| None -> txt ""
| Some hint -> p ~a:[ a_class [ "gap-lg" ] ] [ hint ]
in
items
|> CCList.map (fun (label, item) ->
div
~a:[ a_class [ "flexrow"; "flex-gap"; "align-center" ] ]
[ item; span [ label |> txt ] ])
|> div ~a:[ a_class [ "flexcolumn"; "stack-sm" ] ]
|> fun legend ->
div ~a:[ a_class [ "flexcolumn"; "stack-sm" ] ] (legend @ [ hint ])
;;

let horizontal_table
Expand Down
7 changes: 6 additions & 1 deletion pool/web/view/page/page_admin_assignments.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ module Partials = struct
, legend_text_item Field.(ExternalDataIdAbbr |> show) )
]
in
(if hide_deleted then base else base @ not_matching_filter) |> table_legend
let hint =
Utils.hint_to_string language I18n.ExperimentSessionsCancelDelete
|> HttpUtils.add_line_breaks
in
(if hide_deleted then base else base @ not_matching_filter)
|> table_legend ~hint
;;

let empty language =
Expand Down
31 changes: 21 additions & 10 deletions pool/web/view/page/page_admin_mailings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ let detail

let form
?(mailing : Mailing.t option)
?(has_no_upcoming_session = true)
?(fully_booked = false)
~matching_filter_count
({ Pool_context.language; csrf; _ } as context)
Expand Down Expand Up @@ -507,18 +508,28 @@ let form
]
]
in
let fully_booked_note =
if fully_booked
then
let note =
let open I18n in
let i18n =
match has_no_upcoming_session with
| true ->
CCOption.return
(match Experiment.is_sessionless experiment with
| false -> MailingExperimentNoUpcomingSession
| true -> MailingExperimentNoUpcomingTimewindow)
| false ->
(match fully_booked with
| true -> Some MailingExperimentSessionFullyBooked
| false -> None)
in
match i18n with
| None -> txt ""
| Some i18n ->
div
~a:
[ a_class [ "bg-grey-light"; "border"; "border-radius"; "inset-md" ] ]
[ Pool_common.Utils.text_to_string
language
I18n.MailingExperimentSessionFullyBooked
~a:[ a_class [ "notification"; "warning" ] ]
[ Pool_common.Utils.text_to_string language i18n
|> HttpUtils.add_line_breaks
]
else txt ""
in
let matching_filter_count_note =
p
Expand All @@ -544,7 +555,7 @@ let form
let open Htmx in
div
~a:[ a_class [ "stack" ] ]
([ notification; fully_booked_note; matching_filter_count_note ]
([ notification; note; matching_filter_count_note ]
@ [ form
~a:
[ a_class [ "stack" ]
Expand Down

0 comments on commit 7ea6b9a

Please sign in to comment.