forge
Explore
Log in

Don't you dare go Hollow

Clock time becomes the logs-style searchable dropdown

Browse files at this commit

264fcca1bf14012d20dddb07414a132a9d268c31Ahmet Kaan GümüşParent: 190d506
The time box inside the deadline popover was a plain text input whose
intrinsic width spilled past the 190px panel; it also accepted anything,
leaving the parse refusal as the only guard. It is now one house
dropdown — select.field-input with data-search, the logs filter's own
pattern: 288 five-minute steps, type to narrow, value equal to label.
A stored clock off the five-minute grid appends its exact option rather
than being rounded. data-autosubmit rides the detail popover (a change
posts the whole form, hidden day input along), the modal's select does
not — the same split the day grid already has. Server contract
untouched: one clock_time field, moment_field as it was.
crates/izlek-web/src/detail.rsmodified+31 -3
@@ -542,6 +542,13 @@ fn parse_hhmm(raw: &str) -> Option<(u8, u8)> {
542 (hour <= 23 && minute <= 59).then_some((hour, minute))542 (hour <= 23 && minute <= 59).then_some((hour, minute))
543 }543 }
544 544
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))
550+}
551+
545 /// Saves the title, the description and the moment field — the deadline day552 /// Saves the title, the description and the moment field — the deadline day
546 /// with its optional time. Status is not here: the column a task sits in is553 /// with its optional time. Status is not here: the column a task sits in is
547 /// changed by moving it, a call `board.rs` owns.554 /// changed by moving it, a call `board.rs` owns.
@@ -1305,10 +1312,17 @@ async fn deadline_control(
1305 }1312 }
1306 let toggle = format!("deadline-{}", task.id);1313 let toggle = format!("deadline-{}", task.id);
1307 let input_value = task.deadline_input();1314 let input_value = task.deadline_input();
1308- let time_value = local1315+ let time_selected = local
1309 .map(|at| at.format(&format_description!("[hour]:[minute]")))1316 .map(|at| at.format(&format_description!("[hour]:[minute]")))
1310 .transpose()1317 .transpose()
1311 .unwrap_or_default();1318 .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();
1312 let change_aria = t(lang, Key::ChangeTheDeadline);1326 let change_aria = t(lang, Key::ChangeTheDeadline);
1313 let no_deadline = t(lang, Key::NoDeadline);1327 let no_deadline = t(lang, Key::NoDeadline);
1314 view! {1328 view! {
@@ -1324,7 +1338,15 @@ async fn deadline_control(
1324 <form class="pop-form" method="post" action="/api/save_task">1338 <form class="pop-form" method="post" action="/api/save_task">
1325 <input type="hidden" name="task_id" value=(task.id.clone())>1339 <input type="hidden" name="task_id" value=(task.id.clone())>
1326 (datepicker_grid(cx, "deadline", &input_value, true, lang).await?)1340 (datepicker_grid(cx, "deadline", &input_value, true, lang).await?)
1327- <input class="field-input" type="text" name="clock_time" maxlength="5" placeholder="16:20" inputmode="numeric" value=(time_value)>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>
1328 </form>1350 </form>
1329 (refused(cx, "save_task", lang).await?)1351 (refused(cx, "save_task", lang).await?)
1330 </div>1352 </div>
@@ -2548,6 +2570,7 @@ async fn sheet_view(
2548 /// as [`task_modal`], with a form posting straight to `/api/create_task`.2570 /// as [`task_modal`], with a form posting straight to `/api/create_task`.
2549 /// Wired off the board top bar's "New task" button as `/?new=1`.2571 /// Wired off the board top bar's "New task" button as `/?new=1`.
2550 pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result {2572 pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result {
2573+ let steps: Vec<String> = clock_steps().collect();
2551 view! {2574 view! {
2552 cx =>2575 cx =>
2553 <div class="modal-scrim">2576 <div class="modal-scrim">
@@ -2584,7 +2607,12 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -
2584 </label>2607 </label>
2585 <div class="edit-form pop-panel datepick-panel">2608 <div class="edit-form pop-panel datepick-panel">
2586 (datepicker_grid(cx, "deadline", "", false, lang).await?)2609 (datepicker_grid(cx, "deadline", "", false, lang).await?)
2587- <input class="field-input" type="text" name="clock_time" maxlength="5" placeholder="16:20" inputmode="numeric">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>
2588 </div>2616 </div>
2589 </div>2617 </div>
2590 </div>2618 </div>
crates/izlek-web/src/i18n.rsmodified+3 -0
@@ -358,6 +358,7 @@ pub enum Key {
358 InvitedByLabel,358 InvitedByLabel,
359 MailBatchLabel,359 MailBatchLabel,
360 ReminderMinutesLabel,360 ReminderMinutesLabel,
361+ ClockTime,
361 }362 }
362 363
363 /// The lone templated phrase — a name in the middle reads worse as two364 /// 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 {
1018 (MailBatchLabel, Tr) => "Posta gecikmesi (dakika)",1019 (MailBatchLabel, Tr) => "Posta gecikmesi (dakika)",
1019 (ReminderMinutesLabel, En) => "Reminder (minutes)",1020 (ReminderMinutesLabel, En) => "Reminder (minutes)",
1020 (ReminderMinutesLabel, Tr) => "Hatırlatma (dakika)",1021 (ReminderMinutesLabel, Tr) => "Hatırlatma (dakika)",
1022+ (ClockTime, En) => "Time",
1023+ (ClockTime, Tr) => "Saat",
1021 }1024 }
1022 }1025 }
1023 1026
crates/izlek-web/tests/browser/moment.mjsmodified+29 -4
@@ -99,9 +99,34 @@ const chipLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} · 16:20`;
99 const fieldLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} 16:20`;99 const fieldLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} 16:20`;
100 100
101 101
102-// The time rides the same panel: typed before the day press, so the one102+// The time rides the same panel as a house dropdown: the select is
103-// form post carries both.103+// enhanced into a trigger and a panel, so a hand on it clicks the trigger,
104-await page.fill('.modal-new-task input[name="clock_time"]', '16:20');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());
105 130
106 // Then the day press, whose pick() writes the hidden input in place — in131 // Then the day press, whose pick() writes the hidden input in place — in
107 // the modal nothing autosubmits, so the value is read in the same tick as132 // 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)) {
120 failures.push(`the day pick never wrote the hidden input: '${written.after}'`);145 failures.push(`the day pick never wrote the hidden input: '${written.after}'`);
121 }146 }
122 const atSubmit = await page.evaluate(() => ({147 const atSubmit = await page.evaluate(() => ({
123- time: document.querySelector('.modal-new-task input[name="clock_time"]')?.value,148+ time: document.querySelector('.modal-new-task select[name="clock_time"]')?.value,
124 day: document.querySelector('.modal-new-task .datepick-input')?.value,149 day: document.querySelector('.modal-new-task .datepick-input')?.value,
125 }));150 }));
126 if (atSubmit.time !== '16:20') failures.push(`the time box read '${atSubmit.time}' at submit`);151 if (atSubmit.time !== '16:20') failures.push(`the time box read '${atSubmit.time}' at submit`);
crates/izlek-web/tests/http.rsmodified+45 -5
@@ -8289,7 +8289,7 @@ async fn a_clock_saved_on_a_task_renders_in_the_viewers_stored_timezone() {
8289 .await;8289 .await;
8290 let html = String::from_utf8_lossy(&page.bytes);8290 let html = String::from_utf8_lossy(&page.bytes);
8291 assert!(8291 assert!(
8292- html.contains(r#"inputmode="numeric" value="11:00""#),8292+ html.contains(r#"<option value="11:00" selected="">11:00</option>"#),
8293 "{html}"8293 "{html}"
8294 );8294 );
8295 assert!(html.contains(">Sep 02 11:00<"), "{html}");8295 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() {
8318 .await;8318 .await;
8319 let html = String::from_utf8_lossy(&shifted.bytes);8319 let html = String::from_utf8_lossy(&shifted.bytes);
8320 assert!(8320 assert!(
8321- html.contains(r#"inputmode="numeric" value="14:00""#),8321+ html.contains(r#"<option value="14:00" selected="">14:00</option>"#),
8322 "{html}"8322 "{html}"
8323 );8323 );
8324 assert!(html.contains(">Sep 02 14:00<"), "{html}");8324 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() {
8409 .await;8409 .await;
8410 let html = String::from_utf8_lossy(&page.bytes);8410 let html = String::from_utf8_lossy(&page.bytes);
8411 assert!(html.contains(">Sep 02<"), "{html}");8411 assert!(html.contains(">Sep 02<"), "{html}");
8412- // An empty value renders as no value attribute at all — an empty box.8412+ // An empty time renders as no selected step at all — the bare "--".
8413- assert!(html.contains(r#"inputmode="numeric"></form>"#), "{html}");8413+ assert!(html.contains(r#"name="clock_time""#), "{html}");
8414+ assert!(!html.contains(">Sep 02 11:00<"), "{html}");
8414 let saved = app8415 let saved = app
8415 .post(8416 .post(
8416 "/api/save_task",8417 "/api/save_task",
@@ -8989,6 +8990,45 @@ async fn the_datepicker_script_guards_a_panel_with_no_day_input() {
8989 );8990 );
8990 // The moment field's panel: the grid's hidden day input and the time8991 // The moment field's panel: the grid's hidden day input and the time
8991 // box ride the same form.8992 // box ride the same form.
8992- assert!(html.contains(r#"name="clock_time""#), "{html}");8993+ assert!(
8994+ html.contains(r#"name="clock_time" aria-label="Time" data-autosubmit="" data-search="""#),
8995+ "the moment select lost its searchable chrome: {html}"
8996+ );
8993 assert!(html.contains("datepick-input"), "{html}");8997 assert!(html.contains("datepick-input"), "{html}");
8994 }8998 }
8999+
9000+#[tokio::test]
9001+async fn an_off_step_clock_renders_itself_not_a_rounded_step() {
9002+ // A clock that never sat on a five-minute line — one that arrived
9003+ // before the menu did — is shown exactly as stored: its own option is
9004+ // appended, nothing is rounded onto a step.
9005+ let app = App::open().await;
9006+ let admin_cookie = admin(&app).await;
9007+ let column = first_column(&app).await;
9008+ let task = a_task(&app, &admin_cookie, &column, "Ship it").await;
9009+
9010+ let saved = app
9011+ .post(
9012+ "/api/save_task",
9013+ Some(&admin_cookie),
9014+ &[("task_id", &task), ("deadline", "2026-09-02"), ("clock_time", "11:23")],
9015+ )
9016+ .await;
9017+ assert!(
9018+ !saved
9019+ .location
9020+ .as_deref()
9021+ .unwrap_or_default()
9022+ .contains("refusal="),
9023+ "{:?}",
9024+ saved.location
9025+ );
9026+
9027+ let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await;
9028+ let html = String::from_utf8_lossy(&page.bytes);
9029+ assert!(
9030+ html.contains(r#"<option value="11:23" selected="">11:23</option>"#),
9031+ "{html}"
9032+ );
9033+ assert!(html.contains(">Sep 02 11:23<"), "{html}");
9034+}
style/main.scssmodified+4 -0
@@ -1920,6 +1920,10 @@ img.avatar {
1920 1920
1921 .datepick-panel { width: 190px; }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%; }
1926+
1923 .datepick-head {1927 .datepick-head {
1924 display: flex;1928 display: flex;
1925 align-items: center;1929 align-items: center;