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)> {
542542 (hour <= 23 && minute <= 59).then_some((hour, minute))
543543 }
544544
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+
545552 /// Saves the title, the description and the moment field — the deadline day
546553 /// with its optional time. Status is not here: the column a task sits in is
547554 /// changed by moving it, a call `board.rs` owns.
@@ -1305,10 +1312,17 @@ async fn deadline_control(
13051312 }
13061313 let toggle = format!("deadline-{}", task.id);
13071314 let input_value = task.deadline_input();
1308- let time_value = local
1315+ let time_selected = local
13091316 .map(|at| at.format(&format_description!("[hour]:[minute]")))
13101317 .transpose()
13111318 .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();
13121326 let change_aria = t(lang, Key::ChangeTheDeadline);
13131327 let no_deadline = t(lang, Key::NoDeadline);
13141328 view! {
@@ -1324,7 +1338,15 @@ async fn deadline_control(
13241338 <form class="pop-form" method="post" action="/api/save_task">
13251339 <input type="hidden" name="task_id" value=(task.id.clone())>
13261340 (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>
13281350 </form>
13291351 (refused(cx, "save_task", lang).await?)
13301352 </div>
@@ -2548,6 +2570,7 @@ async fn sheet_view(
25482570 /// as [`task_modal`], with a form posting straight to `/api/create_task`.
25492571 /// Wired off the board top bar's "New task" button as `/?new=1`.
25502572 pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -> Result {
2573+ let steps: Vec<String> = clock_steps().collect();
25512574 view! {
25522575 cx =>
25532576 <div class="modal-scrim">
@@ -2584,7 +2607,12 @@ pub async fn new_task_modal(cx: &Cx, columns: &[(String, String)], lang: Lang) -
25842607 </label>
25852608 <div class="edit-form pop-panel datepick-panel">
25862609 (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>
25882616 </div>
25892617 </div>
25902618 </div>
crates/izlek-web/src/i18n.rsmodified+3 -0
@@ -358,6 +358,7 @@ pub enum Key {
358358 InvitedByLabel,
359359 MailBatchLabel,
360360 ReminderMinutesLabel,
361+ ClockTime,
361362 }
362363
363364 /// 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 {
10181019 (MailBatchLabel, Tr) => "Posta gecikmesi (dakika)",
10191020 (ReminderMinutesLabel, En) => "Reminder (minutes)",
10201021 (ReminderMinutesLabel, Tr) => "Hatırlatma (dakika)",
1022+ (ClockTime, En) => "Time",
1023+ (ClockTime, Tr) => "Saat",
10211024 }
10221025 }
10231026
crates/izlek-web/tests/browser/moment.mjsmodified+29 -4
@@ -99,9 +99,34 @@ const chipLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} · 16:20`;
9999 const fieldLabel = `${MONTHS[picked.month - 1]} ${pad(picked.day)} 16:20`;
100100
101101
102-// The time rides the same panel: typed before the day press, so the one
103-// form post carries both.
104-await page.fill('.modal-new-task input[name="clock_time"]', '16:20');
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());
105130
106131 // Then the day press, whose pick() writes the hidden input in place — in
107132 // 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)) {
120145 failures.push(`the day pick never wrote the hidden input: '${written.after}'`);
121146 }
122147 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,
124149 day: document.querySelector('.modal-new-task .datepick-input')?.value,
125150 }));
126151 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() {
82898289 .await;
82908290 let html = String::from_utf8_lossy(&page.bytes);
82918291 assert!(
8292- html.contains(r#"inputmode="numeric" value="11:00""#),
8292+ html.contains(r#"<option value="11:00" selected="">11:00</option>"#),
82938293 "{html}"
82948294 );
82958295 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() {
83188318 .await;
83198319 let html = String::from_utf8_lossy(&shifted.bytes);
83208320 assert!(
8321- html.contains(r#"inputmode="numeric" value="14:00""#),
8321+ html.contains(r#"<option value="14:00" selected="">14:00</option>"#),
83228322 "{html}"
83238323 );
83248324 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() {
84098409 .await;
84108410 let html = String::from_utf8_lossy(&page.bytes);
84118411 assert!(html.contains(">Sep 02<"), "{html}");
8412- // An empty value renders as no value attribute at all — an empty box.
8413- assert!(html.contains(r#"inputmode="numeric"></form>"#), "{html}");
8412+ // An empty time renders as no selected step at all — the bare "--".
8413+ assert!(html.contains(r#"name="clock_time""#), "{html}");
8414+ assert!(!html.contains(">Sep 02 11:00<"), "{html}");
84148415 let saved = app
84158416 .post(
84168417 "/api/save_task",
@@ -8989,6 +8990,45 @@ async fn the_datepicker_script_guards_a_panel_with_no_day_input() {
89898990 );
89908991 // The moment field's panel: the grid's hidden day input and the time
89918992 // 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+ );
89938997 assert!(html.contains("datepick-input"), "{html}");
89948998 }
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 {
19201920
19211921 .datepick-panel { width: 190px; }
19221922
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+
19231927 .datepick-head {
19241928 display: flex;
19251929 align-items: center;