feat Streamline subjective feedback navigation

Remove the redundant bottom Skip all feedback action. Selecting a score now submits the current factor immediately and advances to the next factor. Replace Next with a Back to previous factor action, keep Skip this factor on scored steps, and use Submit feedback on the final step.

Commit
9a7f6ec7fe74556cb17910cb1386fc3bd552bbaf
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/web/pages.ml
index 5d62ee98..0bee3e9e 100644..100644
@@ -1042,6 +1042,7 @@
1042 1042 Dream_html.string_attr "name" "choice";
1043 1043 Dream_html.string_attr "value" "%s" code;
1044 1044 Dream_html.string_attr "id" "%s-%s" field code;
1045 Added: Dream_html.attr "data-hito-feedback-choice";
1045 1046 ];
1046 1047 tag "span" [] [ txt "%s" text ];
1047 1048 ]
@@ -1104,20 +1105,6 @@
1104 1105 @ if secondary then [ class_ "secondary" ] else [])
1105 1106 [ txt "%s" label ]
1106 1107
1107 Removed: let feedback_cancel_form request =
1108 Removed: tag "form"
1109 Removed: [
1110 Removed: action Routes.cancel_feedback;
1111 Removed: post_form;
1112 Removed: class_ "feedback-cancel-form";
1113 Removed: Dream_html.attr "data-hito-app-form";
1114 Removed: ]
1115 Removed: [
1116 Removed: Dream_html.csrf_tag request;
1117 Removed: feedback_action_button ~action:"cancel" ~label:"Skip all feedback"
1118 Removed: ~secondary:true ();
1119 Removed: ]
1120 Removed:
1121 1108 let feedback_flow_form request flow =
1122 1109 let step = min 5 (max 0 flow.step) in
1123 1110 let fields =
@@ -1149,13 +1136,14 @@
1149 1136 tag "div"
1150 1137 [ class_ "feedback-actions" ]
1151 1138 ((if step > 0 then
1139 Added: let _, previous_label = List.nth feedback_factors (step - 1) in
1152 1140 [
1153 Removed: feedback_action_button ~action:"back" ~label:"Back"
1141 Added: feedback_action_button ~action:"back"
1142 Added: ~label:(Printf.sprintf "Back to %s" previous_label)
1154 1143 ~secondary:true ();
1155 1144 ]
1156 1145 else [])
1157 1146 @ [
1158 Removed: feedback_action_button ~action:"next" ~label:"Next" ();
1159 1147 feedback_action_button ~action:"skip" ~label:"Skip this factor"
1160 1148 ~secondary:true ();
1161 1149 ]);
@@ -1177,11 +1165,9 @@
1177 1165 tag "div"
1178 1166 [ class_ "feedback-actions" ]
1179 1167 [
1180 Removed: feedback_action_button ~action:"back" ~label:"Back"
1181 Removed: ~secondary:true ();
1182 Removed: feedback_action_button ~action:"save" ~label:"Record feedback" ();
1183 Removed: feedback_action_button ~action:"skip" ~label:"Skip this step"
1184 Removed: ~secondary:true ();
1168 Added: feedback_action_button ~action:"back"
1169 Added: ~label:"Back to Perceived difficulty" ~secondary:true ();
1170 Added: feedback_action_button ~action:"save" ~label:"Submit feedback" ();
1185 1171 ];
1186 1172 ]
1187 1173 in
@@ -1227,7 +1213,6 @@
1227 1213 ];
1228 1214 ];
1229 1215 feedback_flow_form request flow;
1230 Removed: feedback_cancel_form request;
1231 1216 ];
1232 1217 ]
1233 1218
lib/web/workout_client.ml
index e5a66408..9eb96aff 100644..100644
@@ -410,6 +410,22 @@
410 410 hidden##setAttribute (Js.string "value") value;
411 411 Js._true)))))
412 412
413 Added: (* Selecting a score advances to the next factor without a separate Next
414 Added: action. The hidden action field keeps the native POST contract. *)
415 Added: let feedback_choice event =
416 Added: match closest "[data-hito-feedback-choice]" (Dom_html.eventTarget event) with
417 Added: | None -> Js._true
418 Added: | Some choice -> (
419 Added: match closest "form" choice with
420 Added: | None -> Js._true
421 Added: | Some form -> (
422 Added: match query_one form "[data-hito-feedback-action-value]" with
423 Added: | None -> Js._true
424 Added: | Some hidden ->
425 Added: hidden##setAttribute (Js.string "value") (Js.string "next");
426 Added: ignore (Js.Unsafe.meth_call form "requestSubmit" [||]);
427 Added: Js._false))
428 Added:
413 429 (* The exercise dropdown navigates the moment its selection changes. It lives in
414 430 a GET form ([data-hito-exercise-form]) that submits to the workout path. The
415 431 client turns a change into a workout-scoped content swap to [?slot=N], so no
@@ -449,6 +465,10 @@
449 465 |> ignore;
450 466 Dom_html.addEventListener document Dom_html.Event.click
451 467 (Dom_html.handler dialog_click)
468 Added: Js._false
469 Added: |> ignore;
470 Added: Dom_html.addEventListener document Dom_html.Event.change
471 Added: (Dom_html.handler feedback_choice)
452 472 Js._false
453 473 |> ignore;
454 474 Dom_html.addEventListener document Dom_html.Event.change