diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index b754652..b739da5 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -542,6 +542,13 @@ fn parse_hhmm(raw: &str) -> Option<(u8, u8)> { (hour <= 23 && minute <= 59).then_some((hour, minute)) } +/// The moment field's menu words: every five minutes of the day, +/// zero-padded, the value and the label the same word — the logs filters' +/// shape, at 288 options a `data-search` box is what makes it usable. +fn clock_steps() -> impl Iterator { + (0..24 * 12).map(|step| format!("{:02}:{:02}", step / 12, (step % 12) * 5)) +} + /// Saves the title, the description and the moment field — the deadline day /// with its optional time. Status is not here: the column a task sits in is /// changed by moving it, a call `board.rs` owns. @@ -1305,10 +1312,17 @@ async fn deadline_control( } let toggle = format!("deadline-{}", task.id); let input_value = task.deadline_input(); - let time_value = local + let time_selected = local .map(|at| at.format(&format_description!("[hour]:[minute]"))) .transpose() .unwrap_or_default(); + let steps: Vec = clock_steps().collect(); + // A clock off the five-minute grid is still the truth that is stored: + // its exact option is appended, never rounded onto a step. + let time_exact = time_selected + .as_ref() + .filter(|value| !steps.iter().any(|step| step == *value)) + .cloned(); let change_aria = t(lang, Key::ChangeTheDeadline); let no_deadline = t(lang, Key::NoDeadline); view! { @@ -1324,7 +1338,15 @@ async fn deadline_control(
(datepicker_grid(cx, "deadline", &input_value, true, lang).await?) - +
(refused(cx, "save_task", lang).await?) @@ -2548,6 +2570,7 @@ async fn sheet_view( /// as [`task_modal`], with a form posting straight to `/api/create_task`. /// Wired off the board top bar's "New task" button as `/?new=1`. pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result { + let steps: Vec = clock_steps().collect(); view! { cx => diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index 7b6b49a..6f886b1 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -358,6 +358,7 @@ pub enum Key { InvitedByLabel, MailBatchLabel, ReminderMinutesLabel, + ClockTime, } /// The lone templated phrase — a name in the middle reads worse as two @@ -1018,6 +1019,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (MailBatchLabel, Tr) => "Posta gecikmesi (dakika)", (ReminderMinutesLabel, En) => "Reminder (minutes)", (ReminderMinutesLabel, Tr) => "Hatırlatma (dakika)", + (ClockTime, En) => "Time", + (ClockTime, Tr) => "Saat", } } diff --git a/crates/izlek-web/tests/browser/moment.mjs b/crates/izlek-web/tests/browser/moment.mjs index 9dae324..f6e8bd5 100644 --- a/crates/izlek-web/tests/browser/moment.mjs +++ b/crates/izlek-web/tests/browser/moment.mjs @@ -99,9 +99,34 @@ const chipLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} · 16:20`; const fieldLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} 16:20`; -// The time rides the same panel: typed before the day press, so the one -// form post carries both. -await page.fill('.modal-new-task input[name="clock_time"]', '16:20'); +// The time rides the same panel as a house dropdown: the select is +// enhanced into a trigger and a panel, so a hand on it clicks the trigger, +// types to filter, and presses the row — which also exercises the search +// box the data-search attribute buys. The dd pick writes the select's +// value; the modal select carries no data-autosubmit, so nothing posts +// until the form's own button. +await page.click( + '.modal-new-task select[name="clock_time"] >> xpath=preceding-sibling::button[1]', +); +const menu = page.locator('.dd-panel.dd-open'); +await menu.locator('.dd-search').fill('16:'); +const filtered = await menu.locator('.dd-search').evaluate((el) => { + const panel = el.closest('.dd-panel'); + const row = panel.querySelector('.dd-option[data-value="16:20"]'); + return { + search: el.value, + rows: panel.querySelectorAll('.dd-option').length, + hidden: panel.querySelectorAll('.dd-option-hidden').length, + rowOn: !!row && !row.classList.contains('dd-option-hidden'), + }; +}); +if (filtered.search !== '16:') failures.push(`the search box read '${filtered.search}'`); +if (filtered.rows !== 289) failures.push(`the menu holds ${filtered.rows} rows, not 289`); +if (!filtered.rowOn) failures.push("typing '16:' did not leave the 16:20 row on the menu"); +// Press the row through its own handler. The panel's scroll-close race can +// make a point-and-click flake here; the handler is the house code either +// way, and the value it writes is asserted below. +await menu.locator('.dd-option[data-value="16:20"]').evaluate((el) => el.click()); // Then the day press, whose pick() writes the hidden input in place — in // the modal nothing autosubmits, so the value is read in the same tick as @@ -120,7 +145,7 @@ if (!/^\d{4}-\d{2}-\d{2}$/.test(written.after)) { failures.push(`the day pick never wrote the hidden input: '${written.after}'`); } const atSubmit = await page.evaluate(() => ({ - time: document.querySelector('.modal-new-task input[name="clock_time"]')?.value, + time: document.querySelector('.modal-new-task select[name="clock_time"]')?.value, day: document.querySelector('.modal-new-task .datepick-input')?.value, })); if (atSubmit.time !== '16:20') failures.push(`the time box read '${atSubmit.time}' at submit`); diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index f398334..0afc0c4 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -8289,7 +8289,7 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { .await; let html = String::from_utf8_lossy(&page.bytes); assert!( - html.contains(r#"inputmode="numeric" value="11:00""#), + html.contains(r#""#), "{html}" ); assert!(html.contains(">Sep 02 11:00<"), "{html}"); @@ -8318,7 +8318,7 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() { .await; let html = String::from_utf8_lossy(&shifted.bytes); assert!( - html.contains(r#"inputmode="numeric" value="14:00""#), + html.contains(r#""#), "{html}" ); assert!(html.contains(">Sep 02 14:00<"), "{html}"); @@ -8409,8 +8409,9 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() { .await; let html = String::from_utf8_lossy(&page.bytes); assert!(html.contains(">Sep 02<"), "{html}"); - // An empty value renders as no value attribute at all — an empty box. - assert!(html.contains(r#"inputmode="numeric">"#), "{html}"); + // An empty time renders as no selected step at all — the bare "--". + assert!(html.contains(r#"name="clock_time""#), "{html}"); + assert!(!html.contains(">Sep 02 11:00<"), "{html}"); let saved = app .post( "/api/save_task", @@ -8989,6 +8990,45 @@ async fn the_datepicker_script_guards_a_panel_with_no_day_input() { ); // The moment field's panel: the grid's hidden day input and the time // box ride the same form. - assert!(html.contains(r#"name="clock_time""#), "{html}"); + assert!( + html.contains(r#"name="clock_time" aria-label="Time" data-autosubmit="" data-search="""#), + "the moment select lost its searchable chrome: {html}" + ); assert!(html.contains("datepick-input"), "{html}"); } + +#[tokio::test] +async fn an_off_step_clock_renders_itself_not_a_rounded_step() { + // A clock that never sat on a five-minute line — one that arrived + // before the menu did — is shown exactly as stored: its own option is + // appended, nothing is rounded onto a step. + let app = App::open().await; + let admin_cookie = admin(&app).await; + let column = first_column(&app).await; + let task = a_task(&app, &admin_cookie, &column, "Ship it").await; + + let saved = app + .post( + "/api/save_task", + Some(&admin_cookie), + &[("task_id", &task), ("deadline", "2026-09-02"), ("clock_time", "11:23")], + ) + .await; + assert!( + !saved + .location + .as_deref() + .unwrap_or_default() + .contains("refusal="), + "{:?}", + saved.location + ); + + let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; + let html = String::from_utf8_lossy(&page.bytes); + assert!( + html.contains(r#""#), + "{html}" + ); + assert!(html.contains(">Sep 02 11:23<"), "{html}"); +} diff --git a/style/main.scss b/style/main.scss index b785cc0..1c5b4f6 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1920,6 +1920,10 @@ img.avatar { .datepick-panel { width: 190px; } +// The time menu rides the same panel as the day grid; a select's intrinsic +// width is wider than the panel, so it is told to fill, not to size itself. +.datepick-panel .field-input { width: 100%; } + .datepick-head { display: flex; align-items: center;