Clock time: two boxes, hour and minute, inside the deadline popover
Browse files at this commit88fee1e27bff791f53a06da1c12934c511bf6b46Parent: 264fcca7 changed files +146 -94
- crates/izlek-web/src/board.rs +12 -4
- crates/izlek-web/src/detail.rs +42 -35
- crates/izlek-web/src/i18n.rs +6 -3
- crates/izlek-web/tests/browser/moment.mjs +6 -29
- crates/izlek-web/tests/browser/run.sh +5 -1
- crates/izlek-web/tests/http.rs +55 -19
- style/main.scss +20 -3
crates/izlek-web/src/board.rsmodified+12 -4
| @@ -81,7 +81,8 @@ async fn create_task_shared( | ||
| 81 | 81 | column_id: &str, |
| 82 | 82 | description: &str, |
| 83 | 83 | deadline_raw: &str, |
| 84 | - time_raw: &str, | |
| 84 | + clock_hour: Option<&str>, | |
| 85 | + clock_minute: Option<&str>, | |
| 85 | 86 | ) -> Result<Option<Refusal>> { |
| 86 | 87 | |
| 87 | 88 | let user = match require_writer(cx).await { |
| @@ -93,10 +94,14 @@ async fn create_task_shared( | ||
| 93 | 94 | return Ok(Some(Refusal::EmptyTitle)); |
| 94 | 95 | } |
| 95 | 96 | let zone = izlek_core::detail::parse_zone(&user.timezone); |
| 97 | + let time = match crate::detail::combine_clock(clock_hour, clock_minute) { | |
| 98 | + Ok(time) => time, | |
| 99 | + Err(refusal) => return Ok(Some(refusal)), | |
| 100 | + }; | |
| 96 | 101 | let (deadline, clock_at) = match crate::detail::moment_field( |
| 97 | 102 | Some(deadline_raw), |
| 98 | 103 | (None, None), |
| 99 | - Some(time_raw), | |
| 104 | + time.as_deref(), | |
| 100 | 105 | zone, |
| 101 | 106 | ) { |
| 102 | 107 | Ok(pair) => pair, |
| @@ -161,7 +166,9 @@ struct CreateTaskForm { | ||
| 161 | 166 | #[serde(default)] |
| 162 | 167 | deadline: String, |
| 163 | 168 | #[serde(default)] |
| 164 | - clock_time: String, | |
| 169 | + clock_hour: Option<String>, | |
| 170 | + #[serde(default)] | |
| 171 | + clock_minute: Option<String>, | |
| 165 | 172 | } |
| 166 | 173 | |
| 167 | 174 | /// A browser without script's way onto the board: a real form post, same |
| @@ -174,7 +181,8 @@ async fn create_task(cx: &Cx, Form(input): Form<CreateTaskForm>) -> Redirect { | ||
| 174 | 181 | &input.column_id, |
| 175 | 182 | &input.description, |
| 176 | 183 | &input.deadline, |
| 177 | - &input.clock_time, | |
| 184 | + input.clock_hour.as_deref(), | |
| 185 | + input.clock_minute.as_deref(), | |
| 178 | 186 | ) |
| 179 | 187 | .await? |
| 180 | 188 | { |
crates/izlek-web/src/detail.rsmodified+42 -35
| @@ -236,7 +236,9 @@ struct SaveTaskForm { | ||
| 236 | 236 | #[serde(default)] |
| 237 | 237 | deadline: Option<String>, |
| 238 | 238 | #[serde(default)] |
| 239 | - clock_time: Option<String>, | |
| 239 | + clock_hour: Option<String>, | |
| 240 | + #[serde(default)] | |
| 241 | + clock_minute: Option<String>, | |
| 240 | 242 | } |
| 241 | 243 | |
| 242 | 244 | #[derive(Deserialize)] |
| @@ -542,11 +544,23 @@ fn parse_hhmm(raw: &str) -> Option<(u8, u8)> { | ||
| 542 | 544 | (hour <= 23 && minute <= 59).then_some((hour, minute)) |
| 543 | 545 | } |
| 544 | 546 | |
| 545 | -/// The moment field's menu words: every five minutes of the day, | |
| 546 | -/// zero-padded, the value and the label the same word — the logs filters' | |
| 547 | -/// shape, at 288 options a `data-search` box is what makes it usable. | |
| 548 | -fn clock_steps() -> impl Iterator<Item = String> { | |
| 549 | - (0..24 * 12).map(|step| format!("{:02}:{:02}", step / 12, (step % 12) * 5)) | |
| 547 | +/// The posted hour and minute words as one `HH:MM` for [`moment_field`], | |
| 548 | +/// which stays the one validator of the shape. Both absent: the form said | |
| 549 | +/// nothing about the time. Both empty: the popover's Clear, clearing the | |
| 550 | +/// clock. Both set: the moment, however the hands typed it. One without | |
| 551 | +/// the other is a form gone wrong, not something to guess past. | |
| 552 | +pub(crate) fn combine_clock( | |
| 553 | + hour: Option<&str>, | |
| 554 | + minute: Option<&str>, | |
| 555 | +) -> std::result::Result<Option<String>, Refusal> { | |
| 556 | + match (hour, minute) { | |
| 557 | + (None, None) => Ok(None), | |
| 558 | + (Some(""), Some("")) => Ok(Some(String::new())), | |
| 559 | + (Some(hour), Some(minute)) => { | |
| 560 | + Ok(Some(format!("{}:{}", hour.trim(), minute.trim()))) | |
| 561 | + } | |
| 562 | + _ => Err(Refusal::BadClock), | |
| 563 | + } | |
| 550 | 564 | } |
| 551 | 565 | |
| 552 | 566 | /// Saves the title, the description and the moment field — the deadline day |
| @@ -576,10 +590,14 @@ async fn save_task(cx: &Cx, Form(input): Form<SaveTaskForm>) -> Redirect { | ||
| 576 | 590 | None => facts.description.clone(), |
| 577 | 591 | }; |
| 578 | 592 | let zone = parse_zone(&user.timezone); |
| 593 | + let time = match combine_clock(input.clock_hour.as_deref(), input.clock_minute.as_deref()) { | |
| 594 | + Ok(time) => time, | |
| 595 | + Err(refusal) => return redirect(cx, Some(refusal)), | |
| 596 | + }; | |
| 579 | 597 | let (deadline, clock_at) = match moment_field( |
| 580 | 598 | input.deadline.as_deref(), |
| 581 | 599 | (facts.row.deadline, facts.row.clock_at), |
| 582 | - input.clock_time.as_deref(), | |
| 600 | + time.as_deref(), | |
| 583 | 601 | zone, |
| 584 | 602 | ) { |
| 585 | 603 | Ok(pair) => pair, |
| @@ -1274,7 +1292,7 @@ async fn deadline_control( | ||
| 1274 | 1292 | may_write: bool, |
| 1275 | 1293 | lang: Lang, |
| 1276 | 1294 | ) -> Result { |
| 1277 | - use time::macros::format_description; | |
| 1295 | + | |
| 1278 | 1296 | |
| 1279 | 1297 | let overdue = task.is_overdue(today); |
| 1280 | 1298 | let local = task.clock_at.map(|at| at.to_offset(zone)); |
| @@ -1312,17 +1330,12 @@ async fn deadline_control( | ||
| 1312 | 1330 | } |
| 1313 | 1331 | let toggle = format!("deadline-{}", task.id); |
| 1314 | 1332 | let input_value = task.deadline_input(); |
| 1315 | - let time_selected = local | |
| 1316 | - .map(|at| at.format(&format_description!("[hour]:[minute]"))) | |
| 1317 | - .transpose() | |
| 1333 | + let hour_value = local | |
| 1334 | + .map(|at| format!("{:02}", at.hour())) | |
| 1335 | + .unwrap_or_default(); | |
| 1336 | + let minute_value = local | |
| 1337 | + .map(|at| format!("{:02}", at.minute())) | |
| 1318 | 1338 | .unwrap_or_default(); |
| 1319 | - let steps: Vec<String> = clock_steps().collect(); | |
| 1320 | - // A clock off the five-minute grid is still the truth that is stored: | |
| 1321 | - // its exact option is appended, never rounded onto a step. | |
| 1322 | - let time_exact = time_selected | |
| 1323 | - .as_ref() | |
| 1324 | - .filter(|value| !steps.iter().any(|step| step == *value)) | |
| 1325 | - .cloned(); | |
| 1326 | 1339 | let change_aria = t(lang, Key::ChangeTheDeadline); |
| 1327 | 1340 | let no_deadline = t(lang, Key::NoDeadline); |
| 1328 | 1341 | view! { |
| @@ -1338,15 +1351,11 @@ async fn deadline_control( | ||
| 1338 | 1351 | <form class="pop-form" method="post" action="/api/save_task"> |
| 1339 | 1352 | <input type="hidden" name="task_id" value=(task.id.clone())> |
| 1340 | 1353 | (datepicker_grid(cx, "deadline", &input_value, true, lang).await?) |
| 1341 | - <select class="field-input" name="clock_time" aria-label=(t(lang, Key::ClockTime)) data-autosubmit="" data-search=""> | |
| 1342 | - <option value="">("--")</option> | |
| 1343 | - for time in &steps { | |
| 1344 | - <option value=(time) selected=(time_selected.as_deref() == Some(time.as_str()))>(time)</option> | |
| 1345 | - } | |
| 1346 | - if let Some(value) = &time_exact { | |
| 1347 | - <option value=(value) selected=(true)>(value)</option> | |
| 1348 | - } | |
| 1349 | - </select> | |
| 1354 | + <div class="datepick-time"> | |
| 1355 | + <input class="field-input" name="clock_hour" type="text" inputmode="numeric" maxlength="2" placeholder="HH" aria-label=(t(lang, Key::ClockHour)) value=(hour_value)> | |
| 1356 | + <span class="datepick-colon">(":")</span> | |
| 1357 | + <input class="field-input" name="clock_minute" type="text" inputmode="numeric" maxlength="2" placeholder="MM" aria-label=(t(lang, Key::ClockMinute)) value=(minute_value)> | |
| 1358 | + </div> | |
| 1350 | 1359 | </form> |
| 1351 | 1360 | (refused(cx, "save_task", lang).await?) |
| 1352 | 1361 | </div> |
| @@ -1432,7 +1441,7 @@ pub(crate) async fn datepicker_script(cx: &Cx, lang: Lang) -> Result { | ||
| 1432 | 1441 | var input = panel.querySelector('.datepick-input');\ |
| 1433 | 1442 | if (!input) {{ return; }}\ |
| 1434 | 1443 | input.value = ymd ? (ymd.y + '-' + pad(ymd.m) + '-' + pad(ymd.d)) : '';\ |
| 1435 | - if (!ymd) {{ var clock = panel.querySelector('[name=clock_time]'); if (clock) {{ clock.value = ''; }} }}\ | |
| 1444 | + if (!ymd) {{ var hh = panel.querySelector('[name=clock_hour]'); if (hh) {{ hh.value = ''; }} var mm = panel.querySelector('[name=clock_minute]'); if (mm) {{ mm.value = ''; }} }}\ | |
| 1436 | 1445 | var pop = panel.closest('.datepick-pop');\ |
| 1437 | 1446 | var label = pop.querySelector('.datepick-label');\ |
| 1438 | 1447 | if (label) {{ label.textContent = ymd ? (MONTHS[ymd.m - 1].slice(0, 3) + ' ' + pad(ymd.d)) : label.dataset.empty; }}\ |
| @@ -2570,7 +2579,6 @@ async fn sheet_view( | ||
| 2570 | 2579 | /// as [`task_modal`], with a form posting straight to `/api/create_task`. |
| 2571 | 2580 | /// Wired off the board top bar's "New task" button as `/?new=1`. |
| 2572 | 2581 | pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result { |
| 2573 | - let steps: Vec<String> = clock_steps().collect(); | |
| 2574 | 2582 | view! { |
| 2575 | 2583 | cx => |
| 2576 | 2584 | <div class="modal-scrim"> |
| @@ -2607,12 +2615,11 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) - | ||
| 2607 | 2615 | </label> |
| 2608 | 2616 | <div class="edit-form pop-panel datepick-panel"> |
| 2609 | 2617 | (datepicker_grid(cx, "deadline", "", false, lang).await?) |
| 2610 | - <select class="field-input" name="clock_time" aria-label=(t(lang, Key::ClockTime)) data-search=""> | |
| 2611 | - <option value="">("--")</option> | |
| 2612 | - for time in &steps { | |
| 2613 | - <option value=(time)>(time)</option> | |
| 2614 | - } | |
| 2615 | - </select> | |
| 2618 | + <div class="datepick-time"> | |
| 2619 | + <input class="field-input" name="clock_hour" type="text" inputmode="numeric" maxlength="2" placeholder="HH" aria-label=(t(lang, Key::ClockHour))> | |
| 2620 | + <span class="datepick-colon">(":")</span> | |
| 2621 | + <input class="field-input" name="clock_minute" type="text" inputmode="numeric" maxlength="2" placeholder="MM" aria-label=(t(lang, Key::ClockMinute))> | |
| 2622 | + </div> | |
| 2616 | 2623 | </div> |
| 2617 | 2624 | </div> |
| 2618 | 2625 | </div> |
crates/izlek-web/src/i18n.rsmodified+6 -3
| @@ -358,7 +358,8 @@ pub enum Key { | ||
| 358 | 358 | InvitedByLabel, |
| 359 | 359 | MailBatchLabel, |
| 360 | 360 | ReminderMinutesLabel, |
| 361 | - ClockTime, | |
| 361 | + ClockHour, | |
| 362 | + ClockMinute, | |
| 362 | 363 | } |
| 363 | 364 | |
| 364 | 365 | /// The lone templated phrase — a name in the middle reads worse as two |
| @@ -1019,8 +1020,10 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | ||
| 1019 | 1020 | (MailBatchLabel, Tr) => "Posta gecikmesi (dakika)", |
| 1020 | 1021 | (ReminderMinutesLabel, En) => "Reminder (minutes)", |
| 1021 | 1022 | (ReminderMinutesLabel, Tr) => "Hatırlatma (dakika)", |
| 1022 | - (ClockTime, En) => "Time", | |
| 1023 | - (ClockTime, Tr) => "Saat", | |
| 1023 | + (ClockHour, En) => "Hour", | |
| 1024 | + (ClockHour, Tr) => "Saat", | |
| 1025 | + (ClockMinute, En) => "Minute", | |
| 1026 | + (ClockMinute, Tr) => "Dakika", | |
| 1024 | 1027 | } |
| 1025 | 1028 | } |
| 1026 | 1029 |
crates/izlek-web/tests/browser/moment.mjsmodified+6 -29
| @@ -99,34 +99,11 @@ const chipLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} · 16:20`; | ||
| 99 | 99 | const fieldLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} 16:20`; |
| 100 | 100 | |
| 101 | 101 | |
| 102 | -// The time rides the same panel as a house dropdown: the select is | |
| 103 | -// enhanced into a trigger and a panel, so a hand on it clicks the trigger, | |
| 104 | -// types to filter, and presses the row — which also exercises the search | |
| 105 | -// box the data-search attribute buys. The dd pick writes the select's | |
| 106 | -// value; the modal select carries no data-autosubmit, so nothing posts | |
| 107 | -// until the form's own button. | |
| 108 | -await page.click( | |
| 109 | - '.modal-new-task select[name="clock_time"] >> xpath=preceding-sibling::button[1]', | |
| 110 | -); | |
| 111 | -const menu = page.locator('.dd-panel.dd-open'); | |
| 112 | -await menu.locator('.dd-search').fill('16:'); | |
| 113 | -const filtered = await menu.locator('.dd-search').evaluate((el) => { | |
| 114 | - const panel = el.closest('.dd-panel'); | |
| 115 | - const row = panel.querySelector('.dd-option[data-value="16:20"]'); | |
| 116 | - return { | |
| 117 | - search: el.value, | |
| 118 | - rows: panel.querySelectorAll('.dd-option').length, | |
| 119 | - hidden: panel.querySelectorAll('.dd-option-hidden').length, | |
| 120 | - rowOn: !!row && !row.classList.contains('dd-option-hidden'), | |
| 121 | - }; | |
| 122 | -}); | |
| 123 | -if (filtered.search !== '16:') failures.push(`the search box read '${filtered.search}'`); | |
| 124 | -if (filtered.rows !== 289) failures.push(`the menu holds ${filtered.rows} rows, not 289`); | |
| 125 | -if (!filtered.rowOn) failures.push("typing '16:' did not leave the 16:20 row on the menu"); | |
| 126 | -// Press the row through its own handler. The panel's scroll-close race can | |
| 127 | -// make a point-and-click flake here; the handler is the house code either | |
| 128 | -// way, and the value it writes is asserted below. | |
| 129 | -await menu.locator('.dd-option[data-value="16:20"]').evaluate((el) => el.click()); | |
| 102 | +// The time rides the same panel as two two-digit boxes — hour, colon, | |
| 103 | +// minute — typed before the day press, so the one form post carries both. | |
| 104 | +// Neither box autosubmits: a lone box is half a value. | |
| 105 | +await page.fill('.modal-new-task input[name="clock_hour"]', '16'); | |
| 106 | +await page.fill('.modal-new-task input[name="clock_minute"]', '20'); | |
| 130 | 107 | |
| 131 | 108 | // Then the day press, whose pick() writes the hidden input in place — in |
| 132 | 109 | // the modal nothing autosubmits, so the value is read in the same tick as |
| @@ -145,7 +122,7 @@ if (!/^\d{4}-\d{2}-\d{2}$/.test(written.after)) { | ||
| 145 | 122 | failures.push(`the day pick never wrote the hidden input: '${written.after}'`); |
| 146 | 123 | } |
| 147 | 124 | const atSubmit = await page.evaluate(() => ({ |
| 148 | - time: document.querySelector('.modal-new-task select[name="clock_time"]')?.value, | |
| 125 | + time: `${document.querySelector('.modal-new-task input[name="clock_hour"]')?.value}:${document.querySelector('.modal-new-task input[name="clock_minute"]')?.value}`, | |
| 149 | 126 | day: document.querySelector('.modal-new-task .datepick-input')?.value, |
| 150 | 127 | })); |
| 151 | 128 | if (atSubmit.time !== '16:20') failures.push(`the time box read '${atSubmit.time}' at submit`); |
crates/izlek-web/tests/browser/run.shmodified+5 -1
| @@ -39,7 +39,11 @@ if [[ ! -f $IZLEK_PLAYWRIGHT ]]; then | ||
| 39 | 39 | (cd "$home" && npx playwright install --only-shell chromium) |
| 40 | 40 | fi |
| 41 | 41 | |
| 42 | -cargo build --manifest-path "$repo/Cargo.toml" -p izlek-web | |
| 42 | +# The bundler runs the build itself and rewrites the content-hash files in | |
| 43 | +# target/<profile>/assets. A plain `cargo build` leaves the previous bundle | |
| 44 | +# in place, and the server would serve the old css from it — a css change | |
| 45 | +# would pass every check here while the page shows the last build. | |
| 46 | +(cd "$repo" && topcoat asset bundle -p izlek-web) | |
| 43 | 47 | |
| 44 | 48 | mkdir -p "$work/config" |
| 45 | 49 | printf 'database = "izlek.db"\nlisten = "127.0.0.1:%s"\n' "$port" > "$work/config/izlek.toml" |
crates/izlek-web/tests/http.rsmodified+55 -19
| @@ -8268,7 +8268,8 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { | ||
| 8268 | 8268 | &[ |
| 8269 | 8269 | ("task_id", &task), |
| 8270 | 8270 | ("deadline", "2026-09-02"), |
| 8271 | - ("clock_time", "11:00"), | |
| 8271 | + ("clock_hour", "11"), | |
| 8272 | + ("clock_minute", "00"), | |
| 8272 | 8273 | ], |
| 8273 | 8274 | ) |
| 8274 | 8275 | .await; |
| @@ -8289,7 +8290,8 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { | ||
| 8289 | 8290 | .await; |
| 8290 | 8291 | let html = String::from_utf8_lossy(&page.bytes); |
| 8291 | 8292 | assert!( |
| 8292 | - html.contains(r#"<option value="11:00" selected="">11:00</option>"#), | |
| 8293 | + html.contains(r#"aria-label="Hour" value="11""#) | |
| 8294 | + && html.contains(r#"aria-label="Minute" value="00""#), | |
| 8293 | 8295 | "{html}" |
| 8294 | 8296 | ); |
| 8295 | 8297 | assert!(html.contains(">Sep 02 11:00<"), "{html}"); |
| @@ -8318,7 +8320,8 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { | ||
| 8318 | 8320 | .await; |
| 8319 | 8321 | let html = String::from_utf8_lossy(&shifted.bytes); |
| 8320 | 8322 | assert!( |
| 8321 | - html.contains(r#"<option value="14:00" selected="">14:00</option>"#), | |
| 8323 | + html.contains(r#"aria-label="Hour" value="14""#) | |
| 8324 | + && html.contains(r#"aria-label="Minute" value="00""#), | |
| 8322 | 8325 | "{html}" |
| 8323 | 8326 | ); |
| 8324 | 8327 | assert!(html.contains(">Sep 02 14:00<"), "{html}"); |
| @@ -8337,7 +8340,8 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() { | ||
| 8337 | 8340 | &[ |
| 8338 | 8341 | ("task_id", &task), |
| 8339 | 8342 | ("deadline", "2026-09-02"), |
| 8340 | - ("clock_time", "11:00"), | |
| 8343 | + ("clock_hour", "11"), | |
| 8344 | + ("clock_minute", "00"), | |
| 8341 | 8345 | ], |
| 8342 | 8346 | ) |
| 8343 | 8347 | .await; |
| @@ -8385,7 +8389,7 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() { | ||
| 8385 | 8389 | .post( |
| 8386 | 8390 | "/api/save_task", |
| 8387 | 8391 | Some(&admin_cookie), |
| 8388 | - &[("task_id", &task), ("clock_time", "")], | |
| 8392 | + &[("task_id", &task), ("clock_hour", ""), ("clock_minute", "")], | |
| 8389 | 8393 | ) |
| 8390 | 8394 | .await; |
| 8391 | 8395 | assert!( |
| @@ -8410,13 +8414,16 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() { | ||
| 8410 | 8414 | let html = String::from_utf8_lossy(&page.bytes); |
| 8411 | 8415 | assert!(html.contains(">Sep 02<"), "{html}"); |
| 8412 | 8416 | // An empty time renders as no selected step at all — the bare "--". |
| 8413 | - assert!(html.contains(r#"name="clock_time""#), "{html}"); | |
| 8417 | + assert!( | |
| 8418 | + html.contains(r#"name="clock_hour""#) && html.contains(r#"name="clock_minute""#), | |
| 8419 | + "{html}" | |
| 8420 | + ); | |
| 8414 | 8421 | assert!(!html.contains(">Sep 02 11:00<"), "{html}"); |
| 8415 | 8422 | let saved = app |
| 8416 | 8423 | .post( |
| 8417 | 8424 | "/api/save_task", |
| 8418 | 8425 | Some(&admin_cookie), |
| 8419 | - &[("task_id", &task), ("deadline", ""), ("clock_time", "")], | |
| 8426 | + &[("task_id", &task), ("deadline", ""), ("clock_hour", ""), ("clock_minute", "")], | |
| 8420 | 8427 | ) |
| 8421 | 8428 | .await; |
| 8422 | 8429 | assert!( |
| @@ -8454,7 +8461,8 @@ async fn a_title_edit_keeps_the_clock() { | ||
| 8454 | 8461 | &[ |
| 8455 | 8462 | ("task_id", &task), |
| 8456 | 8463 | ("deadline", "2026-09-02"), |
| 8457 | - ("clock_time", "11:00"), | |
| 8464 | + ("clock_hour", "11"), | |
| 8465 | + ("clock_minute", "00"), | |
| 8458 | 8466 | ], |
| 8459 | 8467 | ) |
| 8460 | 8468 | .await; |
| @@ -8511,7 +8519,8 @@ async fn a_description_edit_keeps_the_clock() { | ||
| 8511 | 8519 | &[ |
| 8512 | 8520 | ("task_id", &task), |
| 8513 | 8521 | ("deadline", "2026-09-02"), |
| 8514 | - ("clock_time", "11:00"), | |
| 8522 | + ("clock_hour", "11"), | |
| 8523 | + ("clock_minute", "00"), | |
| 8515 | 8524 | ], |
| 8516 | 8525 | ) |
| 8517 | 8526 | .await; |
| @@ -8570,7 +8579,7 @@ async fn a_time_that_cannot_be_used_is_refused_and_saves_nothing() { | ||
| 8570 | 8579 | ("task_id", task.as_str()), |
| 8571 | 8580 | ("title", "Renamed"), |
| 8572 | 8581 | ("deadline", "2026-09-02"), |
| 8573 | - ("clock_time", "not-a-time"), | |
| 8582 | + ("clock_hour", "not-a-time"), | |
| 8574 | 8583 | ], |
| 8575 | 8584 | ) |
| 8576 | 8585 | .await; |
| @@ -8602,7 +8611,11 @@ async fn a_time_that_cannot_be_used_is_refused_and_saves_nothing() { | ||
| 8602 | 8611 | "/api/save_task", |
| 8603 | 8612 | Some(&admin_cookie), |
| 8604 | 8613 | &format!("/?task={orphan}"), |
| 8605 | - &[("task_id", orphan.as_str()), ("clock_time", "16:20")], | |
| 8614 | + &[ | |
| 8615 | + ("task_id", orphan.as_str()), | |
| 8616 | + ("clock_hour", "16"), | |
| 8617 | + ("clock_minute", "20"), | |
| 8618 | + ], | |
| 8606 | 8619 | ) |
| 8607 | 8620 | .await; |
| 8608 | 8621 | let location = answer.location.as_deref().unwrap_or_default(); |
| @@ -8612,8 +8625,27 @@ async fn a_time_that_cannot_be_used_is_refused_and_saves_nothing() { | ||
| 8612 | 8625 | ); |
| 8613 | 8626 | let facts = app.store.task(&orphan).await.unwrap().expect("task gone"); |
| 8614 | 8627 | assert!(facts.row.clock_at.is_none(), "a dayless time was stored"); |
| 8628 | + // And the mirror mistake: a minute with no hour is the same half of | |
| 8629 | + // nothing. | |
| 8630 | + let orphan2 = a_task(&app, &admin_cookie, &column, "Orphan Too").await; | |
| 8631 | + let answer = app | |
| 8632 | + .post_without_script( | |
| 8633 | + "/api/save_task", | |
| 8634 | + Some(&admin_cookie), | |
| 8635 | + &format!("/?task={orphan2}"), | |
| 8636 | + &[("task_id", orphan2.as_str()), ("clock_minute", "45")], | |
| 8637 | + ) | |
| 8638 | + .await; | |
| 8639 | + let location = answer.location.as_deref().unwrap_or_default(); | |
| 8640 | + assert!( | |
| 8641 | + location.contains("refusal=bad-clock&on=save_task"), | |
| 8642 | + "{location}" | |
| 8643 | + ); | |
| 8644 | + let facts = app.store.task(&orphan2).await.unwrap().expect("task gone"); | |
| 8645 | + assert!(facts.row.clock_at.is_none(), "a lone minute was stored"); | |
| 8615 | 8646 | } |
| 8616 | 8647 | |
| 8648 | + | |
| 8617 | 8649 | #[tokio::test] |
| 8618 | 8650 | async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline() { |
| 8619 | 8651 | let app = App::open().await; |
| @@ -8647,7 +8679,8 @@ async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline | ||
| 8647 | 8679 | ("title", "Kickoff"), |
| 8648 | 8680 | ("column_id", &column), |
| 8649 | 8681 | ("deadline", "2026-09-02"), |
| 8650 | - ("clock_time", "14:00"), | |
| 8682 | + ("clock_hour", "14"), | |
| 8683 | + ("clock_minute", "00"), | |
| 8651 | 8684 | ], |
| 8652 | 8685 | ) |
| 8653 | 8686 | .await; |
| @@ -8704,7 +8737,7 @@ async fn a_time_set_on_an_existing_day_writes_both_columns() { | ||
| 8704 | 8737 | .post( |
| 8705 | 8738 | "/api/save_task", |
| 8706 | 8739 | Some(&admin_cookie), |
| 8707 | - &[("task_id", &task), ("clock_time", "16:20")], | |
| 8740 | + &[("task_id", &task), ("clock_hour", "16"), ("clock_minute", "20")], | |
| 8708 | 8741 | ) |
| 8709 | 8742 | .await; |
| 8710 | 8743 | assert!( |
| @@ -8733,7 +8766,8 @@ async fn a_time_set_on_an_existing_day_writes_both_columns() { | ||
| 8733 | 8766 | ("title", "Kickoff"), |
| 8734 | 8767 | ("column_id", &column), |
| 8735 | 8768 | ("deadline", "2026-09-10"), |
| 8736 | - ("clock_time", "09:30"), | |
| 8769 | + ("clock_hour", "9"), | |
| 8770 | + ("clock_minute", "30"), | |
| 8737 | 8771 | ], |
| 8738 | 8772 | ) |
| 8739 | 8773 | .await; |
| @@ -8941,7 +8975,8 @@ async fn the_logs_feed_says_the_clock_in_its_own_words() { | ||
| 8941 | 8975 | &[ |
| 8942 | 8976 | ("task_id", &task), |
| 8943 | 8977 | ("deadline", "2026-09-02"), |
| 8944 | - ("clock_time", "11:00"), | |
| 8978 | + ("clock_hour", "11"), | |
| 8979 | + ("clock_minute", "00"), | |
| 8945 | 8980 | ], |
| 8946 | 8981 | ) |
| 8947 | 8982 | .await; |
| @@ -8991,8 +9026,8 @@ async fn the_datepicker_script_guards_a_panel_with_no_day_input() { | ||
| 8991 | 9026 | // The moment field's panel: the grid's hidden day input and the time |
| 8992 | 9027 | // box ride the same form. |
| 8993 | 9028 | assert!( |
| 8994 | - html.contains(r#"name="clock_time" aria-label="Time" data-autosubmit="" data-search="""#), | |
| 8995 | - "the moment select lost its searchable chrome: {html}" | |
| 9029 | + html.contains(r#"name="clock_hour""#) && html.contains(r#"name="clock_minute""#), | |
| 9030 | + "the moment boxes lost their names: {html}" | |
| 8996 | 9031 | ); |
| 8997 | 9032 | assert!(html.contains("datepick-input"), "{html}"); |
| 8998 | 9033 | } |
| @@ -9011,7 +9046,7 @@ async fn an_off_step_clock_renders_itself_not_a_rounded_step() { | ||
| 9011 | 9046 | .post( |
| 9012 | 9047 | "/api/save_task", |
| 9013 | 9048 | Some(&admin_cookie), |
| 9014 | - &[("task_id", &task), ("deadline", "2026-09-02"), ("clock_time", "11:23")], | |
| 9049 | + &[("task_id", &task), ("deadline", "2026-09-02"), ("clock_hour", "11"), ("clock_minute", "23")], | |
| 9015 | 9050 | ) |
| 9016 | 9051 | .await; |
| 9017 | 9052 | assert!( |
| @@ -9027,7 +9062,8 @@ async fn an_off_step_clock_renders_itself_not_a_rounded_step() { | ||
| 9027 | 9062 | let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; |
| 9028 | 9063 | let html = String::from_utf8_lossy(&page.bytes); |
| 9029 | 9064 | assert!( |
| 9030 | - html.contains(r#"<option value="11:23" selected="">11:23</option>"#), | |
| 9065 | + html.contains(r#"aria-label="Hour" value="11""#) | |
| 9066 | + && html.contains(r#"aria-label="Minute" value="23""#), | |
| 9031 | 9067 | "{html}" |
| 9032 | 9068 | ); |
| 9033 | 9069 | assert!(html.contains(">Sep 02 11:23<"), "{html}"); |
style/main.scssmodified+20 -3
| @@ -1920,9 +1920,26 @@ img.avatar { | ||
| 1920 | 1920 | |
| 1921 | 1921 | .datepick-panel { width: 190px; } |
| 1922 | 1922 | |
| 1923 | -// The time menu rides the same panel as the day grid; a select's intrinsic | |
| 1924 | -// width is wider than the panel, so it is told to fill, not to size itself. | |
| 1925 | -.datepick-panel .field-input { width: 100%; } | |
| 1923 | +// The time row rides the same panel as the day grid: two two-digit boxes | |
| 1924 | +// and a colon between them, one line. An input's intrinsic width is wider | |
| 1925 | +// than its half, so each box fills its half and centers what is typed. | |
| 1926 | +.datepick-time { | |
| 1927 | + display: flex; | |
| 1928 | + gap: 4px; | |
| 1929 | + align-items: center; | |
| 1930 | + margin-top: 6px; | |
| 1931 | +} | |
| 1932 | + | |
| 1933 | +.datepick-time .field-input { | |
| 1934 | + width: 100%; | |
| 1935 | + min-width: 0; | |
| 1936 | + text-align: center; | |
| 1937 | +} | |
| 1938 | + | |
| 1939 | +.datepick-colon { | |
| 1940 | + font-family: var(--font-mono); | |
| 1941 | + color: var(--ink-soft); | |
| 1942 | +} | |
| 1926 | 1943 | |
| 1927 | 1944 | .datepick-head { |
| 1928 | 1945 | display: flex; |