A task shows its parts, and a part names its whole
Browse files at this commit9f8c3b79f954ce7b02fc467cd451d949bce6f9daParent: 08a79b8- feat
- a task shows its parts, and a part names its whole
12 changed files +983 -18
- crates/izlek-core/src/board.rs +50 -0
- crates/izlek-core/src/detail.rs +61 -5
- crates/izlek-core/src/mail.rs +6 -0
- crates/izlek-core/src/store/turso_store.rs +100 -6
- crates/izlek-core/tests/store.rs +191 -5
- crates/izlek-web/src/board.rs +7 -0
- crates/izlek-web/src/detail.rs +271 -1
- crates/izlek-web/src/i18n.rs +44 -0
- crates/izlek-web/src/logs.rs +2 -0
- crates/izlek-web/src/server.rs +8 -0
- crates/izlek-web/tests/http.rs +203 -0
- style/main.scss +40 -1
crates/izlek-core/src/board.rsmodified+50 -0
| @@ -37,6 +37,11 @@ pub struct TaskRow { | |||
| 37 | pub deadline: Option<Date>, | 37 | pub deadline: Option<Date>, |
| 38 | pub position: f64, | 38 | pub position: f64, |
| 39 | pub done_at: Option<OffsetDateTime>, | 39 | pub done_at: Option<OffsetDateTime>, |
| 40 | + /// The task this one is a subtask of. A row with a parent gets no card of | ||
| 41 | + /// its own on the board — it is counted on its parent's instead — but it | ||
| 42 | + /// is still read with the rest, because a key it owns can appear on | ||
| 43 | + /// somebody else's card as a blocker. | ||
| 44 | + pub parent_id: Option<String>, | ||
| 40 | } | 45 | } |
| 41 | 46 | ||
| 42 | /// One card crossing from one column into another, as it was written. | 47 | /// One card crossing from one column into another, as it was written. |
| @@ -123,6 +128,10 @@ pub struct TaskCard { | |||
| 123 | pub blocked_by: Vec<String>, | 128 | pub blocked_by: Vec<String>, |
| 124 | /// Keys of the tasks waiting on this one. | 129 | /// Keys of the tasks waiting on this one. |
| 125 | pub blocks: Vec<String>, | 130 | pub blocks: Vec<String>, |
| 131 | + /// How many subtasks this card has, and how many of them are finished. | ||
| 132 | + /// Both are zero for a card with none, which is what hides the chip. | ||
| 133 | + pub subtask_total: u32, | ||
| 134 | + pub subtask_done: u32, | ||
| 126 | } | 135 | } |
| 127 | 136 | ||
| 128 | impl TaskCard { | 137 | impl TaskCard { |
| @@ -130,6 +139,19 @@ impl TaskCard { | |||
| 130 | self.done_at.is_some() | 139 | self.done_at.is_some() |
| 131 | } | 140 | } |
| 132 | 141 | ||
| 142 | + /// The `2/5` the card wears, or nothing when the task has no parts. It is | ||
| 143 | + /// also the only place the count appears when a move is refused, which is | ||
| 144 | + /// why the refusal itself does not carry one. | ||
| 145 | + pub fn subtask_label(&self) -> Option<String> { | ||
| 146 | + (self.subtask_total > 0) | ||
| 147 | + .then(|| format!("{}/{}", self.subtask_done, self.subtask_total)) | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + /// Whether finishing this card is currently refused. | ||
| 151 | + pub fn holds_on_subtasks(&self) -> bool { | ||
| 152 | + self.subtask_done < self.subtask_total | ||
| 153 | + } | ||
| 154 | + | ||
| 133 | /// Blocked means something unfinished is in front of it. A finished task is | 155 | /// Blocked means something unfinished is in front of it. A finished task is |
| 134 | /// never counted as blocked, whatever it still points at. | 156 | /// never counted as blocked, whatever it still points at. |
| 135 | pub fn is_blocked(&self) -> bool { | 157 | pub fn is_blocked(&self) -> bool { |
| @@ -306,13 +328,41 @@ pub fn assemble( | |||
| 306 | } | 328 | } |
| 307 | } | 329 | } |
| 308 | 330 | ||
| 331 | + // A subtask is counted on its parent's card, never given one of its own. | ||
| 332 | + let mut subtask_total: HashMap<&str, u32> = HashMap::new(); | ||
| 333 | + let mut subtask_done: HashMap<&str, u32> = HashMap::new(); | ||
| 334 | + for task in &tasks { | ||
| 335 | + if let Some(parent) = task.parent_id.as_deref() { | ||
| 336 | + *subtask_total.entry(parent).or_default() += 1; | ||
| 337 | + if task.done_at.is_some() { | ||
| 338 | + *subtask_done.entry(parent).or_default() += 1; | ||
| 339 | + } | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + let subtask_total: HashMap<String, u32> = subtask_total | ||
| 343 | + .into_iter() | ||
| 344 | + .map(|(id, n)| (id.to_string(), n)) | ||
| 345 | + .collect(); | ||
| 346 | + let subtask_done: HashMap<String, u32> = subtask_done | ||
| 347 | + .into_iter() | ||
| 348 | + .map(|(id, n)| (id.to_string(), n)) | ||
| 349 | + .collect(); | ||
| 350 | + | ||
| 309 | let mut cards: HashMap<String, Vec<TaskCard>> = HashMap::new(); | 351 | let mut cards: HashMap<String, Vec<TaskCard>> = HashMap::new(); |
| 310 | for task in tasks { | 352 | for task in tasks { |
| 353 | + // Read with the rest so its key can appear as a blocker chip, but the | ||
| 354 | + // board is a board of tasks: a subtask reaches its page through its | ||
| 355 | + // parent's. | ||
| 356 | + if task.parent_id.is_some() { | ||
| 357 | + continue; | ||
| 358 | + } | ||
| 311 | let card = TaskCard { | 359 | let card = TaskCard { |
| 312 | comment_count: counts.get(&task.id).copied().unwrap_or(0), | 360 | comment_count: counts.get(&task.id).copied().unwrap_or(0), |
| 313 | assignees: people.remove(&task.id).unwrap_or_default(), | 361 | assignees: people.remove(&task.id).unwrap_or_default(), |
| 314 | blocked_by: blocked_by.remove(&task.id).unwrap_or_default(), | 362 | blocked_by: blocked_by.remove(&task.id).unwrap_or_default(), |
| 315 | blocks: blocks.remove(&task.id).unwrap_or_default(), | 363 | blocks: blocks.remove(&task.id).unwrap_or_default(), |
| 364 | + subtask_total: subtask_total.get(&task.id).copied().unwrap_or(0), | ||
| 365 | + subtask_done: subtask_done.get(&task.id).copied().unwrap_or(0), | ||
| 316 | id: task.id, | 366 | id: task.id, |
| 317 | task_key: task.task_key, | 367 | task_key: task.task_key, |
| 318 | title: task.title, | 368 | title: task.title, |
crates/izlek-core/src/detail.rsmodified+61 -5
| @@ -99,6 +99,25 @@ impl FileLine { | |||
| 99 | 99 | ||
| 100 | /// What deleting a task would take with it. The confirmation step says this | 100 | /// What deleting a task would take with it. The confirmation step says this |
| 101 | /// out loud before the button fires. | 101 | /// out loud before the button fires. |
| 102 | +/// One row in the subtask list on a task's page, and the "part of DZ-14" line | ||
| 103 | +/// on a subtask's own page — the same shape both ways, because a subtask and | ||
| 104 | +/// its parent are the same kind of thing. | ||
| 105 | +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
| 106 | +pub struct SubtaskLine { | ||
| 107 | + pub id: String, | ||
| 108 | + pub task_key: String, | ||
| 109 | + pub title: String, | ||
| 110 | + pub column_id: String, | ||
| 111 | + pub done_at: Option<OffsetDateTime>, | ||
| 112 | + pub assignees: Vec<Person>, | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +impl SubtaskLine { | ||
| 116 | + pub fn is_done(&self) -> bool { | ||
| 117 | + self.done_at.is_some() | ||
| 118 | + } | ||
| 119 | +} | ||
| 120 | + | ||
| 102 | #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | 121 | #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
| 103 | pub struct DeletionCost { | 122 | pub struct DeletionCost { |
| 104 | pub task_key: String, | 123 | pub task_key: String, |
| @@ -108,6 +127,9 @@ pub struct DeletionCost { | |||
| 108 | pub link_count: u32, | 127 | pub link_count: u32, |
| 109 | /// Keys of the tasks that would have nothing in front of them afterwards. | 128 | /// Keys of the tasks that would have nothing in front of them afterwards. |
| 110 | pub frees: Vec<String>, | 129 | pub frees: Vec<String>, |
| 130 | + /// How many subtasks would go with it. A part has no meaning once the | ||
| 131 | + /// whole is gone, so deleting a parent deletes them too. | ||
| 132 | + pub subtask_count: u32, | ||
| 111 | } | 133 | } |
| 112 | 134 | ||
| 113 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | 135 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] |
| @@ -133,6 +155,10 @@ pub enum ActivityKind { | |||
| 133 | Unassigned, | 155 | Unassigned, |
| 134 | Linked, | 156 | Linked, |
| 135 | Unlinked, | 157 | Unlinked, |
| 158 | + /// Filed under another task, and let out of it again. The detail is the | ||
| 159 | + /// other task's key both ways. | ||
| 160 | + Parented, | ||
| 161 | + Unparented, | ||
| 136 | Moved, | 162 | Moved, |
| 137 | Unblocked, | 163 | Unblocked, |
| 138 | Deleted, | 164 | Deleted, |
| @@ -169,6 +195,8 @@ impl ActivityKind { | |||
| 169 | pub fn as_str(&self) -> &str { | 195 | pub fn as_str(&self) -> &str { |
| 170 | match self { | 196 | match self { |
| 171 | ActivityKind::Commented => "commented", | 197 | ActivityKind::Commented => "commented", |
| 198 | + ActivityKind::Parented => "parented", | ||
| 199 | + ActivityKind::Unparented => "unparented", | ||
| 172 | ActivityKind::WorkspaceClaimed => "workspace_claimed", | 200 | ActivityKind::WorkspaceClaimed => "workspace_claimed", |
| 173 | ActivityKind::Invited => "invited", | 201 | ActivityKind::Invited => "invited", |
| 174 | ActivityKind::LinkResent => "link_resent", | 202 | ActivityKind::LinkResent => "link_resent", |
| @@ -216,6 +244,8 @@ impl ActivityKind { | |||
| 216 | "unassigned" => ActivityKind::Unassigned, | 244 | "unassigned" => ActivityKind::Unassigned, |
| 217 | "linked" => ActivityKind::Linked, | 245 | "linked" => ActivityKind::Linked, |
| 218 | "unlinked" => ActivityKind::Unlinked, | 246 | "unlinked" => ActivityKind::Unlinked, |
| 247 | + "parented" => ActivityKind::Parented, | ||
| 248 | + "unparented" => ActivityKind::Unparented, | ||
| 219 | "moved" => ActivityKind::Moved, | 249 | "moved" => ActivityKind::Moved, |
| 220 | "unblocked" => ActivityKind::Unblocked, | 250 | "unblocked" => ActivityKind::Unblocked, |
| 221 | "deleted" => ActivityKind::Deleted, | 251 | "deleted" => ActivityKind::Deleted, |
| @@ -272,6 +302,8 @@ impl ActivityEntry { | |||
| 272 | ActivityKind::Unassigned => format!("unassigned {detail}"), | 302 | ActivityKind::Unassigned => format!("unassigned {detail}"), |
| 273 | ActivityKind::Linked => format!("linked {detail}"), | 303 | ActivityKind::Linked => format!("linked {detail}"), |
| 274 | ActivityKind::Unlinked => format!("unlinked {detail}"), | 304 | ActivityKind::Unlinked => format!("unlinked {detail}"), |
| 305 | + ActivityKind::Parented => format!("made this a part of {detail}"), | ||
| 306 | + ActivityKind::Unparented => format!("released this from {detail}"), | ||
| 275 | ActivityKind::Moved => format!("moved {detail}"), | 307 | ActivityKind::Moved => format!("moved {detail}"), |
| 276 | ActivityKind::Unblocked => format!("unblocked this task — {detail}"), | 308 | ActivityKind::Unblocked => format!("unblocked this task — {detail}"), |
| 277 | ActivityKind::Deleted => "deleted this task".to_string(), | 309 | ActivityKind::Deleted => "deleted this task".to_string(), |
| @@ -412,6 +444,10 @@ pub struct TaskDetail { | |||
| 412 | /// Files hung off this task, oldest first. | 444 | /// Files hung off this task, oldest first. |
| 413 | pub files: Vec<FileLine>, | 445 | pub files: Vec<FileLine>, |
| 414 | pub activity: Vec<ActivityEntry>, | 446 | pub activity: Vec<ActivityEntry>, |
| 447 | + /// The task this one is a part of, when it is one. | ||
| 448 | + pub parent: Option<SubtaskLine>, | ||
| 449 | + /// The parts of this task, oldest first. Always empty for a subtask. | ||
| 450 | + pub subtasks: Vec<SubtaskLine>, | ||
| 415 | } | 451 | } |
| 416 | 452 | ||
| 417 | impl TaskDetail { | 453 | impl TaskDetail { |
| @@ -483,7 +519,7 @@ pub use reads::{DetailReads, load}; | |||
| 483 | mod reads { | 519 | mod reads { |
| 484 | use async_trait::async_trait; | 520 | use async_trait::async_trait; |
| 485 | 521 | ||
| 486 | - use super::{ActivityEntry, Comment, DependencyEdge, FileLine, TaskDetail, TaskFacts}; | 522 | + use super::{ActivityEntry, Comment, DependencyEdge, FileLine, SubtaskLine, TaskDetail, TaskFacts}; |
| 487 | use crate::board::{Column, Person}; | 523 | use crate::board::{Column, Person}; |
| 488 | use crate::store::Result; | 524 | use crate::store::Result; |
| 489 | 525 | ||
| @@ -515,14 +551,21 @@ mod reads { | |||
| 515 | async fn files_for_task(&self, task_id: &str) -> Result<Vec<FileLine>>; | 551 | async fn files_for_task(&self, task_id: &str) -> Result<Vec<FileLine>>; |
| 516 | 552 | ||
| 517 | async fn activity_for_task(&self, task_id: &str) -> Result<Vec<ActivityEntry>>; | 553 | async fn activity_for_task(&self, task_id: &str) -> Result<Vec<ActivityEntry>>; |
| 554 | + | ||
| 555 | + /// A task's parent and its subtasks in one read: `true` marks the | ||
| 556 | + /// parent. One of the two is always empty — a subtask has a parent and | ||
| 557 | + /// no children, a parent has children and no parent of its own — but | ||
| 558 | + /// the query is the same either way, so it is one query either way. | ||
| 559 | + async fn family_for_task(&self, task_id: &str) -> Result<Vec<(bool, SubtaskLine)>>; | ||
| 518 | } | 560 | } |
| 519 | 561 | ||
| 520 | - /// Loads one task detail in eight queries — the task, the board's columns, | 562 | + /// Loads one task detail in nine queries — the task, the board's columns, |
| 521 | /// its assignees, the workspace's writers, both directions of its | 563 | /// its assignees, the workspace's writers, both directions of its |
| 522 | - /// dependencies, its comments, its files and its activity. | 564 | + /// dependencies, its comments, its files, its activity, and its family. |
| 523 | /// | 565 | /// |
| 524 | - /// Eight, not eight-plus-one-per-comment: `a_task_detail_costs_eight_ | 566 | + /// Nine, not nine-plus-one-per-comment or -per-subtask: `a_task_detail_ |
| 525 | - /// queries_whatever_it_carries` in `tests/store.rs` holds that line. | 567 | + /// costs_nine_queries_whatever_it_carries` in `tests/store.rs` holds that |
| 568 | + /// line. | ||
| 526 | pub async fn load( | 569 | pub async fn load( |
| 527 | reads: &dyn DetailReads, | 570 | reads: &dyn DetailReads, |
| 528 | workspace_id: &str, | 571 | workspace_id: &str, |
| @@ -544,6 +587,17 @@ mod reads { | |||
| 544 | let comments = reads.comments_for_task(task_id).await?; | 587 | let comments = reads.comments_for_task(task_id).await?; |
| 545 | let files = reads.files_for_task(task_id).await?; | 588 | let files = reads.files_for_task(task_id).await?; |
| 546 | let activity = reads.activity_for_task(task_id).await?; | 589 | let activity = reads.activity_for_task(task_id).await?; |
| 590 | + let family = reads.family_for_task(task_id).await?; | ||
| 591 | + | ||
| 592 | + let mut parent = None; | ||
| 593 | + let mut subtasks = Vec::new(); | ||
| 594 | + for (is_parent, line) in family { | ||
| 595 | + if is_parent { | ||
| 596 | + parent = Some(line); | ||
| 597 | + } else { | ||
| 598 | + subtasks.push(line); | ||
| 599 | + } | ||
| 600 | + } | ||
| 547 | 601 | ||
| 548 | let Some(column) = columns | 602 | let Some(column) = columns |
| 549 | .iter() | 603 | .iter() |
| @@ -578,6 +632,8 @@ mod reads { | |||
| 578 | comments, | 632 | comments, |
| 579 | files, | 633 | files, |
| 580 | activity, | 634 | activity, |
| 635 | + parent, | ||
| 636 | + subtasks, | ||
| 581 | })) | 637 | })) |
| 582 | } | 638 | } |
| 583 | } | 639 | } |
crates/izlek-core/src/mail.rsmodified+6 -0
| @@ -671,6 +671,12 @@ impl Engine { | |||
| 671 | ActivityKind::Retitled => format!("{} renamed it.", actor), | 671 | ActivityKind::Retitled => format!("{} renamed it.", actor), |
| 672 | ActivityKind::Linked => format!("{} linked {}.", actor, activity.detail), | 672 | ActivityKind::Linked => format!("{} linked {}.", actor, activity.detail), |
| 673 | ActivityKind::Unlinked => format!("{} unlinked {}.", actor, activity.detail), | 673 | ActivityKind::Unlinked => format!("{} unlinked {}.", actor, activity.detail), |
| 674 | + ActivityKind::Parented => { | ||
| 675 | + format!("{} made it a part of {}.", actor, activity.detail) | ||
| 676 | + } | ||
| 677 | + ActivityKind::Unparented => { | ||
| 678 | + format!("{} released it from {}.", actor, activity.detail) | ||
| 679 | + } | ||
| 674 | ActivityKind::Deleted => format!("{} deleted it.", actor), | 680 | ActivityKind::Deleted => format!("{} deleted it.", actor), |
| 675 | // Never a wired trigger — `activity_kind_for` never maps to | 681 | // Never a wired trigger — `activity_kind_for` never maps to |
| 676 | // these — and account/admin kinds have no task to be mailed | 682 | // these — and account/admin kinds have no task to be mailed |
crates/izlek-core/src/store/turso_store.rsmodified+100 -6
| @@ -24,7 +24,7 @@ use crate::Role; | |||
| 24 | use crate::board::{BoardMeta, BoardReads, Column, Moved, Person, TaskRow, Transition}; | 24 | use crate::board::{BoardMeta, BoardReads, Column, Moved, Person, TaskRow, Transition}; |
| 25 | use crate::detail::{ | 25 | use crate::detail::{ |
| 26 | ActivityEntry, ActivityKind, Comment, DeletionCost, DependencyEdge, DetailReads, FileLine, | 26 | ActivityEntry, ActivityKind, Comment, DeletionCost, DependencyEdge, DetailReads, FileLine, |
| 27 | - TaskFacts, | 27 | + SubtaskLine, TaskFacts, |
| 28 | }; | 28 | }; |
| 29 | use time::Date; | 29 | use time::Date; |
| 30 | use time::format_description::BorrowedFormatItem; | 30 | use time::format_description::BorrowedFormatItem; |
| @@ -1466,6 +1466,7 @@ impl Store for TursoStore { | |||
| 1466 | deadline: new.deadline, | 1466 | deadline: new.deadline, |
| 1467 | position, | 1467 | position, |
| 1468 | done_at: None, | 1468 | done_at: None, |
| 1469 | + parent_id: new.parent_id.map(str::to_string), | ||
| 1469 | }, | 1470 | }, |
| 1470 | activity_id, | 1471 | activity_id, |
| 1471 | transition: Transition { | 1472 | transition: Transition { |
| @@ -1588,6 +1589,7 @@ impl Store for TursoStore { | |||
| 1588 | deadline: opt_day(&row, 4)?, | 1589 | deadline: opt_day(&row, 4)?, |
| 1589 | position: row.get::<f64>(5).unwrap_or(0.0), | 1590 | position: row.get::<f64>(5).unwrap_or(0.0), |
| 1590 | done_at: opt_stamp(&row, 6)?, | 1591 | done_at: opt_stamp(&row, 6)?, |
| 1592 | + parent_id: Some(parent_id.to_string()), | ||
| 1591 | }); | 1593 | }); |
| 1592 | } | 1594 | } |
| 1593 | Ok(out) | 1595 | Ok(out) |
| @@ -1628,6 +1630,24 @@ impl Store for TursoStore { | |||
| 1628 | } | 1630 | } |
| 1629 | let stamp = stamp(at)?; | 1631 | let stamp = stamp(at)?; |
| 1630 | 1632 | ||
| 1633 | + // A parent and its own part are already related, and the board would | ||
| 1634 | + // draw the relationship twice: once as a chip, once as the count. | ||
| 1635 | + { | ||
| 1636 | + let conn = self.conn.lock().await; | ||
| 1637 | + let mut rows = conn | ||
| 1638 | + .query( | ||
| 1639 | + "SELECT 1 FROM task WHERE (id = ?1 AND parent_id = ?2) \ | ||
| 1640 | + OR (id = ?2 AND parent_id = ?1) LIMIT 1", | ||
| 1641 | + params![blocked_task_id, blocking_task_id], | ||
| 1642 | + ) | ||
| 1643 | + .await | ||
| 1644 | + .map_err(backend)?; | ||
| 1645 | + let related = rows.next().await.map_err(backend)?.is_some(); | ||
| 1646 | + if related { | ||
| 1647 | + return Err(StoreError::Cycle); | ||
| 1648 | + } | ||
| 1649 | + } | ||
| 1650 | + | ||
| 1631 | let mut conn = self.tx_conn().await?; | 1651 | let mut conn = self.tx_conn().await?; |
| 1632 | // IMMEDIATE: the reachability read and the insert that invalidates it | 1652 | // IMMEDIATE: the reachability read and the insert that invalidates it |
| 1633 | // must not be interleaved with another writer's pair, or two adds each | 1653 | // must not be interleaved with another writer's pair, or two adds each |
| @@ -2196,6 +2216,15 @@ impl Store for TursoStore { | |||
| 2196 | params![task_id, stamp.clone()], | 2216 | params![task_id, stamp.clone()], |
| 2197 | ) | 2217 | ) |
| 2198 | .await?; | 2218 | .await?; |
| 2219 | + // The parts go with the whole, in the same write. A subtask that | ||
| 2220 | + // outlived its parent would be unreachable: the board does not | ||
| 2221 | + // show it, and the page that did is gone. | ||
| 2222 | + tx.execute( | ||
| 2223 | + "UPDATE task SET deleted_at = ?2, updated_at = ?2 \ | ||
| 2224 | + WHERE parent_id = ?1 AND deleted_at IS NULL", | ||
| 2225 | + params![task_id, stamp.clone()], | ||
| 2226 | + ) | ||
| 2227 | + .await?; | ||
| 2199 | let deleted_activity_id = Ulid::new().to_string(); | 2228 | let deleted_activity_id = Ulid::new().to_string(); |
| 2200 | tx.execute( | 2229 | tx.execute( |
| 2201 | "INSERT INTO activity (id, task_id, actor_id, kind, detail, created_at) \ | 2230 | "INSERT INTO activity (id, task_id, actor_id, kind, detail, created_at) \ |
| @@ -2324,17 +2353,20 @@ impl Store for TursoStore { | |||
| 2324 | ON t.id = CASE WHEN d.blocked_task_id = ?1 \ | 2353 | ON t.id = CASE WHEN d.blocked_task_id = ?1 \ |
| 2325 | THEN d.blocking_task_id ELSE d.blocked_task_id END \ | 2354 | THEN d.blocking_task_id ELSE d.blocked_task_id END \ |
| 2326 | WHERE (d.blocked_task_id = ?1 OR d.blocking_task_id = ?1) \ | 2355 | WHERE (d.blocked_task_id = ?1 OR d.blocking_task_id = ?1) \ |
| 2327 | - AND d.cleared_at IS NULL AND t.deleted_at IS NULL)", | 2356 | + AND d.cleared_at IS NULL AND t.deleted_at IS NULL), \ |
| 2357 | + (SELECT COUNT(*) FROM task \ | ||
| 2358 | + WHERE parent_id = ?1 AND deleted_at IS NULL)", | ||
| 2328 | params![task_id], | 2359 | params![task_id], |
| 2329 | ) | 2360 | ) |
| 2330 | .await | 2361 | .await |
| 2331 | .map_err(backend)?; | 2362 | .map_err(backend)?; |
| 2332 | - let (comment_count, link_count) = match rows.next().await.map_err(backend)? { | 2363 | + let (comment_count, link_count, subtask_count) = match rows.next().await.map_err(backend)? { |
| 2333 | Some(row) => ( | 2364 | Some(row) => ( |
| 2334 | row.get::<i64>(0).map_err(backend)?.max(0) as u32, | 2365 | row.get::<i64>(0).map_err(backend)?.max(0) as u32, |
| 2335 | row.get::<i64>(1).map_err(backend)?.max(0) as u32, | 2366 | row.get::<i64>(1).map_err(backend)?.max(0) as u32, |
| 2367 | + row.get::<i64>(2).map_err(backend)?.max(0) as u32, | ||
| 2336 | ), | 2368 | ), |
| 2337 | - None => (0, 0), | 2369 | + None => (0, 0, 0), |
| 2338 | }; | 2370 | }; |
| 2339 | drop(rows); | 2371 | drop(rows); |
| 2340 | 2372 | ||
| @@ -2366,6 +2398,7 @@ impl Store for TursoStore { | |||
| 2366 | comment_count, | 2398 | comment_count, |
| 2367 | link_count, | 2399 | link_count, |
| 2368 | frees, | 2400 | frees, |
| 2401 | + subtask_count, | ||
| 2369 | })) | 2402 | })) |
| 2370 | } | 2403 | } |
| 2371 | 2404 | ||
| @@ -3289,7 +3322,7 @@ impl DetailReads for TursoStore { | |||
| 3289 | let row = self | 3322 | let row = self |
| 3290 | .one_row( | 3323 | .one_row( |
| 3291 | "SELECT t.id, t.task_key, t.title, t.column_id, t.deadline, t.position, \ | 3324 | "SELECT t.id, t.task_key, t.title, t.column_id, t.deadline, t.position, \ |
| 3292 | - t.done_at, t.description, t.board_id, b.workspace_id \ | 3325 | + t.done_at, t.description, t.board_id, b.workspace_id, t.parent_id \ |
| 3293 | FROM task t JOIN board b ON b.id = t.board_id \ | 3326 | FROM task t JOIN board b ON b.id = t.board_id \ |
| 3294 | WHERE t.id = ?1 AND t.deleted_at IS NULL", | 3327 | WHERE t.id = ?1 AND t.deleted_at IS NULL", |
| 3295 | params![task_id], | 3328 | params![task_id], |
| @@ -3305,6 +3338,7 @@ impl DetailReads for TursoStore { | |||
| 3305 | deadline: opt_day(&row, 4)?, | 3338 | deadline: opt_day(&row, 4)?, |
| 3306 | position: row.get::<f64>(5).map_err(backend)?, | 3339 | position: row.get::<f64>(5).map_err(backend)?, |
| 3307 | done_at: opt_stamp(&row, 6)?, | 3340 | done_at: opt_stamp(&row, 6)?, |
| 3341 | + parent_id: opt_text(&row, 10)?, | ||
| 3308 | }, | 3342 | }, |
| 3309 | description: text(&row, 7)?, | 3343 | description: text(&row, 7)?, |
| 3310 | board_id: text(&row, 8)?, | 3344 | board_id: text(&row, 8)?, |
| @@ -3486,6 +3520,65 @@ impl DetailReads for TursoStore { | |||
| 3486 | } | 3520 | } |
| 3487 | Ok(out) | 3521 | Ok(out) |
| 3488 | } | 3522 | } |
| 3523 | + | ||
| 3524 | + async fn family_for_task(&self, task_id: &str) -> Result<Vec<(bool, SubtaskLine)>> { | ||
| 3525 | + let conn = self.conn.lock().await; | ||
| 3526 | + // One query for both directions, and one for the assignees too: the | ||
| 3527 | + // LEFT JOIN repeats a task's row once per person it points at, and the | ||
| 3528 | + // fold below puts them back together. A task detail is not allowed to | ||
| 3529 | + // cost a query per subtask. | ||
| 3530 | + let mut rows = conn | ||
| 3531 | + .query( | ||
| 3532 | + "SELECT t.id, t.task_key, t.title, t.column_id, t.done_at, t.parent_id, \ | ||
| 3533 | + u.id, u.display_name, (u.photo IS NOT NULL) \ | ||
| 3534 | + FROM task t \ | ||
| 3535 | + LEFT JOIN task_assignee a ON a.task_id = t.id \ | ||
| 3536 | + LEFT JOIN user u ON u.id = a.user_id \ | ||
| 3537 | + WHERE t.deleted_at IS NULL AND ( \ | ||
| 3538 | + t.parent_id = ?1 \ | ||
| 3539 | + OR t.id = (SELECT parent_id FROM task WHERE id = ?1) \ | ||
| 3540 | + ) \ | ||
| 3541 | + ORDER BY t.created_at, u.display_name", | ||
| 3542 | + params![task_id], | ||
| 3543 | + ) | ||
| 3544 | + .await | ||
| 3545 | + .map_err(backend)?; | ||
| 3546 | + | ||
| 3547 | + let mut out: Vec<(bool, SubtaskLine)> = Vec::new(); | ||
| 3548 | + while let Some(row) = rows.next().await.map_err(backend)? { | ||
| 3549 | + let id = text(&row, 0)?; | ||
| 3550 | + // A row whose parent is the task we asked about is one of its | ||
| 3551 | + // parts; anything else this query can return is the parent. | ||
| 3552 | + let is_parent = opt_text(&row, 5)?.as_deref() != Some(task_id); | ||
| 3553 | + let person = match opt_text(&row, 6)? { | ||
| 3554 | + Some(user_id) => Some(Person { | ||
| 3555 | + id: user_id, | ||
| 3556 | + display_name: text(&row, 7)?, | ||
| 3557 | + has_photo: row.get::<i64>(8).map_err(backend)? != 0, | ||
| 3558 | + }), | ||
| 3559 | + None => None, | ||
| 3560 | + }; | ||
| 3561 | + match out.last_mut() { | ||
| 3562 | + Some((_, line)) if line.id == id => { | ||
| 3563 | + if let Some(person) = person { | ||
| 3564 | + line.assignees.push(person); | ||
| 3565 | + } | ||
| 3566 | + } | ||
| 3567 | + _ => out.push(( | ||
| 3568 | + is_parent, | ||
| 3569 | + SubtaskLine { | ||
| 3570 | + id, | ||
| 3571 | + task_key: text(&row, 1)?, | ||
| 3572 | + title: text(&row, 2)?, | ||
| 3573 | + column_id: text(&row, 3)?, | ||
| 3574 | + done_at: opt_stamp(&row, 4)?, | ||
| 3575 | + assignees: person.into_iter().collect(), | ||
| 3576 | + }, | ||
| 3577 | + )), | ||
| 3578 | + } | ||
| 3579 | + } | ||
| 3580 | + Ok(out) | ||
| 3581 | + } | ||
| 3489 | } | 3582 | } |
| 3490 | 3583 | ||
| 3491 | #[async_trait] | 3584 | #[async_trait] |
| @@ -3534,7 +3627,7 @@ impl BoardReads for TursoStore { | |||
| 3534 | let conn = self.conn.lock().await; | 3627 | let conn = self.conn.lock().await; |
| 3535 | let mut rows = conn | 3628 | let mut rows = conn |
| 3536 | .query( | 3629 | .query( |
| 3537 | - "SELECT id, task_key, title, column_id, deadline, position, done_at \ | 3630 | + "SELECT id, task_key, title, column_id, deadline, position, done_at, parent_id \ |
| 3538 | FROM task WHERE board_id = ?1 AND deleted_at IS NULL", | 3631 | FROM task WHERE board_id = ?1 AND deleted_at IS NULL", |
| 3539 | params![board_id], | 3632 | params![board_id], |
| 3540 | ) | 3633 | ) |
| @@ -3550,6 +3643,7 @@ impl BoardReads for TursoStore { | |||
| 3550 | deadline: opt_day(&row, 4)?, | 3643 | deadline: opt_day(&row, 4)?, |
| 3551 | position: row.get::<f64>(5).map_err(backend)?, | 3644 | position: row.get::<f64>(5).map_err(backend)?, |
| 3552 | done_at: opt_stamp(&row, 6)?, | 3645 | done_at: opt_stamp(&row, 6)?, |
| 3646 | + parent_id: opt_text(&row, 7)?, | ||
| 3553 | }); | 3647 | }); |
| 3554 | } | 3648 | } |
| 3555 | Ok(out) | 3649 | Ok(out) |
crates/izlek-core/tests/store.rsmodified+191 -5
| @@ -404,6 +404,170 @@ async fn a_promoted_subtask_stops_holding_its_parent() { | |||
| 404 | moved_to(&scratch.store, &workspace, &parent, "Backlog", "Done", &admin).await; | 404 | moved_to(&scratch.store, &workspace, &parent, "Backlog", "Done", &admin).await; |
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | +#[tokio::test] | ||
| 408 | +async fn the_board_counts_subtasks_instead_of_carding_them() { | ||
| 409 | + let scratch = Scratch::open().await; | ||
| 410 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 411 | + let (parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 412 | + | ||
| 413 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 414 | + let cards: Vec<&izlek_core::board::TaskCard> = | ||
| 415 | + board.columns.iter().flat_map(|c| &c.cards).collect(); | ||
| 416 | + assert_eq!(cards.len(), 1, "the subtask took a card of its own"); | ||
| 417 | + assert_eq!(cards[0].id, parent); | ||
| 418 | + assert_eq!(cards[0].subtask_total, 1); | ||
| 419 | + assert_eq!(cards[0].subtask_done, 0); | ||
| 420 | + assert_eq!(cards[0].subtask_label().as_deref(), Some("0/1")); | ||
| 421 | + assert!(cards[0].holds_on_subtasks()); | ||
| 422 | + | ||
| 423 | + moved_to(&scratch.store, &workspace, &child, "Backlog", "Done", &admin).await; | ||
| 424 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 425 | + let card = board | ||
| 426 | + .columns | ||
| 427 | + .iter() | ||
| 428 | + .flat_map(|c| &c.cards) | ||
| 429 | + .find(|card| card.id == parent) | ||
| 430 | + .unwrap(); | ||
| 431 | + assert_eq!(card.subtask_label().as_deref(), Some("1/1")); | ||
| 432 | + assert!(!card.holds_on_subtasks()); | ||
| 433 | +} | ||
| 434 | + | ||
| 435 | +#[tokio::test] | ||
| 436 | +async fn a_card_with_no_parts_wears_no_chip() { | ||
| 437 | + let scratch = Scratch::open().await; | ||
| 438 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 439 | + add_task(&scratch.store, &workspace, "Backlog", "Alone", None, &admin).await; | ||
| 440 | + | ||
| 441 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 442 | + let card = board.columns.iter().flat_map(|c| &c.cards).next().unwrap(); | ||
| 443 | + assert_eq!(card.subtask_label(), None); | ||
| 444 | + assert!(!card.holds_on_subtasks()); | ||
| 445 | +} | ||
| 446 | + | ||
| 447 | +#[tokio::test] | ||
| 448 | +async fn a_subtask_blocking_a_card_still_names_itself_on_it() { | ||
| 449 | + let scratch = Scratch::open().await; | ||
| 450 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 451 | + let (_parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 452 | + let other = add_task(&scratch.store, &workspace, "Backlog", "Waiting", None, &admin).await; | ||
| 453 | + scratch | ||
| 454 | + .store | ||
| 455 | + .add_dependency(&other, &child, OffsetDateTime::now_utc()) | ||
| 456 | + .await | ||
| 457 | + .unwrap(); | ||
| 458 | + | ||
| 459 | + // The subtask has no card, but its key is real and the chip has to show | ||
| 460 | + // it: dropping the row would leave the blocked card looking free. | ||
| 461 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 462 | + let waiting = board | ||
| 463 | + .columns | ||
| 464 | + .iter() | ||
| 465 | + .flat_map(|c| &c.cards) | ||
| 466 | + .find(|card| card.id == other) | ||
| 467 | + .unwrap(); | ||
| 468 | + assert_eq!(waiting.blocked_by.len(), 1); | ||
| 469 | + assert!(waiting.is_blocked()); | ||
| 470 | +} | ||
| 471 | + | ||
| 472 | +#[tokio::test] | ||
| 473 | +async fn a_parent_and_its_own_part_are_not_linked_as_well() { | ||
| 474 | + let scratch = Scratch::open().await; | ||
| 475 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 476 | + let (parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 477 | + let now = OffsetDateTime::now_utc(); | ||
| 478 | + | ||
| 479 | + assert!(matches!( | ||
| 480 | + scratch.store.add_dependency(&parent, &child, now).await, | ||
| 481 | + Err(StoreError::Cycle) | ||
| 482 | + )); | ||
| 483 | + assert!(matches!( | ||
| 484 | + scratch.store.add_dependency(&child, &parent, now).await, | ||
| 485 | + Err(StoreError::Cycle) | ||
| 486 | + )); | ||
| 487 | +} | ||
| 488 | + | ||
| 489 | +#[tokio::test] | ||
| 490 | +async fn a_task_detail_carries_its_family_both_ways() { | ||
| 491 | + let scratch = Scratch::open().await; | ||
| 492 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 493 | + let (parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 494 | + scratch.store.assign_task(&child, &admin).await.unwrap(); | ||
| 495 | + | ||
| 496 | + let whole = load_detail(&scratch.store, &workspace, &parent) | ||
| 497 | + .await | ||
| 498 | + .unwrap() | ||
| 499 | + .unwrap(); | ||
| 500 | + assert!(whole.parent.is_none()); | ||
| 501 | + assert_eq!(whole.subtasks.len(), 1); | ||
| 502 | + assert_eq!(whole.subtasks[0].id, child); | ||
| 503 | + assert_eq!(whole.subtasks[0].assignees.len(), 1); | ||
| 504 | + assert!(!whole.subtasks[0].is_done()); | ||
| 505 | + | ||
| 506 | + let part = load_detail(&scratch.store, &workspace, &child) | ||
| 507 | + .await | ||
| 508 | + .unwrap() | ||
| 509 | + .unwrap(); | ||
| 510 | + assert_eq!(part.parent.as_ref().unwrap().id, parent); | ||
| 511 | + assert!( | ||
| 512 | + part.subtasks.is_empty(), | ||
| 513 | + "a subtask has no parts of its own" | ||
| 514 | + ); | ||
| 515 | +} | ||
| 516 | + | ||
| 517 | +#[tokio::test] | ||
| 518 | +async fn deleting_a_parent_says_what_it_takes_and_takes_it() { | ||
| 519 | + let scratch = Scratch::open().await; | ||
| 520 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 521 | + let (parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 522 | + | ||
| 523 | + let cost = scratch | ||
| 524 | + .store | ||
| 525 | + .deletion_cost(&parent) | ||
| 526 | + .await | ||
| 527 | + .unwrap() | ||
| 528 | + .expect("the parent is there to delete"); | ||
| 529 | + assert_eq!(cost.subtask_count, 1); | ||
| 530 | + | ||
| 531 | + scratch | ||
| 532 | + .store | ||
| 533 | + .delete_task(&parent, &admin, OffsetDateTime::now_utc()) | ||
| 534 | + .await | ||
| 535 | + .unwrap(); | ||
| 536 | + | ||
| 537 | + // The part went with the whole, in the same write. A subtask that | ||
| 538 | + // outlived its parent would be unreachable. | ||
| 539 | + assert!( | ||
| 540 | + load_detail(&scratch.store, &workspace, &child) | ||
| 541 | + .await | ||
| 542 | + .unwrap() | ||
| 543 | + .is_none() | ||
| 544 | + ); | ||
| 545 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 546 | + assert_eq!(board.columns.iter().flat_map(|c| &c.cards).count(), 0); | ||
| 547 | +} | ||
| 548 | + | ||
| 549 | +#[tokio::test] | ||
| 550 | +async fn deleting_a_subtask_leaves_its_parent_standing() { | ||
| 551 | + let scratch = Scratch::open().await; | ||
| 552 | + let (workspace, admin) = claim(&scratch.store).await; | ||
| 553 | + let (parent, child) = a_parent_and_one_subtask(&scratch.store, &workspace, &admin).await; | ||
| 554 | + | ||
| 555 | + scratch | ||
| 556 | + .store | ||
| 557 | + .delete_task(&child, &admin, OffsetDateTime::now_utc()) | ||
| 558 | + .await | ||
| 559 | + .unwrap(); | ||
| 560 | + | ||
| 561 | + let whole = load_detail(&scratch.store, &workspace, &parent) | ||
| 562 | + .await | ||
| 563 | + .unwrap() | ||
| 564 | + .unwrap(); | ||
| 565 | + assert!(whole.subtasks.is_empty()); | ||
| 566 | + let board = load(&scratch.store, &workspace).await.unwrap().unwrap(); | ||
| 567 | + let card = board.columns.iter().flat_map(|c| &c.cards).next().unwrap(); | ||
| 568 | + assert_eq!(card.subtask_label(), None); | ||
| 569 | +} | ||
| 570 | + | ||
| 407 | #[tokio::test] | 571 | #[tokio::test] |
| 408 | async fn the_first_account_owns_the_workspace() { | 572 | async fn the_first_account_owns_the_workspace() { |
| 409 | let scratch = Scratch::open().await; | 573 | let scratch = Scratch::open().await; |
| @@ -2553,6 +2717,14 @@ impl DetailReads for CountingDetail<'_> { | |||
| 2553 | self.tick(); | 2717 | self.tick(); |
| 2554 | self.inner.activity_for_task(task_id).await | 2718 | self.inner.activity_for_task(task_id).await |
| 2555 | } | 2719 | } |
| 2720 | + | ||
| 2721 | + async fn family_for_task( | ||
| 2722 | + &self, | ||
| 2723 | + task_id: &str, | ||
| 2724 | + ) -> Result<Vec<(bool, izlek_core::detail::SubtaskLine)>, StoreError> { | ||
| 2725 | + self.tick(); | ||
| 2726 | + self.inner.family_for_task(task_id).await | ||
| 2727 | + } | ||
| 2556 | } | 2728 | } |
| 2557 | 2729 | ||
| 2558 | #[tokio::test] | 2730 | #[tokio::test] |
| @@ -2867,7 +3039,7 @@ async fn saving_a_task_records_only_what_changed() { | |||
| 2867 | } | 3039 | } |
| 2868 | 3040 | ||
| 2869 | #[tokio::test] | 3041 | #[tokio::test] |
| 2870 | -async fn a_task_detail_costs_eight_queries_whatever_it_carries() { | 3042 | +async fn a_task_detail_costs_nine_queries_whatever_it_carries() { |
| 2871 | let (scratch, workspace, admin) = workspace_with_admin().await; | 3043 | let (scratch, workspace, admin) = workspace_with_admin().await; |
| 2872 | let store = &scratch.store; | 3044 | let store = &scratch.store; |
| 2873 | let now = OffsetDateTime::now_utc(); | 3045 | let now = OffsetDateTime::now_utc(); |
| @@ -2875,11 +3047,12 @@ async fn a_task_detail_costs_eight_queries_whatever_it_carries() { | |||
| 2875 | let bare = add_task(store, &workspace, "Backlog", "bare", None, &admin).await; | 3047 | let bare = add_task(store, &workspace, "Backlog", "bare", None, &admin).await; |
| 2876 | let counted = CountingDetail::new(store); | 3048 | let counted = CountingDetail::new(store); |
| 2877 | load_detail(&counted, &workspace, &bare).await.unwrap(); | 3049 | load_detail(&counted, &workspace, &bare).await.unwrap(); |
| 2878 | - assert_eq!(counted.count(), 8, "a task with nothing hung off it"); | 3050 | + assert_eq!(counted.count(), 9, "a task with nothing hung off it"); |
| 2879 | 3051 | ||
| 2880 | // Twenty comments, twenty activity lines, twenty people who could be | 3052 | // Twenty comments, twenty activity lines, twenty people who could be |
| 2881 | - // assigned and twenty tasks on the other end of a dependency — the four | 3053 | + // assigned, twenty tasks on the other end of a dependency and twenty |
| 2882 | - // things a naive detail query fans out on. | 3054 | + // subtasks each with an assignee — the things a naive detail query fans |
| 3055 | + // out on. | ||
| 2883 | let heavy = add_task(store, &workspace, "Backlog", "heavy", None, &admin).await; | 3056 | let heavy = add_task(store, &workspace, "Backlog", "heavy", None, &admin).await; |
| 2884 | for n in 0..20 { | 3057 | for n in 0..20 { |
| 2885 | let person = store | 3058 | let person = store |
| @@ -2910,6 +3083,10 @@ async fn a_task_detail_costs_eight_queries_whatever_it_carries() { | |||
| 2910 | let neighbour = | 3083 | let neighbour = |
| 2911 | add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await; | 3084 | add_task(store, &workspace, "Backlog", &format!("n{n}"), None, &admin).await; |
| 2912 | store.add_dependency(&neighbour, &heavy, now).await.unwrap(); | 3085 | store.add_dependency(&neighbour, &heavy, now).await.unwrap(); |
| 3086 | + | ||
| 3087 | + let part = add_task(store, &workspace, "Backlog", &format!("p{n}"), None, &admin).await; | ||
| 3088 | + store.set_parent(&part, Some(&heavy)).await.unwrap(); | ||
| 3089 | + store.assign_task(&part, &person.id).await.unwrap(); | ||
| 2913 | } | 3090 | } |
| 2914 | 3091 | ||
| 2915 | let counted = CountingDetail::new(store); | 3092 | let counted = CountingDetail::new(store); |
| @@ -2920,12 +3097,21 @@ async fn a_task_detail_costs_eight_queries_whatever_it_carries() { | |||
| 2920 | assert_eq!(detail.comments.len(), 20); | 3097 | assert_eq!(detail.comments.len(), 20); |
| 2921 | assert_eq!(detail.assignees.len(), 20); | 3098 | assert_eq!(detail.assignees.len(), 20); |
| 2922 | assert_eq!(detail.blocks.len(), 20); | 3099 | assert_eq!(detail.blocks.len(), 20); |
| 3100 | + assert_eq!(detail.subtasks.len(), 20); | ||
| 3101 | + assert!(detail.parent.is_none()); | ||
| 3102 | + assert!( | ||
| 3103 | + detail | ||
| 3104 | + .subtasks | ||
| 3105 | + .iter() | ||
| 3106 | + .all(|part| part.assignees.len() == 1), | ||
| 3107 | + "a subtask row carries who holds it" | ||
| 3108 | + ); | ||
| 2923 | // Twenty comments (each its own Commented line), twenty moves, plus the | 3109 | // Twenty comments (each its own Commented line), twenty moves, plus the |
| 2924 | // line create_task wrote. | 3110 | // line create_task wrote. |
| 2925 | assert_eq!(detail.activity.len(), 41); | 3111 | assert_eq!(detail.activity.len(), 41); |
| 2926 | assert_eq!( | 3112 | assert_eq!( |
| 2927 | counted.count(), | 3113 | counted.count(), |
| 2928 | - 8, | 3114 | + 9, |
| 2929 | "the round trips a detail costs must not follow what it carries" | 3115 | "the round trips a detail costs must not follow what it carries" |
| 2930 | ); | 3116 | ); |
| 2931 | } | 3117 | } |
crates/izlek-web/src/board.rsmodified+7 -0
| @@ -343,6 +343,8 @@ async fn render_card( | |||
| 343 | None => t(lang, Key::NoDeadline).to_string(), | 343 | None => t(lang, Key::NoDeadline).to_string(), |
| 344 | }; | 344 | }; |
| 345 | let comments = card.comment_count; | 345 | let comments = card.comment_count; |
| 346 | + let subtasks = card.subtask_label(); | ||
| 347 | + let subtasks_open = card.holds_on_subtasks(); | ||
| 346 | let mut assignees = Vec::new(); | 348 | let mut assignees = Vec::new(); |
| 347 | for person in card.assignees.iter() { | 349 | for person in card.assignees.iter() { |
| 348 | assignees.push(crate::layout::avatar(cx, person, "").await?); | 350 | assignees.push(crate::layout::avatar(cx, person, "").await?); |
| @@ -377,6 +379,9 @@ async fn render_card( | |||
| 377 | <span class="card-deadline" class:card-deadline-overdue=(overdue) class:card-deadline-none=(!dated)> | 379 | <span class="card-deadline" class:card-deadline-overdue=(overdue) class:card-deadline-none=(!dated)> |
| 378 | (deadline) | 380 | (deadline) |
| 379 | </span> | 381 | </span> |
| 382 | + if let Some(parts) = subtasks.clone() { | ||
| 383 | + <span class="card-subtasks" class:card-subtasks-open=(subtasks_open)>(format!("{parts} \u{2630}"))</span> | ||
| 384 | + } | ||
| 380 | if comments > 0 { <span class="card-comments">(format!("{comments} \u{270e}"))</span> } | 385 | if comments > 0 { <span class="card-comments">(format!("{comments} \u{270e}"))</span> } |
| 381 | <div class="spacer"></div> | 386 | <div class="spacer"></div> |
| 382 | <div class="avatars"> | 387 | <div class="avatars"> |
| @@ -620,6 +625,8 @@ mod sort_tests { | |||
| 620 | comment_count: 0, | 625 | comment_count: 0, |
| 621 | blocked_by: Vec::new(), | 626 | blocked_by: Vec::new(), |
| 622 | blocks: Vec::new(), | 627 | blocks: Vec::new(), |
| 628 | + subtask_total: 0, | ||
| 629 | + subtask_done: 0, | ||
| 623 | } | 630 | } |
| 624 | } | 631 | } |
| 625 | 632 | ||
crates/izlek-web/src/detail.rsmodified+271 -1
| @@ -77,6 +77,10 @@ pub struct DetailSnapshot { | |||
| 77 | /// shift into this, the same as `/logs` does. | 77 | /// shift into this, the same as `/logs` does. |
| 78 | pub zone: UtcOffset, | 78 | pub zone: UtcOffset, |
| 79 | pub linkable: Vec<LinkTarget>, | 79 | pub linkable: Vec<LinkTarget>, |
| 80 | + /// Tasks this one could take in as parts: the board's other top-level | ||
| 81 | + /// tasks that have no parts of their own. Empty when this task is itself | ||
| 82 | + /// a part — subtasks go one level deep. | ||
| 83 | + pub adoptable: Vec<LinkTarget>, | ||
| 80 | pub may_write: bool, | 84 | pub may_write: bool, |
| 81 | pub may_comment: bool, | 85 | pub may_comment: bool, |
| 82 | pub may_delete: bool, | 86 | pub may_delete: bool, |
| @@ -234,6 +238,21 @@ struct LinkForm { | |||
| 234 | direction: Direction, | 238 | direction: Direction, |
| 235 | } | 239 | } |
| 236 | 240 | ||
| 241 | +#[derive(Deserialize)] | ||
| 242 | +struct NewSubtaskForm { | ||
| 243 | + parent_id: String, | ||
| 244 | + title: String, | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +#[derive(Deserialize)] | ||
| 248 | +struct ParentForm { | ||
| 249 | + task_id: String, | ||
| 250 | + /// Empty means "let it out": the same form both ways, because parenting | ||
| 251 | + /// and promoting are the same single write. | ||
| 252 | + #[serde(default)] | ||
| 253 | + parent_id: String, | ||
| 254 | +} | ||
| 255 | + | ||
| 237 | #[derive(Deserialize)] | 256 | #[derive(Deserialize)] |
| 238 | struct CommentForm { | 257 | struct CommentForm { |
| 239 | task_id: String, | 258 | task_id: String, |
| @@ -272,6 +291,7 @@ async fn load_snapshot( | |||
| 272 | // already on either end of a live link with this one. A cleared edge is | 291 | // already on either end of a live link with this one. A cleared edge is |
| 273 | // not a link any more, so its task comes back to the picker. | 292 | // not a link any more, so its task comes back to the picker. |
| 274 | let mut linkable = Vec::new(); | 293 | let mut linkable = Vec::new(); |
| 294 | + let mut adoptable = Vec::new(); | ||
| 275 | if let Some(board) = store.board(&user.workspace_id).await? { | 295 | if let Some(board) = store.board(&user.workspace_id).await? { |
| 276 | let taken: Vec<&str> = detail | 296 | let taken: Vec<&str> = detail |
| 277 | .blocked_by | 297 | .blocked_by |
| @@ -280,7 +300,28 @@ async fn load_snapshot( | |||
| 280 | .filter(|edge| edge.cleared_at.is_none()) | 300 | .filter(|edge| edge.cleared_at.is_none()) |
| 281 | .map(|edge| edge.task_id.as_str()) | 301 | .map(|edge| edge.task_id.as_str()) |
| 282 | .collect(); | 302 | .collect(); |
| 283 | - for task in store.tasks_for_board(&board.id).await? { | 303 | + let tasks = store.tasks_for_board(&board.id).await?; |
| 304 | + // Who already has parts, so the picker does not offer a task whose | ||
| 305 | + // own children would become grandchildren. | ||
| 306 | + let parents: Vec<&str> = tasks | ||
| 307 | + .iter() | ||
| 308 | + .filter_map(|task| task.parent_id.as_deref()) | ||
| 309 | + .collect(); | ||
| 310 | + for task in &tasks { | ||
| 311 | + let is_self = task.id == detail.id; | ||
| 312 | + if detail.parent.is_none() | ||
| 313 | + && !is_self | ||
| 314 | + && task.parent_id.is_none() | ||
| 315 | + && !parents.contains(&task.id.as_str()) | ||
| 316 | + { | ||
| 317 | + adoptable.push(LinkTarget { | ||
| 318 | + id: task.id.clone(), | ||
| 319 | + task_key: task.task_key.clone(), | ||
| 320 | + title: task.title.clone(), | ||
| 321 | + }); | ||
| 322 | + } | ||
| 323 | + } | ||
| 324 | + for task in tasks { | ||
| 284 | if task.id == detail.id || taken.contains(&task.id.as_str()) { | 325 | if task.id == detail.id || taken.contains(&task.id.as_str()) { |
| 285 | continue; | 326 | continue; |
| 286 | } | 327 | } |
| @@ -290,6 +331,7 @@ async fn load_snapshot( | |||
| 290 | title: task.title, | 331 | title: task.title, |
| 291 | }); | 332 | }); |
| 292 | } | 333 | } |
| 334 | + adoptable.sort_by(|a, b| a.id.cmp(&b.id)); | ||
| 293 | // Sorted by id, not `task_key`: the key's tail is a random ULID | 335 | // Sorted by id, not `task_key`: the key's tail is a random ULID |
| 294 | // suffix now, not a counter, so only the id (a ULID itself) still | 336 | // suffix now, not a counter, so only the id (a ULID itself) still |
| 295 | // orders these by creation time. | 337 | // orders these by creation time. |
| @@ -375,6 +417,7 @@ async fn load_snapshot( | |||
| 375 | Ok(Ok(DetailSnapshot { | 417 | Ok(Ok(DetailSnapshot { |
| 376 | detail, | 418 | detail, |
| 377 | linkable, | 419 | linkable, |
| 420 | + adoptable, | ||
| 378 | may_write, | 421 | may_write, |
| 379 | may_comment: user.role.can_comment(), | 422 | may_comment: user.role.can_comment(), |
| 380 | may_delete: may_write, | 423 | may_delete: may_write, |
| @@ -588,6 +631,104 @@ async fn unlink_tasks(cx: &Cx, Form(input): Form<LinkForm>) -> Redirect { | |||
| 588 | redirect(cx, None) | 631 | redirect(cx, None) |
| 589 | } | 632 | } |
| 590 | 633 | ||
| 634 | +/// Opens a new task already filed under this one. It starts in the board's | ||
| 635 | +/// first column, the way a card dropped on the board's first column would. | ||
| 636 | +#[route(POST "/api/create_subtask")] | ||
| 637 | +async fn create_subtask(cx: &Cx, Form(input): Form<NewSubtaskForm>) -> Redirect { | ||
| 638 | + use izlek_core::store::NewTask; | ||
| 639 | + | ||
| 640 | + let (actor, parent) = match writer_and_task(cx, &input.parent_id).await { | ||
| 641 | + Ok(pair) => pair, | ||
| 642 | + Err(refusal) => return redirect(cx, Some(refusal)), | ||
| 643 | + }; | ||
| 644 | + let title = input.title.trim(); | ||
| 645 | + if title.is_empty() { | ||
| 646 | + return redirect(cx, Some(Refusal::EmptyTitle)); | ||
| 647 | + } | ||
| 648 | + let store = accounts(cx).store().clone(); | ||
| 649 | + let columns = store.columns(&parent.board_id).await?; | ||
| 650 | + let Some(first) = columns.iter().min_by_key(|column| column.position) else { | ||
| 651 | + return redirect(cx, Some(Refusal::NotFound)); | ||
| 652 | + }; | ||
| 653 | + let created = match store | ||
| 654 | + .create_task(NewTask { | ||
| 655 | + board_id: &parent.board_id, | ||
| 656 | + column_id: &first.id, | ||
| 657 | + parent_id: Some(&input.parent_id), | ||
| 658 | + title, | ||
| 659 | + description: "", | ||
| 660 | + deadline: None, | ||
| 661 | + created_by: &actor.id, | ||
| 662 | + }) | ||
| 663 | + .await | ||
| 664 | + { | ||
| 665 | + Ok(created) => created, | ||
| 666 | + Err(StoreError::NotNestable) => return redirect(cx, Some(Refusal::NotNestable)), | ||
| 667 | + Err(error) => return Err(error.into()), | ||
| 668 | + }; | ||
| 669 | + mail(cx).after_activity(store.clone(), created.activity_id); | ||
| 670 | + mail(cx).after(created.transition); | ||
| 671 | + redirect(cx, None) | ||
| 672 | +} | ||
| 673 | + | ||
| 674 | +/// Files a task under another one, or lets it out again — an empty | ||
| 675 | +/// `parent_id` is the second. One handler, because it is one write. | ||
| 676 | +#[route(POST "/api/set_parent")] | ||
| 677 | +async fn set_parent(cx: &Cx, Form(input): Form<ParentForm>) -> Redirect { | ||
| 678 | + use izlek_core::detail::ActivityKind; | ||
| 679 | + use time::OffsetDateTime; | ||
| 680 | + | ||
| 681 | + let (actor, task) = match writer_and_task(cx, &input.task_id).await { | ||
| 682 | + Ok(pair) => pair, | ||
| 683 | + Err(refusal) => return redirect(cx, Some(refusal)), | ||
| 684 | + }; | ||
| 685 | + let store = accounts(cx).store().clone(); | ||
| 686 | + let wanted = input.parent_id.trim(); | ||
| 687 | + | ||
| 688 | + // Whichever end is not the task itself has to be a task this person may | ||
| 689 | + // see, so the key the activity line names is one they already have. | ||
| 690 | + let (parent_id, other_key) = if wanted.is_empty() { | ||
| 691 | + let Some(had) = task.row.parent_id.clone() else { | ||
| 692 | + return redirect(cx, None); | ||
| 693 | + }; | ||
| 694 | + match task_of(store.as_ref(), &actor, &had).await { | ||
| 695 | + Ok(facts) => (None, facts.row.task_key), | ||
| 696 | + Err(refusal) => return redirect(cx, Some(refusal)), | ||
| 697 | + } | ||
| 698 | + } else { | ||
| 699 | + match task_of(store.as_ref(), &actor, wanted).await { | ||
| 700 | + Ok(facts) => (Some(facts.row.id.clone()), facts.row.task_key), | ||
| 701 | + Err(refusal) => return redirect(cx, Some(refusal)), | ||
| 702 | + } | ||
| 703 | + }; | ||
| 704 | + | ||
| 705 | + match store.set_parent(&input.task_id, parent_id.as_deref()).await { | ||
| 706 | + Ok(()) => {} | ||
| 707 | + Err(StoreError::NotNestable) => return redirect(cx, Some(Refusal::NotNestable)), | ||
| 708 | + Err(StoreError::OtherBoard) => return redirect(cx, Some(Refusal::Forbidden)), | ||
| 709 | + Err(StoreError::Cycle) => return redirect(cx, Some(Refusal::Cycle)), | ||
| 710 | + Err(StoreError::NotFound) => return redirect(cx, Some(Refusal::NotFound)), | ||
| 711 | + Err(error) => return Err(error.into()), | ||
| 712 | + } | ||
| 713 | + | ||
| 714 | + let kind = if parent_id.is_some() { | ||
| 715 | + ActivityKind::Parented | ||
| 716 | + } else { | ||
| 717 | + ActivityKind::Unparented | ||
| 718 | + }; | ||
| 719 | + let activity_id = store | ||
| 720 | + .record_activity( | ||
| 721 | + &input.task_id, | ||
| 722 | + Some(&actor.id), | ||
| 723 | + &kind, | ||
| 724 | + &other_key, | ||
| 725 | + OffsetDateTime::now_utc(), | ||
| 726 | + ) | ||
| 727 | + .await?; | ||
| 728 | + mail(cx).after_activity(store, activity_id); | ||
| 729 | + redirect(cx, None) | ||
| 730 | +} | ||
| 731 | + | ||
| 591 | /// Writes a comment. The author is the session's user; there is no author | 732 | /// Writes a comment. The author is the session's user; there is no author |
| 592 | /// field on the form. A Viewer is refused here, not merely shown no textarea. | 733 | /// field on the form. A Viewer is refused here, not merely shown no textarea. |
| 593 | #[route(POST "/api/post_comment")] | 734 | #[route(POST "/api/post_comment")] |
| @@ -1231,6 +1372,88 @@ async fn link_picker(cx: &Cx, task_id: &str, linkable: &[LinkTarget], lang: Lang | |||
| 1231 | } | 1372 | } |
| 1232 | } | 1373 | } |
| 1233 | 1374 | ||
| 1375 | +/// One part on its parent's page: its key, its title, who holds it, and the | ||
| 1376 | +/// button that lets it out. The status is the column's name, read off the | ||
| 1377 | +/// board's columns the page already has. | ||
| 1378 | +async fn subtask_row( | ||
| 1379 | + cx: &Cx, | ||
| 1380 | + part: &izlek_core::detail::SubtaskLine, | ||
| 1381 | + columns: &[izlek_core::Column], | ||
| 1382 | + may_write: bool, | ||
| 1383 | + lang: Lang, | ||
| 1384 | +) -> Result { | ||
| 1385 | + let done = part.is_done(); | ||
| 1386 | + let status = columns | ||
| 1387 | + .iter() | ||
| 1388 | + .find(|column| column.id == part.column_id) | ||
| 1389 | + .map(|column| column.name.clone()) | ||
| 1390 | + .unwrap_or_default(); | ||
| 1391 | + let href = format!("/?task={}", part.id); | ||
| 1392 | + let release_title = t(lang, Key::ReleaseThisPart); | ||
| 1393 | + let mut faces = Vec::new(); | ||
| 1394 | + for person in &part.assignees { | ||
| 1395 | + faces.push(crate::layout::avatar(cx, person, "").await?); | ||
| 1396 | + } | ||
| 1397 | + view! { | ||
| 1398 | + cx => | ||
| 1399 | + <div class=(class!("dep-row", "subtask-row-done" if done))> | ||
| 1400 | + if done { (glyph::tick(cx).await?) } else { (glyph::lock(cx).await?) } | ||
| 1401 | + <a class="dep-key" href=(href.clone())>(part.task_key.clone())</a> | ||
| 1402 | + <a class="dep-title" href=(href)>(part.title.clone())</a> | ||
| 1403 | + <div class="spacer"></div> | ||
| 1404 | + <span class="dep-note">(status)</span> | ||
| 1405 | + <div class="avatars"> | ||
| 1406 | + for face in faces { (face) } | ||
| 1407 | + </div> | ||
| 1408 | + if may_write { | ||
| 1409 | + <form class="dep-unlink-form" method="post" action="/api/set_parent"> | ||
| 1410 | + <input type="hidden" name="task_id" value=(part.id.clone())> | ||
| 1411 | + <input type="hidden" name="parent_id" value=""> | ||
| 1412 | + <button class="dep-unlink" type="submit" title=(release_title)>(glyph::cross(cx).await?)</button> | ||
| 1413 | + </form> | ||
| 1414 | + } | ||
| 1415 | + </div> | ||
| 1416 | + } | ||
| 1417 | +} | ||
| 1418 | + | ||
| 1419 | +/// Takes an existing task in as a part. The same shape as `link_picker`, and | ||
| 1420 | +/// absent for the same reason: with nothing to offer it shows nothing. | ||
| 1421 | +async fn adopt_picker(cx: &Cx, task_id: &str, adoptable: &[LinkTarget], lang: Lang) -> Result { | ||
| 1422 | + if adoptable.is_empty() { | ||
| 1423 | + return view! { cx => }; | ||
| 1424 | + } | ||
| 1425 | + let toggle = format!("adopt-{task_id}"); | ||
| 1426 | + let aria = t(lang, Key::MakeAPart); | ||
| 1427 | + view! { | ||
| 1428 | + cx => | ||
| 1429 | + <div class="edit edit-pop link-pop"> | ||
| 1430 | + <input class="edit-toggle" type="checkbox" id=(toggle.clone()) aria-label=(aria)> | ||
| 1431 | + <label class="dep-chip edit-view edit-hit" for=(toggle.clone())> | ||
| 1432 | + (glyph::plus(cx).await?) | ||
| 1433 | + <span class="dep-chip-text">(t(lang, Key::MakeAPart))</span> | ||
| 1434 | + </label> | ||
| 1435 | + <div class="edit-form pop-panel pop-panel-wide"> | ||
| 1436 | + <form class="pop-form" method="post" action="/api/set_parent"> | ||
| 1437 | + <input type="hidden" name="parent_id" value=(task_id.to_string())> | ||
| 1438 | + <div class="pop-list pop-list-scroll"> | ||
| 1439 | + for target in adoptable { | ||
| 1440 | + <label class="pick-row"> | ||
| 1441 | + <input type="radio" name="task_id" value=(target.id.clone()) required=""> | ||
| 1442 | + <span class="dep-key">(target.task_key.clone())</span> | ||
| 1443 | + <span class="pick-title">(target.title.clone())</span> | ||
| 1444 | + </label> | ||
| 1445 | + } | ||
| 1446 | + </div> | ||
| 1447 | + <div class="edit-row"> | ||
| 1448 | + <button class="edit-save" type="submit">(t(lang, Key::ExistingTask))</button> | ||
| 1449 | + <label class="edit-cancel" for=(toggle)>(t(lang, Key::Cancel))</label> | ||
| 1450 | + </div> | ||
| 1451 | + </form> | ||
| 1452 | + </div> | ||
| 1453 | + </div> | ||
| 1454 | + } | ||
| 1455 | +} | ||
| 1456 | + | ||
| 1234 | async fn dep_row( | 1457 | async fn dep_row( |
| 1235 | cx: &Cx, | 1458 | cx: &Cx, |
| 1236 | task_id: &str, | 1459 | task_id: &str, |
| @@ -1402,6 +1625,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1402 | today, | 1625 | today, |
| 1403 | zone, | 1626 | zone, |
| 1404 | linkable, | 1627 | linkable, |
| 1628 | + adoptable, | ||
| 1405 | may_write, | 1629 | may_write, |
| 1406 | may_comment, | 1630 | may_comment, |
| 1407 | may_delete, | 1631 | may_delete, |
| @@ -1413,6 +1637,7 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1413 | let lang = Lang::from_code(&me.language); | 1637 | let lang = Lang::from_code(&me.language); |
| 1414 | 1638 | ||
| 1415 | let unassigned: Vec<Person> = detail.unassigned().cloned().collect(); | 1639 | let unassigned: Vec<Person> = detail.unassigned().cloned().collect(); |
| 1640 | + let done_parts = detail.subtasks.iter().filter(|part| part.is_done()).count(); | ||
| 1416 | let has_deps = !detail.blocked_by.is_empty() || !detail.blocks.is_empty(); | 1641 | let has_deps = !detail.blocked_by.is_empty() || !detail.blocks.is_empty(); |
| 1417 | let accept = (!allowed_file_types.is_empty()) | 1642 | let accept = (!allowed_file_types.is_empty()) |
| 1418 | .then(|| { | 1643 | .then(|| { |
| @@ -1443,6 +1668,11 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1443 | <div class="detail-mast"> | 1668 | <div class="detail-mast"> |
| 1444 | <header class="detail-head"> | 1669 | <header class="detail-head"> |
| 1445 | <div class="detail-headline"> | 1670 | <div class="detail-headline"> |
| 1671 | + if let Some(parent) = detail.parent.clone() { | ||
| 1672 | + <a class="detail-parent" href=(format!("/?task={}", parent.id))> | ||
| 1673 | + (format!("{} {}", t(lang, Key::PartOf), parent.task_key)) | ||
| 1674 | + </a> | ||
| 1675 | + } | ||
| 1446 | <span class="detail-key">(detail.task_key.clone())</span> | 1676 | <span class="detail-key">(detail.task_key.clone())</span> |
| 1447 | (title_control(cx, &detail, may_write, lang).await?) | 1677 | (title_control(cx, &detail, may_write, lang).await?) |
| 1448 | </div> | 1678 | </div> |
| @@ -1557,6 +1787,43 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1557 | if tab == Tab::Task { | 1787 | if tab == Tab::Task { |
| 1558 | 1788 | ||
| 1559 | 1789 | ||
| 1790 | + if detail.parent.is_none() { | ||
| 1791 | + <section class="detail-block"> | ||
| 1792 | + <div class="detail-block-head"> | ||
| 1793 | + <span class="detail-label">(t(lang, Key::Subtasks))</span> | ||
| 1794 | + if !detail.subtasks.is_empty() { | ||
| 1795 | + <span class="detail-count">(format!("{}/{}", done_parts, detail.subtasks.len()))</span> | ||
| 1796 | + } | ||
| 1797 | + <div class="spacer"></div> | ||
| 1798 | + if may_write { | ||
| 1799 | + (adopt_picker(cx, &detail.id, &adoptable, lang).await?) | ||
| 1800 | + } | ||
| 1801 | + </div> | ||
| 1802 | + if may_write { | ||
| 1803 | + <form class="subtask-new" method="post" action="/api/create_subtask"> | ||
| 1804 | + <input type="hidden" name="parent_id" value=(detail.id.clone())> | ||
| 1805 | + <label class="field-box subtask-new-box"> | ||
| 1806 | + (glyph::plus(cx).await?) | ||
| 1807 | + <input class="field-input" type="text" name="title" | ||
| 1808 | + placeholder=(t(lang, Key::NewSubtask)) required="" maxlength="200"> | ||
| 1809 | + </label> | ||
| 1810 | + <button class="edit-save" type="submit">(t(lang, Key::AddSubtask))</button> | ||
| 1811 | + </form> | ||
| 1812 | + } | ||
| 1813 | + (refused(cx, "create_subtask", lang).await?) | ||
| 1814 | + (refused(cx, "set_parent", lang).await?) | ||
| 1815 | + if detail.subtasks.is_empty() { | ||
| 1816 | + <p class="detail-prose detail-prose-empty">(t(lang, Key::NoSubtasks))</p> | ||
| 1817 | + } else { | ||
| 1818 | + <div class="dep-list"> | ||
| 1819 | + for part in &detail.subtasks { | ||
| 1820 | + (subtask_row(cx, part, &detail.columns, may_write, lang).await?) | ||
| 1821 | + } | ||
| 1822 | + </div> | ||
| 1823 | + } | ||
| 1824 | + </section> | ||
| 1825 | + } | ||
| 1826 | + | ||
| 1560 | <section class="detail-block"> | 1827 | <section class="detail-block"> |
| 1561 | <span class="detail-label">(t(lang, Key::Description))</span> | 1828 | <span class="detail-label">(t(lang, Key::Description))</span> |
| 1562 | (description_control(cx, &detail, may_write, lang).await?) | 1829 | (description_control(cx, &detail, may_write, lang).await?) |
| @@ -1683,6 +1950,9 @@ pub async fn task_modal(cx: &Cx, task_id: &str, confirm_delete: bool, tab: Tab) | |||
| 1683 | if cost.comment_count > 0 { | 1950 | if cost.comment_count > 0 { |
| 1684 | <li>(if cost.comment_count == 1 { t(lang, Key::CommentGoesWithIt).to_string() } else { format!("{} {}", cost.comment_count, t(lang, Key::CommentsGoWithIt)) })</li> | 1951 | <li>(if cost.comment_count == 1 { t(lang, Key::CommentGoesWithIt).to_string() } else { format!("{} {}", cost.comment_count, t(lang, Key::CommentsGoWithIt)) })</li> |
| 1685 | } | 1952 | } |
| 1953 | + if cost.subtask_count > 0 { | ||
| 1954 | + <li>(if cost.subtask_count == 1 { t(lang, Key::SubtaskGoesWithIt).to_string() } else { format!("{} {}", cost.subtask_count, t(lang, Key::SubtasksGoWithIt)) })</li> | ||
| 1955 | + } | ||
| 1686 | if cost.link_count > 0 { | 1956 | if cost.link_count > 0 { |
| 1687 | <li>(if cost.link_count == 1 { t(lang, Key::DependencyStopsApplying).to_string() } else { format!("{} {}", cost.link_count, t(lang, Key::DependenciesStopApplying)) })</li> | 1957 | <li>(if cost.link_count == 1 { t(lang, Key::DependencyStopsApplying).to_string() } else { format!("{} {}", cost.link_count, t(lang, Key::DependenciesStopApplying)) })</li> |
| 1688 | } | 1958 | } |
crates/izlek-web/src/i18n.rsmodified+44 -0
| @@ -283,6 +283,16 @@ pub enum Key { | |||
| 283 | NoTasks, | 283 | NoTasks, |
| 284 | NoDescription, | 284 | NoDescription, |
| 285 | NoDependencies, | 285 | NoDependencies, |
| 286 | + Subtasks, | ||
| 287 | + SubtaskGoesWithIt, | ||
| 288 | + SubtasksGoWithIt, | ||
| 289 | + NoSubtasks, | ||
| 290 | + NewSubtask, | ||
| 291 | + AddSubtask, | ||
| 292 | + PartOf, | ||
| 293 | + MakeAPart, | ||
| 294 | + ReleaseThisPart, | ||
| 295 | + ExistingTask, | ||
| 286 | DonePrefix, | 296 | DonePrefix, |
| 287 | Clear, | 297 | Clear, |
| 288 | Today, | 298 | Today, |
| @@ -822,6 +832,26 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 822 | (NoDescription, Tr) => "açıklama yok", | 832 | (NoDescription, Tr) => "açıklama yok", |
| 823 | (NoDependencies, En) => "no dependencies", | 833 | (NoDependencies, En) => "no dependencies", |
| 824 | (NoDependencies, Tr) => "bağımlılık yok", | 834 | (NoDependencies, Tr) => "bağımlılık yok", |
| 835 | + (SubtaskGoesWithIt, En) => "its subtask goes with it", | ||
| 836 | + (SubtaskGoesWithIt, Tr) => "alt görevi de silinir", | ||
| 837 | + (SubtasksGoWithIt, En) => "subtasks go with it", | ||
| 838 | + (SubtasksGoWithIt, Tr) => "alt görevi de silinir", | ||
| 839 | + (Subtasks, En) => "Subtasks", | ||
| 840 | + (Subtasks, Tr) => "Alt görevler", | ||
| 841 | + (NoSubtasks, En) => "no subtasks", | ||
| 842 | + (NoSubtasks, Tr) => "alt görev yok", | ||
| 843 | + (NewSubtask, En) => "Subtask", | ||
| 844 | + (NewSubtask, Tr) => "Alt görev", | ||
| 845 | + (AddSubtask, En) => "Add", | ||
| 846 | + (AddSubtask, Tr) => "Ekle", | ||
| 847 | + (PartOf, En) => "Part of", | ||
| 848 | + (PartOf, Tr) => "Şunun parçası:", | ||
| 849 | + (MakeAPart, En) => "Take an existing task", | ||
| 850 | + (MakeAPart, Tr) => "Var olan görevi al", | ||
| 851 | + (ReleaseThisPart, En) => "Release this subtask", | ||
| 852 | + (ReleaseThisPart, Tr) => "Bu alt görevi serbest bırak", | ||
| 853 | + (ExistingTask, En) => "Take", | ||
| 854 | + (ExistingTask, Tr) => "Al", | ||
| 825 | (DonePrefix, En) => "done ", | 855 | (DonePrefix, En) => "done ", |
| 826 | (DonePrefix, Tr) => "bitti ", | 856 | (DonePrefix, Tr) => "bitti ", |
| 827 | (Clear, En) => "Clear", | 857 | (Clear, En) => "Clear", |
| @@ -996,6 +1026,20 @@ pub fn linked_label(lang: Lang, detail: &str) -> String { | |||
| 996 | } | 1026 | } |
| 997 | } | 1027 | } |
| 998 | 1028 | ||
| 1029 | +pub fn parented_label(lang: Lang, detail: &str) -> String { | ||
| 1030 | + match lang { | ||
| 1031 | + Lang::En => format!("made this a part of {detail}"), | ||
| 1032 | + Lang::Tr => format!("bunu {detail} görevinin parçası yaptı"), | ||
| 1033 | + } | ||
| 1034 | +} | ||
| 1035 | + | ||
| 1036 | +pub fn unparented_label(lang: Lang, detail: &str) -> String { | ||
| 1037 | + match lang { | ||
| 1038 | + Lang::En => format!("released this from {detail}"), | ||
| 1039 | + Lang::Tr => format!("bunu {detail} görevinden çıkardı"), | ||
| 1040 | + } | ||
| 1041 | +} | ||
| 1042 | + | ||
| 999 | pub fn unlinked_label(lang: Lang, detail: &str) -> String { | 1043 | pub fn unlinked_label(lang: Lang, detail: &str) -> String { |
| 1000 | match lang { | 1044 | match lang { |
| 1001 | Lang::En => format!("unlinked {detail}"), | 1045 | Lang::En => format!("unlinked {detail}"), |
crates/izlek-web/src/logs.rsmodified+2 -0
| @@ -155,6 +155,8 @@ fn activity_sentence(kind: &izlek_core::detail::ActivityKind, detail: &str, lang | |||
| 155 | ActivityKind::Unassigned => crate::i18n::unassigned_label(lang, detail), | 155 | ActivityKind::Unassigned => crate::i18n::unassigned_label(lang, detail), |
| 156 | ActivityKind::Linked => crate::i18n::linked_label(lang, detail), | 156 | ActivityKind::Linked => crate::i18n::linked_label(lang, detail), |
| 157 | ActivityKind::Unlinked => crate::i18n::unlinked_label(lang, detail), | 157 | ActivityKind::Unlinked => crate::i18n::unlinked_label(lang, detail), |
| 158 | + ActivityKind::Parented => crate::i18n::parented_label(lang, detail), | ||
| 159 | + ActivityKind::Unparented => crate::i18n::unparented_label(lang, detail), | ||
| 158 | ActivityKind::Moved => crate::i18n::moved_label(lang, detail), | 160 | ActivityKind::Moved => crate::i18n::moved_label(lang, detail), |
| 159 | ActivityKind::Unblocked => crate::i18n::unblocked_label(lang, detail), | 161 | ActivityKind::Unblocked => crate::i18n::unblocked_label(lang, detail), |
| 160 | ActivityKind::Deleted => t(lang, Key::ActDeleted).to_string(), | 162 | ActivityKind::Deleted => t(lang, Key::ActDeleted).to_string(), |
crates/izlek-web/src/server.rsmodified+8 -0
| @@ -365,6 +365,9 @@ pub enum Refusal { | |||
| 365 | /// carries it, and a number cannot survive the round trip through the | 365 | /// carries it, and a number cannot survive the round trip through the |
| 366 | /// address bar that a browser without script makes. | 366 | /// address bar that a browser without script makes. |
| 367 | SubtasksOpen, | 367 | SubtasksOpen, |
| 368 | + /// Subtasks go one level deep: the task named as a parent is itself a | ||
| 369 | + /// part, or the task being filed already has parts of its own. | ||
| 370 | + NotNestable, | ||
| 368 | /// No such task — or none this account may see. Deliberately one answer for | 371 | /// No such task — or none this account may see. Deliberately one answer for |
| 369 | /// both. | 372 | /// both. |
| 370 | NotFound, | 373 | NotFound, |
| @@ -415,6 +418,7 @@ impl Refusal { | |||
| 415 | Refusal::Cycle => "That link would put this task behind itself.".to_string(), | 418 | Refusal::Cycle => "That link would put this task behind itself.".to_string(), |
| 416 | Refusal::MovedAlready => "Somebody moved this card first.".to_string(), | 419 | Refusal::MovedAlready => "Somebody moved this card first.".to_string(), |
| 417 | Refusal::SubtasksOpen => "Subtasks are still open.".to_string(), | 420 | Refusal::SubtasksOpen => "Subtasks are still open.".to_string(), |
| 421 | + Refusal::NotNestable => "Subtasks go one level deep.".to_string(), | ||
| 418 | Refusal::NotFound => "No such task.".to_string(), | 422 | Refusal::NotFound => "No such task.".to_string(), |
| 419 | Refusal::NoSuchMember => "No such member.".to_string(), | 423 | Refusal::NoSuchMember => "No such member.".to_string(), |
| 420 | Refusal::Unavailable => "Something went wrong.".to_string(), | 424 | Refusal::Unavailable => "Something went wrong.".to_string(), |
| @@ -445,6 +449,7 @@ impl Refusal { | |||
| 445 | Refusal::Cycle => "Bu bağlantı görevi kendi arkasına koyar.".to_string(), | 449 | Refusal::Cycle => "Bu bağlantı görevi kendi arkasına koyar.".to_string(), |
| 446 | Refusal::MovedAlready => "Bu kartı başka biri zaten taşıdı.".to_string(), | 450 | Refusal::MovedAlready => "Bu kartı başka biri zaten taşıdı.".to_string(), |
| 447 | Refusal::SubtasksOpen => "Alt görevler hâlâ açık.".to_string(), | 451 | Refusal::SubtasksOpen => "Alt görevler hâlâ açık.".to_string(), |
| 452 | + Refusal::NotNestable => "Alt görevler tek seviyedir.".to_string(), | ||
| 448 | Refusal::NotFound => "Böyle bir görev yok.".to_string(), | 453 | Refusal::NotFound => "Böyle bir görev yok.".to_string(), |
| 449 | Refusal::NoSuchMember => "Böyle bir üye yok.".to_string(), | 454 | Refusal::NoSuchMember => "Böyle bir üye yok.".to_string(), |
| 450 | Refusal::Unavailable => "Bir şeyler ters gitti.".to_string(), | 455 | Refusal::Unavailable => "Bir şeyler ters gitti.".to_string(), |
| @@ -520,6 +525,7 @@ impl Refusal { | |||
| 520 | "cycle" => Refusal::Cycle, | 525 | "cycle" => Refusal::Cycle, |
| 521 | "moved-already" => Refusal::MovedAlready, | 526 | "moved-already" => Refusal::MovedAlready, |
| 522 | "subtasks-open" => Refusal::SubtasksOpen, | 527 | "subtasks-open" => Refusal::SubtasksOpen, |
| 528 | + "not-nestable" => Refusal::NotNestable, | ||
| 523 | "not-found" => Refusal::NotFound, | 529 | "not-found" => Refusal::NotFound, |
| 524 | "no-such-member" => Refusal::NoSuchMember, | 530 | "no-such-member" => Refusal::NoSuchMember, |
| 525 | "unavailable" => Refusal::Unavailable, | 531 | "unavailable" => Refusal::Unavailable, |
| @@ -574,6 +580,7 @@ impl Refusal { | |||
| 574 | Refusal::Cycle => "cycle", | 580 | Refusal::Cycle => "cycle", |
| 575 | Refusal::MovedAlready => "moved-already", | 581 | Refusal::MovedAlready => "moved-already", |
| 576 | Refusal::SubtasksOpen => "subtasks-open", | 582 | Refusal::SubtasksOpen => "subtasks-open", |
| 583 | + Refusal::NotNestable => "not-nestable", | ||
| 577 | Refusal::NotFound => "not-found", | 584 | Refusal::NotFound => "not-found", |
| 578 | Refusal::NoSuchMember => "no-such-member", | 585 | Refusal::NoSuchMember => "no-such-member", |
| 579 | Refusal::Unavailable => "unavailable", | 586 | Refusal::Unavailable => "unavailable", |
| @@ -852,6 +859,7 @@ mod refusal_message_tests { | |||
| 852 | Refusal::Cycle, | 859 | Refusal::Cycle, |
| 853 | Refusal::MovedAlready, | 860 | Refusal::MovedAlready, |
| 854 | Refusal::SubtasksOpen, | 861 | Refusal::SubtasksOpen, |
| 862 | + Refusal::NotNestable, | ||
| 855 | Refusal::NotFound, | 863 | Refusal::NotFound, |
| 856 | Refusal::NoSuchMember, | 864 | Refusal::NoSuchMember, |
| 857 | Refusal::Unavailable, | 865 | Refusal::Unavailable, |
crates/izlek-web/tests/http.rsmodified+203 -0
| @@ -1429,6 +1429,209 @@ async fn a_card_with_open_subtasks_is_refused_the_done_column() { | |||
| 1429 | ); | 1429 | ); |
| 1430 | } | 1430 | } |
| 1431 | 1431 | ||
| 1432 | +#[tokio::test] | ||
| 1433 | +async fn a_subtask_is_opened_from_its_parents_page_and_shows_up_there() { | ||
| 1434 | + let app = App::open().await; | ||
| 1435 | + let admin = admin(&app).await; | ||
| 1436 | + let columns = columns_of(&app).await; | ||
| 1437 | + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; | ||
| 1438 | + | ||
| 1439 | + let made = app | ||
| 1440 | + .post( | ||
| 1441 | + "/api/create_subtask", | ||
| 1442 | + Some(&admin), | ||
| 1443 | + &[("parent_id", &parent), ("title", "Write the CSV writer")], | ||
| 1444 | + ) | ||
| 1445 | + .await; | ||
| 1446 | + assert_eq!(made.body, "null", "the subtask was refused: {}", made.body); | ||
| 1447 | + | ||
| 1448 | + // The parent's page lists it; the board does not card it. | ||
| 1449 | + let page = app.get(&format!("/?task={parent}"), Some(&admin)).await; | ||
| 1450 | + let page = String::from_utf8_lossy(&page.bytes); | ||
| 1451 | + assert!( | ||
| 1452 | + page.contains("Write the CSV writer"), | ||
| 1453 | + "the subtask is not on its parent's page" | ||
| 1454 | + ); | ||
| 1455 | + | ||
| 1456 | + let workspace_id = app.workspace_id().await; | ||
| 1457 | + let board = izlek_core::board::load(app.store.as_ref(), &workspace_id) | ||
| 1458 | + .await | ||
| 1459 | + .unwrap() | ||
| 1460 | + .unwrap(); | ||
| 1461 | + let cards: Vec<_> = board.columns.iter().flat_map(|c| &c.cards).collect(); | ||
| 1462 | + assert_eq!(cards.len(), 1, "the subtask took a card of its own"); | ||
| 1463 | + assert_eq!(cards[0].subtask_label().as_deref(), Some("0/1")); | ||
| 1464 | +} | ||
| 1465 | + | ||
| 1466 | +#[tokio::test] | ||
| 1467 | +async fn a_subtask_with_nothing_in_its_title_is_refused() { | ||
| 1468 | + let app = App::open().await; | ||
| 1469 | + let admin = admin(&app).await; | ||
| 1470 | + let columns = columns_of(&app).await; | ||
| 1471 | + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; | ||
| 1472 | + | ||
| 1473 | + // Posted the way a browser without script does, so the refusal has to | ||
| 1474 | + // survive the round trip through the address bar. | ||
| 1475 | + let empty = app | ||
| 1476 | + .post_without_script( | ||
| 1477 | + "/api/create_subtask", | ||
| 1478 | + Some(&admin), | ||
| 1479 | + &format!("http://izlek.sh/?task={parent}"), | ||
| 1480 | + &[("parent_id", &parent), ("title", " ")], | ||
| 1481 | + ) | ||
| 1482 | + .await; | ||
| 1483 | + assert!( | ||
| 1484 | + empty | ||
| 1485 | + .location | ||
| 1486 | + .as_deref() | ||
| 1487 | + .unwrap_or_default() | ||
| 1488 | + .contains("refusal=empty-title&on=create_subtask"), | ||
| 1489 | + "{:?}", | ||
| 1490 | + empty.location | ||
| 1491 | + ); | ||
| 1492 | +} | ||
| 1493 | + | ||
| 1494 | +#[tokio::test] | ||
| 1495 | +async fn taking_a_task_in_and_letting_it_out_are_the_same_form() { | ||
| 1496 | + let app = App::open().await; | ||
| 1497 | + let admin = admin(&app).await; | ||
| 1498 | + let columns = columns_of(&app).await; | ||
| 1499 | + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; | ||
| 1500 | + let loose = a_task(&app, &admin, &columns[1], "Write the CSV writer").await; | ||
| 1501 | + | ||
| 1502 | + let taken = app | ||
| 1503 | + .post( | ||
| 1504 | + "/api/set_parent", | ||
| 1505 | + Some(&admin), | ||
| 1506 | + &[("task_id", &loose), ("parent_id", &parent)], | ||
| 1507 | + ) | ||
| 1508 | + .await; | ||
| 1509 | + assert_eq!(taken.body, "null", "taking it in was refused: {}", taken.body); | ||
| 1510 | + let workspace_id = app.workspace_id().await; | ||
| 1511 | + let board = izlek_core::board::load(app.store.as_ref(), &workspace_id) | ||
| 1512 | + .await | ||
| 1513 | + .unwrap() | ||
| 1514 | + .unwrap(); | ||
| 1515 | + assert_eq!(board.columns.iter().flat_map(|c| &c.cards).count(), 1); | ||
| 1516 | + | ||
| 1517 | + // The subtask kept its column: being taken in is not a move. | ||
| 1518 | + let page = app.get(&format!("/?task={loose}"), Some(&admin)).await; | ||
| 1519 | + let page = String::from_utf8_lossy(&page.bytes); | ||
| 1520 | + assert!( | ||
| 1521 | + page.contains("Part of"), | ||
| 1522 | + "the part does not name its whole" | ||
| 1523 | + ); | ||
| 1524 | + | ||
| 1525 | + let released = app | ||
| 1526 | + .post( | ||
| 1527 | + "/api/set_parent", | ||
| 1528 | + Some(&admin), | ||
| 1529 | + &[("task_id", &loose), ("parent_id", "")], | ||
| 1530 | + ) | ||
| 1531 | + .await; | ||
| 1532 | + assert_eq!(released.body, "null", "letting it out was refused: {}", released.body); | ||
| 1533 | + let board = izlek_core::board::load(app.store.as_ref(), &workspace_id) | ||
| 1534 | + .await | ||
| 1535 | + .unwrap() | ||
| 1536 | + .unwrap(); | ||
| 1537 | + assert_eq!( | ||
| 1538 | + board.columns.iter().flat_map(|c| &c.cards).count(), | ||
| 1539 | + 2, | ||
| 1540 | + "the released task did not come back to the board" | ||
| 1541 | + ); | ||
| 1542 | +} | ||
| 1543 | + | ||
| 1544 | +#[tokio::test] | ||
| 1545 | +async fn a_second_level_of_subtask_is_refused_at_the_door() { | ||
| 1546 | + let app = App::open().await; | ||
| 1547 | + let admin = admin(&app).await; | ||
| 1548 | + let columns = columns_of(&app).await; | ||
| 1549 | + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; | ||
| 1550 | + let child = a_task(&app, &admin, &columns[0], "Write the CSV writer").await; | ||
| 1551 | + let loose = a_task(&app, &admin, &columns[0], "Loose").await; | ||
| 1552 | + app.store.set_parent(&child, Some(&parent)).await.unwrap(); | ||
| 1553 | + | ||
| 1554 | + let refused = app | ||
| 1555 | + .post_without_script( | ||
| 1556 | + "/api/create_subtask", | ||
| 1557 | + Some(&admin), | ||
| 1558 | + &format!("http://izlek.sh/?task={child}"), | ||
| 1559 | + &[("parent_id", &child), ("title", "Deeper")], | ||
| 1560 | + ) | ||
| 1561 | + .await; | ||
| 1562 | + assert!( | ||
| 1563 | + refused | ||
| 1564 | + .location | ||
| 1565 | + .as_deref() | ||
| 1566 | + .unwrap_or_default() | ||
| 1567 | + .contains("refusal=not-nestable&on=create_subtask"), | ||
| 1568 | + "{:?}", | ||
| 1569 | + refused.location | ||
| 1570 | + ); | ||
| 1571 | + | ||
| 1572 | + let also_refused = app | ||
| 1573 | + .post_without_script( | ||
| 1574 | + "/api/set_parent", | ||
| 1575 | + Some(&admin), | ||
| 1576 | + &format!("http://izlek.sh/?task={child}"), | ||
| 1577 | + &[("task_id", &loose), ("parent_id", &child)], | ||
| 1578 | + ) | ||
| 1579 | + .await; | ||
| 1580 | + assert!( | ||
| 1581 | + also_refused | ||
| 1582 | + .location | ||
| 1583 | + .as_deref() | ||
| 1584 | + .unwrap_or_default() | ||
| 1585 | + .contains("refusal=not-nestable&on=set_parent"), | ||
| 1586 | + "{:?}", | ||
| 1587 | + also_refused.location | ||
| 1588 | + ); | ||
| 1589 | +} | ||
| 1590 | + | ||
| 1591 | +#[tokio::test] | ||
| 1592 | +async fn a_viewer_may_not_open_or_move_a_subtask() { | ||
| 1593 | + let app = App::open().await; | ||
| 1594 | + let admin = admin(&app).await; | ||
| 1595 | + let watcher = invited(&app, &admin, "kay@izlek.sh", "Kay Watcher", Role::Viewer).await; | ||
| 1596 | + let columns = columns_of(&app).await; | ||
| 1597 | + let parent = a_task(&app, &admin, &columns[0], "Ship the exporter").await; | ||
| 1598 | + | ||
| 1599 | + let refused = app | ||
| 1600 | + .post_without_script( | ||
| 1601 | + "/api/create_subtask", | ||
| 1602 | + Some(&watcher), | ||
| 1603 | + &format!("http://izlek.sh/?task={parent}"), | ||
| 1604 | + &[("parent_id", &parent), ("title", "Not yours")], | ||
| 1605 | + ) | ||
| 1606 | + .await; | ||
| 1607 | + assert!( | ||
| 1608 | + refused | ||
| 1609 | + .location | ||
| 1610 | + .as_deref() | ||
| 1611 | + .unwrap_or_default() | ||
| 1612 | + .contains("refusal=forbidden"), | ||
| 1613 | + "{:?}", | ||
| 1614 | + refused.location | ||
| 1615 | + ); | ||
| 1616 | + | ||
| 1617 | + let also = app | ||
| 1618 | + .post_without_script( | ||
| 1619 | + "/api/set_parent", | ||
| 1620 | + Some(&watcher), | ||
| 1621 | + &format!("http://izlek.sh/?task={parent}"), | ||
| 1622 | + &[("task_id", &parent), ("parent_id", "")], | ||
| 1623 | + ) | ||
| 1624 | + .await; | ||
| 1625 | + assert!( | ||
| 1626 | + also.location | ||
| 1627 | + .as_deref() | ||
| 1628 | + .unwrap_or_default() | ||
| 1629 | + .contains("refusal=forbidden"), | ||
| 1630 | + "{:?}", | ||
| 1631 | + also.location | ||
| 1632 | + ); | ||
| 1633 | +} | ||
| 1634 | + | ||
| 1432 | #[tokio::test] | 1635 | #[tokio::test] |
| 1433 | async fn a_drop_decided_against_a_stale_board_is_refused() { | 1636 | async fn a_drop_decided_against_a_stale_board_is_refused() { |
| 1434 | let app = App::open().await; | 1637 | let app = App::open().await; |
style/main.scssmodified+40 -1
| @@ -858,12 +858,17 @@ a { | |||
| 858 | } | 858 | } |
| 859 | } | 859 | } |
| 860 | 860 | ||
| 861 | -.card-comments { | 861 | +.card-comments, |
| 862 | +.card-subtasks { | ||
| 862 | font-family: var(--font-mono); | 863 | font-family: var(--font-mono); |
| 863 | font-size: 11px; | 864 | font-size: 11px; |
| 864 | color: var(--muted); | 865 | color: var(--muted); |
| 865 | } | 866 | } |
| 866 | 867 | ||
| 868 | +/// Parts still open is the same warning the blocker chips carry: this card | ||
| 869 | +/// cannot reach the done column yet. | ||
| 870 | +.card-subtasks-open { color: var(--warn-ink); } | ||
| 871 | + | ||
| 867 | .avatars { | 872 | .avatars { |
| 868 | display: flex; | 873 | display: flex; |
| 869 | align-items: center; | 874 | align-items: center; |
| @@ -1441,6 +1446,18 @@ img.avatar { | |||
| 1441 | color: var(--muted-soft); | 1446 | color: var(--muted-soft); |
| 1442 | } | 1447 | } |
| 1443 | 1448 | ||
| 1449 | +// A subtask says whose part it is above its own key, so the page it opens on | ||
| 1450 | +// still names the work it belongs to. | ||
| 1451 | +.detail-parent { | ||
| 1452 | + display: block; | ||
| 1453 | + font-family: var(--font-mono); | ||
| 1454 | + font-size: 11px; | ||
| 1455 | + color: var(--muted); | ||
| 1456 | + text-decoration: none; | ||
| 1457 | + | ||
| 1458 | + &:hover { color: var(--ink); } | ||
| 1459 | +} | ||
| 1460 | + | ||
| 1444 | .detail-title { | 1461 | .detail-title { |
| 1445 | margin: 0; | 1462 | margin: 0; |
| 1446 | font-size: 18px; | 1463 | font-size: 18px; |
| @@ -1926,6 +1943,28 @@ img.avatar { | |||
| 1926 | font-size: 13px; | 1943 | font-size: 13px; |
| 1927 | } | 1944 | } |
| 1928 | 1945 | ||
| 1946 | +// A finished part reads back the way a finished card does: still there, | ||
| 1947 | +// still legible, plainly no longer in the way. | ||
| 1948 | +.subtask-row-done { | ||
| 1949 | + .dep-key, | ||
| 1950 | + .dep-title, | ||
| 1951 | + .dep-note { color: var(--muted-soft); } | ||
| 1952 | + | ||
| 1953 | + .dep-title { text-decoration: line-through; } | ||
| 1954 | +} | ||
| 1955 | + | ||
| 1956 | +.subtask-new { | ||
| 1957 | + display: flex; | ||
| 1958 | + align-items: center; | ||
| 1959 | + gap: 8px; | ||
| 1960 | + margin-bottom: 8px; | ||
| 1961 | +} | ||
| 1962 | + | ||
| 1963 | +.subtask-new-box { | ||
| 1964 | + flex: 1; | ||
| 1965 | + min-width: 0; | ||
| 1966 | +} | ||
| 1967 | + | ||
| 1929 | .dep-row-waiting { | 1968 | .dep-row-waiting { |
| 1930 | background: var(--warn-tint-soft); | 1969 | background: var(--warn-tint-soft); |
| 1931 | border-color: var(--warn-border); | 1970 | border-color: var(--warn-border); |