[OCaml] High Intensity Training Online
fix Advance on repeated feedback choices
Handle feedback choice clicks rather than only change events. Browsers do not emit change when a user clicks the already-selected radio, so the repeated score now advances to the following factor like any other choice.
Changed files
lib/web/pages.ml
@@ -1045,7 +1045,7 @@
1045
1045
let feedback_level_buttons field label ~selected =
1046
1046
let choice code text =
1047
1047
tag "label"
1048
Removed:
[ class_ "feedback-choice" ]
1048
Added:
[ class_ "feedback-choice"; Dream_html.attr "data-hito-feedback-choice" ]
1049
1049
[
1050
1050
void "input"
1051
1051
([
@@ -1053,7 +1053,6 @@
1053
1053
Dream_html.string_attr "name" "choice";
1054
1054
Dream_html.string_attr "value" "%s" code;
1055
1055
Dream_html.string_attr "id" "%s-%s" field code;
1056
Removed:
Dream_html.attr "data-hito-feedback-choice";
1057
1056
]
1058
1057
@
1059
1058
if String.equal code selected then [ Dream_html.attr "checked" ]
lib/web/workout_client.ml
@@ -411,7 +411,8 @@
411
411
Js._true)))))
412
412
413
413
(* Selecting a score advances to the next factor without a separate Next
414
Removed:
action. The hidden action field keeps the native POST contract. *)
414
Added:
action. Handle click rather than change so selecting the current score again
415
Added:
follows the same path. The hidden action field keeps the native POST contract. *)
415
416
let feedback_choice event =
416
417
match closest "[data-hito-feedback-choice]" (Dom_html.eventTarget event) with
417
418
| None -> Js._true
@@ -467,7 +468,7 @@
467
468
(Dom_html.handler dialog_click)
468
469
Js._false
469
470
|> ignore;
470
Removed:
Dom_html.addEventListener document Dom_html.Event.change
471
Added:
Dom_html.addEventListener document Dom_html.Event.click
471
472
(Dom_html.handler feedback_choice)
472
473
Js._false
473
474
|> ignore;