|
1 |
+ |
//! The weekly review, described rather than built.
|
|
2 |
+ |
//!
|
|
3 |
+ |
//! <!-- wiki: quasi-overview -->
|
|
4 |
+ |
//!
|
|
5 |
+ |
//! Fifth screen ported, after the project dashboard, chosen 2026-08-09 by
|
|
6 |
+ |
//! weight over the events calendar.
|
|
7 |
+ |
//! `weekly-review-render.js` is the heaviest un-described file left at 16
|
|
8 |
+ |
//! `esc()` calls, and the calendar is heavier in lines but not in description:
|
|
9 |
+ |
//! its three renderers are a month grid, a week grid and a mobile day column,
|
|
10 |
+ |
//! which is the shape [`RegionKind::Bespoke`] was named for on the task
|
|
11 |
+ |
//! overview's heatmap. Porting it would produce a screen that is one bespoke
|
|
12 |
+ |
//! region with the JS still filling it, and would teach the vocabulary nothing.
|
|
13 |
+ |
//!
|
|
14 |
+ |
//! The shipped screen is `frontend/js/weekly-review.js` and its render module
|
|
15 |
+ |
//! exactly as before; see [the module above](super) for why both exist at once.
|
|
16 |
+ |
//!
|
|
17 |
+ |
//! This is the first screen that is mostly a *report* rather than a list of
|
|
18 |
+ |
//! things, and it is the first one whose whole content is scoped by something
|
|
19 |
+ |
//! other than an id: every route carries the week. Four things the description
|
|
20 |
+ |
//! could not say turned up, recorded where each one bites.
|
|
21 |
+ |
//!
|
|
22 |
+ |
//! # The shape
|
|
23 |
+ |
//!
|
|
24 |
+ |
//! - `GET /weekly-review` — the whole review, for `?week=` or for this week.
|
|
25 |
+ |
//! - `POST /weekly-review/focus/{id}` — put a task in the week's focus, or take
|
|
26 |
+ |
//! it out, under `focus`.
|
|
27 |
+ |
//! - `POST /weekly-review/focus/clear` — take everything out.
|
|
28 |
+ |
//! - `POST /weekly-review/vacation/{day}` — mark a weekday off, or on again.
|
|
29 |
+ |
//! - `POST /weekly-review/complete` — save the reflection and mark it reviewed.
|
|
30 |
+ |
//!
|
|
31 |
+ |
//! Every described control reaches one of those, which is the standard the
|
|
32 |
+ |
//! contacts port set.
|
|
33 |
+ |
//!
|
|
34 |
+ |
//! # The week is an address, not a variable
|
|
35 |
+ |
//!
|
|
36 |
+ |
//! `weekly-review.js` holds `currentWeekStart` in module scope and re-renders
|
|
37 |
+ |
//! from it. Here it is a query param, per decision 2, so a past week is
|
|
38 |
+ |
//! reachable by address and no state has to survive between two clicks. That
|
|
39 |
+ |
//! carries the same consequence the projects filters did: every action the
|
|
40 |
+ |
//! screen offers has to carry the week it was offered under, or acting silently
|
|
41 |
+ |
//! moves the user to the current week and writes there. [`in_week`] is that,
|
|
42 |
+ |
//! applied to all five routes and to both arrows.
|
|
43 |
+ |
|
|
44 |
+ |
// Handlers take their params by value because `quasi_router::Handler` is a
|
|
45 |
+ |
// plain `fn(&S, Params)` pointer, so the signature is the router's and not a
|
|
46 |
+ |
// choice made here. Same allow, for the same reason, as quasi-axum's tests.
|
|
47 |
+ |
#![allow(clippy::needless_pass_by_value)]
|
|
48 |
+ |
|
|
49 |
+ |
use chrono::{Duration, NaiveDate};
|
|
50 |
+ |
use goingson_core::Task;
|
|
51 |
+ |
use goingson_core::weekly_review::{
|
|
52 |
+ |
self, EventSummary, ProjectHealth, TimelineDayData, WeeklyReviewData,
|
|
53 |
+ |
};
|
|
54 |
+ |
use quasi_router::screen::{Act, Field, Figure, Meter, Row, Tag};
|
|
55 |
+ |
use quasi_router::{Action, Node, RegionKind, Response, RouteError, Router, Screen, Slot};
|
|
56 |
+ |
|
|
57 |
+ |
use crate::commands::gather_weekly_review;
|
|
58 |
+ |
use crate::state::{AppState, DESKTOP_USER_ID};
|
|
59 |
+ |
|
|
60 |
+ |
#[cfg(test)]
|
|
61 |
+ |
mod tests;
|
|
62 |
+ |
|
|
63 |
+ |
/// How many priorities the week's focus holds.
|
|
64 |
+ |
///
|
|
65 |
+ |
/// `weekly-review-render.js:renderFocusSection` counts to 3 and the repository
|
|
66 |
+ |
/// enforces nothing, so this is the screen's rule and it is stated once here
|
|
67 |
+ |
/// rather than in the three places that ask about it.
|
|
68 |
+ |
const FOCUS_SLOTS: usize = 3;
|
|
69 |
+ |
|
|
70 |
+ |
/// The seven weekday names, Monday first.
|
|
71 |
+ |
///
|
|
72 |
+ |
/// The JS draws single letters (`M T W T F S S`), which is a renderer's
|
|
73 |
+ |
/// abbreviation of a name and not the name. A description that said "T" would
|
|
74 |
+ |
/// be handing a terminal and a screen reader the same ambiguity a sighted user
|
|
75 |
+ |
/// resolves from position.
|
|
76 |
+ |
const WEEKDAYS: [&str; 7] = [
|
|
77 |
+ |
"Monday",
|
|
78 |
+ |
"Tuesday",
|
|
79 |
+ |
"Wednesday",
|
|
80 |
+ |
"Thursday",
|
|
81 |
+ |
"Friday",
|
|
82 |
+ |
"Saturday",
|
|
83 |
+ |
"Sunday",
|
|
84 |
+ |
];
|
|
85 |
+ |
|
|
86 |
+ |
/// The week a route was addressed at, or the current one.
|
|
87 |
+ |
///
|
|
88 |
+ |
/// An unparseable `week` is this week rather than a 400, matching
|
|
89 |
+ |
/// `resolve_week_start`'s tolerance at the command layer only in outcome: there
|
|
90 |
+ |
/// a bad value is a client bug worth reporting, and here it is a hand-typed
|
|
91 |
+ |
/// address, where landing on this week is the more useful answer than an error
|
|
92 |
+ |
/// page.
|
|
93 |
+ |
fn week_of(params: &quasi_router::Params) -> NaiveDate {
|
|
94 |
+ |
params
|
|
95 |
+ |
.get("week")
|
|
96 |
+ |
.and_then(weekly_review::parse_week_start)
|
|
97 |
+ |
.unwrap_or_else(weekly_review::current_week_start)
|
|
98 |
+ |
}
|
|
99 |
+ |
|
|
100 |
+ |
/// The same action, still pointed at the week it was offered under.
|
|
101 |
+ |
fn in_week(action: Action, week: NaiveDate) -> Action {
|
|
102 |
+ |
action.with("week", week.to_string())
|
|
103 |
+ |
}
|
|
104 |
+ |
|
|
105 |
+ |
/// Read the week.
|
|
106 |
+ |
fn load(state: &AppState, week: NaiveDate) -> Result<WeeklyReviewData, RouteError> {
|
|
107 |
+ |
gather_weekly_review(state, week).map_err(|error| RouteError::internal(error.to_string()))
|
|
108 |
+ |
}
|
|
109 |
+ |
|
|
110 |
+ |
/// The tone a project's health wears.
|
|
111 |
+ |
///
|
|
112 |
+ |
/// `ProjectHealth::status` is a string the core crate writes and the JS turns
|
|
113 |
+ |
/// into a class name. Both ends of that already agree on three values, so this
|
|
114 |
+ |
/// is the third reader rather than a new vocabulary; an unrecognised one is
|
|
115 |
+ |
/// neutral rather than a panic, because a health string is data and not a
|
|
116 |
+ |
/// contract this screen can enforce.
|
|
117 |
+ |
fn health_tone(status: &str) -> makeover_layout::Tone {
|
|
118 |
+ |
match status {
|
|
119 |
+ |
"healthy" => makeover_layout::Tone::Success,
|
|
120 |
+ |
"warning" => makeover_layout::Tone::Warning,
|
|
121 |
+ |
"danger" => makeover_layout::Tone::Danger,
|
|
122 |
+ |
_ => makeover_layout::Tone::Neutral,
|
|
123 |
+ |
}
|
|
124 |
+ |
}
|
|
125 |
+ |
|
|
126 |
+ |
/// One task, the way every list on this screen writes one.
|
|
127 |
+ |
///
|
|
128 |
+ |
/// The project is `meta` rather than a token: it is a plain trailing fact with
|
|
129 |
+ |
/// no tone of its own and no click to answer, which is the line
|
|
130 |
+ |
/// [`Row::tokens`](quasi_router::screen::Row::tokens) draws.
|
|
131 |
+ |
fn task_row(task: &Task) -> Row {
|
|
132 |
+ |
let row = Row::new(&task.title);
|
|
133 |
+ |
match &task.project_name {
|
|
134 |
+ |
Some(project) => row.meta(project),
|
|
135 |
+ |
None => row,
|
|
136 |
+ |
}
|
|
137 |
+ |
}
|
|
138 |
+ |
|
|
139 |
+ |
/// The week at a glance.
|
|
140 |
+ |
///
|
|
141 |
+ |
/// # The first finding
|
|
142 |
+ |
///
|
|
143 |
+ |
/// **A strip that runs across is described as a list that runs down, and two
|
|
144 |
+ |
/// separate things are lost saying so.**
|
|
145 |
+ |
///
|
|
146 |
+ |
/// The first loss is the direction, and it is not one worth closing. Seven days
|
|
147 |
+ |
/// in a row and seven days in a column are the same seven facts, and a terminal
|
|
148 |
+ |
/// renderer would draw the column whatever the description said. That is
|
|
149 |
+ |
/// [`Node::Stats`]' grouping argument pointed the other way, and it comes out
|
|
150 |
+ |
/// the other way: the set is already one node, so the renderer has what it
|
|
151 |
+ |
/// needs to decide.
|
|
152 |
+ |
///
|
|
153 |
+ |
/// The second is real. The JS encodes each day's counts as up to three dots,
|
|
154 |
+ |
/// capping completed at 3 and events, overdue and due at 2. A dot is a
|
|
155 |
+ |
/// renderer's encoding of a number and the cap is that encoding running out of
|
|
156 |
+ |
/// room, so the description carries the numbers and lets a host that has room
|
|
157 |
+ |
/// draw them as it likes. A day with 9 completed tasks reads as 9 here and as
|
|
158 |
+ |
/// three dots there, and the description is the one that is right.
|
|
159 |
+ |
///
|
|
160 |
+ |
/// Filed as a finding rather than a member: nothing is missing from the
|
|
161 |
+ |
/// vocabulary, and what the JS does is a thing the port should stop doing.
|
|
162 |
+ |
fn timeline(days: &[TimelineDayData]) -> Vec<Node> {
|
|
163 |
+ |
let rows = days.iter().map(|day| {
|
|
164 |
+ |
let mut counts = Vec::new();
|
|
165 |
+ |
if day.completed_count > 0 {
|
|
166 |
+ |
counts.push(format!("{} done", day.completed_count));
|
|
167 |
+ |
}
|
|
168 |
+ |
if day.event_count > 0 {
|
|
169 |
+ |
counts.push(format!("{} events", day.event_count));
|
|
170 |
+ |
}
|
|
171 |
+ |
if day.overdue_count > 0 {
|
|
172 |
+ |
counts.push(format!("{} overdue", day.overdue_count));
|
|
173 |
+ |
}
|
|
174 |
+ |
// Due is a future fact: a day that has passed has no tasks still due on
|
|
175 |
+ |
// it, they are the overdue count above. `renderDayDots` says the same
|
|
176 |
+ |
// with `if (!day.isPast)`.
|
|
177 |
+ |
if !day.is_past && day.due_count > 0 {
|
|
178 |
+ |
counts.push(format!("{} due", day.due_count));
|
|
179 |
+ |
}
|
|
180 |
+ |
|
|
181 |
+ |
let mut row = Row::new(format!("{} {}", day.day_name, day.day_number));
|
|
182 |
+ |
if day.is_today {
|
|
183 |
+ |
row = row.token(Tag::badge("Today").tone(makeover_layout::Tone::Info));
|
|
184 |
+ |
}
|
|
185 |
+ |
if day.is_vacation {
|
|
186 |
+ |
// A day off is why the counts are absent rather than zero, so it is
|
|
187 |
+ |
// a token and not merely a style on the row.
|
|
188 |
+ |
row = row.token(Tag::badge("Day off"));
|
|
189 |
+ |
}
|
|
190 |
+ |
if counts.is_empty() {
|
|
191 |
+ |
row
|
|
192 |
+ |
} else {
|
|
193 |
+ |
row.meta(counts.join(", "))
|
|
194 |
+ |
}
|
|
195 |
+ |
});
|
|
196 |
+ |
|
|
197 |
+ |
vec![Node::section("Week at a Glance"), Node::list(rows)]
|
|
198 |
+ |
}
|
|
199 |
+ |
|
|
200 |
+ |
/// One event, in the compact form both event lists here use.
|
|
201 |
+ |
fn event_row(event: &EventSummary) -> Row {
|
|
202 |
+ |
let row = Row::new(&event.title).meta(&event.formatted_time);
|
|
203 |
+ |
match &event.project_name {
|
|
204 |
+ |
Some(project) => row.token(Tag::badge(project)),
|
|
205 |
+ |
None => row,
|
|
206 |
+ |
}
|
|
207 |
+ |
}
|
|
208 |
+ |
|
|
209 |
+ |
/// The week's events, under the day each fell on.
|
|
210 |
+ |
///
|
|
211 |
+ |
/// A list holds rows and nothing else, so the grouping is headings between
|
|
212 |
+ |
/// lists rather than anything inside one. That is the vocabulary working: the
|
|
213 |
+ |
/// JS wraps each day in a `timeline-events-day` div because it needs somewhere
|
|
214 |
+ |
/// to hang a label, and a heading is what the label actually is.
|
|
215 |
+ |
fn week_events(days: &[TimelineDayData]) -> Vec<Node> {
|
|
216 |
+ |
let with_events: Vec<&TimelineDayData> =
|
|
217 |
+ |
days.iter().filter(|day| !day.events.is_empty()).collect();
|
|
218 |
+ |
if with_events.is_empty() {
|
|
219 |
+ |
return Vec::new();
|
|
220 |
+ |
}
|
|
221 |
+ |
|
|
222 |
+ |
let mut out = vec![Node::section("Week's Events")];
|
|
223 |
+ |
for day in with_events {
|
|
224 |
+ |
out.push(Node::Heading {
|
|
225 |
+ |
level: makeover_layout::Heading::Subsection,
|
|
226 |
+ |
text: format!("{} {}", day.day_name, day.day_number),
|
|
227 |
+ |
});
|
|
228 |
+ |
out.push(Node::list(day.events.iter().map(event_row)));
|
|
229 |
+ |
}
|
|
230 |
+ |
out
|
|
231 |
+ |
}
|
|
232 |
+ |
|
|
233 |
+ |
/// What got done.
|
|
234 |
+ |
///
|
|
235 |
+ |
/// # The second finding
|
|
236 |
+ |
///
|
|
237 |
+ |
/// **A cap that exists to fit a card is not a fact, and the description should
|
|
238 |
+ |
/// not carry it.**
|
|
239 |
+ |
///
|
|
240 |
+ |
/// The JS shows the first 6 completed tasks, the first 3 overdue and the first
|
|
241 |
+ |
/// 3 carried over, with nothing saying there are more. Those numbers are the
|
|
242 |
+ |
/// height of a card in a grid, which is the renderer's problem, and
|
|
243 |
+ |
/// [`Rest`](quasi_router::screen::Rest) is not the answer to them: it wants an
|
|
244 |
+ |
/// action, because `346567f9` was about lists with a real remainder to go and
|
|
245 |
+ |
/// ask for. There is no address here holding "the rest of what you finished" and
|
|
246 |
+ |
/// inventing one would be adding a screen to justify a cap.
|
|
247 |
+ |
///
|
|
248 |
+ |
/// So every list on this screen is whole, and a renderer that can only draw six
|
|
249 |
+ |
/// rows is the thing that decides that. The count stays as a figure beside it,
|
|
250 |
+ |
/// which is the fact the badge was carrying.
|
|
251 |
+ |
fn accomplished(data: &WeeklyReviewData) -> Vec<Node> {
|
|
252 |
+ |
let mut out = vec![
|
|
253 |
+ |
Node::section("Accomplished"),
|
|
254 |
+ |
Node::stats([
|
|
255 |
+ |
Figure::new(data.tasks_completed_count.to_string(), "Tasks Completed")
|
|
256 |
+ |
.tone(makeover_layout::Tone::Success),
|
|
257 |
+ |
Figure::new(data.events_occurred_count.to_string(), "Events Attended"),
|
|
258 |
+ |
]),
|
|
259 |
+ |
];
|
|
260 |
+ |
if data.tasks_completed.is_empty() {
|
|
261 |
+ |
out.push(Node::empty("Nothing completed this week"));
|
|
262 |
+ |
} else {
|
|
263 |
+ |
out.push(Node::list(data.tasks_completed.iter().map(task_row)));
|
|
264 |
+ |
}
|
|
265 |
+ |
out
|
|
266 |
+ |
}
|
|
267 |
+ |
|
|
268 |
+ |
/// What slipped.
|
|
269 |
+ |
///
|
|
270 |
+ |
/// Overdue and carried-over are one list in the JS and one list here, told
|
|
271 |
+ |
/// apart by a token rather than by order: the JS puts overdue first and relies
|
|
272 |
+ |
/// on the reader noticing the red due date, which is a distinction that
|
|
273 |
+ |
/// survives only for someone who can see both halves at once.
|
|
274 |
+ |
fn needs_attention(data: &WeeklyReviewData) -> Vec<Node> {
|
|
275 |
+ |
let mut out = vec![
|
|
276 |
+ |
Node::section("Needs Attention"),
|
|
277 |
+ |
Node::stats([
|
|
278 |
+ |
Figure::new(data.tasks_overdue_count.to_string(), "Overdue").tone(
|
|
279 |
+ |
if data.tasks_overdue_count > 0 {
|
|
280 |
+ |
makeover_layout::Tone::Danger
|
|
281 |
+ |
} else {
|
|
282 |
+ |
makeover_layout::Tone::Neutral
|
|
283 |
+ |
},
|
|
284 |
+ |
),
|
|
285 |
+ |
Figure::new(data.carried_over_count.to_string(), "Carried Over")
|
|
286 |
+ |
.tone(makeover_layout::Tone::Info),
|
|
287 |
+ |
]),
|
|
288 |
+ |
];
|
|
289 |
+ |
|
|
290 |
+ |
let mut rows: Vec<Row> = data
|
|
291 |
+ |
.tasks_overdue
|
|
292 |
+ |
.iter()
|
|
293 |
+ |
.map(|task| {
|
|
294 |
+ |
task_row(task)
|
|
295 |
+ |
.token(Tag::badge("Overdue").tone(makeover_layout::Tone::Danger))
|
|
296 |
+ |
.meta(task.due_formatted())
|
|
297 |
+ |
})
|
|
298 |
+ |
.collect();
|
|
299 |
+ |
rows.extend(
|
|
300 |
+ |
data.carried_over_tasks
|
|
301 |
+ |
.iter()
|
|
302 |
+ |
.map(|task| task_row(task).token(Tag::badge("Carried over"))),
|
|
303 |
+ |
);
|
|
304 |
+ |
|
|
305 |
+ |
if !rows.is_empty() {
|
|
306 |
+ |
out.push(Node::list(rows));
|
|
307 |
+ |
}
|
|
308 |
+ |
out
|
|
309 |
+ |
}
|
|
310 |
+ |
|
|
311 |
+ |
/// What is coming.
|
|
312 |
+ |
fn due_this_week(data: &WeeklyReviewData) -> Vec<Node> {
|
|
313 |
+ |
let mut out = vec![Node::section("Due This Week")];
|
|
314 |
+ |
if data.tasks_due_next_week.is_empty() {
|
|
315 |
+ |
out.push(Node::empty("No tasks due this week"));
|
|
316 |
+ |
} else {
|
|
317 |
+ |
out.push(Node::list(
|
|
318 |
+ |
data.tasks_due_next_week
|
|
319 |
+ |
.iter()
|
|
320 |
+ |
.map(|task| task_row(task).meta(task.due_formatted())),
|
|
321 |
+ |
));
|
|
322 |
+ |
}
|
|
323 |
+ |
out
|
|
324 |
+ |
}
|
|
325 |
+ |
|
|
326 |
+ |
/// The week's priorities.
|
|
327 |
+ |
///
|
|
328 |
+ |
/// # The third finding
|
|
329 |
+ |
///
|
|
330 |
+ |
/// **A place awaiting content has no name in the vocabulary.**
|
|
331 |
+ |
///
|
|
332 |
+ |
/// `renderFocusSection` always draws three slots. A filled one holds a task; an
|
|
333 |
+ |
/// empty one is a real described thing — it is focusable, it says "Press Enter
|
|
334 |
+ |
/// or click a task to add focus", and it is where a chosen task lands. Two
|
|
335 |
+ |
/// filled slots and one empty slot is not a list of two tasks, and describing
|
|
336 |
+ |
/// it as one loses that there is room for a third.
|
|
337 |
+ |
///
|
|
338 |
+ |
/// Every way of saying it inside the vocabulary is worse than not saying it.
|
|
339 |
+ |
/// A row reading "Priority 3 - empty" is a row standing for nothing, which is
|
|
340 |
+ |
/// the thing [`Node::StandIn`] exists to avoid doing per-item, and it would
|
|
341 |
+ |
/// carry no action because the JS's slot is a drop target rather than a control.
|
|
342 |
+ |
///
|
|
343 |
+ |
/// So the description says the fact and drops the furniture: a
|
|
344 |
+ |
/// [`Meter`] of how many of the three are taken, then the chosen ones, then
|
|
345 |
+ |
/// what could fill the rest. A renderer with three boxes to draw has the number
|
|
346 |
+ |
/// it needs to draw them, and one without does not have to pretend.
|
|
347 |
+ |
///
|
|
348 |
+ |
/// Filed against quasicoherent rather than closed here. It is the same shape as
|
|
349 |
+ |
/// the row ruling of 2026-08-08 and probably ends the same way — a slot is a
|
|
350 |
+ |
/// region, and `Slot` already exists — but a region per empty priority is a
|
|
351 |
+ |
/// heavy answer to a light question and it wants a second consumer before
|
|
352 |
+ |
/// anyone reaches for it.
|
|
353 |
+ |
fn focus(data: &WeeklyReviewData, week: NaiveDate) -> Vec<Node> {
|
|
354 |
+ |
let taken = data.focused_tasks.len();
|
|
355 |
+ |
let mut out = vec![
|
|
356 |
+ |
Node::section("This Week's Focus"),
|
|
357 |
+ |
Node::Meter(
|
|
358 |
+ |
Meter::new(
|
|
359 |
+ |
u32::try_from(taken).unwrap_or(u32::MAX),
|
|
360 |
+ |
u32::try_from(FOCUS_SLOTS).unwrap_or(u32::MAX),
|
|
361 |
+ |
)
|
|
362 |
+ |
// Neutral, not success: a full focus list is a week that has been
|
|
363 |
+ |
// planned, and there is nothing good or bad about the number
|
|
364 |
+ |
// itself. The subtask bar's Success would read as "well done for
|
|
365 |
+ |
// picking three".
|
|
366 |
+ |
.label("priorities"),
|
|
367 |
+ |
),
|
|
368 |
+ |
];
|
|
369 |
+ |
|
|
370 |
+ |
if data.focused_tasks.is_empty() {
|
|
371 |
+ |
out.push(Node::empty("No priorities picked for this week"));
|
|
372 |
+ |
} else {
|
|
373 |
+ |
out.push(Node::list(data.focused_tasks.iter().map(|task| {
|
|
374 |
+ |
task_row(task).act(Act::new(
|
|
375 |
+ |
"Remove",
|
|
376 |
+ |
in_week(
|
|
377 |
+ |
Action::post(format!("/weekly-review/focus/{}", task.id))
|
|
378 |
+ |
.with("focus", "false"),
|
|
379 |
+ |
week,
|
|
380 |
+ |
),
|
|
381 |
+ |
))
|
|
382 |
+ |
})));
|
|
383 |
+ |
out.push(Node::act(
|
|
384 |
+ |
"Clear all focus",
|
|
385 |
+ |
in_week(Action::post("/weekly-review/focus/clear"), week),
|
|
386 |
+ |
));
|
|
387 |
+ |
}
|
|
388 |
+ |
|
|
389 |
+ |
// The suggestions are offered only while there is somewhere to put one,
|
|
390 |
+ |
// which is `available.length > 0 && focused.length < 3` in the JS. The
|
|
391 |
+ |
// repository already caps the candidates at 10, so unlike the lists above
|
|
392 |
+ |
// this is a limit in the data rather than in a card.
|
|
393 |
+ |
if taken < FOCUS_SLOTS && !data.available_for_focus.is_empty() {
|
|
394 |
+ |
out.push(Node::Heading {
|
|
395 |
+ |
level: makeover_layout::Heading::Subsection,
|
|
396 |
+ |
text: "Suggested".to_owned(),
|
|
397 |
+ |
});
|
|
398 |
+ |
out.push(Node::list(data.available_for_focus.iter().map(|task| {
|
|
399 |
+ |
task_row(task).act(Act::new(
|
|
400 |
+ |
"Focus",
|
|
401 |
+ |
in_week(
|
|
402 |
+ |
Action::post(format!("/weekly-review/focus/{}", task.id)).with("focus", "true"),
|
|
403 |
+ |
week,
|
|
404 |
+ |
),
|
|
405 |
+ |
))
|
|
406 |
+ |
})));
|
|
407 |
+ |
}
|
|
408 |
+ |
out
|
|
409 |
+ |
}
|
|
410 |
+ |
|
|
411 |
+ |
/// How each project is doing.
|
|
412 |
+ |
fn projects_health(health: &[ProjectHealth]) -> Vec<Node> {
|
|
413 |
+ |
if health.is_empty() {
|
|
414 |
+ |
return Vec::new();
|
|
415 |
+ |
}
|
|
416 |
+ |
|
|
417 |
+ |
vec![
|
|
418 |
+ |
Node::section("Projects Health"),
|
|
419 |
+ |
Node::list(health.iter().map(|project| {
|
|
420 |
+ |
let mut row = Row::new(&project.name)
|
|
421 |
+ |
.meta(format!(
|
|
422 |
+ |
"{} active, {} total",
|
|
423 |
+ |
project.active_count, project.total_count
|
|
424 |
+ |
))
|
|
425 |
+ |
.token(Tag::badge(&project.status).tone(health_tone(&project.status)));
|
|
426 |
+ |
if project.overdue_count > 0 {
|
|
427 |
+ |
row = row.token(
|
|
428 |
+ |
Tag::badge(format!("{} overdue", project.overdue_count))
|
|
429 |
+ |
.tone(makeover_layout::Tone::Danger),
|
|
430 |
+ |
);
|
|
431 |
+ |
}
|
|
432 |
+ |
row
|
|
433 |
+ |
})),
|
|
434 |
+ |
]
|
|
435 |
+ |
}
|
|
436 |
+ |
|
|
437 |
+ |
/// The days marked off.
|
|
438 |
+ |
///
|
|
439 |
+ |
/// The one section here where the vocabulary already had the answer and the
|
|
440 |
+ |
/// port did not have to argue for it. Seven independently latched things, each
|
|
441 |
+ |
/// answering a click, is [`Tag::chip`] with
|
|
442 |
+ |
/// [`latched`](quasi_router::screen::Tag::latched) — which arrived for filter
|
|
443 |
+ |
/// chips and turns out to describe this without a change.
|
|
444 |
+ |
///
|
|
445 |
+ |
/// Not a [`Node::Select`]: that picks one of a set and sends the picked value,
|
|
446 |
+ |
/// and days off are seven yes-or-no answers where any number can be yes.
|
|
447 |
+ |
fn days_off(data: &WeeklyReviewData, week: NaiveDate) -> Vec<Node> {
|
|
448 |
+ |
let mut out = vec![Node::section("Days Off")];
|
|
449 |
+ |
out.extend(WEEKDAYS.iter().enumerate().map(|(index, name)| {
|
|
450 |
+ |
let off = data
|
|
451 |
+ |
.vacation_days
|
|
452 |
+ |
.contains(&u8::try_from(index).unwrap_or(0));
|
|
453 |
+ |
Node::Token(
|
|
454 |
+ |
Tag::chip(
|
|
455 |
+ |
*name,
|
|
456 |
+ |
in_week(
|
|
457 |
+ |
Action::post(format!("/weekly-review/vacation/{index}")),
|
|
458 |
+ |
week,
|
|
459 |
+ |
),
|
|
460 |
+ |
)
|
|
461 |
+ |
.latched(off),
|
|
462 |
+ |
)
|
|
463 |
+ |
}));
|
|
464 |
+ |
out
|
|
465 |
+ |
}
|
|
466 |
+ |
|
|
467 |
+ |
/// Pull one prompt's answer back out of the stored notes.
|
|
468 |
+ |
///
|
|
469 |
+ |
/// The review stores its two answers as one string with the prompts written
|
|
470 |
+ |
/// into it, and `weekly-review-render.js:renderReflection` picks them apart with
|
|
471 |
+ |
/// two regexes. Read here rather than stored apart because the storage is the
|
|
472 |
+ |
/// JS screen's too and it still ships: a described screen that wrote a second
|
|
473 |
+ |
/// format would make the two disagree about a week they both open.
|
|
474 |
+ |
fn prompt_answer(notes: &str, marker: &str, until: Option<&str>) -> String {
|
|
475 |
+ |
let Some(start) = notes.find(marker) else {
|
|
476 |
+ |
return String::new();
|
|
477 |
+ |
};
|
|
478 |
+ |
let rest = ¬es[start + marker.len()..];
|
|
479 |
+ |
let end = until.and_then(|next| rest.find(next)).unwrap_or(rest.len());
|
|
480 |
+ |
rest[..end].trim().to_owned()
|
|
481 |
+ |
}
|
|
482 |
+ |
|
|
483 |
+ |
/// The reflection.
|
|
484 |
+ |
///
|
|
485 |
+ |
/// # The fourth finding
|
|
486 |
+ |
///
|
|
487 |
+ |
/// **A field cannot say its value is a draft.**
|
|
488 |
+ |
///
|
|
489 |
+ |
/// `weekly-review.js` keeps what the user has typed in `localStorage` against
|
|
490 |
+ |
/// the week, restores it over the stored notes on render, and clears it on
|
|
491 |
+ |
/// completion, so a review survives closing the app halfway through writing it.
|
|
492 |
+ |
/// Nothing in [`Field`] can say that: `value` is what the field holds, and
|
|
493 |
+ |
/// whether the host should be keeping unsent keystrokes somewhere is not a
|
|
494 |
+ |
/// property of the value.
|
|
495 |
+ |
///
|
|
496 |
+ |
/// The described screen therefore loses the draft and shows what is stored,
|
|
497 |
+ |
/// which is correct and worse. Filed against quasicoherent rather than worked
|
|
498 |
+ |
/// around, because the workaround is a route that writes on every keystroke and
|
|
499 |
+ |
/// that is a different feature wearing this one's name.
|
|
500 |
+ |
///
|