refactor remove the recent-feedback section from the logbook

The recent-feedback list restated data already visible elsewhere. Drop it and its presenter argument. Also add the month name to the calendar heading and adjust the logbook tests accordingly.

Commit
7834ba6668ce95c765c1f7021d67aa5ec42ab132
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/presenter/pages.mli
index 091a17f5..db5f655a 100644..100644
@@ -57,7 +57,6 @@
57 57 Dream.request ->
58 58 ?logging:bool ->
59 59 viewer:View_model.Viewer.t ->
60 Removed: ?feedback:View_model.Feedback.report list ->
61 60 ?calendar:View_model.Calendar.t ->
62 61 ?suggest_feedback:bool ->
63 62 ?feedback_open:bool ->
@@ -67,11 +66,10 @@
67 66 page
68 67 (** The logbook: recorded workouts and a modal subjective feedback form that
69 68 shows every factor at once, each optionally rated against the trainee's
70 Removed: usual, with one submit. [feedback] lists past reports, most recent first.
71 Removed: [calendar] is the current month above the table, highlighting days a workout
72 Removed: was performed. [suggest_feedback] shows a prompt inviting feedback, set
73 Removed: after a workout finishes. [feedback_open] renders the modal open for
74 Removed: no-script clients. *)
69 Added: usual, with one submit. [calendar] is the current month above the table,
70 Added: highlighting days a workout was performed. [suggest_feedback] shows a prompt
71 Added: inviting feedback, set after a workout finishes. [feedback_open] renders the
72 Added: modal open for no-script clients. *)
75 73
76 74 val progress :
77 75 Dream.request ->
lib/presenter/pages_logbook.ml
index f31c829c..8a735f64 100644..100644
@@ -84,20 +84,6 @@
84 84 [ tag "h2" [] [ txt "How are you feeling?" ]; feedback_form request ];
85 85 ]
86 86
87 Removed: let feedback_list (reports : View_model.Feedback.report list) =
88 Removed: if reports = [] then []
89 Removed: else
90 Removed: [
91 Removed: tag "ul"
92 Removed: [ class_ "feedback-list" ]
93 Removed: (List.map
94 Removed: (fun (report : View_model.Feedback.report) ->
95 Removed: let signals = String.concat ", " report.signals in
96 Removed: tag "li" []
97 Removed: [ txt "%s" (if signals = "" then "No signals" else signals) ])
98 Removed: reports);
99 Removed: ]
100 Removed:
101 87 let delete_record_dialog request (record : View_model.Logbook_entry.t) =
102 88 tag "dialog"
103 89 [ class_ "confirm-dialog"; Dream_html.attr "open" ]
@@ -261,6 +247,24 @@
261 247
262 248 (* A single month as a week grid. Days that carry a workout are highlighted;
263 249 today is marked. Rendered above the logbook table. *)
250 Added: let calendar_month_name month =
251 Added: List.nth
252 Added: [
253 Added: "January";
254 Added: "February";
255 Added: "March";
256 Added: "April";
257 Added: "May";
258 Added: "June";
259 Added: "July";
260 Added: "August";
261 Added: "September";
262 Added: "October";
263 Added: "November";
264 Added: "December";
265 Added: ]
266 Added: (month - 1)
267 Added:
264 268 let calendar_grid (cal : View_model.Calendar.t) =
265 269 let cell = function
266 270 | View_model.Calendar.Blank -> tag "td" [ class_ "calendar-blank" ] []
@@ -304,6 +308,13 @@
304 308 [ class_ "calendar-header" ]
305 309 [
306 310 arrow ~label:"‹" prev_month "Previous month";
311 Added: tag "span"
312 Added: [ class_ "calendar-month" ]
313 Added: [
314 Added: txt "%s %d"
315 Added: (calendar_month_name cal.selected_month)
316 Added: cal.selected_year;
317 Added: ];
307 318 tag "a"
308 319 [
309 320 href Routes.logbook;
@@ -331,7 +342,7 @@
331 342 ];
332 343 ]
333 344
334 Removed: let logbook request ?(logging = false) ~viewer ?(feedback = []) ?calendar
345 Added: let logbook request ?(logging = false) ~viewer ?calendar
335 346 ?(suggest_feedback = false) ?(feedback_open = false) ?delete_record
336 347 ?expanded_record records =
337 348 ignore expanded_record;
@@ -419,12 +430,9 @@
419 430 ]);
420 431 ]
421 432 (* The subjective-feedback modal stays in the DOM so the Record feedback
422 Removed: button opens it. Past reports, when any, list below; the delete-confirm
423 Removed: dialog appears only when a row asked for it. *)
433 Added: button opens it. The delete-confirm dialog appears only when a row asked
434 Added: for it. *)
424 435 @ [ feedback_modal request ~open_:feedback_open ]
425 Removed: @ (match feedback_list feedback with
426 Removed: | [] -> []
427 Removed: | list -> tag "h2" [] [ txt "Recent feedback" ] :: list)
428 436 @
429 437 match delete_record with
430 438 | Some record -> [ delete_record_dialog request record ]
test/web/logbook.ml
index b91e3632..1947e4be 100644..100644
@@ -769,6 +769,9 @@
769 769 "the calendar is present" true
770 770 (Option.is_some (index_from ~needle:"class=\"calendar\"" page 0));
771 771 Alcotest.(check bool)
772 Added: "the calendar shows the month name" true
773 Added: (Option.is_some (index_from ~needle:"January 1970" page 0));
774 Added: Alcotest.(check bool)
772 775 "a Today link is present" true
773 776 (Option.is_some (index_from ~needle:"calendar-today-link" page 0));
774 777 Alcotest.(check bool)