From 5189bb99df96686712bfbbb4fda1197a19cfbc95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 02:32:30 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(web):=20a=20conditional=20cl?= =?UTF-8?q?ass=20has=20never=20reached=20the=20class=20attribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Driving the real page in a browser turned up that `class:foo=(cond)` renders as a literal `class:foo=""` attribute rather than merging into `class`. The boolean is honoured — a false one is omitted — but the name is wrong, so the class never applied. Three states have been invisible since they were written: a finished card never greyed (`card-done`), an overdue deadline chip never turned red, and a dateless one never dimmed. The new parts chip made four. All four are built with the `class!` macro the rest of the file already uses, and a test asserts no `class:` survives into the rendered board. Two fixes the same pass found, both on the subtask block: the new-part field wore a `field-box` around a `field-input`, which is a box inside a box and drew as two; and its label read `Subtasks` where every other label on the page is written upper-case in the string itself. And the dependency picker no longer offers a task its own parts or its own whole. The store refuses that edge — the relationship already exists — so the picker was offering an option that could only ever be refused. --- crates/izlek-web/src/board.rs | 8 ++-- crates/izlek-web/src/detail.rs | 22 ++++++++--- crates/izlek-web/src/i18n.rs | 4 +- crates/izlek-web/tests/http.rs | 68 ++++++++++++++++++++++++++++++++++ style/main.scss | 2 +- 5 files changed, 91 insertions(+), 13 deletions(-) diff --git a/crates/izlek-web/src/board.rs b/crates/izlek-web/src/board.rs index acecf4c..995beed 100644 --- a/crates/izlek-web/src/board.rs +++ b/crates/izlek-web/src/board.rs @@ -14,7 +14,7 @@ use topcoat::context::Cx; use topcoat::router::content::Form; use topcoat::router::request::headers; use topcoat::router::{HeaderName, StatusCode, header, query_params, route}; -use topcoat::view::view; +use topcoat::view::{class, view}; use crate::i18n::{Key, Lang, t}; use crate::server::{Refusal, accounts, mail, require_user, require_writer}; @@ -361,7 +361,7 @@ async fn render_card( .collect(); view! { cx => -
(card.title.clone())
- + (deadline) if let Some(parts) = subtasks.clone() { - (format!("{parts} \u{2630}")) + (format!("{parts} \u{2630}")) } if comments > 0 { (format!("{comments} \u{270e}")) }
diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index 4d9ae79..8d3d4ea 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -321,8 +321,21 @@ async fn load_snapshot( }); } } + // A task's own family is not offered: a parent and its part are + // already related, the store refuses the edge, and a picker that + // offers what will always be refused is a worse control than one that + // does not offer it. + let family: Vec<&str> = detail + .subtasks + .iter() + .map(|part| part.id.as_str()) + .chain(detail.parent.iter().map(|whole| whole.id.as_str())) + .collect(); for task in tasks { - if task.id == detail.id || taken.contains(&task.id.as_str()) { + if task.id == detail.id + || taken.contains(&task.id.as_str()) + || family.contains(&task.id.as_str()) + { continue; } linkable.push(LinkTarget { @@ -1802,11 +1815,8 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) if may_write {
- +
} diff --git a/crates/izlek-web/src/i18n.rs b/crates/izlek-web/src/i18n.rs index e69efa4..3aa2316 100644 --- a/crates/izlek-web/src/i18n.rs +++ b/crates/izlek-web/src/i18n.rs @@ -836,8 +836,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (SubtaskGoesWithIt, Tr) => "alt görevi de silinir", (SubtasksGoWithIt, En) => "subtasks go with it", (SubtasksGoWithIt, Tr) => "alt görevi de silinir", - (Subtasks, En) => "Subtasks", - (Subtasks, Tr) => "Alt görevler", + (Subtasks, En) => "SUBTASKS", + (Subtasks, Tr) => "ALT GÖREVLER", (NoSubtasks, En) => "no subtasks", (NoSubtasks, Tr) => "alt görev yok", (NewSubtask, En) => "Subtask", diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index 7166d93..c6acf92 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -1632,6 +1632,74 @@ async fn a_viewer_may_not_open_or_move_a_subtask() { ); } +#[tokio::test] +async fn a_card_wears_its_conditional_classes() { + // `class:foo=(cond)` renders as a literal attribute in this view macro + // rather than merging into `class`, so every state that used it — a done + // card, an overdue chip, a dateless chip, an open-parts chip — was + // invisible. They are built with `class!` now; this holds that. + let app = App::open().await; + let admin = admin(&app).await; + let columns = columns_of(&app).await; + let task = a_task(&app, &admin, &columns[0], "Undated").await; + + let page = app.get("/", Some(&admin)).await; + let page = String::from_utf8_lossy(&page.bytes); + assert!( + !page.contains("class:"), + "a conditional class rendered as a literal attribute" + ); + assert!( + page.contains("card-deadline card-deadline-none"), + "the dateless chip lost its class" + ); + + // A card in a done column carries card-done, which is what greys it. + let done = columns.last().unwrap(); + app.post( + "/api/move_card", + Some(&admin), + &[ + ("task_id", &task), + ("from_column_id", &columns[0]), + ("to_column_id", done), + ], + ) + .await; + let page = app.get("/", Some(&admin)).await; + let page = String::from_utf8_lossy(&page.bytes); + assert!(page.contains("card card-done"), "a finished card is not marked"); +} + +#[tokio::test] +async fn a_parents_own_part_is_not_offered_as_a_blocker() { + let app = App::open().await; + let admin = admin(&app).await; + let columns = columns_of(&app).await; + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; + let child = a_task(&app, &admin, &columns[0], "Write the CSV writer").await; + let stranger = a_task(&app, &admin, &columns[0], "Unrelated work").await; + app.store.set_parent(&child, Some(&parent)).await.unwrap(); + + // The store refuses a parent-to-part edge, so the picker must not offer + // one: an option that is always refused is a worse control than no option. + let page = app.get(&format!("/?task={parent}"), Some(&admin)).await; + let page = String::from_utf8_lossy(&page.bytes); + let picker = page + .split_once("link-pop") + .map(|(_, rest)| rest.split_once("
").map(|(p, _)| p).unwrap_or(rest)) + .unwrap_or_default() + .to_string(); + assert!( + !picker.contains(&child), + "the picker offered the task's own part" + ); + assert!( + page.contains(&stranger), + "an unrelated task vanished from the page" + ); +} + #[tokio::test] async fn a_drop_decided_against_a_stale_board_is_refused() { let app = App::open().await; diff --git a/style/main.scss b/style/main.scss index fd294b1..6d8ae36 100644 --- a/style/main.scss +++ b/style/main.scss @@ -1960,7 +1960,7 @@ img.avatar { margin-bottom: 8px; } -.subtask-new-box { +.subtask-new-input { flex: 1; min-width: 0; }